AHK Works, EXE Version Throwing An Error Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

AHK Works, EXE Version Throwing An Error

Post by Mulsiphix » 18 Jan 2022, 10:42

The code below works flawlessly when I run the AHK script. But if I convert the AHK to EXE the EXE version throws an error when the hotkey is activated. Any idea why?

Error Produced
Image

Code: Select all

; What It Does: If Shift is double tapped, press the insert key and run P2T-8F-2560x1440.ahk

;Variables
P2T_8F_PATH_PARTIAL := "\Eight Frames (Colorized)" ; 
P2T_8F_PATH_FULL := A_ScriptDir P2T_8F_PATH_PARTIAL
; MsgBox, %P2T_8F_PATH_FULL% ; Uncomment to verify varible contents.

~Shift::
	if (A_PriorHotkey <> "~Shift" or A_TimeSincePriorHotkey > 500)
	{
		KeyWait, LShift
		Return
	}
If toggle := !toggle ; Enables a toggle for Push-To-Talk between On/Off
   {
   Send, {Insert down}
   Run, P2T-8F-2560x1440.ahk, %P2T_8F_PATH_FULL%,, P2T_8F_2560x1440
   }
Else
   {
   Send, {Insert up}
   Process, Close, %P2T_8F_2560x1440%
   }
Return

User avatar
mikeyww
Posts: 26855
Joined: 09 Sep 2014, 18:38

Re: AHK Works, EXE Version Throwing An Error  Topic is solved

Post by mikeyww » 18 Jan 2022, 10:47

Since the file is not found, I would try specifying the full path to your file. You can also first use FileExist to display whether AHK finds the file.
The script's working directory is the default directory that is used to access files and folders when an absolute path has not been specified. A script's initial working directory is determined by how it was launched. For example, if it was run via shortcut -- such as on the Start Menu -- its working directory is determined by the "Start in" field within the shortcut's properties. To make a script unconditionally use its own folder as its working directory, make its first line the following: SetWorkingDir %A_ScriptDir%. Once changed, the new working directory is instantly and globally in effect throughout the script. All interrupted, paused, and newly launched threads are affected, including Timers.

User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: AHK Works, EXE Version Throwing An Error

Post by JoeWinograd » 18 Jan 2022, 11:14

Mulsiphix wrote:works flawlessly when I run the AHK script. But if I convert the AHK to EXE the EXE version throws an error
Smells a lot like this issue:

viewtopic.php?f=76&t=88473

Regards, Joe

Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Re: AHK Works, EXE Version Throwing An Error

Post by Mulsiphix » 18 Jan 2022, 14:30

Thank you both very much for the quick reply. I feel very foolish at this moment. It did not dawn on me earlier that my compiled EXE file was in a different location than the AHK file. Because of how I chose to specify the path for the AHK file, the script only works when executed from the AHK file directory. Obvious to me now and easy to fix. Sorry about that. Thank you very much for your support :oops:

Post Reply

Return to “Ask for Help (v1)”