Sign in to follow this  
Followers 0
Tenaya

GUI event for double-click

11 posts in this topic

Is therer a possiblity to destinguish whether a button was clicked only once or double?

Share this post


Link to post
Share on other sites



Is therer a possiblity to destinguish whether a button was clicked only once or double?

Yes

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

per topic... not per question

by SmOke_N

include <GUIConstants.au3>
#NoTrayIcon
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2

$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)


While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
            Sleep(10); Delay not to run multiple copies
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    If $nID = $GCCList Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
                Return 0
        EndSwitch
    EndIf
EndFunc

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Holger wrote the MY_WM_COMMAND() UDF, I just seem to be the only one that uses it :o


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Holger wrote the MY_WM_COMMAND() UDF, I just seem to be the only one that uses it :o

http://www.autoitscript.com/forum/index.ph...opic=22717&st=0

Val, u cut of the # in #include <GUIConstants.au3>

here's my pathetic attempt.. at notify

CODE

#include <GUIConstants.au3>

#NoTrayIcon

Global Const $WM_COMMAND = 0x0111

Global Const $LBN_SELCHANGE = 1

Global Const $LBN_DBLCLK = 2

$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)

GUISetIcon("D:\005.ico")

$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)

GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")

$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)

GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

GUISetState(@SW_SHOW)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'

If GUICtrlRead($GCCList) = 'n.notepad' Then MsgBox(262208, "Window", "You hit enter!", 4)

Sleep(10); Delay not to run multiple copies

Case ControlGetFocus($Form2) = 'ListBox1'

If GUICtrlRead($GCCList) = 'n.notepad' Then MsgBox(262208, "Window", "You click me", 4)

EndSelect

WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

$nNotifyCode = BitShift($wParam, 16)

$nID = BitAnd($wParam, 0x0000FFFF)

$hCtrl = $lParam

If $nID = $GCCList Then

Switch $nNotifyCode

Case $LBN_DBLCLK

If GUICtrlRead($GCCList) = 'n.notepad' Then MsgBox(262208, "Window", "You double clicked!", 4)

Return 0

EndSwitch

EndIf

EndFunc

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')

Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)

If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1

Return 0

EndFunc

Share this post


Link to post
Share on other sites

http://www.autoitscript.com/forum/index.ph...opic=22717&st=0

Val, u cut of the # in #include <GUIConstants.au3>

here's my pathetic attempt.. at notify

CODE

#include <GUIConstants.au3>

#NoTrayIcon

Global Const $WM_COMMAND = 0x0111

Global Const $LBN_SELCHANGE = 1

Global Const $LBN_DBLCLK = 2

$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)

GUISetIcon("D:\005.ico")

$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)

GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")

$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)

GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

GUISetState(@SW_SHOW)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'

If GUICtrlRead($GCCList) = 'n.notepad' Then MsgBox(262208, "Window", "You hit enter!", 4)

Sleep(10); Delay not to run multiple copies

Case ControlGetFocus($Form2) = 'ListBox1'

If GUICtrlRead($GCCList) = 'n.notepad' Then MsgBox(262208, "Window", "You click me", 4)

EndSelect

WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

$nNotifyCode = BitShift($wParam, 16)

$nID = BitAnd($wParam, 0x0000FFFF)

$hCtrl = $lParam

If $nID = $GCCList Then

Switch $nNotifyCode

Case $LBN_DBLCLK

If GUICtrlRead($GCCList) = 'n.notepad' Then MsgBox(262208, "Window", "You double clicked!", 4)

Return 0

EndSwitch

EndIf

EndFunc

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')

Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)

If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1

Return 0

EndFunc

Um... Didn't I write that... other than the MsgBox? (and now ... 'My' Attempt is pathetic?? :o)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Um... Didn't I write that... other than the MsgBox? (and now ... 'My' Attempt is pathetic?? :o)

are you slightly_abnormal? :geek:

Share this post


Link to post
Share on other sites

Um... Didn't I write that... other than the MsgBox? (and now ... 'My' Attempt is pathetic?? :geek:)

i added the alerts to notify if double click or normal click.. :o

Share this post


Link to post
Share on other sites

Holger wrote the MY_WM_COMMAND() UDF, I just seem to be the only one that uses it :)

beg to differ, check out the code snippet you'll see it was modified to fit the needs of the script.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

beg to differ, check out the code snippet you'll see it was modified to fit the needs of the script.

Sorry Gary... I've only seen it once... and that was in a Dbl Click Input post a while back.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Sorry Gary... I've only seen it once... and that was in a Dbl Click Input post a while back.

Np, the one I'm surprised to not see more use of is the GUICtrlRegisterListViewSort, enough people start using that I could do away with the Sort in the UDF's.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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