geekhack
geekhack Community => Keyboards => Topic started by: Herman on Tue, 15 May 2012, 14:41:09
-
Hi I just started using auto hot key, and i have some commands to open different things like this,
!^m::Run C:\music\mp3.m3u
!^d::Run C:\funny.vbs
this is just some examples, and as you can see my code is extremely simple.
my question is, I'm not the best at English, so I have some trouble to understand the different guides around the net, but i would like another shortcut so I can close these programs again, can somebody in here tell me how, or hand me a little piece of code I could steal.
Thanks in advance :)
-
Hey Herman. The fine guys at donationcoder.com might well be able to help you out. One guy, Skrommel, seems to be an AHK wizard...
-
Here's one that'll pop the calculator app:
#c:: ; Calculator
IfWinExist Calculator
IfWinActive Calculator
WinClose
else
WinActivate
else
Run C:\Windows\system32\calc.exe
return
If the Calculator has focus, it'll close it. If it's running but doesn't have focus it'll pull it to the front and focus it. If it's not running, it'll run it.
To change it to open and close Calculator regardless of focus:
#c:: ; Calculator
IfWinExist Calculator
WinClose
else
Run C:\Windows\system32\calc.exe
return
-
^I like the calc toggle. Thanks ;D
-
Oh hey, be warned, I haven't rewritten this one because it rarely blows up. The word Calculator in a browser window will cause that window to be closed instead of calc opening... :sorry:
ok, that was easy:
#c:: ; Calculator
Launch_App2::
IfWinExist ahk_class CalcFrame
IfWinActive ahk_class CalcFrame
WinClose
else
WinActivate
else
Run C:\Windows\system32\calc.exe
return
-
Well, you can always use:
#c:: ; Calculator
IfWinExist Calculator
Process, close, calc.exe
else
Run C:\Windows\system32\calc.exe
return
-
That would work for the case where the Calculator is running but you also have a browser up w/ Calculator. But if calc wasn't running and the browser was, nothing would happen. So I modified it to the Window Class instead of title matching.
-
True. I guess I could try to detect the calc.exe process. Lemme see if I can get it done with less code
Process, exist, calc.exe
If ErrorLevel
Process, close, calc.exe
else
Run C:\Windows\system32\calc.exe
return