RealisT Posted February 14, 2008 Share Posted February 14, 2008 I keep experiencing a situation within my GUI in which a $GUI_EVENT_PRIMARYDOWN event occurs but without my ever clicking the mouse. (There is no command designed in the code to generate such an event, and there are no controls in this GUI). What is causing this? How can I prevent this? Link to comment Share on other sites More sharing options...
martin Posted February 14, 2008 Share Posted February 14, 2008 I keep experiencing a situation within my GUI in which a $GUI_EVENT_PRIMARYDOWN event occurs but without my ever clicking the mouse.(There is no command designed in the code to generate such an event, and there are no controls in this GUI).What is causing this? How can I prevent this?Can you show any code? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
RealisT Posted February 14, 2008 Author Share Posted February 14, 2008 Can you show any code? There's just too much code to place here. However, the GUI and the Event code are as follows: GUISetState() While 1 $msg = GUIGetMsg() $currPos = MouseGetPos () . . . If $currentWinGUI = 1 Then Select Case $msg = $GUI_EVENT_PRIMARYDOWN ; Something is causing this Event to happen without a mouse If $dragInProgress = 0 Then ; BEGIN DRAG ************** $dragInProgress = 1 $startX = $currPos[0] $startY = $currPos[1] Beep(466, 200) ; This is just to tell me that the event is occurring EndIf . . . EndSelect EndIf Wend Func captureScreenNow($captMode) . . . If $captMode = 1 Then ; ====================== REGION CAPTURE =========================== GUIDelete($mainForm) ; WORKS WinWaitClose($mainFormName, "") ; Places Bitmap of Screen on top of Screen $captureFilename = createFileName() _ScreenCapture_Capture($captureFilename, 0, 0, -1, -1, False) $fakeScreen = GUICreate("Invisible Name", @DesktopWidth, @DesktopHeight, -3, -3, $WS_POPUP,$WS_EX_DLGMODALFRAME+$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW) ; Full Screen, without Titlebar, not on Task Tray $dragInProgress = 0 GUISetBkColor(0x999999, $fakeScreen) WinWait("Invisible Name") $winGUIhandle = WinGetHandle("Invisible Name") $penGraphic = _GDIPlus_GraphicsCreateFromHWND ($winGUIhandle) $selPen = _GDIPlus_PenCreate () _GDIPlus_PenSetColor($selPen, 0xFF999999) _GDIPlus_PenSetDashStyle($selPen, $GDIP_DASHSTYLEDOT) $currentWinGUI = 1 $backgroundPic = GUICtrlCreatePic ($captureFilename, 0, 0, @DesktopWidth, @DesktopHeight) GUICtrlSetState ($backgroundPic, $GUI_DISABLE) ; Makes image a de facto background; allows controls to exist on top Sleep(10) GUISetState() WinActivate("Invisible Name") WinWaitActive("Invisible Name") Sleep(20) $msg = 0 ; Clears Event EndIf . . . EndFunc Link to comment Share on other sites More sharing options...
weaponx Posted February 14, 2008 Share Posted February 14, 2008 (edited) $GUI_EVENT_PRIMARYDOWN does not belong in a GUI message loop, this is for OnEvent mode only. See here:http://www.autoitscript.com/autoit3/docs/g...OnEventMode.htm Edited February 14, 2008 by weaponx Link to comment Share on other sites More sharing options...
weaponx Posted February 14, 2008 Share Posted February 14, 2008 Here is an example of OnEvent with mouse clicks. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("OnEvent Mouseclick", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE") GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "LeftClick") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "RightClick") GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func LeftClick() MsgBox(0, "GUI Event", "You left clicked!") EndFunc Func RightClick() MsgBox(0, "GUI Event", "You right clicked!") EndFunc Func CLOSE() Exit EndFunc Link to comment Share on other sites More sharing options...
Siao Posted February 14, 2008 Share Posted February 14, 2008 $GUI_EVENT_PRIMARYDOWN does not belong in a GUI message loop, this is for OnEvent mode only. See here:http://www.autoitscript.com/autoit3/docs/g...OnEventMode.htmThat would be news to me. "be smart, drink your wine" Link to comment Share on other sites More sharing options...
weaponx Posted February 14, 2008 Share Posted February 14, 2008 (edited) That would be news to me.EDIT: Misread helpfile... Edited February 14, 2008 by weaponx Link to comment Share on other sites More sharing options...
Valuater Posted February 14, 2008 Share Posted February 14, 2008 That would be news to me. Ditto I use this all the time While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit_btn Exit 8) Link to comment Share on other sites More sharing options...
weaponx Posted February 14, 2008 Share Posted February 14, 2008 (edited) Sorry. I retract my previous statement. #include <GUIConstants.au3> $mainwindow = GUICreate("OnEvent Mouseclick", 200, 100) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE CLOSE() Case $GUI_EVENT_PRIMARYDOWN LeftClick() Case $GUI_EVENT_SECONDARYDOWN RightClick() EndSwitch Sleep(100) WEnd Func LeftClick() MsgBox(0, "GUI Event", "You left clicked!") EndFunc Func RightClick() MsgBox(0, "GUI Event", "You right clicked!") EndFunc Func CLOSE() Exit EndFunc Edited February 14, 2008 by weaponx Link to comment Share on other sites More sharing options...
RealisT Posted February 15, 2008 Author Share Posted February 15, 2008 Sorry. I retract my previous statement. #include <GUIConstants.au3> $mainwindow = GUICreate("OnEvent Mouseclick", 200, 100) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE CLOSE() Case $GUI_EVENT_PRIMARYDOWN LeftClick() Case $GUI_EVENT_SECONDARYDOWN RightClick() EndSwitch Sleep(100) WEnd Func LeftClick() MsgBox(0, "GUI Event", "You left clicked!") EndFunc Func RightClick() MsgBox(0, "GUI Event", "You right clicked!") EndFunc Func CLOSE() Exit EndFunc I will try the OnEvent mode. Enlighten me about Switch / EndSwitch.....(I can't find info on these among the AutoIt functions documentation)...how is this distinguished from Select / EndSelect ? Does this find the value of GUIGetMsg() automatically without having to use an additional variable to represent it within the Switch / EndSwitch lines? Thanks Link to comment Share on other sites More sharing options...
weaponx Posted February 15, 2008 Share Posted February 15, 2008 Conditional statements:http://www.autoitscript.com/autoit3/docs/i...conditional.htm 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