Page 1 of 1

From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 15 Dec 2015, 12:18
by alllala
Hi,

Since the last update I have some issues with my Scripts, so they don´t work fully as intended like before the update

For Example:

Code: Select all

Runwait some.exe
;to work it seems now be written as:
Runwait, some.exe
Excuse me, if I´m missing something obvious.

Edit1:
After investigating the matter further I have to correct myself.
A_Workingdir seems to have changed.
Before Dir was the same path as the Script that runs the command

Code: Select all

Runwait some.exe
;to work it seems now be written as:
Runwait some.exe, Dir

Re: From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 15 Dec 2015, 12:21
by TheDewd
I am running the latest version of AutoHotkey, and I'm not experiencing this issue...

FYI: I always find it best to write your code with the proper capitalization and punctuation, for better readability if nothing else...

RunWait, some.exe

Re: From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 15 Dec 2015, 12:23
by Exaskryz

Code: Select all

^8::
runwait notepad.exe
MsgBox Hi
return
This works fine for me. Launches notepad, and when I manually close it I get a MsgBox as expected.

Re: From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 15 Dec 2015, 12:30
by alllala
Edit1

Re: From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 19 Dec 2015, 10:37
by alllala
Has A_Workingdir changed ?

Re: From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 19 Dec 2015, 19:33
by lexikos
It most likely has nothing to do with changes between v1.1.22.0x and v1.1.22.09.

A_WorkingDir just returns the working directory. AutoHotkey v1 does not set the initial working directory. Either you must set it, or the working directory set by the program which launched AutoHotkey will be used. If you launched AutoHotkey by double-clicking/running a shortcut file, a script file or AutoHotkey.exe, that program is most likely explorer.exe. For shortcut files, the working directory can be specified in the shortcut's properties.

Re: From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 20 Dec 2015, 10:41
by alllala
Thank you for your reply.

I believe to have found the cause of the different behavior. As I updated AHK to .09, I let the Update tool restart my Script, which let A_WorkingDir to be in a different Folder than usual.

Re: From 1.1.22.0x -> 1.1.22.09 : Something changed, Scripts not working fully

Posted: 23 Dec 2015, 04:54
by lexikos
Thanks for reporting back. I have updated the installer (for the next release) to set the working directory to the directory which contains the script. It was defaulting to whatever working directory explorer.exe had (probably System32).

I considered retrieving the working directory of the script and restarting it with that, but it would be more complicated. It is also possible that the script expects to start in a different working directory to what it is using at the moment the installer closes it. We can't just send a reload message to the script, because it's not running ;) and a standard reload wouldn't work anyway because the new window title is different (if the AutoHotkey version changed).

It is generally recommended to SetWorkingDir in your script's auto-execute section. For instance, the default "New AutoHotkey Script" template contains the following line:

Code: Select all

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
AutoHotkey v2-alpha sets the working directory to A_ScriptDir by default.