0

I'm trying to make an AutoHotKey script that will launch all the third party programs for the game Digital Combat Simulator, as well as the game itself, but I keep getting an error on my first program launch.

Is it better to launch the programs as a secondary script, or can I run the programs I need and also set up my hotkeys all from the same script?

SendMode Input 
SetWorkingDir %A_ScriptDir%
#UseHook On

Run, C:\Program Files (x86)\H2ik\Joystick Gremlin\joystick_gremlin.exe, ,min

q0 = 0

#IfWinActive Digital Combat Simulator
;===========================================================
;For toggle switches
;X is the key the toggle presses while in the ON position
;===========================================================
x::
if (q0 == 1)
    return
if (q0 == 0) {  
    SendEvent {q 2}
    q0 = 1
    return
}

x Up::
    SendEvent {Lshift down}{q 2}{Lshift up}
    q0 = 0
    return

;===========================================================
;End X toggle switch block
;===========================================================    
#IfWinActive
;===========================================================
;Control + Escape exits script
;===========================================================    
^Escape::
ExitApp
Return
John B
  • 11
  • What does the error say exactly? You can launch all programs from your main script or from a secondary script(s); there really isn't a definite general advantage either way, but both are possible. – EJE May 03 '19 at 15:24
  • "Failed to execute script joystick_gremlin" – John B May 04 '19 at 19:22
  • I am also getting the same message. When I run it manually, it says "vJoy is not present or incorrectly setup." What does it say for you when you run it manually? – EJE May 06 '19 at 13:58
  • Okay, installed vJoy and now it opens normally manually. The program appears to be written (at least partially) in Python. Doing a search for "Failed to execute script" brings up a lot of Python-related posts. This makes me suspect that the problem may be related to the program and not AHK. – EJE May 06 '19 at 15:03

1 Answers1

0

The problem is related to the program itself and not AutoHotkey (as this can be duplicated in the console), but fortunately, we can get it to work.

Just set the working directory to be the same path as the executable (prior to the Run command) and it should function normally. For some reason, though, it won't load minimized, but there are also other ways to take of that if needed.

SetWorkingDir , C:\Program Files (x86)\H2ik\Joystick Gremlin\

I suspect that there is some dependency that doesn't get mapped properly unless the proper environment variables are set. For reference, the comment to the top-voted answer to the link below steered me to the answer.

Windows- Pyinstaller Error "failed to execute script " When App Clicked

EJE
  • 1,868
  • 2
  • 8
  • 18