How to run AutoHotKey Scipt via Remote Action?
I'm coming from recently upgrading from UR 2.x to 3.x and I can't figure out how to make a remote action run my AutoHotKey script.
In version 2.x I was able to run the script from inside my .xml file for the remote:
<ActionRef Name="Run" Target="Core.Task" Extra="C:\batchfiles\mutemon.ahk"/>
I'm attempting to recreate the same action in 3.x without any luck.
--The batch script attempts to call the ahk file. It works when ran directly in windows, but, doesn't work via os.open. os.open("C:\\batchfiles\\mutemon.bat"); --The converter found at http://dev.unifiedremote.com/converter converts my XML it to use os.start, however from the examples I'm unsure if it can support a Windows directory path? os.start("C:\\batchfiles\\mutemon.ahk"); --Another attempted workaround. Again this works when directly ran via command prompt in Windows, but not through os.script. os.script("start /min /d \"C:\\batchfiles\" mutemon.ahk");
Is there some type of fundamental limitation with scripts in regard to Windows security? I'm on Windows 8 running UR Server 184.108.40.2063
Hello there.... your slashes in the paths are the wrong way...... they need to lean forwards...
Also, (I do not remember) you might need the complete path to the file.....
os.open("C:/Program Files (x86)/Image-Line/FL Studio 8/Data/Projects/Loop Maya.flp");
Still no luck, at this point I'm simply trying to find any UF function to run an autohotkey script like 2.x did.
- My remote action contains a print() which triggers as expected and shows in the trace log.
- My AHK script contains OutputDebug, HIT which when ran prints in DebugView (although it never shows, since the script isn't ran).
Does anyone have a working 3.x UF remote running an AHK script? Any reference would be greatly appreciated.
@smorris Hello again, I would guess that......
or probably also with your "escaped" backslashes should work.
An *.ahk file is just a text file, and not an executable, so it needs to be "opened" and not "started". It is then opened and the instruction executed automatically by autohotkey.exe (or mutemon.exe if you have renamed a copy of autohotkey.exe especially for this function) which is called because of the file extension .ahk.
If you are trying to open the .ahk from a .bat you should look at this........http://stackoverflow.com/questions/11074849/run-a-batch-file-in-a-new-window-from-batch
Do you just double-click your batch file for it to work normally?
If you right-click the batch and check the permissions you might find an answer about win8 security.......
Problem solved, I found the limitation when trying to use os.open(). The folders/files available are only those on the same drive that UR Server is running from. In my scenario the 3.x UR Server was running from a different drive from where the batch/ahk files were stored.
Thanks for the guidance David, testing with os.open() gave me enough to find the issue.
P.S. The escaped backslashes are shown in the documentation for os.open() which is where I got the idea from. I don't think it makes any difference in the end as long as the code is written correctly. https://github.com/unifiedremote/Docs/blob/master/libs/os.md#osopen-path-args-
@smorris That's good news.
The escaped backslashes are necessary in lua (and a lot of other programs as well) because backslash is very often a reserved (i.e. special) character.........