| View previous topic :: View next topic |
| Author |
Message |
Futurepower(R)
Joined: 20 Jun 2005 Posts: 35
|
Posted: Tue Mar 11, 2008 8:35 pm Post subject: Exit AutoHotkey from command line? |
|
|
Is it possbile to exit AutoHotkey from the command line?
I've searched the help and not found a method of doing that. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Tue Mar 11, 2008 9:50 pm Post subject: |
|
|
Add the following to the end of your AHK script: | Code: | #IfWinActive ahk_class ConsoleWindowClass
!z::ExitApp
::exitahk::
ExitApp |
If in a console window you press ALT-Z or type "exitahk" (w/o quotes) and a space or enter, your AHK script terminates. |
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 174
|
Posted: Tue Mar 11, 2008 10:10 pm Post subject: |
|
|
do you mean windows cmd prompt?
| Code: | | TASKKILL /F /IM autohotkey.exe |
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Mar 12, 2008 1:21 pm Post subject: Thanks. TaskKill does the job. |
|
|
| Both answers are interesting. I am interested mostly in TaskKill, which I had forgotten. |
|
| Back to top |
|
 |
Futurepower(R)
Joined: 20 Jun 2005 Posts: 35
|
Posted: Wed Mar 12, 2008 2:03 pm Post subject: Laszlo: ::exitahk:: explained. |
|
|
Laszlo, When I first read your comment, I completely understood 3 lines out of the four you wrote. I didn't understand this:
::exitahk::
I didn't see any way to find that in the Help, because Windows Help won't search for punctuation. So, for the benefit of anyone who reads this, here is the answer I found eventually:
Hotstrings and Auto-replace
"To define a hotstring, enclose the triggering abbreviation between pairs of colons as in this example:
::btw::by the way
"... a hotstring may also be defined to perform any custom action as in the following examples. Note that the commands must appear beneath the hotstring:
::btw::
MsgBox You typed "btw".
return
:*:]d:: ; This hotstring replaces "]d" with the current date and time via the commands below.
FormatTime, CurrentDateTime,, M/d/yyyy h:mm tt ; It will look like 9/1/2005 3:53 PM
SendInput %CurrentDateTime%
return
"Even though the two examples above are not auto-replace hotstrings, the abbreviation you type is erased by default. This is done via automatic backspacing, which can be disabled via the b0 option." |
|
| Back to top |
|
 |
Aybra
Joined: 16 May 2006 Posts: 58
|
Posted: Wed Mar 12, 2008 2:08 pm Post subject: |
|
|
If you just want the program to shut down and your using a GUI... use this.
| Quote: | GuiClose: Launched when the window is closed by any of the following: pressing its X button in the title bar, selecting "Close" from its system menu, or closing it with WinClose. If this label is absent, closing the window simply hides it, which is the same effect as Gui Cancel. One of the most common actions to take in response to GuiClose is ExitApp; for example:
GuiClose:
ExitApp
|
| Code: |
~Pause::Reload
Reload
return
|
I use this to reload my scripts, but swap out the Reload for ExitApp and it will do the same thing. |
|
| Back to top |
|
 |
|