Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

DoubleClick on Gui pictures puts their path in your clipboard


  • Please log in to reply
7 replies to this topic
dantheuber
  • Members
  • 7 posts
  • Last active: Oct 11 2013 10:48 AM
  • Joined: 27 Apr 2013

This is not anywhere in the documentation and is an undesirable functionality for most people i would think... 

 

Example of this:

https://gist.github....onymous/5895714

 

 

If you dont want this to happen you have to have had the clipboard saved prior to their doubleclick of it so that you can put it back. And in my case, with multiple images that usually ends up being a convoluted If RegexMatch() bit to look for all your gui's images path's in your clipboard. this should be fixed... 



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

You can ask Microsoft about that, it can't be 'fixed' with ahk, only a workaround is possible.

Gui,Add,text,x10 y30 w180 gLabel, DOUBLE_CLICK_HERE
Gui,Show,w200 h100,test app
return
Label:
If (A_GuiEvent="DoubleClick")
  Clipboard:=BkpClipboard1
ToolTip,% "clipboard: " Clipboard 
return

GuiClose:
ExitApp

OnClipboardChange:
If A_EventInfo
  BkpClipboard1:=BkpClipboard,BkpClipboard:=Clipboard
return


dantheuber
  • Members
  • 7 posts
  • Last active: Oct 11 2013 10:48 AM
  • Joined: 27 Apr 2013

does this with text too?

 

https://gist.github....onymous/5895929



dantheuber
  • Members
  • 7 posts
  • Last active: Oct 11 2013 10:48 AM
  • Joined: 27 Apr 2013

does this with text too?

 

https://gist.github....onymous/5895929



dantheuber
  • Members
  • 7 posts
  • Last active: Oct 11 2013 10:48 AM
  • Joined: 27 Apr 2013

Ah i see - Yes i made my own workaround in my scripts but its still annoying =P



JnLLnd
  • Members
  • 193 posts
  • Last active: Jul 23 2015 02:15 AM
  • Joined: 30 Dec 2007

I had to do some edits to make to this workaround work for me. I found that the using BkpClipboard1 was unnecessary. Also, using ClipboardAll will preserve any kind of content in the clipboard (image, etc.).

Gui,Add,text,x10 y30 w180 gLabel, DOUBLE_CLICK_HERE
Gui,Show,w200 h100,test app
return

Label:
If (A_GuiEvent="DoubleClick")
  Clipboard := BkpClipboardAll
MsgBox, Clipboard: %Clipboard%
return

GuiClose:
ToolTip
ExitApp

OnClipboardChange:
If A_EventInfo
  BkpClipboardAll := ClipboardAll
return

Hope this works for you.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

That's a terrible workaround.

 

Copying its text to the clipboard when double-clicked is the default behaviour of a Static control. Therefore you just need to override the default behaviour, the same way that you can for any other message.

 

If a monitor function uses Return without any parameters, or it specifies a blank value such as "" (or it never uses Return at all), the incoming message goes on to be processed normally when the function finishes. The same thing happens if the function Exits or causes a runtime error such as running a nonexistent file. By contrast, returning an integer causes it to be sent immediately as a reply; that is, the program does not process the message any further. For example, a function monitoring WM_LBUTTONDOWN (0x201) may return an integer to prevent the target window from being notified that a mouse click has occurred. In many cases (such as a message arriving via PostMessage), it does not matter which integer is returned; but if in doubt, 0 is usually safest.

OnMessage(0x203, "OnLButtonDblClk")

OnLButtonDblClk(wParam, lParam, msg, hwnd) {
    WinGetClass class, ahk_id %hwnd%
    if (class = "Static") {
        if !A_Gui
            return 0  ; Just prevent Clipboard change.
        ; Send a WM_COMMAND message to the Gui to trigger the control's g-label.
        Gui +LastFound
        id := DllCall("GetDlgCtrlID", "ptr", hwnd) ; Requires AutoHotkey v1.1.
        static STN_DBLCLK := 1
        PostMessage 0x111, id | (STN_DBLCLK << 16), hwnd
        ; Return a value to prevent the default handling of this message.
        return 0
    }
}


JnLLnd
  • Members
  • 193 posts
  • Last active: Jul 23 2015 02:15 AM
  • Joined: 30 Dec 2007

It took me some time to come back to this issue but I just wanted to tell you that I implemented this much better solution. It works perfectly.

 

Thank you again for sharing, Lexikos.