Sign in to follow this  
Followers 0
whocares

OnEvent-Mode does not enter functions

4 posts in this topic

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:

 

#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.

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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. :sweating:

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0