Jump to content
Sign in to follow this  
changos

How to get parameter at the start time ?

Recommended Posts

changos

Hi all !

I want to that my application get some parameters at the start time .

In short , how to run the application from command line and pass some parameters into it , for example

C:\myapplication.exe -s 100

and in myapplication.exe can get those parameters are -s and 100 .

Thanks.

---------------------------------------------------------------------------------------------------

Nguyen Xuan Truong

Email: chunchang.ithut@hotmail.com

Share this post


Link to post
Share on other sites
FireFox

@changos

for run your application with parameters use : ShellExecute("yourapp.ext","parameters")

And for create command line parameters in your script use :

Func _GetCmdLine($aArgument, $bArgument = '', $CmdDelim = "/")
    Local $RetCmd = _GetMidleString($CmdLineRaw, $aArgument, ' ')
    If $RetCmd = '' Then $RetCmd = _GetMidleString($CmdLineRaw, $aArgument, ' ' & $CmdDelim)
    If $RetCmd = '' Then $RetCmd = _GetMidleString($CmdLineRaw, $aArgument, '$')
    If $RetCmd = '' Then $RetCmd = _GetMidleString($CmdLineRaw, $aArgument, $bArgument)
    Return StringStripWS($RetCmd, 3)
EndFunc   ;==>_GetCmdLine

Func _GetMidleString($sString, $sStart, $sEnd, $iCase = -1, $iRetType = 0)
    Local $iCaseSence = ''
    If $iCase = -1 Then $iCaseSence = '(?i)'
    
    Local $aArray = StringRegExp($sString, '(?s)' & $iCaseSence & $sStart & '(.*?)' & $sEnd, 3)
    Local $IsArrayCheck = IsArray($aArray)
    
    If $IsArrayCheck And $iRetType = 1 Then Return $aArray
    If $IsArrayCheck And $iRetType = 2 Then
        Local $iUbound = UBound($aArray)
        If Not StringInStr($aArray[$iUbound - 1], "Next") Then Return $aArray[$iUbound - 1]
        If ($iUbound - 2) >= 0 Then Return $aArray[$iUbound - 2]
        Return $aArray[$iUbound - 1]
    EndIf
    
    If $IsArrayCheck Then Return $aArray[0]
    Return SetError(1, 0, "")
EndFunc   ;==>_GetMidleString

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×