Run command won't work Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
seolo
Posts: 5
Joined: 30 Jul 2021, 03:01

Run command won't work

Post by seolo » 30 Jul 2021, 07:50

First of all, i'm new to autokeykey.

I have built an arcade cabinet which has no mouse or keyboard, just game buttons.
When window10 starts I want to use autohotkey to use my buttons to start the games.

My script looks like this.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force

GroupAdd, vGroupDesktop, ahk_class Progman ;desktop
GroupAdd, vGroupDesktop, ahk_class WorkerW ;desktop

#IfWinActive, ahk_group vGroupDesktop

Joy2::
Run, ‪C:\PinballX\Pinball.exe
Return

Joy3::
Run, ‪C:\CoinopsArcade\ARCADE(Micro).exe
Return

Joy4::
Run, ‪C:\CoinopsArcade\ARCADE(All).exe
Return

Joy11 & Joy12::
run, %comspec% /k shutdown -r -t 30
Return


#IfWinActive
But I don't start any programs? It says it can't find them and I tripplechecked the path.
Any suggestions? As a test put an msg box instead and it detects the buttons!

Regards
Johan
User avatar
mikeyww
Posts: 26854
Joined: 09 Sep 2014, 18:38

Re: Run command won't work

Post by mikeyww » 30 Jul 2021, 09:03

Since your script does not work, simplify it while you test. Try the following with no other code.

Code: Select all

file = C:\PinballX\Pinball.exe
Joy2::
If FileExist(file)
 Run, %file%
Else MsgBox, 48, Error, File not found.`n`n%file%
Return
If it works, expand gradually, testing carefully along the way.
seolo
Posts: 5
Joined: 30 Jul 2021, 03:01

Re: Run command won't work

Post by seolo » 30 Jul 2021, 09:32

Thanks for help!

When i press button 2(Joy2) it opens a windows showing files on the desktop!
There is no error msg.
Se below for picture

https://imgur.com/a/dA6TRfb
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Run command won't work

Post by gregster » 30 Jul 2021, 09:43

I think the problem is that you have some invisible unicode characters in your code (happens often when copy-pasting from somewhere).
You can test here: https://www.soscisurvey.de/tools/view-chars.php

Copy your code above (at least the run-lines), paste it to that page, and see that you have some (U+202A) characters in your run-lines (so called 'LEFT-TO-RIGHT EMBEDDING' chars) which will throw off the AutoHotkey parser.
seolo
Posts: 5
Joined: 30 Jul 2021, 03:01

Re: Run command won't work

Post by seolo » 30 Jul 2021, 11:41

gregster wrote:
30 Jul 2021, 09:43
I think the problem is that you have some invisible unicode characters in your code (happens often when copy-pasting from somewhere).
You can test here: https://www.soscisurvey.de/tools/view-chars.php

Copy your code above (at least the run-lines), paste it to that page, and see that you have some (U+202A) characters in your run-lines (so called 'LEFT-TO-RIGHT EMBEDDING' chars) which will throw off the AutoHotkey parser.
Thanks!
Tested it but no other characters!
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Run command won't work

Post by gregster » 30 Jul 2021, 11:56

seolo wrote:
30 Jul 2021, 11:41
Tested it but no other characters!
How do you mean ?!
Clearly, there are:

invisible unicode.png
invisible unicode.png (17.6 KiB) Viewed 419 times
seolo
Posts: 5
Joined: 30 Jul 2021, 03:01

Re: Run command won't work

Post by seolo » 30 Jul 2021, 12:10

gregster wrote:
30 Jul 2021, 11:56
seolo wrote:
30 Jul 2021, 11:41
Tested it but no other characters!
How do you mean ?!
Clearly, there are:


invisible unicode.png
Strange, I only got the 'CR' and 'LF'!
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Run command won't work  Topic is solved

Post by gregster » 30 Jul 2021, 12:18

Well, the invisible characters are clearly a reason that the run command can't find valid paths. Otherwise, there is no explanation.

I have now removed these characters from the code. Thy this

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force

GroupAdd, vGroupDesktop, ahk_class Progman ;desktop
GroupAdd, vGroupDesktop, ahk_class WorkerW ;desktop

#IfWinActive, ahk_group vGroupDesktop

Joy2::
Run, C:\PinballX\Pinball.exe
Return

Joy3::
Run, C:\CoinopsArcade\ARCADE(Micro).exe
Return

Joy4::
Run, C:\CoinopsArcade\ARCADE(All).exe
Return

Joy11 & Joy12::
run, %comspec% /k shutdown -r -t 30
Return


#IfWinActive
seolo
Posts: 5
Joined: 30 Jul 2021, 03:01

Re: Run command won't work

Post by seolo » 31 Jul 2021, 02:34

Thank you gregster!

I am so stupid, i was working from 2 different computers and when I checked for invisible characters I was doing it from another computer....sorry!
When doing it from the arcade-computer it detected the invisible characters.

It now works and am so grateful!
Post Reply

Return to “Ask for Help (v1)”