Jump to content
Sign in to follow this  
markdui

GUI button issue

Recommended Posts

markdui

Hi may i know how can i do the below in AutoIT GUI

Create a Button upon mouse click it will run a batch file.

Create a Inputbox (textbox). The batch file will call the textinout and excute then and sent the output to a screen below it.

Share this post


Link to post
Share on other sites
BrettF

Hi may i know how can i do the below in AutoIT GUI

Create a Button upon mouse click it will run a batch file.

Create a Inputbox (textbox). The batch file will call the textinout and excute then and sent the output to a screen below it.

Could you please provide us with some GUI code?? And what you have tried?

Also, look at Run in the helpfile.

:)

Share this post


Link to post
Share on other sites
markdui

I have try creating some button and inputbox. Didnt know how to place the rest of the code. Anyway i will try reading the run in help. Thanks

Share this post


Link to post
Share on other sites
BrettF

I have try creating some button and inputbox. Didnt know how to place the rest of the code. Anyway i will try reading the run in help. Thanks

Well here's how I do it.

;;All the needed includes...
#include <GuiConstants.au3>
;Any Varibles are declared.
Dim $var = "I am a varible.  W00000tttttt!"
;GUI is created
GUICreate($var)
;And GUI Opt modes can be declared here, or above.
Opt("GUICoordMode", 2); Alters the positioning of controls.
;Create any controls on the GUI
$Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100)
$Button_2 = GUICtrlCreateButton("Button Test", 0, -1)
;Show the GUI
GUISetState(@SW_SHOW)

;Run The GUI until the dialouge is closed
While 1
;Poll the GUI for any changes- Button Presses, changes in text...
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE; So if the big red X on the GUI is pressed, exit
            ExitLoop
        Case $msg = $Button_1; if $button_1 is pressed
            Run('Notepad.exe')   ; Will run notepad
        Case $msg = $Button_2; if $button_2 is pressed
            MsgBox(0, 'Testing', 'Button 2 was pressed')   ; Shows a message box that apears when the button was pressed.
    EndSelect
WEnd

That should get you on your merry way... =)

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.