fRequEnCy Posted June 7, 2008 Share Posted June 7, 2008 Hello all, My GUI works the way I want made with Koda (FormDesigner) but want CmdLine options as well. So if I run my script without parameters. It opens my GUI. For example: script.exe If I have parameters after script then I don't want to run GUI. I want just just run the commands I tell it to. For example: script.exe -parameter1 So if CmdLine[0] = 0 Then run GUI else run without. What's an easy way to do this? I'm sure i'm just missing something with the way Koda generates the code. Please assist. Thanks in advance. Link to comment Share on other sites More sharing options...
James Posted June 7, 2008 Share Posted June 7, 2008 Look for "Running Scripts" under the helpfile Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
fRequEnCy Posted June 7, 2008 Author Share Posted June 7, 2008 (edited) Look for "Running Scripts" under the helpfile Well I already know how to run with commandline parameters but how do I get to co-exist? #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Jeremy\Desktop\My Scripts\EmuWrapper\Form2.kxf $Form2 = GUICreate("Multi-Emulator Wrapper v1.0", 527, 343, 240, 170) $Combo1 = GUICtrlCreateCombo("Combo1", 176, 40, 313, 25) $Label1 = GUICtrlCreateLabel("Emulator Configuration", 16, 40, 110, 17) $Edit1 = GUICtrlCreateEdit("", 176, 184, 313, 113) GUICtrlSetData(-1, "Edit1") $Label2 = GUICtrlCreateLabel("Command Line Parameters", 16, 192, 130, 17) $Button2 = GUICtrlCreateButton("...", 456, 72, 35, 25, 0) $Input2 = GUICtrlCreateInput("Input2", 176, 72, 273, 21) $Label4 = GUICtrlCreateLabel("Executable", 16, 72, 57, 17) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("&About") $MenuItem4 = GUICtrlCreateMenuItem("Help", $MenuItem2) $MenuItem5 = GUICtrlCreateMenuItem("About", $MenuItem2) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd So there's the basic code that koda generates. What do I need to add to not use it if Cmdline[0] <> 0? Edited June 7, 2008 by fRequEnCy Link to comment Share on other sites More sharing options...
ProgAndy Posted June 7, 2008 Share Posted June 7, 2008 Use OnEventMode and Make an If-Else: e.g.: #include <GUIConstants.au3> Opt("GUIOnEventMode",1) #region - GUI Create GUICreate('dd') GUISetOnEvent($GUI_EVENT_CLOSE,"_EXIT") $in = GUICtrlCreateInput("",10,10,200,30) $OK = GUICtrlCreateButton("OK",10,45) GUICtrlSetOnEvent(-1,"_OKClick") #endregion If $CMDLINE[0] > 0 Then GUICtrlSetData($in,$CMDLINE[1]) _OKClick() _EXIT() Else GUISetState() EndIf #region - GUI SelectLoop While 1 Sleep(1000) WEnd #endregion Func _EXIT() Exit EndFunc Func _OKClick() MsgBox(0, '', GUICtrlRead($in)) EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
fRequEnCy Posted June 7, 2008 Author Share Posted June 7, 2008 Use OnEventMode and Make an If-Else: e.g.: #include <GUIConstants.au3> Opt("GUIOnEventMode",1) #region - GUI Create GUICreate('dd') GUISetOnEvent($GUI_EVENT_CLOSE,"_EXIT") $in = GUICtrlCreateInput("",10,10,200,30) $OK = GUICtrlCreateButton("OK",10,45) GUICtrlSetOnEvent(-1,"_OKClick") #endregion If $CMDLINE[0] > 0 Then GUICtrlSetData($in,$CMDLINE[1]) _OKClick() _EXIT() Else GUISetState() EndIf #region - GUI SelectLoop While 1 Sleep(1000) WEnd #endregion Func _EXIT() Exit EndFunc Func _OKClick() MsgBox(0, '', GUICtrlRead($in)) EndFunc Got it working! Thanks a lot ProgAndy! 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