 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
bbint
Joined: 17 Sep 2008 Posts: 19
|
Posted: Sat May 30, 2009 7:28 pm Post subject: Way to make a hotkey that closes all current scripts? |
|
|
Is there a way to make a hotkey that closes all current scripts and opens a new script?
I have a script for firefox and I sometimes overlap that script with another script for certain web applications
During the web browsing, I might want to press PrtScr and paste it to paint.net
I have a separate 3rd script for paint.net
Currently, I have Insert::ExitApp in the first 2 web browsing scripts
I press “Insert” twice, and then I manually click the 3rd paint.net script from the desktop
Would a possible 1-button solution look something like this?
| Code: | anyButton::
“Something that will ExitApp twice or more”
OnExit, ExitSub
ExitSub:
Run, Thirdscript.ahk, C:\Documents and Settings\Jeff\Desktop, hide
ExitApp |
I don’t want to run Thirdscript.ahk until the first 2 web browsing scripts are closed
So pretty much..
1) ExitApp
2) If another script exists, close it first
3) If another script exists, close it first
4) Only run Thirdscript.ahk if there's no other script left to close
Do I run into complications for trying to close multiple scripts simultaneously?
Is there an ExitApp to close a specific script name or all running scripts?
Is it better to just learn to deal with switching between scripts 1 at a time?
Thanks |
|
| Back to top |
|
 |
etopsirhc
Joined: 12 Mar 2008 Posts: 62 Location: OR
|
Posted: Sat May 30, 2009 10:25 pm Post subject: |
|
|
this will close ALL uncompiled ahk scripts
| Code: |
hotkey::
Process, Close, AutoHotkey.exe
return |
--NOTE--
Close: If a matching process is successfully terminated, ErrorLevel is set to its former Process ID (PID). Otherwise (there was no matching process or there was a problem terminating it), it is set to 0. Since the process will be abruptly terminated -- possibly interrupting its work at a critical point or resulting in the loss of unsaved data in its windows (if it has any) -- this method should be used only if a process cannot be closed by using WinClose on one of its windows _________________ life is but a dream
death is the reality |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Sat May 30, 2009 10:48 pm Post subject: |
|
|
Try | Code: | DetectHiddenWindows,On
Process, Exist
OWNPID:=ErrorLevel
WinGet, ID, List, AHK_class AutoHotkey
Loop %ID%
{
WinGet, PID,PID,% "ahk_id " . ID%A_Index%
If (PID!=OWNPID)
PostMessage, 0x111,65400,,,% "ahk_id " ID%A_Index% ;Reload Script
} |
EDIT:
Changed to work on window ID rather than PID (does not always work) _________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|
| Back to top |
|
 |
LazyLarry Guest
|
Posted: Sat May 30, 2009 11:31 pm Post subject: |
|
|
Here is a more elaborate hotkey that exits all AutoHotkey scripts (in case you're ever running more than one simultaneously):
| Code: | ^!x::
; Close all other instances of AutoHotkey except this one:
DetectHiddenWindows, on
LOOP
{
IfWinNotExist, - AutoHotkey v, , %A_SCRIPTFULLPATH%
BREAK
WinClose
WinWaitClose
}
;Now close this one:
EXITAPP | [Moderator's note: Added code tags.] |
|
| Back to top |
|
 |
ballyhairs
Joined: 02 Feb 2009 Posts: 112
|
Posted: Mon Sep 07, 2009 1:00 pm Post subject: |
|
|
| I was searching for something else on the forum and came across this thread, however all above didn't work |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Mon Sep 07, 2009 7:50 pm Post subject: |
|
|
Try this to close all running scripts:
| Code: | DetectHiddenWindows,On
Process, Exist
OWNPID:=ErrorLevel
WinGet, ID, List, AHK_class AutoHotkey
Loop %ID%
{
WinGet, PID,PID,% "ahk_id " . ID%A_Index%
If (PID!=OWNPID){
WinClose,% "ahk_id " ID%A_Index%
Process,WaitClose,%PID%,0.3
If (ErrorLevel){
WinKill,% "ahk_id " ID%A_Index%
Process,WaitClose,%PID%,0.3
If (ErrorLevel){
WinGetTitle,name,% "ahk_id " ID%A_Index%
MsgBox,262148,Kill Script,Would you like to kill %name%
IfMsgBox Yes
Process,Close,%PID%
}
}
}
} |
_________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|
| Back to top |
|
 |
ballyhairs
Joined: 02 Feb 2009 Posts: 112
|
Posted: Mon Sep 07, 2009 7:54 pm Post subject: |
|
|
That does work, you really are genius  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|