Jump to content

How do I get buttons to open stuff, like batch files, or notepad?


Gooey
 Share

Recommended Posts

Hey, I need some help I have this batch file, it can call other files by pressing numbers than enter, well I'd like to make a GUI version so I can click a button and it will load that file, or whatever.. I found this code in examples it's very simple.. it does not work and the images aren't even the ones I want.. :geek:

I need a template that I can edit so i can click a button and it will e.g. open notepad, another will open a batch file.. or just a little assistance that will lead me in the right direction :o

; button buster
; by gui_tex
;
#include <GUIConstants.au3>

GUICreate("test",240,180)
$button1 = GUICtrlCreateButton ("1", 0,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",5)
Opt("GUIOnEventMode", 1)
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
; does not work at all!! notepad starts up autmatically, buttons dont do anything

$button2 = GUICtrlCreateButton ("2", 40,00,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",7)
Opt("GUIOnEventMode", 1)
Run("C:\Tools\Bat\open.bat")

$button3 = GUICtrlCreateButton ("3", 80,00,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",22)

$button4 = GUICtrlCreateButton ("4", 120,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",23)

$button5 = GUICtrlCreateButton ("5", 160,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",32)

$buttonclose = GUICtrlCreateButton ("close", 200,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",28)
GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg() 
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

GUIDelete()
Link to comment
Share on other sites

I think this is what you were looking for... :o

#include <GUIConstants.au3>

GUICreate("test",240,180)
$button1 = GUICtrlCreateButton ("", 0,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",6)
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
; does not work at all!! notepad starts up autmatically, buttons dont do anything

$button2 = GUICtrlCreateButton ("", 40,00,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",7)

$button3 = GUICtrlCreateButton ("", 80,00,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",22)

$button4 = GUICtrlCreateButton ("", 120,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",23)

$button5 = GUICtrlCreateButton ("", 160,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",32)

$buttonclose = GUICtrlCreateButton ("", 200,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",28)

GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
     Case $msg = $GUI_EVENT_CLOSE
       exitloop
     Case $msg = $button1
     msgbox(64,"","This is button 1")
Case $msg = $button2
     msgbox(64,"","This is button 2. It Will run open.bat")
     Run("C:\Tools\Bat\open.bat")
Case $msg = $button3
     msgbox(64,"","This is button 3")
Case $msg = $button4
     msgbox(64,"","This is button 4")
Case $msg = $button5
     msgbox(64,"","This is button 5")
Case $msg = $buttonclose
     msgbox(64,"","Goodbye")
endselect

Wend

Hope it works out for you. :geek:

F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
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...