Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AutoHotkey Script Restarter v1.01


  • Please log in to reply
27 replies to this topic
evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
I usually have quite a few uncompiled (.ahk format) scripts running and these need to be closed before I can update to a new version of AutoHotkey (since uncompiled scripts make use of AutoHotkey.exe). I've updated it to also be able to just close selected processes.

This script shows a list of all such running scripts and has a button for stopping them and a button for restarting them (after having updated AutoHotkey).

Save the script from the link below, but note that is MUST be compiled before use otherwise AutoHotkey.exe will still be in use, since the script can't stop itself :wink:

AutoHotkey Script Restarter

Updated to v1.01:
- Selected script processes can be ended (e.g. tidy up after testing some scripts out).
- Option to also close the help file (for updating).
- Some small fixes.

Thanks go to Shimanov for his code to retrieve the process information and the command line parameters they were run with.

robiandi
  • Guests
  • Last active:
  • Joined: --
- A repeating line, is this a typo ?
GuiClose:

GuiEscape:

HandleExit: 

   DllCall( "CloseHandle", "uint", ht_this ) 

   DllCall( "CloseHandle", "uint", hp_this ) 

ExitApp 

- Perhaps one should/could add AutoHotkey.chm to the list of running processes

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
That's part of Shimanov's code and I don't think it's a typo.

I thought about also closing the manual but wasn't sure. I'll probably add a checkbox for whether to close it or not, thanks for reminding me about that.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
Updated to v1.01 (see 1st post):
- Selected script processes can be ended (e.g. tidy up after testing some scripts out).
- Option to also close the help file (for updating).
- Some small fixes.

robiandi
  • Guests
  • Last active:
  • Joined: --
many thanks.

robiandi
  • Guests
  • Last active:
  • Joined: --
I upgraded succcessfully to AutoHotKey 1.0.43.03 commenting one of the above double lines.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
I just updated too. Those lines are not doubled as far as I'm aware - they're for closing handles that the script creates during its running. Although it will function without both of them, it would leave behind un-closed handles to processes after the script exits. That's my understanding, but it's shimanov's bit of script.

robiandi
  • Guests
  • Last active:
  • Joined: --
ok

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
evl is right.
Besides, the lines are not identical: "ht_this" vs "hp_this"
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

robiandi
  • Guests
  • Last active:
  • Joined: --
thanks, now I see,
there are no repeating lines.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
I picked a good time to write this script - 2 AutoHotkey updates from Chris in as many days :lol: Maybe Chris could integrate something like this into the installer itself? I'm not sure if there would be a convenient way of doing it though because I have no experience of packaging software with an installer.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Some kind of auto-update or update-check is already on the to-do list due to repeated suggestions from others over the past two years. Thanks.

badmojo
  • Members
  • 204 posts
  • Last active: Jul 23 2014 01:39 AM
  • Joined: 11 Nov 2005
very useful script, but i had run into a problem because i use the zipped version of AHK.

I had this confirmed by checking the help file. It has to do with the built-in variable, A_AhkPath which, in a compiled script, looks for AutoHotkey.exe here -> HKLM\SOFTWARE\AutoHotkey\InstallDir. Since there will be no such key in the registry, A_AhkPath will be blank and therefore the script would raise an error.

So this is my work-around, in case anyone else has had same the problem... :wink:
; If compiled, put AHK.exe path into this variable, AHKPath
; because the internal var A_AhkPath would be empty
AHKPath=%ProgramFiles%\AutoHotkey\AutoHotkey.exe
...
    ;Run, %A_LoopField%, %Script_WorkingDir%
    Run, %AHKPath% %A_LoopField%

badmojo

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
I didn't use A_AhkPath anywhere in the script. The script retrieves the path to the .ahk file and just runs that, with the same directory as its working directory (very important or else you get your ini files not saved in the right place etc). Nowhere does it include the path to autohotkey.exe.

I can only think that you don't have ahk files associated to run when double-clicked?

badmojo
  • Members
  • 204 posts
  • Last active: Jul 23 2014 01:39 AM
  • Joined: 11 Nov 2005

I can only think that you don't have ahk files associated to run when double-clicked?

you're right, i don't have ahk files associated with AHK. that's why i had to modify this line:

;Run, %A_LoopField%, %Script_WorkingDir%
    Run, %A_AHKPath% %A_LoopField%
but of course, in my case A_AhkPath is blank, therefore i had to add a variable containing the path to AHK's exe. sorry for not clarifying but i thought that by mentioning that i was using the zipped version of AHK, one would assume this would be the case...

anyway, tks for the super-cool script. :idea: