BrettF Posted June 27, 2009 Posted June 27, 2009 Well here is my code: expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> ;Global $playing_state = -1 Global $DoubleClicked = 0, $clicked = 0, $current_viz = 1 $viz_width = 800;@DesktopWidth $viz_height = 600;@DesktopHeight $on_top = 0 $win = GUICreate("Visualization Test", $viz_width, $viz_height, Default, Default, $WS_POPUP, $on_top) $lbl = GUICtrlCreateLabel("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) $viz = GUICtrlCreatePic("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case - 3 Exit EndSwitch Switch $DoubleClicked Case $lbl MsgBox(0, "", "DBLCLK") $DoubleClicked = 0 EndSwitch Switch $clicked Case $lbl If Not $DoubleClicked Then MsgBox(0, "", "CLK") $clicked = 0 EndSwitch WEnd Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam) Local Const $STN_DBLCLK = 1, $STN_CLICKED = 0 Local $nID = BitAND($wParam, 0xFFFF) Local $nNotifyCode = BitShift($wParam, 16) Switch $nNotifyCode Case $STN_CLICKED $clicked = $nID Case $STN_DBLCLK $DoubleClicked = $nID EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Whenever I try to do a double click, the single click message comes up and then double click. How can I fix this? Is there also a way to make it register dragging of the window (as not not call the click function), and display a message on right click? Thanks, Brett 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!
Moderators Melba23 Posted June 27, 2009 Moderators Posted June 27, 2009 BrettF,I am assuming you want both single and double clicks to register:expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> ;Global $playing_state = -1 Global $DoubleClicked = 0, $clicked = 0, $current_viz = 1 $viz_width = 800;@DesktopWidth $viz_height = 600;@DesktopHeight $on_top = 0 $win = GUICreate("Visualization Test", $viz_width, $viz_height, Default, Default, $WS_POPUP, $on_top) $lbl = GUICtrlCreateLabel("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) $viz = GUICtrlCreatePic("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case - 3 Exit EndSwitch Switch $clicked Case $lbl $Begin = TimerInit() Do Switch $DoubleClicked Case $lbl MsgBox(0, "", "DBLCLK") $DoubleClicked = 0 $Clicked = 0 EndSwitch Until TimerDiff($Begin) > 100 ; Adjust to suit required double clicking speed If $Clicked Then MsgBox(0, "", "CLK") $clicked = 0 EndSwitch WEnd Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam) Local Const $STN_DBLCLK = 1, $STN_CLICKED = 0 Local $nID = BitAND($wParam, 0xFFFF) Local $nNotifyCode = BitShift($wParam, 16) Switch $nNotifyCode Case $STN_CLICKED $clicked = $nID Case $STN_DBLCLK $DoubleClicked = $nID EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDM23 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
BrettF Posted June 27, 2009 Author Posted June 27, 2009 Why thank you. Exactly what I was after. Tweaked it to get double click speed from RegRead ("HKEY_CURRENT_USER\Control Panel\Mouse", "DoubleClickSpeed"). Still wondering about right click though 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!
Authenticity Posted June 27, 2009 Posted June 27, 2009 You can use GetDoubleClickTime() to get that instead.
martin Posted June 27, 2009 Posted June 27, 2009 Why thank you. Exactly what I was after. Tweaked it to get double click speed from RegRead ("HKEY_CURRENT_USER\Control Panel\Mouse", "DoubleClickSpeed"). Still wondering about right click though I think Melba23's code could go wrong once every 6 thousnad years say, because you could click just at the end of the time period for detecting the double click. So I think it is better to time f rom the click, which happens first, rather than the double click. Also, you can get round the clkick on drag using another flag. expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> ;Global $playing_state = -1 Global $DoubleClicked = 0, $clicked = 0, $current_viz = 1 $viz_width = 800;@DesktopWidth $viz_height = 600;@DesktopHeight $on_top = 0 $win = GUICreate("Visualization Test", $viz_width, $viz_height, Default, Default, $WS_POPUP, $on_top) $lbl = GUICtrlCreateLabel("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) $viz = GUICtrlCreatePic("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) GUISetState() Global $esmNO = 0 GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg(0x0232, "ESM");$WM_EXITSIZEMOVE While 1 $nMsg = GUIGetMsg() Switch $nMsg Case - 3 Exit EndSwitch Switch $clicked Case $lbl If $clicked Then $Begin = TimerInit() Do Sleep(10) Until TimerDiff($Begin) > 100; Adjust to suit required double clicking speed If $DoubleClicked Then Switch $DoubleClicked Case $lbl MsgBox(0, "", "DBLCLK") $DoubleClicked = 0 $clicked = 0 EndSwitch Else If Not $esmNO Then MsgBox(0, "", "CLK") Else $esmNO = 0 EndIf $clicked = 0 EndIf EndIf EndSwitch WEnd Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam) Local Const $STN_DBLCLK = 1, $STN_CLICKED = 0 Local $nID = BitAND($wParam, 0xFFFF) Local $nNotifyCode = BitShift($wParam, 16) Switch $nNotifyCode Case $STN_CLICKED $clicked = $nID Case $STN_DBLCLK $DoubleClicked = $nID EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func esm() $esmNO = 1 ConsoleWrite("esmed" & @CRLF) EndFunc ;==>esm 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.
Moderators Melba23 Posted June 27, 2009 Moderators Posted June 27, 2009 martin, Now there is the difference between a hobbyist like me and a professional! :-) 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
BrettF Posted June 27, 2009 Author Posted June 27, 2009 Thanks all. AAMP is about ready for an update with visualizations... 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!
ProgAndy Posted June 27, 2009 Posted June 27, 2009 (edited) I would do it this way: expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global Const $iDoubleClickTime = _GetDoubleClickTime() Func _GetDoubleClickTime() Local $aResult = DllCall("user32.dll", "uint", "GetDoubleClickTime") If @error Then Return SetError(1,0,100) Return $aResult[0] EndFunc ;Global $playing_state = -1 Global $DoubleClicked = 0, $clicked = 0, $current_viz = 1 $viz_width = 800;@DesktopWidth $viz_height = 600;@DesktopHeight $on_top = 0 $win = GUICreate("Visualization Test", $viz_width, $viz_height, Default, Default, $WS_POPUP, $on_top) GUISetBkColor(0x123456) $lbl = GUICtrlCreateLabel("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) $viz = GUICtrlCreatePic("", 0, 0, $viz_width, $viz_height, 0x0100, 0x00100000) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case - 3 Exit EndSwitch If $clicked Then $tDblClickTime = TimerInit() Do Switch $DoubleClicked Case 0 Sleep(10) Case $lbl MsgBox(0, "", "DBLCLK") ExitLoop EndSwitch If $DoubleClicked Then $clicked = 0 Until TimerDiff($tDblClickTime) > $iDoubleClickTime $DoubleClicked = 0 Switch $clicked Case 0 ; nothing Case $lbl If Not $DoubleClicked Then MsgBox(0, "", "CLK") EndSwitch $clicked = 0 EndIf WEnd Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam) Local Const $STN_DBLCLK = 1, $STN_CLICKED = 0 Local $nID = BitAND($wParam, 0xFFFF) Local $nNotifyCode = BitShift($wParam, 16) Switch $nNotifyCode Case $STN_CLICKED $clicked = $nID Case $STN_DBLCLK $DoubleClicked = $nID EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Edited June 27, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
kjcdude Posted February 6, 2010 Posted February 6, 2010 Thanks to whoever created this. Very useful code to see when a guictrl is clicked on.
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