AutoHotkey Community

It is currently May 27th, 2012, 10:47 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: March 11th, 2008, 9:35 pm 
Offline

Joined: June 20th, 2005, 9:13 pm
Posts: 37
Is it possbile to exit AutoHotkey from the command line?

I've searched the help and not found a method of doing that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2008, 10:50 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2008, 11:10 pm 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
do you mean windows cmd prompt?
Code:
TASKKILL /F /IM autohotkey.exe


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 12th, 2008, 2:21 pm 
Both answers are interesting. I am interested mostly in TaskKill, which I had forgotten.


Report this post
Top
  
Reply with quote  
PostPosted: March 12th, 2008, 3:03 pm 
Offline

Joined: June 20th, 2005, 9:13 pm
Posts: 37
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."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2008, 3:08 pm 
Offline

Joined: May 16th, 2006, 8:21 pm
Posts: 58
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, Google Feedfetcher, specter333, Yahoo [Bot] and 46 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group