I've set up a script to handle listboxes (thanks to mikeyww's help; see viewtopic.php?f=76&t=97257)
I'm wondering if I can make a listbox to show my last 10 clipboard clips as list entries. The idea would be similar to this script https://www.autohotkey.com/board/topic/94747-clipboard-content-several-items-from-the-clipboard-to-the-word/ , but without the GUI, instead saving the clips within a listbox. In other words, it would show the last 10 clips within the listbox, and then clicking any list entry would paste that clip into the current application.
My reason for wanting to put a clip function within a listbox is: (1) I'm trying to consolidate a bunch of useful functions within my multi-listbox script and (2) use less CPU/RAM in processing clips, since the listbox would only be viewed/accessed when I press a hot key.
Help Adding Clipboard to ListBox
Help Adding Clipboard to ListBox
Last edited by AlFlo on 03 Dec 2021, 15:59, edited 1 time in total.
Re: Help Adding Clipboard to ListBox
Here is a menu approach that you can adapt. viewtopic.php?p=432487#p432487
Re: Help Adding Clipboard to ListBox
Thanks, but after 4 hours of trying, I give up (I have to get back to work).
Re: Help Adding Clipboard to ListBox
Here is an example.
Code: Select all
Global clip := [], max := 10, choices, clipNum
Gui, Font, s10
Gui, Add, ListBox, w200 r10 AltSubmit vclipNum
Gui, Add, Button, xm ym Hidden Default gWM_LBUTTONUP, OK
OnClipboardChange("clipChanged"), OnMessage(WM_LBUTTONUP := 0x0202, "WM_LBUTTONUP")
^!0::Gui, Show,, Clipboard
GuiEscape:
GuiClose:
Gui, Hide
Return
clipChanged(type) {
If (type != 1)
Return
SoundBeep, 2500
If clip.Count() = max
clip.RemoveAt(max), choices := RegExReplace(choices, ".+\K\|.*")
clip.InsertAt(1, Clipboard)
GuiControl,, clipNum, % choices := "|" SubStr(Clipboard, 1, 25) "||" Trim(StrReplace(choices, "||", "|"), "|")
}
WM_LBUTTONUP(wParam := "", lParam := "") { ; User clicked on the GUI
Gui, Submit
SendInput % "{Text}" clip[clipNum]
}
Re: Help Adding Clipboard to ListBox
Thank you! This is very helpful. Is there a way to make the clipboard gui stay showing after I click and insert text, instead of closing the clipboard gui and clearing all of the clips?
Re: Help Adding Clipboard to ListBox
Sure. I'm not seeing that all of the clips are cleared. Is that what you are seeing when you run the script?
Code: Select all
Global clip := [], max := 10, choices, clipNum
Gui, Font, s10
Gui, Add, ListBox, w200 r10 AltSubmit vclipNum
Gui, Add, Button, xm ym Hidden Default gWM_LBUTTONUP, OK
OnClipboardChange("clipChanged"), OnMessage(WM_LBUTTONUP := 0x0202, "WM_LBUTTONUP")
^!0::Gui, Show,, Clipboard
GuiEscape:
GuiClose:
Gui, Hide
Return
clipChanged(type) {
If (type != 1)
Return
SoundBeep, 2500
If clip.Count() = max
clip.RemoveAt(max), choices := RegExReplace(choices, ".+\K\|.*")
clip.InsertAt(1, Clipboard)
GuiControl,, clipNum
, % choices := "|" SubStr(Clipboard, 1, 25) "||" Trim(StrReplace(choices, "||", "|"), "|")
}
WM_LBUTTONUP(wParam := "", lParam := "") { ; User clicked on the GUI
Gui, Submit
Sleep, 25
SendInput % "{Text}" clip[clipNum]
Sleep, 50
Gosub, ^!0
}
Re: Help Adding Clipboard to ListBox
I am seeing all of the clips cleared after I select a clip which is inserted as text. But I haven't tried integrating it yet into my other listboxes.
Perhaps when I integrate it, the clips won't disappear?
Perhaps when I integrate it, the clips won't disappear?
Re: Help Adding Clipboard to ListBox
I am seeing all of the clips cleared after I select a clip which is inserted as text. But I haven't tried integrating it yet into my other listboxes.
Perhaps when I integrate it, the clips won't disappear?
Perhaps when I integrate it, the clips won't disappear?
Re: Help Adding Clipboard to ListBox
I don't know. If you are referring to this exact script, there is no line that deletes all of the rows from the ListBox. I'd be interested in seeing a screenshot of before & after, when you run the script that I posted.
Who is online
Users browsing this forum: AlFlo and 144 guests