Jump to content

need help with a gui with a image-button..


Recommended Posts

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

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 :D

Edited by Somniis
Link to comment
Share on other sites

yes,it works but..

i got errors if i use script like:

#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

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. :D The above runs fine for me without any errors.

EDIT: If you still get errors, make sure you have the latest version of AutoIT. :wacko:

Edited by Somniis
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...