whocares Posted May 21, 2013 Share Posted May 21, 2013 I need help with Autoit's OneEvent-Mode which doesn't seem to work with my script. Autoit just doesn't call the associated functions when clicking buttons. Exception is $GUI_EVENT_CLOSE. Closing a windows is working as usual.Of course I enabled the OnEvent-mode at beginning of the script. AutoItSetOption("GUIOnEventMode", 1) Association of buttons and functions is done with: GUISetOnEvent When I click the buttons, there is just no effect! I tried debugging already with a msgbox at beginning of the function. It seems it doesn't get called at all. Here is the script: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AutoItSetOption("WinTitleMatchMode",4) AutoItSetOption("GUIOnEventMode", 1) AutoItSetOption("MustDeclareVars", 1) Global $MyGUI=GuiCreate("BBE-Clicker", 297, 200,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) Global $Label_1 = GuiCtrlCreateLabel("BBE-Schalter zur Klangverbesserung in Jetaudio dauerklicken?", 20, 10, 250, 25) Global $Button_1 = GuiCtrlCreateButton("BBE", 20, 50, 250, 20) Global $Button_2 = GuiCtrlCreateButton("BBE + BBE-Viva", 20, 75,250, 20) Global $Button_3 = GuiCtrlCreateButton("Stop", 20, 120, 250, 30) GUICtrlSetState($Button_3,$GUI_DISABLE) GuiSetState() ;GUISwitch($MyGUI) GUISetOnEvent($Button_1,"_ClickBBE") GUISetOnEvent($Button_2,"_ClickBBEViva") GUISetOnEvent($Button_3,"_StopClicking") GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked") Global $BBE_X = 290 Global $BBE_Y = 130 Global $BBEV_X = 290 Global $BBEV_Y =157 Global $Jet_Handle=WinGetHandle("classname=COWON Jet-Audio MainWnd Class","Jet-Audio Clock Window") If @error Then AutoItSetOption("WinTitleMatchMode",2) Global $Jet_Handle=WinGetHandle("] [-","Jet-Audio") AutoItSetOption("WinTitleMatchMode",4) EndIf Global $Jet_Pos = WinGetPos($Jet_Handle) Global $stopit=0 While 1 sleep (10) WEnd Func _StopClicking() $stopit=1 EndFunc Func _ClickBBE() GUICtrlSetState($Button_1,$GUI_DISABLE) GUICtrlSetState($Button_2,$GUI_DISABLE) GUICtrlSetState($Button_3,$GUI_ENABLE) $stopit=0 while $stopit=0 WinActivate($Jet_Handle) $Jet_Pos = WinGetPos($Jet_Handle) MouseMove($Jet_Pos[0]+$BBE_X,$Jet_Pos[1]+$BBE_Y,5) MouseClick ("left") WinWaitActive("jetAudio","Plus version or Sound Effect Extension Pack") ControlClick("jetAudio","&No",7) Sleep(8000) WinActivate($Jet_Handle) $Jet_Pos = WinGetPos($Jet_Handle) MouseMove($Jet_Pos[0]+$BBE_X,$Jet_Pos[1]+$BBE_Y,5) MouseClick ("left") WEnd GUICtrlSetState($Button_1,$GUI_ENABLE) GUICtrlSetState($Button_2,$GUI_ENABLE) GUICtrlSetState($Button_3,$GUI_DISABLE) EndFunc Func _ClickBBEViva() GUICtrlSetState($Button_1,$GUI_DISABLE) GUICtrlSetState($Button_2,$GUI_DISABLE) GUICtrlSetState($Button_3,$GUI_ENABLE) $stopit=0 while $stopit=0 WinActivate($Jet_Handle) $Jet_Pos = WinGetPos($Jet_Handle) MouseMove($Jet_Pos[0]+$BBE_X,$Jet_Pos[1]+$BBE_Y,5) MouseClick ("left") WinWaitActive("jetAudio","Plus version or Sound Effect Extension Pack") ControlClick("jetAudio","&No",7) MouseMove($Jet_Pos[0]+$BBEV_X,$Jet_Pos[1]+$BBEV_Y,5) MouseClick ("left") WinWaitActive("jetAudio","Plus version or Sound Effect Extension Pack") ControlClick("jetAudio","&No",7) Sleep(8000) WinActivate($Jet_Handle) $Jet_Pos = WinGetPos($Jet_Handle) MouseMove($Jet_Pos[0]+$BBE_X,$Jet_Pos[1]+$BBE_Y,5) MouseClick ("left") MouseMove($Jet_Pos[0]+$BBEV_X,$Jet_Pos[1]+$BBEV_Y,5) MouseClick ("left") WEnd GUICtrlSetState($Button_1,$GUI_ENABLE) GUICtrlSetState($Button_2,$GUI_ENABLE) GUICtrlSetState($Button_3,$GUI_DISABLE) EndFunc Func _CLOSEClicked() $stopit=1 Exit EndFunc I even tried setting global variables global manually to exclude misunderstandings. But it didn't solve the problem. Somebody please help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 21, 2013 Moderators Share Posted May 21, 2013 whocares, Welcome to the AutoIt forum. The solution to your problem is easy. You say you are using GUISetOnEvent to link controls and functions - that will only link GUI events (such as $GUI_EVENT_CLOSE) to functions. For controls you need GUICtrlSetOnEvent - notice the difference? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
whocares Posted May 21, 2013 Author Share Posted May 21, 2013 Thank you Melba! I tried debugging over and over. I rewrote the whole thing three times. I thought "it must be something silly and simple" but I just didn't get it! Thank you very much. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 21, 2013 Moderators Share Posted May 21, 2013 whocares, Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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