Doll Posted January 27, 2009 Share Posted January 27, 2009 I would like to know if this is possible. I want to set my AutoIt program to run only with proper parameters only. So if you run it without the parameters or other parameters, it won't run. It's like when you right-clicked a shortcut in your desktop, you'll have a parameters in the Target first. Target: "C:\AutoIt.exe" -START So I want to set my AutoIt.exe to run when parameter "-START" is applied. Could someone give me a sample or at least answer my question? Smile. :) Link to comment Share on other sites More sharing options...
KaFu Posted January 27, 2009 Share Posted January 27, 2009 (edited) Look up Command Line Parameters in Help-file section 'Running Scripts'. If @Compiled Then if ($CmdLine[0] = 0) or ($CmdLine[0] > 0 AND NOT StringInStr($CmdLine[1], "-START")) Then MsgBox(0,'','Wrong CmdLine Parameters, program start canceled!') Exit EndIf EndIf GUICreate("test", 230, 90) GUISetState() While 1 $msg = GUIGetMsg() If $msg = -3 Then ExitLoop sleep(5) WEnd Edited January 27, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Doll Posted January 27, 2009 Author Share Posted January 27, 2009 I got it working, thanks! Smile. :) Link to comment Share on other sites More sharing options...
Doll Posted January 27, 2009 Author Share Posted January 27, 2009 (edited) Sorry for double posting, again.Anyway I got that working (Running Scripts - Parameters) but if I use the function AutoItErrorHandler, it won't work now. I don't know what to mod or to do next.Any help would be appreciated.edit:I do think it is because of the "$CmdLine" in my code and the "$CmdLineRaw". Edited January 27, 2009 by Doll Smile. :) Link to comment Share on other sites More sharing options...
KaFu Posted January 27, 2009 Share Posted January 27, 2009 (edited) Close... ooookay, that wasn't that simple. The AutoItErrorHandler UDF seems to be a wrapper program (nice find , new to me). Thus the flow is about as follows: - if you call your 'program.exe -start' it starts AutoItErrorHandler() and idles out afterwards! AutoItErrorHandler() takes over the progress flow of this first instance, the code flow never reaches your original script. - AutoItErrorHandler() calls your program.exe the with a commandline option '/AutoIt3ExecuteScript', which indicates the new instance NOT to run AutoItErrorHandler() again! - this new instance of your script is NOT started with the original commandline, the original command line parsed to the first instance of the program is lost... Heres a (dirty?) tweak for that: Your program has to use this to read the command-line: $CmdLineRaw_New = stringright($CmdLineRaw,StringLen($CmdLineRaw)-StringInStr($CmdLineRaw,'|')) If @Compiled Then if NOT StringInStr($CmdLineRaw_New, "-start") Then MsgBox(0,'','Wrong CmdLine Parameters, program start canceled!' & @crlf & $CmdLineRaw_New) Exit Else MsgBox(0,'',$CmdLineRaw_New) EndIf EndIf In AutoItErrorHandler_UDF_NoStd.au3 replace this Local $iPID = Run($sRunLine, @ScriptDir) with this $CmdLineRaw_New = StringReplace($CmdLineRaw, $sRunLine,'') Local $iPID = Run($sRunLine & " | " & $CmdLineRaw_New, @ScriptDir) and this Run($sRunLine, @ScriptDir) with this. $CmdLineRaw_New = StringReplace($CmdLineRaw, $sRunLine,'') Run($sRunLine & " | " & $CmdLineRaw_New, @ScriptDir) Didn't check it for AutoItErrorHandler_UDF.au3, but taking a look it seems quiet the same, just be sure make replacements accordingly (e.g. insert ', 0, 2 + 4)' into the new Run() syntax as well, as this part is for activating stdout). Best Regards Edited January 27, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now