gui529 Posted April 1, 2009 Share Posted April 1, 2009 Hi is there a way to preset a button like you can do to hotkeys...here is an example... HotKeySet("{INSERT}", "Options") I want do it to a button in a gui called $Start and run a function called Begin() Link to comment Share on other sites More sharing options...
Skruge Posted April 1, 2009 Share Posted April 1, 2009 Hi is there a way to preset a button like you can do to hotkeys...here is an example...HotKeySet("{INSERT}", "Options")I want do it to a button in a gui called $Start and run a function called Begin()I'm not sure exactly what you're asking... Can you rephrase your question, or post some code that tries to demonstrate what you're trying to do?It sounds like you're looking for GUICtrlSetOnEvent... [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
stampy Posted April 1, 2009 Share Posted April 1, 2009 You'll just add it to the code: for event mode (straight from the helpfile): #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Hello World", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUICtrlSetOnEvent($okbutton, "OKButton")<-----------------------tell is what function to do if that button is pressed GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func OKButton() ;Note: at this point @GUI_CTRLID would equal $okbutton, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You pressed OK!") EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") Exit EndFunc loop mode would be similar but within if /case statement. Link to comment Share on other sites More sharing options...
gui529 Posted April 1, 2009 Author Share Posted April 1, 2009 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $Exit GUICtrlSetOnEvent($Exit, "Terminate") GUISetState(@SW_SHOW) #Region ### START Koda GUI section ### Form=c:\documents and settings\hp_owner\my documents\my pictures\form1.kxf $Form1_1 = GUICreate("Form1", 392, 178, 479, 367) $Main = GUICtrlCreateTab(0, 0, 391, 145) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Main") $TabSheet2 = GUICtrlCreateTabItem("Attack Settings") $Attack1 = GUICtrlCreateCheckbox("Attack 1", 16, 32, 65, 17) $Atk1key = GUICtrlCreateInput("", 88, 32, 49, 21) $Atk2key = GUICtrlCreateInput("", 88, 59, 49, 21) $Atk3key = GUICtrlCreateInput("", 88, 88, 49, 21) $Attack2 = GUICtrlCreateCheckbox("Attack 2", 16, 59, 65, 25) $Attack3 = GUICtrlCreateCheckbox("Attack 3", 16, 88, 65, 25) $Label1 = GUICtrlCreateLabel("Place the hotkey of the attack in boxes.", 8, 112, 327, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("*Recomended only two attacks.", 168, 32, 155, 17) $TabSheet3 = GUICtrlCreateTabItem("Buffs Settings") GUICtrlSetState(-1,$GUI_SHOW) $Buff1 = GUICtrlCreateCheckbox("Buff 1", 14, 35, 65, 17) $Buff2 = GUICtrlCreateCheckbox("Buff 2", 14, 64, 65, 17) $Buff4 = GUICtrlCreateCheckbox("Buff 4", 149, 64, 65, 17) $Buff3 = GUICtrlCreateCheckbox("Buff 3", 149, 35, 65, 17) $Buff4key = GUICtrlCreateInput("", 219, 64, 49, 21) $Label3 = GUICtrlCreateLabel("Place the hotkey of buffs in boxes!", 24, 96, 288, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Buff3key = GUICtrlCreateInput("", 219, 35, 49, 21) $Buff1key = GUICtrlCreateInput("", 80, 35, 49, 21) $Buff2key = GUICtrlCreateInput("", 80, 64, 49, 21) $TabSheet4 = GUICtrlCreateTabItem("Others") GUICtrlCreateTabItem("") $Start = GUICtrlCreateButton("START", 8, 144, 65, 33) GUICtrlSetBkColor(-1, 0x00FF00) $Stop = GUICtrlCreateButton("STOP", 77, 144, 65, 33) GUICtrlSetBkColor(-1, 0xFF0000) $Exit = GUICtrlCreateButton("EXIT", 148, 144, 65, 33) GUICtrlSetBkColor(-1, 0x808000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() WEnd ;=====FUNCTION THAT EXITS BOT=========== Func Terminate() Exit EndFunc K...can you help me identify what is wrong with this??? basically If i press the button $EXIT I want the bot to run the func terminate... The gui opens and all but nothing happens when i press EXIT Link to comment Share on other sites More sharing options...
stampy Posted April 1, 2009 Share Posted April 1, 2009 Define the setonevent AFTER defining the button itself. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $Exit #Region ### START Koda GUI section ### Form=c:\documents and settings\hp_owner\my documents\my pictures\form1.kxf $Form1_1 = GUICreate("Form1", 392, 178, 479, 367) $Main = GUICtrlCreateTab(0, 0, 391, 145) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Main") $TabSheet2 = GUICtrlCreateTabItem("Attack Settings") $Attack1 = GUICtrlCreateCheckbox("Attack 1", 16, 32, 65, 17) $Atk1key = GUICtrlCreateInput("", 88, 32, 49, 21) $Atk2key = GUICtrlCreateInput("", 88, 59, 49, 21) $Atk3key = GUICtrlCreateInput("", 88, 88, 49, 21) $Attack2 = GUICtrlCreateCheckbox("Attack 2", 16, 59, 65, 25) $Attack3 = GUICtrlCreateCheckbox("Attack 3", 16, 88, 65, 25) $Label1 = GUICtrlCreateLabel("Place the hotkey of the attack in boxes.", 8, 112, 327, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("*Recomended only two attacks.", 168, 32, 155, 17) $TabSheet3 = GUICtrlCreateTabItem("Buffs Settings") GUICtrlSetState(-1,$GUI_SHOW) $Buff1 = GUICtrlCreateCheckbox("Buff 1", 14, 35, 65, 17) $Buff2 = GUICtrlCreateCheckbox("Buff 2", 14, 64, 65, 17) $Buff4 = GUICtrlCreateCheckbox("Buff 4", 149, 64, 65, 17) $Buff3 = GUICtrlCreateCheckbox("Buff 3", 149, 35, 65, 17) $Buff4key = GUICtrlCreateInput("", 219, 64, 49, 21) $Label3 = GUICtrlCreateLabel("Place the hotkey of buffs in boxes!", 24, 96, 288, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Buff3key = GUICtrlCreateInput("", 219, 35, 49, 21) $Buff1key = GUICtrlCreateInput("", 80, 35, 49, 21) $Buff2key = GUICtrlCreateInput("", 80, 64, 49, 21) $TabSheet4 = GUICtrlCreateTabItem("Others") GUICtrlCreateTabItem("") $Start = GUICtrlCreateButton("START", 8, 144, 65, 33) GUICtrlSetBkColor(-1, 0x00FF00) $Stop = GUICtrlCreateButton("STOP", 77, 144, 65, 33) GUICtrlSetBkColor(-1, 0xFF0000) $Exit = GUICtrlCreateButton("EXIT", 148, 144, 65, 33) GUICtrlSetBkColor(-1, 0x808000) GUICtrlSetOnEvent($Exit, "Terminate") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() WEnd ;=====FUNCTION THAT EXITS BOT=========== Func Terminate() Exit EndFunc 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