DonationCoder.com Software > Post New Requests Here
Alt-LMBclick puts filename in GUI Edit element. Without using clipboard
huismus:
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
return
Explorecopy:
If WinActive ahk_group Explore
{
explorerClass = ExploreWClass
~!Lbutton::
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.
Huismus
MilesAhead:
A simpler approach may be
--- Code: Autohotkey ---ClipSave := ClipboardAll; do whatever thenClipboard := ClipSave
huismus:
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 := "http://www.site.com/" . myFileName ; Concatenate string and copy it to the clipboard.
}
Return
Copied from this forum topic; This also returns an empty string... I must be doing something very basic wrong. :huh:
MilesAhead:
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
huismus:
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 =
click
Send ^c
ClipWait, 0.2
clipboard = %clipboard%
MsgBox %clipboard%
;clipboard:= ClipSaved
Return
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.
Navigation
[0] Message Index
[#] Next page
Go to full version