Jump to content

CmdLine & GUI help


Recommended Posts

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

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 by fRequEnCy
Link to comment
Share on other sites

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...