Jump to content

Recommended Posts

Posted

Hello,

I am very new to AutoIt just started using it today actually. What I want to do is simple I believe but I do not know the syntax. I have generated my form so now all I need to do is tell the buttons how to connect to the .bat files I want to run. Here's my code I have so far:

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=SetupForm.kxf

$Form1 = GUICreate("Setup Menu", 428, 312, 2127, 228)

$DesktopBtn = GUICtrlCreateButton("Desktop Setup", 48, 24, 131, 25, $WS_GROUP)

$InfinityBtn = GUICtrlCreateButton("Infinity Setup", 48, 56, 131, 25, $WS_GROUP)

$XPBtn = GUICtrlCreateButton("Windows XP x64 Setup", 48, 88, 131, 25, $WS_GROUP)

$BticBtn = GUICtrlCreateButton("Ballistics Setup", 48, 120, 131, 25, $WS_GROUP)

$DesktopLbl = GUICtrlCreateLabel("Launch Desktop or Laptop Configuration", 200, 24, 196, 17)

$InfinityLbl = GUICtrlCreateLabel("Launch Infinity Configuration", 200, 56, 138, 17)

$XPLbl = GUICtrlCreateLabel("Launch Windows XP 64 bit Configuration", 200, 88, 198, 17)

$Label1 = GUICtrlCreateLabel("Launch Ballistics Configuration", 200, 120, 148, 17)

$ExitBtn = GUICtrlCreateButton("EXIT", 56, 256, 75, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

How do I link each button to a .bat file so when clicked they will run that file?

Thanks!!

Posted

Just add more Case to your Switch. For each button you would have a case to run the .BAT. Something like:

Global $sDesktopBat = @ScriptDir & "\Desktop.bat"
Global $sInfinityBat = @ScriptDir & "\Infinity.bat"

; ...

Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $DesktopBtn
        RunWait($sDesktopBat, @WorkingDir, @SW_MINIMIZE)
    Case $InfinityBtn
        RunWait($sInfinityBat, @WorkingDir, @SW_MINIMIZE)
        
    ; ... etc.
EndSwitch

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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
×
×
  • Create New...