Jump to content

If i click on button then..


 Share

Recommended Posts

I need help with a thing

How do i put so if i click on one button something will happends?

What wrong with the code? dont say nothing is wrong because thats not true,it just wont work :/

Ex case..

Case $Button6
MsgBox(1 ,"Hello","Hello")

Full code.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=Bot load.kxf\Bot load.kxf
$Form2 = GUICreate("Ztb", 602, 354, 180, 109)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\omnibook\Skrivbord\zbot.bmp", -16, 0, 617, 353, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Button1 = GUICtrlCreateButton("&Afk Tools", 32, 72, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Button2 = GUICtrlCreateButton("&Rune Making", 32, 112, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Button3 = GUICtrlCreateButton("&Alarms", 32, 160, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Button4 = GUICtrlCreateButton("&Shortcuts", 32, 200, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Button5 = GUICtrlCreateButton("&Scripts", 32, 240, 75, 25, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Button6 = GUICtrlCreateButton("&Help", 488, 48, 75, 41, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Edit1 = GUICtrlCreateEdit("", 464, 104, 97, 81, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetData(-1, StringFormat("READ!\r\nNote that is bot is\r\njust in beta so\r\nbugs and errors\r\nmay/can occur.\r\n"))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg

Case $Button6
MsgBox(1 ,"Hello","Hello")

Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Whats wrong? sad.gif
Link to comment
Share on other sites

Of course nothing will happen if you use GUICtrlSetState(-1, $GUI_HIDE) on the button, you cannot click it!

I've already tested to take that away and it didn't work, im gona look in the helpfile for the flags.
Link to comment
Share on other sites

There's nothing wrong with his MsgBox call.

If you want to check if something was pressed in the message box, you need to check the return value.

#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=Bot load.kxf\Bot load.kxf
$Form2 = GUICreate("Ztb", 602, 354, 180, 109)
;$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\omnibook\Skrivbord\zbot.bmp", -16, 0, 617, 353, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Button1 = GUICtrlCreateButton("&Afk Tools", 32, 72, 75, 25, 0)
$Button2 = GUICtrlCreateButton("&Rune Making", 32, 112, 75, 25, 0)
$Button3 = GUICtrlCreateButton("&Alarms", 32, 160, 75, 25, 0)
$Button4 = GUICtrlCreateButton("&Shortcuts", 32, 200, 75, 25, 0)
$Button5 = GUICtrlCreateButton("&Scripts", 32, 240, 75, 25, 0)
$Button6 = GUICtrlCreateButton("&Help", 488, 48, 75, 41, 0)
$Edit1 = GUICtrlCreateEdit("", 464, 104, 97, 81, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetData(-1, StringFormat("READ!\r\nNote that is bot is\r\njust in beta so\r\nbugs and errors\r\nmay/can occur.\r\n"))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

    Case $Button6
        $ret = MsgBox(1 ,"Hello","Hello")
        if ($ret == 1) Then MsgBox(0, "", "The user pressed OK")
        if ($ret == 2) Then MsgBox(0, "", "The user pressed Cancel")

    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd
Edited by cppman
Link to comment
Share on other sites

You need to disable the background image (Picture control).

#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=Bot load.kxf\Bot load.kxf
$Form2 = GUICreate("Ztb", 602, 354, 180, 109)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\omnibook\Skrivbord\zbot.bmp", -16, 0, 617, 353, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetState($Pic1, $GUI_DISABLE)
$Button1 = GUICtrlCreateButton("&Afk Tools", 32, 72, 75, 25, 0)
$Button2 = GUICtrlCreateButton("&Rune Making", 32, 112, 75, 25, 0)
$Button3 = GUICtrlCreateButton("&Alarms", 32, 160, 75, 25, 0)
$Button4 = GUICtrlCreateButton("&Shortcuts", 32, 200, 75, 25, 0)
$Button5 = GUICtrlCreateButton("&Scripts", 32, 240, 75, 25, 0)
$Button6 = GUICtrlCreateButton("&Help", 488, 48, 75, 41, 0)
$Edit1 = GUICtrlCreateEdit("", 464, 104, 97, 81, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetData(-1, StringFormat("READ!\r\nNote that is bot is\r\njust in beta so\r\nbugs and errors\r\nmay/can occur.\r\n"))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

    Case $Button6
        $ret = MsgBox(1 ,"Hello","Hello")
        if ($ret == 1) Then MsgBox(0, "", "The user pressed OK")
        if ($ret == 2) Then MsgBox(0, "", "The user pressed Cancel")

    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd
Edited by cppman
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...