AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing Command Line Parameters to a Non-Compiled Script ?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Thu Feb 24, 2005 2:52 pm    Post subject: Passing Command Line Parameters to a Non-Compiled Script ? Reply with quote

Compiled scripts accept parameters, see quote from help.
Quote:
Passing Command Line Parameters to a Script
Scripts support command line parameters. The format is:
CompiledScript.exe [Switches] [Script Parameters]
[...]
Script Parameters can be any strings you want to pass into the script (but any string that contains spaces must be enclosed in double quotes). The script sees incoming parameters as the variables %1%, %2%, and so on. In addition, %0% contains the number of parameters passed (0 if none).
But how can I hand a parameter over to a non-compiled script?
I tried this, but without success:
Code:
Run, %ScriptFilename%.ahk %Parameter%

Do I have to use a ini-file to transfer the parameter or is there another way?
Thank you in advance for any hint/help.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Thu Feb 24, 2005 3:27 pm    Post subject: Reply with quote

test.ahk:
Code:
msgbox,%1%


Start | Run... | test.ahk Hello! | Ok
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Feb 24, 2005 3:38 pm    Post subject: Reply with quote

The format is in the help file but somehow got omitted from the section you quoted:

AutoHotkey.exe [Switches] [Script Filename] [Script Parameters]
Back to top
View user's profile Send private message Send e-mail
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Thu Feb 24, 2005 3:56 pm    Post subject: Reply with quote

I have two files:
mystart.ahk:
Code:
Run, mytest.ahk Hallo

and mytest.ahk:
Code:
Msgbox, %0%`n%1%

But when I start mystart.ahk it give the following message from mystart.ahk:
Quote:
Error: Failed attempt to launch program or document:
Action: <mytest.ahk Hallo>
Params: <>
[...]
--> Run,test.ahk Hallo


And when I start mytest in a shell with "mytest.ahk Hallo" I get a message window with 0 and nothing, as if nothing is handed over.

Any idea?

[...Thinking...]

Forget about the above, I read Chris again and again. I could get the meaning, but since he doesn't post nonsense. I was missing something. And it was the missing of "Autohotkey.exe" in my script, so mystart.ahk has to be
Code:
Run, AutoHotkey.exe test.ahk Hallo


I didn't understood the help file in that case. Could you maybe extend that section, so that other do not fall into the same trap. Something like this
Quote:
Scripts support command line parameters. For non-compiled scripts the format is:
AutoHotkey.exe [Switches] [Script Filename] [Script Parameters]
For compiled scripts the format is:
CompiledScript.exe [Switches] [Script Parameters]


Thanks for the help.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Feb 24, 2005 10:49 pm    Post subject: Reply with quote

toralf wrote:
Could you maybe extend that section, so that other do not fall into the same trap.
Thanks. I have made that change and it seems clearer now.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group