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 

Exit AutoHotkey from command line?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Futurepower(R)



Joined: 20 Jun 2005
Posts: 35

PostPosted: Tue Mar 11, 2008 8:35 pm    Post subject: Exit AutoHotkey from command line? Reply with quote

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



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Tue Mar 11, 2008 9:50 pm    Post subject: Reply with quote

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



Joined: 20 Jul 2006
Posts: 174

PostPosted: Tue Mar 11, 2008 10:10 pm    Post subject: Reply with quote

do you mean windows cmd prompt?
Code:
TASKKILL /F /IM autohotkey.exe
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Mar 12, 2008 1:21 pm    Post subject: Thanks. TaskKill does the job. Reply with quote

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

PostPosted: Wed Mar 12, 2008 2:03 pm    Post subject: Laszlo: ::exitahk:: explained. Reply with quote

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



Joined: 16 May 2006
Posts: 58

PostPosted: Wed Mar 12, 2008 2:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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