lordlol Posted July 2, 2006 Share Posted July 2, 2006 Hello Im new to autoit programming. i want to build a prog,which starts when i click on a image-button: $button1 = GUICtrlCreateButton ("1", 0,0,40,40,$BS_ICON) guictrlsetimage(-1,"pat.ico") -- Exemble. well i want to create ~5 buttons with images. i hope some1 can give me the code for starting a func when an icon is pressed. Regards Lordlol Link to comment Share on other sites More sharing options...
BigDod Posted July 2, 2006 Share Posted July 2, 2006 Quick example #include <GUIConstants.au3> ; == GUI generated with Koda ==); $Form1 = GUICreate("AForm1", 622, 441, 192, 125) $Button1 = GUICtrlCreateButton("(Not allowed)", 96, 40, 81, 57, $BS_ICON) GUICtrlSetImage($Button1, "D:\AutoIT\icon1.ico") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 Run('Notepad.exe') ; Will Run/Open Notepad Case Else ;;;;;;; EndSelect WEnd Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
lordlol Posted July 2, 2006 Author Share Posted July 2, 2006 thx,and if i got 5 buttons? Link to comment Share on other sites More sharing options...
Somniis Posted July 2, 2006 Share Posted July 2, 2006 (edited) thx,and if i got 5 buttons? Just a little added onto the code that BigDod wrote: #include <GUIConstants.au3> ; == GUI generated with Koda ==); $Form1 = GUICreate("AForm1", 622, 441, 192, 125) $Button1 = GUICtrlCreateButton("(Not allowed)", 96, 40, 81, 57, $BS_ICON) GUICtrlSetImage($Button1, "D:\AutoIT\icon1.ico") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button2 ; Actions here Case $msg = $Button3 ; Actions here Case $msg = $Button4 ; Actions here Case $msg = $Button5 ; etc etc Case Else ;;;;;;; EndSelect WEnd Just make sure to define/create the other buttons Edited July 2, 2006 by Somniis Link to comment Share on other sites More sharing options...
lordlol Posted July 2, 2006 Author Share Posted July 2, 2006 yes,it works but.. i got errors if i use script like: expandcollapse popup#include <GUIConstants.au3> GUICreate("Test",240,180) #include <GUIConstants.au3> $Button1 = GUICtrlCreateButton("", 10, 10, 40, 40, $BS_ICON) GUICtrlSetImage($Button1, "test.ico") $msg1 = Guictrlcreatelabel("lalala",50,30) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 Global $Paused HotKeySet("{up}", "Start") HotKeySet("{down}", "Terminate") While 1 Sleep(100) WEnd Func Start() $Paused = NOT $Paused While $Paused MouseClick("Left") WEnd EndFunc Func Terminate() Exit 0 EndFunc Case Else ;;;;;;; EndSelect WEnd Error: ""While" statement has no matching "Wend" statement" How to fix it? Ty in advance, Lordlol Link to comment Share on other sites More sharing options...
Somniis Posted July 2, 2006 Share Posted July 2, 2006 (edited) Error: ""While" statement has no matching "Wend" statement" How to fix it? Ty in advance, Lordlol #include <GUIConstants.au3> GUICreate("Test",240,180) $Button1 = GUICtrlCreateButton("", 10, 10, 40, 40, $BS_ICON) GUICtrlSetImage($Button1, "test.ico") $msg1 = Guictrlcreatelabel("lalala",50,30) GUISetState(@SW_SHOW) HotKeySet("{up}", "Start") HotKeySet("{down}", "Terminate") Global $Paused While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Func Start() $Paused = NOT $Paused While $Paused MouseClick("Left") WEnd EndFunc Func Terminate() Exit 0 EndFunc Instead of putting the functions in the While statement, put them at the end of the code. Also, put the variables and HotKeySet()s before the While loop. The above runs fine for me without any errors. EDIT: If you still get errors, make sure you have the latest version of AutoIT. Edited July 2, 2006 by Somniis Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now