Sign in to follow this  
Followers 0
original21

run .exe or .cmd files

9 posts in this topic

Hello to all.

I am new in the autoit forum and i need your help.

I want to make a small GUI with 2 buttons. Every button executes a .exe or .cmd file.

I dont have a script to show you, but can you please point me to the wright direction? I check the General Help and Support topic for help but it confized me more. :shocked:

Thanks


Please allow me to introduce myself I'm a man of wealth and taste I've been around for a long, long year Stole many a man's soul and faith

Share this post


Link to post
Share on other sites

Thanks MHz.

Here is the code that Koda generate.

I have the 2 buttons on the form.

How i add the code for each button to run the .cmd files

Thanks again

===============================================

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$MyForm = GUICreate("MyForm", 633, 454, 193, 115)

$Button1 = GUICtrlCreateButton("Backup", 136, 168, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Restore", 376, 168, 75, 25, 0)

GUISetState(@SW_SHOW)

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

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

======================================================


Please allow me to introduce myself I'm a man of wealth and taste I've been around for a long, long year Stole many a man's soul and faith

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ok. Now you have to create another case to tell what happens when the button is pressed. So that looks like:

Switch $nMsg
    Case $button1
        ;Do Stuff
    Case $button2
        ;Do More stuff
EndSwitchoÝ÷ Ø   ݶ§i×m«m¢Ø^)jëh×6Switch $nMsg
    Case $button1
        Run("Notepad.exe", "", @SW_MAXIMIZE)
    Case $button2
        ShellExecute("Notepad.exe")
EndSwitch

EDIT: Missed a bit :shocked:

Edited by Bert

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks for your help Bertt

Is working fine.

Here is the script :

============================================

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$MyForm = GUICreate("MyForm", 633, 454, 193, 115)

$Button1 = GUICtrlCreateButton("Button1", 136, 168, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Button2", 376, 168, 75, 25, 0)

GUISetState(@SW_SHOW)

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

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

Switch $nMsg

Case $button1

Run("Notepad.exe", "", @SW_MAXIMIZE)

Case $button2

Run("Notepad.exe", "", @SW_MAXIMIZE)

EndSwitch

WEnd

=================================================================

One final question.

Can i add some text on the form?

Edited by original21

Please allow me to introduce myself I'm a man of wealth and taste I've been around for a long, long year Stole many a man's soul and faith

Share this post


Link to post
Share on other sites

One final question.

Can i add some text on the form?

Yes you can add text by using a label. Look at the function GUICtrlCreateLabel() in the help file.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$MyForm = GUICreate("MyForm", 633, 454, 193, 115)
GUICtrlCreateLabel('Some text on a label', 20, 20)
$Button1 = GUICtrlCreateButton("Button1", 136, 168, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 376, 168, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Run("Notepad.exe", "", @SW_MAXIMIZE)
        Case $Button2
            Run("Notepad.exe", "", @SW_MAXIMIZE)
    EndSwitch

WEnd

:shocked:

Share this post


Link to post
Share on other sites

Thanks for your help Bertt

Its Brett or Bert, whatever you prefer :shocked: When putting autoit code into you posts, make sure you use the tags for them. It makes them so much easier to read :( The button with the "A" is the one you want... or [ autoit ][/ autoit ] (Withoutspaces!)

Regards

Share this post


Link to post
Share on other sites

Thanks again to all.

Is working fine.

Sorry Brett :shocked:


Please allow me to introduce myself I'm a man of wealth and taste I've been around for a long, long year Stole many a man's soul and faith

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  
Followers 0