Sign in to follow this  
Followers 0
rasim

Button double click

5 posts in this topic

How can processed double click on the button?

I tryed with this code, but unsuccessfully

#include <GuiConstants.au3>

Global Const $WM_LBUTTONDBLCLK = 0x0203

$hGui = GUICreate("Test", 300, 100, -1, -1, Default, $WS_EX_APPWINDOW + $WS_EX_TOOLWINDOW)

$Run_Button = GUICtrlCreateButton("Ok", 10, 70, 50, 20)
GUICtrlSetCursor(-1, 0)
$Close_Button = GUICtrlCreateButton("Close", 240, 70, 50, 20)
GUICtrlSetCursor(-1, 0)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE, $Close_Button
        ExitLoop
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $tagNMHDR, $event, $code, $bID
    
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    $code = DllStructGetData($tagNMHDR, 3)
    $bID = BitAND($wParam, 0xFFFF)
    If $bID = $Run_Button And $code = -3 Then MsgBox(0, "", "Double click")
        
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites



core code snippet:

Global Const $WM_COMMAND = 0x0111
 Global Const $BN_DOUBLECLICKED = 5
 ;~ Global Const $BN_CLICKED = 0
 
 GUIRegisterMsg ($WM_COMMAND, "MY_WM_COMMAND")
 
 Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
     $nNotifyCode = _HiWord($wParam)
     $nID = _LoWord($wParam)
     $hCtrl = $lParam
     
     If $nID = $test Then
         Switch $nNotifyCode
 ;~             Case $BN_CLICKED
 ;~                 Vysledek(0)
             Case $BN_DOUBLECLICKED
                 Vysledek(1)
         EndSwitch
         Return 0
     Else ; to  preserve Esc functionality
         Return $GUI_RUNDEFMSG
     EndIf
 EndFunc
 
 Func _HiWord($x)
     Return BitShift($x, 16)
 EndFunc
 
 Func _LoWord($x)
     Return BitAND($x, 0xFFFF)
 EndFuncoÝ÷ Ûhç(uçë¢i²+m橦Xjبú+µë-x ¢m§]¢æåyÉbrK§^Ú'{'­¨(~æÊj-êí¢)©®ÞêÝ¢æåyÉbrK$Yljëh×6#NoTrayIcon
 #include "GUIConstants.au3"
 
 Global Const $WM_COMMAND = 0x0111
 Global Const $BN_DOUBLECLICKED = 5
 ;~ Global Const $BN_CLICKED = 0
 
 GUICreate("Dvojklik - test", 300, 250) ; doubleclick - test
 GUISetBkColor(0xc8ffc8)
 
 $gr = GuiCtrlCreateGraphic(100, 50, 100, 50)
 GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xff33ff, 0xff33ff) ; pink
 GUICtrlSetGraphic(-1,$GUI_GR_RECT, 0,0, 99,49) ; under WIN98 must be  1px less
 GUICtrlSetState(-1,$GUI_DISABLE)
 
 $test = GUICtrlCreateButton("Test", 100, 50, 100, 50)
 GUICtrlSetstate(-1, $GUI_FOCUS)
 
 $ok = GUICtrlCreateLabel("dobře", 100, 150, 100, 50, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER)) ; well
 GUICtrlSetFont(-1, 24, 800, 0, "Arial") ; bold
 GUICtrlSetColor(-1, 0x0000ff) ; blue
 GUICtrlSetstate(-1, $GUI_HIDE)
 GUISetState(@SW_SHOW)
 
 GUIRegisterMsg ($WM_COMMAND, "MY_WM_COMMAND")
 
 global $je_drag = 0
 global $pos_start[2]
 global $pos_test[2]
 
 While 1
     $msg = GUIGetMsg()
     Select
         Case $msg = $GUI_EVENT_CLOSE 
             Exit
     
         Case $msg = $GUI_EVENT_SECONDARYDOWN
             GUICtrlSetPos($test, 100, 50, 100, 50)
 
         Case $msg = $GUI_EVENT_PRIMARYDOWN
             $pos = GUIGetCursorInfo()
             If $pos[4] = $test Then 
                 $je_drag = 1
                 $pos_test = ControlGetPos("", "", $test)
                 $pos_start = MouseGetPos()
             EndIf
             
         Case $msg = $GUI_EVENT_PRIMARYUP
             If $je_drag Then $je_drag = 0
             
         Case $msg = $GUI_EVENT_MOUSEMOVE
             If $je_drag Then
                 $pos = MouseGetPos()
                 GUICtrlSetPos($test, $pos_test[0] + $pos[0] - $pos_start[0], $pos_test[1] + $pos[1] - $pos_start[1])
             EndIf
     EndSelect
 WEnd
 
 Func Vysledek($dobre) ; result
     If $dobre Then
         GUICtrlSetstate($ok, $GUI_show)
         SoundPlay(@WindowsDir & "\media\ding.wav",0) ; tada chord ding
     EndIf
     
     Sleep(750)
     GUICtrlSetstate($ok, $GUI_HIDE)
 EndFunc
 
 Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
     $nNotifyCode = _HiWord($wParam)
     $nID = _LoWord($wParam)
     $hCtrl = $lParam
     
     If $nID = $test Then
         Switch $nNotifyCode
 ;~             Case $BN_CLICKED
 ;~                 Vysledek(0)
             Case $BN_DOUBLECLICKED
                 Vysledek(1)
         EndSwitch
         Return 0
     Else ; to  preserve Esc functionality
         Return $GUI_RUNDEFMSG
     EndIf
 EndFunc
 
 Func _HiWord($x)
     Return BitShift($x, 16)
 EndFunc
 
 Func _LoWord($x)
     Return BitAND($x, 0xFFFF)
 EndFunc

Share this post


Link to post
Share on other sites

Zedna

Thanks, but your code not work :)

Used Autoit v3.2.10.0

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Zedna

Thanks, but your code not work :)

Used Autoit v3.2.10.0

This is very old script but it should work fine.

Just comment some constants which are mentioned in error message.

Send full Scite output with errors.

EDIT: probablty this one

Global Const $WM_COMMAND = 0x0111
Edited by Zedna

Share this post


Link to post
Share on other sites

Zedna

No, don`t work, label "Dobre" not show when double click. :) Mayb have another example?

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