AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Explode Mouse - Practical Joke / WinSet Region Demo
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
ManaUser



Joined: 24 May 2007
Posts: 1121

PostPosted: Sat Jun 30, 2007 5:38 pm    Post subject: Explode Mouse - Practical Joke / WinSet Region Demo Reply with quote

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
View user's profile Send private message
wibumba (not logged in)
Guest





PostPosted: Sun Jul 01, 2007 8:13 am    Post subject: Reply with quote

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






PostPosted: Sun Jul 01, 2007 8:14 am    Post subject: Reply with quote

scratch that. Damn thing made me jump. I had my speakers turned up.
Back to top
OctalMage as a guest
Guest





PostPosted: Sun Jul 01, 2007 10:33 pm    Post subject: cool Reply with quote

man, this script it really cool.

I really enjoy it.

Thanks for sharing.

Smile
Back to top
rockeveryone21



Joined: 06 Aug 2008
Posts: 13

PostPosted: Wed Aug 06, 2008 3:41 pm    Post subject: Reply with quote

it didnt work forme i downloaded everything
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Wed Aug 06, 2008 9:09 pm    Post subject: Reply with quote

highly amusing, nice one Wink
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1390
Location: The Interwebs

PostPosted: Wed Aug 06, 2008 9:18 pm    Post subject: Reply with quote

That, is very cool.
Back to top
View user's profile Send private message AIM Address
Azerty



Joined: 19 Dec 2006
Posts: 72
Location: France

PostPosted: Thu Aug 07, 2008 8:13 am    Post subject: Reply with quote

excellent POC, thx for sharing Smile
_________________
Assembler-coded MCode.ahk ASCII85.ahk library
Back to top
View user's profile Send private message
rockeveryone22
Guest





PostPosted: Thu Aug 07, 2008 9:26 am    Post subject: Reply with quote

ok mates for those of you had made it work what did u exactly do please help Razz
Back to top
shajul



Joined: 15 Sep 2006
Posts: 564

PostPosted: Thu Aug 07, 2008 5:41 pm    Post subject: Vista effect Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger
Guest






PostPosted: Fri Aug 08, 2008 4:32 pm    Post subject: Reply with quote

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






PostPosted: Sat Aug 09, 2008 2:19 am    Post subject: Reply with quote

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

PostPosted: Sat Aug 20, 2011 6:07 pm    Post subject: Reply with quote

Just had the chance to test this out, Very nice. Smile

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
View user's profile Send private message Send e-mail
nimda



Joined: 26 Dec 2010
Posts: 3856
Location: Awesometown, USA

PostPosted: Sat Aug 20, 2011 6:19 pm    Post subject: Reply with quote

There is a dllcall for "GetDoubleClickSpeed" or something like that. You should use it instead of 200
_________________
Spam. Autoclick. Rapidfire.Window Control ToolsLicense
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Sat Aug 20, 2011 6:26 pm    Post subject: Reply with quote

@nimda: user32\GetDoubleClickTime
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group