Jump to content
Sign in to follow this  
XuxinhaKill

How to identify a double click on a GUI label

Recommended Posts

XuxinhaKill

Well that is what I need... Identify a double click on a GUI label

Something like this:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$n1 = "Null"
$n2 = "Null"
GUICreate("Teste",200,200)
$Name1 = GUICtrlCreateLabel($n1,0,0,100,100,$SS_CENTER)
$Name2 = GUICtrlCreateLabel($n2,0,100,100,100,$SS_CENTER)
GUISetState(@SW_SHOW)

While 1
; If the label Name1 is double clicked then it pops up a inputbox
If DoubleClick($Name1) Then
$n1 = InputBox("Name","Name")
GUICtrlSetData($Name1,$n1)
EndIf
WEnd

Share this post


Link to post
Share on other sites
FireFox

Hi,

On a label it won't be very accurate as you can see with this example :

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Local $n1 = "Null", $n2 = "Null"

GUICreate("Teste", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$Name1 = GUICtrlCreateLabel($n1, 0, 0, 100, 100, $SS_CENTER)
GUICtrlSetOnEvent($Name1, "_Name1")

$Name2 = GUICtrlCreateLabel($n2, 0, 100, 100, 100, $SS_CENTER)
GUICtrlSetOnEvent($Name2, "_Name1")

GUISetState()

While 1
   Sleep(1000)
WEnd

Func _Name1()
   Local Static $hTimerDbClick = 0
   If $hTimerDbClick = 0 Or TimerDiff($hTimerDbClick) > 500 Then
      $hTimerDbClick = TimerInit()
      Return ;
   EndIf

   $n1 = InputBox("Name", "Name")
   GUICtrlSetData($Name1, $n1)
EndFunc

Func _Exit()
    Exit
EndFunc

You should use another control that handles more than 1 click per second.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
johnmcloud

I'm not a good coder, but try this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Global $Flag

$hGui = GUICreate("", 150, 100)
$hLabel = GUICtrlCreateLabel("DOUBLE_CLICK", 20, 20, 100, 20)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "TEST_WM_COMMAND")

While 1
 $msg = GUIGetMsg()
 Switch $msg
  Case $GUI_EVENT_CLOSE
   ExitLoop
 EndSwitch
 If $Flag = True Then
  MsgBox(0, 0, "Double click")
  $Flag = False
 EndIf
WEnd

Func TEST_WM_COMMAND($hWnd, $MsgID, $wParam, $lParam)
 Local Const $STN_DBLCLK = 1
 Local $nID = BitAND($wParam, 0xFFFF)
 Local $nCode = BitShift($wParam, 16)
 If $nID = $hLabel And $nCode = $STN_DBLCLK Then $Flag = True
 Return $GUI_RUNDEFMSG
EndFunc   ;==>TEST_WM_COMMAND
Edited by johnmcloud

Share this post


Link to post
Share on other sites
FireFox

I'm not a good coder

However you found the right way (that I had not thought) to make it ;)

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
johnmcloud

it was just a fortuitous event, beacuse i have that problem some time ago

Share this post


Link to post
Share on other sites
FireFox

it was just a fortuitous event, beacuse i have that problem some time ago

More you know and more you can answer to requests. It's yet fortuitous events even it does not seem to be.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
XuxinhaKill

Thanks @FireFox and @johnmcloud!

I'm new in this GUI stuff, so I'm trying to understand your codes.

Thanks again guys.

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  

  • Similar Content

    • Paxman
      By Paxman
      Just seem to have hit a bit of a hurdle.
      I am trying to get Autoit to tick a box in a dialogue box. However no windows shortcut works (eg. spacebar etc.).
      So having moved to the tick box (how can i produce a double click of the mouse (which ticks the box) without moving the mouse each time. I will need to do this many times in a tall dialogue box you need to scroll through if trying to use the mouse to do it?
      Can i map a keyboard shortcut or something?
      Thanks
      Neil
       
    • Reziskonh
      By Reziskonh
      Hi, everybody
      I look for GUI whose behavior similar to the message of an email client or antivirus
      In other words:
          Any PC screen able to calculate the size
          To consider the Task bar size
          To find the lower corner on the right/below and to nestle on it

      Notes:
      In GUI the GUICtrlCreateEdit field (as option) - that can be received and displayed through variable information
      Thanks a lot
      PS
      I use the translator, excuse if something is not clear
       

    • Pike
      By Pike
      Hello Everyone,
      New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help.
      1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click.
      2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much!
      Pike
    • VollachR
      By VollachR
      Hi,
      I'd like to show a progress bar for an operation performed by an external program my script is running silently, I want to show it in a GUI I created using the GUICtrlCreateProgress but I have no idea how to do it.
      The important thing to point out is that there's no way of knowing how long the external program will run, as it is a file splitter and it depends on the size of file it splits and the split parts size.
      Can someone point me in the right direction or give me an example how to do so?
      This is my RunWait command:
      RunWait($MYFILES1 & '\fsplit.exe -split ' & $Size & ' mb ' & $File & " -f " & $File & "." & $extension) It uses multiple variables declared and set earlier in the script, how will I got about having the progress of that command shown using GUICtrlCreateProgress ? Is it possible?
      Thank you.
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry and I hope to find the answer here
      I want to create a graphical user interface
      but I want to hide the system menu
      I mean the window menu
      Is this possible?
      If is possible please give me how to do that
      Thanks in advance
×