Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I have an AHK script which has a variable in it - how can I pass a value to that variable so that the script runs with that value?

Can I call an AHK script from PHP or Javascript - if so how? I ask this as it may be a solution to my first question (value passed when AHK script is called)

share|improve this question
add comment

1 Answer

Yes. From http://www.autohotkey.com/docs/Scripts.htm#cmd, "Passing Command Line Parameters to a Script":

AutoHotkey.exe [Switches] [Script Filename] [Script Parameters]

So from any system which can execute commands, you would call the autohotkey.exe executable with the name of your script followed by your script's parameters (which will map them to variables like %1, %2, etc).

If you were using PHP to execute this, you might use PHP's shell_exec command:

<?php
$output = shell_exec('autohotkey script.ahk arg1 arg2');
echo "<pre>$output</pre>";
?>
share|improve this answer
    
Looks good - but where is the shell_exec directory? I think that my script is not being found but I am guessing. –  Doclands Sep 12 '12 at 11:00
    
Thanks @ckhan - I can run my script from the command prompt but not from PHP which is my aim - I think that it is a directory problem - I do not know where to place my ahk script so that script_exec can find it (or which root to use so I can put the path in the scrip_exec command) –  Doclands Sep 12 '12 at 11:38
    
Sorted - thank you - your solution is perfectly correct - I am using EasyPhP as my PhP server - the script should have been in the root directory of the server - also I needed to use %1% rather than %1. –  Doclands Sep 12 '12 at 14:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.