Context Menu Clipboard History

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Stinkfoot9
Posts: 51
Joined: 29 May 2022, 12:17

Context Menu Clipboard History

Post by Stinkfoot9 » 11 Mar 2023, 01:26

Access Clipboard History Via a Context Menu..

I Have it Set to the Last 5 Items But you can set it to as many as 9
Timer Clears Var sos12 and the context menu after 5 minutes.

Press !V to open context menu press keys 1-5 to paste numbered items.

Edit: Changed Delimiters $ to `|

Code: Select all


; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=114923&p=513489#p513489

#Persistent                  
OnClipboardChange("ClipChanged")

ClipChanged(Type) 
	{
	If (tog113 != 1)
		{
		CB1 := Trim(Clipboard, " ")
		global sos12 := CB1 "`|" sos12
		Loop, parse, sos12, `|
			{
			If A_loopfield is not space
				{
				If (a_index = 1)                                                   
					{                                                              
					Menu, MyMenu, add,,                                   
					Menu, Mymenu, DeleteAll
					}
				If (a_index < 7 )                               
					{
					Cl1 := StrReplace(a_loopfield, "`r`n")      
					Cl1 := StrReplace(CL1, A_space)             
					Cl1 := StrReplace(Cl1, "`t")
					CL1 := SubStr(CL1, 1 ,50)
					Menu, MyMenu, add,%a_index%. %CL1%, MenuHandler
					}
				If (a_index = 6)
					{
					Menu, Mymenu, Delete, 6&
					}
				}
			}			
		Tooltip, Copied
		sleep 500                                                        
		Tooltip                                                     
		settimer, emptyclips, -300000 ; 5minute        
		}                                      
	}                                          
	
return



menuhandler:                                          
Loop,parse,sos12, `|
	{
	if (a_index = A_thismenuitempos)         
		{
		global tog113 = 1                  
		sleep 200
		clipboard := A_loopfield
		send, ^v
		Global Tog113 = 0
		}
	}
return

!v::               
If sos12 is not space        
	{
	Menu, MyMenu, Show   
	}
Else 
	{
	Tooltip, Empty
	sleep 200
	tooltip
	}
return

					
emptyclips:
sos12 = 
Menu, MyMenu, Deleteall
return

Last edited by Stinkfoot9 on 22 Mar 2023, 04:42, edited 4 times in total.

User avatar
DataLife
Posts: 445
Joined: 29 Sep 2013, 19:52

Re: Context Menu Clipboard History

Post by DataLife » 14 Mar 2023, 00:49

I like the idea and this is very easy to use, however, this script does not completely paste large clipboards.

Sometimes, only 150 out of 2000, sometimes only 330 out of 528 lines of code is pasted.

It splits large clipboards into 5 separate entries in the context menu and none of them are the complete clipboard.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

gya
Posts: 25
Joined: 04 Nov 2021, 01:22

Re: Context Menu Clipboard History

Post by gya » 14 Mar 2023, 02:34

DataLife wrote:
14 Mar 2023, 00:49
I like the idea ... Sometimes, only 150 out of 2000, sometimes only 330 out of 528 lines of code is pasted ...]
[Mod edit: Added a closing tag to the quote.]

Yes, that's an excellent point by @DataLife which @Stinkfoot9 should look into as it's a serious bug.
Note that for a long script, it's always at the same place that the cut is made.

Sincerely.

User avatar
DataLife
Posts: 445
Joined: 29 Sep 2013, 19:52

Re: Context Menu Clipboard History

Post by DataLife » 15 Mar 2023, 09:06

DataLife wrote:
14 Mar 2023, 00:49
I like the idea and this is very easy to use, however, this script does not completely paste large clipboards.

Sometimes, only 150 out of 2000, sometimes only 330 out of 528 lines of code is pasted.

It splits large clipboards into 5 separate entries in the context menu and none of them are the complete clipboard.
The problem is the delimiter "$"


This works find on clipboards without the the $ symbol in the clipboard.

Probably could safely use one of these ¢ ¤ ¥ ¦ § © ª « ® µ ¶ or use a string of characters as the delimiter.

I changed the delimiter from $ to ¦ and it works great.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

User avatar
Stinkfoot9
Posts: 51
Joined: 29 May 2022, 12:17

Re: Context Menu Clipboard History

Post by Stinkfoot9 » 20 Mar 2023, 20:28

gya wrote:
14 Mar 2023, 02:34
Note that for a long script, it's always at the same place that the cut is made.
As far as cutting off for long scripts i think you may be reaching the Variables capacity, not sure what that is but that sounds like it could be it.

DataLife wrote:
15 Mar 2023, 09:06

The problem is the delimiter "$"

This works find on clipboards without the the $ symbol in the clipboard.

Probably could safely use one of these ¢ ¤ ¥ ¦ § © ª « ® µ ¶ or use a string of characters as the delimiter.

I changed the delimiter from $ to ¦ and it works great.
I tried to use the character "¦" and it doesn't work for me not sure why. I'm not sure if "|" would be safe to use but that's what i changed it too.

But if any one else can change the delimiter to one of those characters that would be recommended for now I'll change it to "|" because it works for me.




Hope you guys find this script useful! ;D

User avatar
Stinkfoot9
Posts: 51
Joined: 29 May 2022, 12:17

Re: Context Menu Clipboard History

Post by Stinkfoot9 » 27 Mar 2023, 02:58

Does anyone know if it is possible to keep the context menu open when selecting a option or clicking the mouse?

Id like to add a pin option to the top of the menu and have it pinned to the corner of the screen.

I tried using settimer to have it manifest over and over but it blocks my input.

Post Reply

Return to “Scripts and Functions (v1)”