trol4ever Posted October 23, 2007 Share Posted October 23, 2007 Can someone show me a code , how to bind a button to a funcion : Example : $Button2 = GUICtrlCreateButton("Hide Window", 128, 16, 89, 33, 0) with Func Hide() GUISetState(@SW_HIDE) EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 23, 2007 Moderators Share Posted October 23, 2007 GUICtrlSetOnEvent Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
trol4ever Posted October 23, 2007 Author Share Posted October 23, 2007 ... tell me what i'm wrong becouse : GUICtrlSetOnEvent($Button2, "Hide") its not working :| Link to comment Share on other sites More sharing options...
DjDeep00 Posted October 23, 2007 Share Posted October 23, 2007 Ofcourse it works...u are doing it wrong...search the help file for "guisetonevent"...there is a great example there... Link to comment Share on other sites More sharing options...
DW1 Posted October 23, 2007 Share Posted October 23, 2007 You must specify that you are using on event mode. Try adding this to the top of your script:Opt ("GUIOnEventMode", 1) AutoIt3 Online Help Link to comment Share on other sites More sharing options...
GEOSoft Posted October 23, 2007 Share Posted October 23, 2007 You must specify that you are using on event mode. Try adding this to the top of your script:Opt ("GUIOnEventMode", 1)It can also be done in the idle loop While 1 $msg = GUIGetMsg() Switch $Msg Case $Button2 Hide() EndSwitch WEnd George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
trol4ever Posted October 23, 2007 Author Share Posted October 23, 2007 (edited) So : expandcollapse popup#include <GUIConstants.au3> Opt ("GUIOnEventMode", 1) Global $Paused = 0, $IsHotkey = 0 HotKeySet("{F1}", "PauseByHotKey") HotKeySet("{F2}", "Hide") HotKeySet("{F3}", "Show") HotKeySet("{F4}", "Escape") $Button1 = GUICtrlCreateButton("Pause", 16, 16, 97, 73, 0) $Button2 = GUICtrlCreateButton("Hide Window", 128, 16, 89, 33, 0) $Button3 = GUICtrlCreateButton("Show Window", 128, 56, 89, 33, 0) $Input2 = GUICtrlCreateInput("F1 = Start/Pause", 16, 120, 97, 21) $Input3 = GUICtrlCreateInput("F2 = Hide Window", 120, 120, 97, 21) $Input4 = GUICtrlCreateInput("F3 = Show Window", 64, 144, 113, 21) GUISetOnEvent($GUI_EVENT_CLOSE, "Escape") GUICtrlSetOnEvent($Button1, "Pause") GUICtrlSetOnEvent($Button2, "Hide") GUICtrlSetOnEvent($Button3, "Show") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func PauseByHotKey() If $Paused Then $IsHotkey = 1 Pause() EndFunc Func Pause() Opt("GuiOnEventMode", 0) GUICtrlSetData($Button1, "Start") $Paused = 1 While $Paused Sleep(10) $Msg = GUIGetMsg() ToolTip('ScripT Is On PausE ModE',0,0) If $Msg = $Button1 Or $IsHotkey = 1 Then ExitLoop WEnd $IsHotkey = 0 $Paused = 0 ToolTip("") Opt("GuiOnEventMode", 1) GUICtrlSetData($Button1, "Pause") EndFunc Func Hide() GUISetState(@SW_HIDE) EndFunc Func Show() GUISetState(@SW_SHOW) EndFunc Func Escape() Exit EndFunc and :| no result , The hotkeys work but the buttons don't Edited October 23, 2007 by trol4ever Link to comment Share on other sites More sharing options...
GEOSoft Posted October 23, 2007 Share Posted October 23, 2007 The code for that GUI is a bit hard on the eyes. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
trol4ever Posted October 23, 2007 Author Share Posted October 23, 2007 Ok , figured it out , the buttons do not work when the script is paused . However ... when i start the scrip how can i make it to start only when i push the "Start" button ? without adding Pause() in front ... Link to comment Share on other sites More sharing options...
evilertoaster Posted October 23, 2007 Share Posted October 23, 2007 humm, maybe this- expandcollapse popup#include <GUIConstants.au3> Opt ("GUIOnEventMode", 1) Global $Paused = 0 HotKeySet("{F1}", "Pause") HotKeySet("{F2}", "Hide") HotKeySet("{F3}", "Show") HotKeySet("{F4}", "Escape") GUICreate("SomeGUI") $Button1 = GUICtrlCreateButton("Pause", 16, 16, 97, 73, 0) $Button2 = GUICtrlCreateButton("Hide Window", 128, 16, 89, 33, 0) $Button3 = GUICtrlCreateButton("Show Window", 128, 56, 89, 33, 0) $Input2 = GUICtrlCreateInput("F1 = Start/Pause", 16, 120, 97, 21) $Input3 = GUICtrlCreateInput("F2 = Hide Window", 120, 120, 97, 21) $Input4 = GUICtrlCreateInput("F3 = Show Window", 64, 144, 113, 21) GUISetOnEvent($GUI_EVENT_CLOSE, "Escape") GUICtrlSetOnEvent($Button1, "Pause") GUICtrlSetOnEvent($Button2, "Hide") GUICtrlSetOnEvent($Button3, "Show") GUISetState(@SW_SHOW) While 1 Sleep(100) if $Paused=0 then ContinueLoop ToolTip('ScripT Is On PausE ModE',0,0) WEnd Func Pause() if $Paused=0 then GUICtrlSetData($Button1, "Start") $Paused = 1 Else $Paused = 0 ToolTip("") GUICtrlSetData($Button1, "Pause") EndIf EndFunc Func Hide() GUISetState(@SW_HIDE) EndFunc Func Show() GUISetState(@SW_SHOW) EndFunc Func Escape() Exit EndFunc Link to comment Share on other sites More sharing options...
trol4ever Posted October 24, 2007 Author Share Posted October 24, 2007 still doesn't work ... it starts with the macro , u need to pause it ... i want to start with the macro paused and work only when i push Start . Link to comment Share on other sites More sharing options...
BrettF Posted October 24, 2007 Share Posted October 24, 2007 Maybe... expandcollapse popup#include <GUIConstants.au3> Opt ("GUIOnEventMode", 1) Global $Paused = 1 HotKeySet("{F1}", "Pause") HotKeySet("{F2}", "Hide") HotKeySet("{F3}", "Show") HotKeySet("{F4}", "Escape") GUICreate("SomeGUI") $Button1 = GUICtrlCreateButton("Pause", 16, 16, 97, 73, 0) $Button2 = GUICtrlCreateButton("Hide Window", 128, 16, 89, 33, 0) $Button3 = GUICtrlCreateButton("Show Window", 128, 56, 89, 33, 0) $Input2 = GUICtrlCreateInput("F1 = Start/Pause", 16, 120, 97, 21) $Input3 = GUICtrlCreateInput("F2 = Hide Window", 120, 120, 97, 21) $Input4 = GUICtrlCreateInput("F3 = Show Window", 64, 144, 113, 21) GUISetOnEvent($GUI_EVENT_CLOSE, "Escape") GUICtrlSetOnEvent($Button1, "Pause") GUICtrlSetOnEvent($Button2, "Hide") GUICtrlSetOnEvent($Button3, "Show") GUISetState(@SW_SHOW) While 1 Sleep(100) if $Paused=0 then ContinueLoop ToolTip('ScripT Is On PausE ModE',0,0) WEnd Func Pause() if $Paused=0 then GUICtrlSetData($Button1, "Start") $Paused = 1 Else $Paused = 0 ToolTip("") GUICtrlSetData($Button1, "Pause") EndIf EndFunc Func Hide() GUISetState(@SW_HIDE) EndFunc Func Show() GUISetState(@SW_SHOW) EndFunc Func Escape() Exit EndFunc Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
trol4ever Posted October 24, 2007 Author Share Posted October 24, 2007 thx bert ... it works , but ? what have u done ? what changes u made ? Link to comment Share on other sites More sharing options...
GEOSoft Posted October 24, 2007 Share Posted October 24, 2007 thx bert ... it works , but ? what have u done ? what changes u made ?Global Paused = 1 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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