AutoHotkey Community

It is currently May 27th, 2012, 5:07 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Command Line Support
PostPosted: May 9th, 2010, 11:06 am 
Offline

Joined: April 18th, 2010, 11:33 am
Posts: 159
I know ahk has Command Line Support but can i use it like this

myexe.exe -switch "param" -switch2 "parameter"

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2010, 12:27 pm 
Quote:
but can i use it like this
:arrow: :?: Isn't that that obscure character which is used to indicate that a sentence should be interpreted as a question? And erm, btw have you tried it :arrow: :?:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2010, 1:47 pm 
Offline

Joined: October 18th, 2007, 9:21 pm
Posts: 343
Location: Saarland, Germany
Code:
Loop, %0% ; # of parameters
    msg .= "Parameter" A_Index " = " %A_Index% "`n"
MsgBox, %msg%
Works for ahk and exe (tested).

_________________
Wolf

Schön wär's, wenn's schön wär!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2010, 7:13 pm 
@ wolf_II
I guess the thing is to identify parameters via its keynames :wink:
-<keyname> <value>


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2010, 8:24 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
In that case I would suggest using a loop similar to wolf_II's, but reading the values to an array then using using analyzing the array values to determine the best course of action.
For example, with
Quote:
myexe.exe -switch "param" -switch2 "parameter"

You would check the first element in the array. It equals to "-switch", so you know that the second element in the array must be some quoted string, in this case "param". And then just continue with similar logic through all of the parameters.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2010, 10:15 pm 
But what if a switch itself is the param ?
Code:
myexe.exe -switch "param" -switch2 "param" -switch3 -switch4 -switch5


Code:
myexe.exe -name "Chris" -surname "Mallett" -a -h -k


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2010, 10:18 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
I would assume that it would be known in advance would switches would be followed by a parameter and which ones would not, in which case you would simply test for this.

However, even if a parameter after a certain switch was optional, you could simply check if the following string is a switch or parameter—i.e., does it start a hyphen (-).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2010, 3:23 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
[Lib] argp v3.0 Argument Options Parser by Tuncay
Parameters and switches parser by Yook


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2010, 1:37 pm 
Offline

Joined: April 18th, 2010, 11:33 am
Posts: 159
Thanks a lot SKAN aka Goyyah aka Suresh Kumar AN aka ???

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 74 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group