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

Get help with using AutoHotkey and its commands and hotkeys
alllala
Posts: 17
Joined: 03 Apr 2014, 05:04

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

15 Dec 2015, 12:18

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
Last edited by alllala on 15 Dec 2015, 12:31, edited 2 times in total.
User avatar
TheDewd
Posts: 1361
Joined: 19 Dec 2013, 11:16
Location: USA

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

15 Dec 2015, 12:21

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
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

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

15 Dec 2015, 12:23

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.
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

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

19 Dec 2015, 19:33

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.
alllala
Posts: 17
Joined: 03 Apr 2014, 05:04

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

20 Dec 2015, 10:41

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.
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

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

23 Dec 2015, 04:54

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.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, eagerahk, Google [Bot], Rohwedder, TAC109 and 236 guests