ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE. Software > Post New Requests Here

Alt-LMBclick puts filename in GUI Edit element. Without using clipboard

(1/2) > >>

I've created a small GUI with an Edit element where users can type a filename, this filename is submitted with a button and based on part of the filename string, the GUI gets expanded with different elements.

The problem is as follows: The typical filename to be typed is over 25 characters long and typing it is rather error prone. So... I'm working on adding a button that
hides the GUI, allows the user click to an explorer window and Alt-LMBclick on a filename. The filename then gets placed in the edit element and the GUI is unhidden. As the user may have valuable data on the clipboard, I do not want to use the clipboard for this.

I've been trying to use this code:

--- ---TitleCopyExplorer:
SetTimer, Explorecopy, 150
If WinActive ahk_group Explore
explorerClass = ExploreWClass


WinGetClass explorerClass, A
ControlGet, selectedFile, List, Selected Col1, SysListView321,ahk_class %explorerClass%
msgbox %selectedFile%
return(modified from: this forum topic)

However, this just returns an empty string in the msgbox.

Thanks for your help.

A simpler approach may be

--- Code: Autohotkey ---ClipSave := ClipboardAll; do whatever thenClipboard := ClipSave

Thanks Miles, That's a good idea. But leads me to two new questions:
- Would this require a lot of memory?
- In VBA you'd set an object to Nothing as good coding practice. Is this possible in AHK?

Also, I still do not understand why my code snippet returns an empty string.

BTW: I also tried the following code of Skwire:

--- ---#c::
    SendInput, ^c ; Copy image path to clipboard.

    SplitPath, Clipboard, myFileName ; Get filename from the path.

    Clipboard := "" . myFileName ; Concatenate string and copy it to the clipboard.


Copied from this forum topic; This also returns an empty string... I must be doing something very basic wrong. :huh:

See this link for freeing the saved clipboard memory
ClipSaved =

Also when you use Send ^c you need to give a delay to wait for the clipboard to have the new data.  I believe if you use no number it waits forever.  See ClipWait

Thanks for the help MilesAhead! I'm now using:

--- --- Send ^c
ClipWait, 1
clipboard = %clipboard%
MsgBox %clipboard%The difference between an empty msgbox and a msgbox with the title was:

--- ---clipboard = %clipboard%
Case closed :up:

 >:( grmph...

Still having issues with it after I added the clipsaved option. The script works fine like this:

--- ---MButton::
;ClipSaved := ClipboardAll
;ClipWait, 0.2
SetTimer, CopyFileName, Off
;clipboard =
Send ^c
ClipWait, 0.2
clipboard = %clipboard%
MsgBox %clipboard%
;clipboard:= ClipSaved

But I once again get an empty string in the message box if I uncomment the clipboard related lines (3x). Somehow it seems like messagebox is slow and the script goes ahead changing the content of the clipboard before the msgbox is rendered??  :huh:
BTW: As you see I changed the hotkey from !Lbutton to MButton.


[0] Message Index

[#] Next page

Go to full version