Jump to content

Create GUI with checkboxes that runs program


mgh2468
 Share

Recommended Posts

I am also new with AutoitGui

Maybe this example can help you understand. I found it in this forum.

You should search the forum, there are lots of example and guidance.

:idiot::D

GuiCreate ("MyGUI", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000)

$checkCN = GUICtrlCreatecheckbox ("APPEND", 20, 10, 90, 40)
$checkCN2 = GUICtrlCreatecheckbox ("ARCHIVE=n", 20, 40, 90, 40)
$CHECKBOX_3 = GUICtrlCreatecheckbox ("APPEND", 20, 70, 90, 40)
$CHECKBOX_4 = GUICtrlCreatecheckbox ("ARCHIVE=n", 20, 100, 90, 40)
$BUTTON_1 = GUICtrlCreatebutton ("Start Scan", 400, 300, 100, 40)
GuiSetState (@SW_SHOW)
$msg = 0
While $msg <> -3
  $msg = GuiGetMsg()
Select

case $msg = $button_1
    $state1 = GuiRead($checkCN)
    $state2 = GuiRead($checkCN2)
    $state3 = GuiRead($CHECKBOX_3)
    $state4 = GuiRead($CHECKBOX_4)
    
  if $state1 = 1 Then 
     $arg1 = "1 "
  Else
     $arg1 = ""
  EndIf
  
  If $state2 = 1 Then
     $arg2 = "2 "
  Else
     $arg2 = ""
  EndIf
  
  if $state3 = 1 Then 
     $arg3 = "3 "
  Else
     $arg3 = ""
  EndIf
  
  If $state4 = 1 Then
     $arg4 = "4 "
  Else
     $arg4 = ""
  EndIf
  
  $arguments = $arg1 & $arg2 & $arg3 & $arg4
  
  MsgBox(0, "The arguments are", $arguments)

EndSelect
Wend
Exit
Link to comment
Share on other sites

Cyberslug has a great program called Autobuilder. So it can help take care of the "building the GUI issues" many newbies and part-timers have.

Overeall a general weakness for the AutoIT GUI is the lack of easily linking controls to "events", executable, etc...

I think Cyberslug would be a newbie's best chance, so far, but there are many great programmers that might help... Cyberslug may be able to create an additional option in Autobuilder, where it is easy to put in the code or get a drop down list of "things" a control can DO.

I'm trying to convince people this is a good idea. Feel free to discuss the merit of this.

An ADVOCATE for AutoIT
Link to comment
Share on other sites

Here is a program I wrote called LaunchPad which will help you, the only difference is I also allow the user to enter a UserId & Password, feel free to do what you want with the code:

AutoIt Code

; Setup some useful options that you may want to turn on - see the helpfile for details.
#include <GUIConstants.au3>

; Expand all types of variables inside strings
Opt("ExpandEnvStrings", 1)
Opt("ExpandVarStrings", 1)

; Require that variables are declared (Dim) before use (helps to eliminate silly mistakes)
Opt("MustDeclareVars", 1)
Dim $checkNotes, $checkRem, $checkSAP, $ok, $Cancel, $msg, $UserID
Dim $PassNotes, $PassRem, $PassSAP, $getUser, $NotesPath, $RemPath, $SAPPath, $PassMaster

; set up some variables before we get to the meat of the program
$getUser = EnvGet("USERNAME")

$NotesPath = IniRead(@ScriptDir & "\Launchpad.ini", "Apps", "AppNotes", "")
$RemPath = IniRead(@ScriptDir & "\Launchpad.ini", "Apps", "AppRem", "")
$SAPPath = IniRead(@ScriptDir & "\Launchpad.ini", "Apps", "AppSAP", "")

if $NotesPath = "" Then
   MsgBox(4096,"Problem", "Notes path not set in Launchpad.ini")
   Exit
EndIf

if $RemPath = "" Then
   MsgBox(4096,"Problem", "Remedy path not set in Launchpad.ini")
   Exit
EndIf

if $SAPPath = "" Then
   MsgBox(4096,"Problem", "SAP path not set in Launchpad.ini")
   Exit
EndIf

; ----------------------------------------------------------------------------
; Script Start - Add your code below here
; ----------------------------------------------------------------------------

GUICreate("Launch Pad", 200, 180, -1, -1, $WS_EX_DLGMODALFRAME)
GuiCtrlCreateLabel("User ID:", 10, 10, 50)
$UserID = GUICtrlCreateInput ( "", 65,  10, 100, 20)
GUICtrlSetData(-1, $getUser)
GuiCtrlCreateLabel("Master Password:", 10, 35, 85)
$PassMaster = GUICtrlCreateInput ( "", 95,  35, 80, 20, $ES_PASSWORD)
GUICtrlSetTip(-1,"Use this if all Passwords are the same")
GUICtrlSetState(-1,$GUI_FOCUS)
$checkNotes = GUICtrlCreateCheckbox ("Lotus Notes", 10, 55, 80, 20)
$PassNotes = GUICtrlCreateInput ( "", 95,  55, 80, 20, $ES_PASSWORD)
GUICtrlSetTip(-1,"Notes Password")
$checkRem = GUICtrlCreateCheckbox ("Remedy", 10, 75, 80, 20)
$PassRem = GUICtrlCreateInput ( "", 95,  75, 80, 20, $ES_PASSWORD)
GUICtrlSetTip(-1,"Remedy Password")
$checkSAP = GUICtrlCreateCheckbox ("SAP", 10, 95, 80, 20)
$PassSAP = GUICtrlCreateInput ( "", 95,  95, 80, 20, $ES_PASSWORD)
GUICtrlSetTip(-1,"SAP Password")
$ok = GUICtrlCreateButton("Ok", 30, 120, 50)
$Cancel = GUICtrlCreateButton("Cancel", 110, 120, 50)

GuiSetState()

While 1
   $msg = GUIGetMsg()
   If GUIRead($PassMaster) > "" Then
      GUICtrlSetState($PassNotes,$GUI_DISABLE)
      GUICtrlSetState($PassRem,$GUI_DISABLE)
      GUICtrlSetState($PassSAP,$GUI_DISABLE)
   EndIf
   If (GUIRead($PassNotes) > "") Or (GUIRead($PassRem) > "") Or (GUIRead($PassSAP) > "") Then
      GUICtrlSetState($PassMaster,$GUI_DISABLE)
   EndIf
   Select
      Case $msg = $ok
         If GUIRead($PassMaster) > "" Then
            $PassNotes = $PassMaster
            $PassRem = $PassMaster
            $PassSAP = $PassMaster
         EndIf
         If GUIRead($checkNotes) = 1 Then
            If GUIRead($PassNotes) = "" Then
               MsgBox(4096, "Password", "Notes password not set")
               ContinueLoop
            EndIf
            Run($NotesPath, "", @SW_MAXIMIZE)
            WinWaitActive("Lotus Notes", "Enter your", 30)
            Send(GUIRead($PassNotes) & "{ENTER}")
         EndIf
         If GUIRead($checkRem) = 1 Then
            If GUIRead($PassRem) = "" Then
               MsgBox(4096, "Password", "Remedy password not set")
               ContinueLoop
            EndIf
            Run($RemPath, "", @SW_MAXIMIZE)
            WinWaitActive("Login - Remedy", "User", 30)
            Send(GUIRead($UserID) & "{TAB}" & GUIRead($PassRem) & "{ENTER}")
         EndIf
         If GUIRead($checkSAP) = 1 Then
            If GUIRead($PassSAP) = "" Then
               MsgBox(4096, "Password", "SAP password not set")
               ContinueLoop
            EndIf
            Run($SAPPath, "")
            WinWaitActive("SAP Logon 620", "List1", 30)
            send("!l")
            WinWaitActive("SAP R/3", "", 30)
            Send(GUIRead($UserID) & "{TAB}" & GUIRead($PassSAP) & "{ENTER}")
         EndIf
         Exit
      Case $msg = $cancel
         Exit
   EndSelect
Wend

the INI file:

[Apps]
AppNotes=c:\program files\notes\notes.exe
AppRem=C:\Program Files\ARS_402\User\aruser.exe
AppSAP=C:\Program Files\Sap_620\sapgui\saplogon.exe
Link to comment
Share on other sites

Here is a program I wrote called LaunchPad which will help you, the only difference is I also allow the user to enter a UserId & Password, feel free to do what you want with the code:

Thanks for both of your inputs.

My dream APP is a GUI with workstation names listed for shutdown. I could choose just one or all, or groups. This dream APP would also show for each workstation listed if they are on or not (ping maybe??) and also who, if anyone, is logged on.

Not sure if I will ever figure all this out, but that is what I want to work toward. First is workstation check list to shutdown. I may use psshutdown, I have not worked out how it incorporate it into the 2 example scripts yet. My be after some rest and Christmas is past. :idiot:

Any input or help in this is much appreciated

M

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...