; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Written on WinXP ; Author Function: ; Template script (you can customize this template by pressing CTRL + ALT + SHIFT + Q) ; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #singleinstance, force SendMode Input ; Recommended for new scripts due to its superior speed and reliability. rand(min = 0, max = 2147483647, integer = true) { if 389fhe8rhj38fhshg894hg89e = display random number generator copyright data { display = ( This function uses the Mersenne Twister random number generator, MT19937, written by Takuji Nishimura and Makoto Matsumoto, Shawn Cokus, Matthe Bellew and Isaku Wada. The Mersenne Twister is an algorithm for generating random numbers. It was designed with consideration of the flaws in various other generators. The period, 219937-1, and the order of equidistribution, 623 dimensions, are far greater. The generator is also fast; it avoids multiplication and division, and it benefits from caches and pipelines. For more information see the inventors' web page at www.math.keio.ac.jp/~matumoto/emt.html Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. Please Also Note: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Do NOT use for CRYPTOGRAPHY without securely hashing several returned values together, otherwise the generator state can be learned after reading 624 consecutive values. When you use this, send an email to: matumoto@math.keio.ac.jp with an appropriate reference to your work. It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu when you write. ) msgbox, %display% } random, rnd_result, %min%, %max% if integer rnd_result := round(rnd_result) return, rnd_result } ;start script here setbatchlines, -1 setkeydelay, -1 setwindelay, 5 stopspeed := .96 accel := 0 decel := 0 extraspacex := 3 * 2 extraspacey := 29 + 3 movetype := 0 gui, add, picture, x22 y20 vpic1 gstop, e-brake.bmp gui, add, picture, x175 y180 vpic2 gyank, emret.bmp gui, add, text, x12 y208 w44 h13 vtext1, Friction: gui, add, edit, x53 y204 w62 h21 gchangespeed number hwndhwndstop, gui, add, updown, vstopspeed gchangespeed range0-1000 gui, add, text, x12 y231 w89 h16 vtext2, Movement Speed: gui, add, edit, x103 y228 w60 h20 gchngmovespeed number hwndhwndmove, gui, add, updown, vmovespeed gchngmovespeed range0-100, 100 gui, add, text, x12 y254 w87 h14 vtext3, Random Intensity: gui, add, edit, x103 y252 w60 h20 gchangerndpwr number hwndhwndrnd, gui, add, updown, vrndpwr gchangerndpwr range0-10, 3 gui, add, text, x12 y277 w80 h13 vtext4, Gravity Strength: gui, add, edit, x97 y274 w66 h20 ggravstr hwndhwndgstr, gui, add, updown, vgravstr ggravstr range0-100, 50 gui, add, text, x12 y300, Window to affect: gui, add, dropdownlist, x100 y297 gchangewindow vaffwinnum altsubmit, gui, add, button, x230 y296 gcheckwindows, Check Windows gui, add, button, x330 y296 gstart, Bounce gui, add, checkbox, x16 y185 vgravity ggravity, Gravity gui, add, checkbox, x72 y185 vmovetype gmovetype, Move Randomly gui, add, text, x12 y324, Bounciness: gui, add, edit, x73 y321 w70 gbounciness hwndhwndbnce, gui, add, updown, vbounce gbounciness range0-100, 100 gui, add, checkbox, gmovetype vmovestick x160 y325, Stick to Edges gui, +delimiter¢ menu, tray, tip, Movement: 100`nFriction: 0`nGravity Force: 50`, off`%`nRandom Limit: 3X`, off`nbounce: 100`%`nStick: off`nWindow: Bounce Me gui, show, w400 h350, Bounce Me affwin := "Bounce Me" gosub, checkwindows sleep, 100 wingetpos, lastx, lasty, lastw, lasth, Bounce Me sysget, size, monitor, 1 maxx := sizeright - lastw maxy := sizebottom - lasth movex := 0 movey := 0 bounce := 1 rnd = 0 newmove := 0 loop { wingetpos, xx, yy, ww, hh, ahk_id %affwinnumhwnd% maxx := sizeright - ww maxy := sizebottom - hh if xx = -32000 { sleep, 100 continue } if (xx = round(movex)) xx = %movex% else newmove := 1 if (yy = round(movey)) yy = %movey% else newmove := 1 if newmove = 0 { movex := (xx - lastx) * stopspeed movey := (yy - lasty) * stopspeed } else { movex := (xx - lastx) * stopspeed * movespeed movey := (yy - lasty) * stopspeed * movespeed } if accel = 1 { accel := 0 movex := movex * 1.05 movey := movey * 1.05 } if decel = 1 { decel := 0 movex := movex / 1.05 movey := movey / 1.05 } movex := movex + xx if gravity = 1 movey := movey + yy + gravstr else movey := movey + yy lasty := yy lastx := xx if movex < 0 { lastx := -xx * bounce movex := -movex * bounce if movestick = 1 { if movey <> %lasty% movey := ((lastx/(lastx - movex)) * (movey - lasty)) + lasty else movey := lasty lasty := movey movex := 0 lastx := movex } } if movey < 0 { lasty := -yy * bounce movey := -movey * bounce if movestick = 1 { if movex <> %lastx% movex := ((lasty/(lasty - movey)) * (movex - lastx)) + lastx else movex := lastx lastx := movex movey := 0 lasty := movey } } if movex > %maxx% { lastx := ((maxx - lastx) * bounce) + maxx movex := ((maxx - movex) * bounce) + maxx if movestick = 1 { if movey <> %lasty% movey := (((lastx - maxx)/(lastx - movex)) * (movey - lasty)) + lasty else movey := lasty lasty := movey movex := maxx lastx := movex } } if movey > %maxy% { lasty := ((maxy - lasty) * bounce) + maxy movey := ((maxy - movey) * bounce) + maxy if movestick = 1 { if movex <> %lastx% movex := (((lasty - maxy)/(lasty - movey)) * (movex - lastx)) + lastx else movex := movex := movex lastx := movex movey := maxy lasty := movey } } if stop = 1 { movex := xx movey := yy lastx := xx lasty := yy stop := 0 sleep 100 } else if stop = 2 { winmove, ahk_id %affwinnumhwnd%, , 0, 0 movex := 0 movey := 0 lastx := 0 lasty := 0 stop := 0 sleep 100 } if start = 1 { start := 0 lastx := xx lasty := yy movex := xx + rand(-rndpwr * 5, rndpwr * 5, 0) movey := yy + rand(-rndpwr * 5, rndpwr * 5, 0) } if addx = 1 { addx := 0 movex := movex + .5 * movespeed } if subx = 1 { subx := 0 movex := movex - .5 * movespeed } if addy = 1 { addy := 0 movey := movey + .5 * movespeed } if suby = 1 { suby := 0 movey := movey - .5 * movespeed } winmove, ahk_id %affwinnumhwnd%, ,round(movex), round(movey) if (a_timeidle > 60000) or (movetype = 1) { lastx := lastx + rand(-rndpwr, rndpwr, 0) lasty := lasty + rand(-rndpwr, rndpwr, 0) } ifwinnotexist, ahk_id %affwinnumhwnd% { stop := 1 gosub, checkwindows gosub, changewindow } newmove := 0 } exitapp return changewindow: stop := 1 bounciness: gravstr: gravity: movetype: changespeed: chngmovespeed: changerndpwr: gui, submit, nohide affwinnumhwnd := window%affwinnum% affwin := title%affwinnum% movespeedtip := movespeed stopspeedtip := stopspeed bouncetip := bounce bounce := bounce / 100 gravstrtip := gravstr movespeed := movespeed / 100 stopspeed := 1 - stopspeed / 2000 gravstr := gravstr / 100 stringreplace, gravtip, gravity, 1, on stringreplace, gravtip, gravtip, 0, off stringreplace, movtip, movetype, 1, on stringreplace, movtip, movtip, 0, off stringreplace, stktip, movestick, 1, on stringreplace, stktip, stktip, 0, off menu, tray, tip, Movement: %movespeedtip%`nFriction: %stopspeedtip%`nGravity Force: %gravstrtip%`%`, %gravtip%`nRandom Limit: %rndpwr%X`, %movtip%`nBounce: %bouncetip%`%`nStick: %stktip%`nWindow: %affwin% return checkwindows: winget, window, list list = loop, %window% { ahk_id := window%a_index% wingettitle, title%a_index%, ahk_id %ahk_id% if title%a_index% = title%a_index% = (No Title) if title%a_index% = %affwin% list := list . title%a_index% . "¢¢" else list := list . title%a_index% . "¢" } guicontrol, , affwinnum, ¢%list% ifnotinstring, list, ¢¢ guicontrol, choosestring, affwinnum, Bounce Me return yank: gravity := 0 guicontrol, , gravity, 0 movetype := 0 guicontrol, , movetype, 0 stop := 2 stringreplace, gravtip, gravity, 1, on stringreplace, gravtip, gravtip, 0, off stringreplace, movtip, movetype, 1, on stringreplace, movtip, movtip, 0, off menu, tray, tip, Movement: %movespeedtip%`nFriction: %stopspeedtip%`nGravity Force: %gravstrtip%`%`, %gravtip%`nRandom Limit: %rndpwr%X`, %movtip%`nBounce: %bouncetip%`%`nStick: %stktip%`nWindow: %affwin% return start: start := 1 return ^esc:: gosub, yank return ^g:: gravity := abs(1 - gravity) guicontrol, , gravity, %gravity% stringreplace, gravtip, gravity, 1, on stringreplace, gravtip, gravtip, 0, off menu, tray, tip, Movement: %movespeedtip%`nFriction: %stopspeedtip%`nGravity Force: %gravstrtip%`%`, %gravtip%`nRandom Limit: %rndpwr%X`, %movtip%`nBounce: %bouncetip%`%`nStick: %stktip%`nWindow: %affwin% return ^m:: movetype := abs(1 - movetype) guicontrol, , movetype, %movetype% stringreplace, movtip, movetype, 1, on stringreplace, movtip, movtip, 0, off menu, tray, tip, Movement: %movespeedtip%`nFriction: %stopspeedtip%`nGravity Force: %gravstrtip%`%`, %gravtip%`nRandom Limit: %rndpwr%X`, %movtip%`nBounce: %bouncetip%`%`nStick: %stktip%`nWindow: %affwin% return ^w:: movestick := abs(1 - movestick) guicontrol, , movestick, %movestick% stringreplace, stktip, movestick, 1, on stringreplace, stktip, stktip, 0, off menu, tray, tip, Movement: %movespeedtip%`nFriction: %stopspeedtip%`nGravity Force: %gravstrtip%`%`, %gravtip%`nRandom Limit: %rndpwr%X`, %movtip%`nBounce: %bouncetip%`%`nStick: %stktip%`nWindow: %affwin% return ^enter::gosub, start ^r::reload ^x::exitapp lbutton UP:: clicking = 1 click, up return up::controlsend, , {up}, ahk_id %hwndbnce% down::controlsend, , {down}, ahk_id %hwndbnce% ^up::controlsend, , {up}, ahk_id %hwndstop% ^down::controlsend, , {down}, ahk_id %hwndstop% !up::controlsend, , {up}, ahk_id %hwndmove% !down::controlsend, , {down}, ahk_id %hwndmove% #up::controlsend, , {up}, ahk_id %hwndrnd% #down::controlsend, , {down}, ahk_id %hwndrnd% +up::controlsend, , {up}, ahk_id %hwndgstr% +down::controlsend, , {down}, ahk_id %hwndgstr% numpadadd::accel := 1 numpadsub::decel := 1 lbutton:: click, down loop { if clicking = 1 { clicking = 0 break } sleep 10 } return esc:: guiescape: stop: stop := 1 gravity := 0 guicontrol, , gravity, 0 movetype := 0 guicontrol, , movetype, 0 stringreplace, gravtip, gravity, 1, on stringreplace, gravtip, gravtip, 0, off stringreplace, movtip, movetype, 1, on stringreplace, movtip, movtip, 0, off menu, tray, tip, Movement: %movespeedtip%`nFriction: %stopspeedtip%`nGravity Force: %gravstrtip%`%`, %gravtip%`nRandom Limit: %rndpwr%X`, %movtip%`nBounce: %bouncetip%`%`nStick: %stktip%`nWindow: %affwin% return guiclose: gui, hide menu, tray, add, show window, show return show: gui, show menu, tray, delete, show window return numpad4::subx := 1 numpad6::addx := 1 numpad8::suby := 1 numpad2::addy := 1 F1:: bouncing = ( visual controls: Note - Bouncing has been suspended for the duration of this messagebox. to make a window bounce, drag it normally, as though moving it. more drag = more bounce. to move a bouncy window without rocketing it all over the place, either set the movement speed to 0 or hold escape and drag. Emergency Brake - Stops window's motion, toggles gravity to off and toggles random movement to off Emergency Return - Stops window's motion, toggles gravity to off, toggles random movement to off and moves window to x=0, y=0 gravity checkbox - toggles gravity on or off rnadom movement checkbox - toggles random movement on or off friction - toggles window slowdown speed (1000 for fast stop, 0 for no speed loss) movement speed - changes launch sensativity and nudge sensetivity random intensity - changes the sensetivity when the launch button is used and when left inactive for a period of time gravity strength - changes the force of gravity bounciness - changes windows reflectiveness against edges of the screen (100 is no loss, 0 is slide) stick to edges checkbox - stops all movement when window his an edge window to affect - the title of the window that bounces check windows - updates the list of windows bounce button - sets the chosen window moving hotkey controls: ctrl alt shift q - edits template script (included in all of my scripts by default) escape - activates emergency brake (duh) ctrl escape - activates emergency return (duh) ctrl g - toddles gravity (gravity checkbox) ctrl m - toggles movement type ctrl w - toggles stick to egdes ctrl r - reloads script ctrl x - exits script ctrl enter - activates instant motion (bounce button) up and down - changes bounciness ctrl up and ctrl down - changes friction alt up and alt down - changes move speed win up and win down - changes random intensity shift up and shift down - changes gravity strength + (num pad) - raises speed of bouncing window, no effect if its not moving - (num pad) - lowers speed of bouncing window, no effect if its not moving 4 (num pad) - nudges window left 6 (num pad) - nudges window right 8 (num pad) - nudges window up 2 (num pad) - nudges window down F1 - accesses this help message ) msgbox, , How to Bounce, %bouncing% return