| View previous topic :: View next topic |
| Author |
Message |
ManaUser
Joined: 24 May 2007 Posts: 1121
|
Posted: Sat Jun 30, 2007 5:38 pm Post subject: Explode Mouse - Practical Joke / WinSet Region Demo |
|
|
This is a silly little script that will literally blow a hole in any window other than Windows Explorer or My Computer when you double-click. An explosion without a suitable sound effect would be no fun, so you can download one here. Just put it in the same folder as the script. You can also Download the script if you prefer it top copy and paste.
Commands:
Double-Click - Explode!
Ctrl+Alt+Shift+Z - "Repair" the active window.
Ctrl+Alt+Shift+F12 - End program.
| Code: | #SingleInstance Force
#NoEnv
;#NoTrayIcon ;uncomment if you want to be sneaky...
LastClick = 0
CoordMode, Mouse, Screen
;Get this at http://www.autohotkey.net/~ManaUser/KBoom.wav
FileInstall KBoom.wav, %A_Temp%\KBoom.wav
sStr = OPEN %A_Temp%\KBoom.wav TYPE waveaudio ALIAS KBoom
DllCall("winmm.dll\mciExecute", "Str", sStr)
OnExit DoExit
GroupAdd System, ahk_class ExploreWClass ;Windows Explore
GroupAdd System, ahk_class CabinetWClass ;My Computer type window
GroupAdd System, ahk_class Shell_TrayWnd ;Task bar
GroupAdd System, ahk_class Progman ;Desktop
~LButton::
If WinActive("ahk_group System")
Return
ClickSpeed := A_TickCount - LastClick
If (ClickSpeed > 200) ;rough approximation of a double-click.
{
LastClick := A_TickCount
Return
}
MouseGetPos X, Y, Win
WinGetPos WX, WY, , , ahk_id %Win%
X -= WX ;adjsut for screen co-ord mode.
Y -= WY
Pattern = 0:-5|4:-12|4:-6|8:-7|7:-3|11:-2|7:-1|13:1|7:0|12:4|8:3|10:6|13:7|10:7|10:9|9:6|5:4|7:10|3:5|3:11|0:7|-2:14|-3:6|-6:9|-5:4|-11:5|-6:2|-11:-2|-6:-3|-10:-10|-3:-5|-2:-7|-3:-13|-1:-9|0:-11
;These are off-sets from the cursor for each point in the shape. It was a pain to encode...
CCrack := Crack%Win% ;get current shape (if any) from active window.
CCrack .= " " . X . "-0" ;a point on at the top of the window, centered over the cutout.
Loop Parse, Pattern, |
{
StringSplit XY, A_LoopField, :
;Parse the offset string and add the mouse position.
CCrack .= " " . X + XY1 * 10 . "-" . Y + XY2 * 10
}
CCrack .= " " . X . "-0" ;another point on at the top of the window, centered over the cutout.
Crack%Win% := CCrack ;save shape in a unique variable for active window.
sStr = PLAY KBoom FROM 0
DllCall("winmm.dll\mciExecute", "Str", sStr) ;Kaboom!
sleep 100
WinSet Region, 0-0 %CCrack% 3000-0 3000-2000 0-2000, ahk_id %Win%
; So it "draws" a region like this... (2-4 repeat for each shape)
;
; 1----(2,4)----+ - - - - 5
; | | | :
; | | | :
; | 3 | :
; | SHAPE | :
; | | :
; +-------------+ :
; : :
; : :
; 7 - - - - - - - - - - - 6
;
; It's bigger than the window to allow for resizing.
Return
^+!z::
Win := WinExist("A")
WinSet Region, , ahk_id %Win%
Crack%Win% =
Return
^+!F12::
FileDelete %A_Temp%\KBoom.wav
ExitApp
Return
DoExit:
FileDelete %A_Temp%\KBoom.wav
ExitApp
Return |
Aside from being amusing (I hope) it demonstrates a way to cut one or more shapes out of a window using WinSet Region.
Last edited by ManaUser on Mon Jul 09, 2007 1:31 am; edited 2 times in total |
|
| Back to top |
|
 |
wibumba (not logged in) Guest
|
Posted: Sun Jul 01, 2007 8:13 am Post subject: |
|
|
| For some reason it wont work for me. Nothing happens at all when I double click in a window, the script is still running too. |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jul 01, 2007 8:14 am Post subject: |
|
|
| scratch that. Damn thing made me jump. I had my speakers turned up. |
|
| Back to top |
|
 |
OctalMage as a guest Guest
|
Posted: Sun Jul 01, 2007 10:33 pm Post subject: cool |
|
|
man, this script it really cool.
I really enjoy it.
Thanks for sharing.
 |
|
| Back to top |
|
 |
rockeveryone21
Joined: 06 Aug 2008 Posts: 13
|
Posted: Wed Aug 06, 2008 3:41 pm Post subject: |
|
|
| it didnt work forme i downloaded everything |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1390 Location: The Interwebs
|
Posted: Wed Aug 06, 2008 9:18 pm Post subject: |
|
|
| That, is very cool. |
|
| Back to top |
|
 |
Azerty
Joined: 19 Dec 2006 Posts: 72 Location: France
|
Posted: Thu Aug 07, 2008 8:13 am Post subject: |
|
|
excellent POC, thx for sharing  _________________ Assembler-coded MCode.ahk ASCII85.ahk library |
|
| Back to top |
|
 |
rockeveryone22 Guest
|
Posted: Thu Aug 07, 2008 9:26 am Post subject: |
|
|
ok mates for those of you had made it work what did u exactly do please help  |
|
| Back to top |
|
 |
shajul
Joined: 15 Sep 2006 Posts: 564
|
Posted: Thu Aug 07, 2008 5:41 pm Post subject: Vista effect |
|
|
On Vista Home Premium,
the holes are blown, but not immediately visible, till the window is minimized and again restored..
otherwise, the effect works well.. very nice! |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Aug 08, 2008 4:32 pm Post subject: |
|
|
| yeah mate i wish i could see it run but on xp sp2 the program runs but does nothing i, hate my life |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Aug 09, 2008 2:19 am Post subject: |
|
|
| Anonymous wrote: | | ...i, hate my life |
...oookkk, then, well did you try double clicking? Let me revise that, run the program (by double clicking on it)...THEN open notepad (for example)...then double click in the empty notepad...you should get a (non-circular) hole...plus testing on notepad you don't have to deal with a hole in a window you need...(yes I know there's a "repair" key)...I can confirm in XP SP1 it works... |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sat Aug 20, 2011 6:07 pm Post subject: |
|
|
Just had the chance to test this out, Very nice.
mci error dialog gets triggered in AHK Unicode version.
The couple of mciExecute() need to be altered as follows:
| Code: | | DllCall( "winmm.dll\mciExecute", A_IsUnicode ? "AStr" : "Str", sStr ) |
|
|
| Back to top |
|
 |
nimda
Joined: 26 Dec 2010 Posts: 3856 Location: Awesometown, USA
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sat Aug 20, 2011 6:26 pm Post subject: |
|
|
| @nimda: user32\GetDoubleClickTime |
|
| Back to top |
|
 |
|