Restoring my clipboard after set time Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Restoring my clipboard after set time

27 Dec 2019, 18:39

hello i am working on a macro tool that can be setup to do multiple things. One of them is to read content of files to the clipboard so i can then paste it anywhere i like, or i can have a macro send ctrl+v to a window to paste it for me. To do this i need to store what was in the clipboard (could be anything) and recall it after a set time to restore my previous clipboard

i have tried 4 things and i am at a loss why none of these are working so i ask for some help pointing me in the right direction

for all gui: the settings used are created in another gui here not included, the gui stuff for these labels not included

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  method 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Label1:
ClipSaved := ClipboardAll
SetTimer, Restore, 5000 
Start() ; related to my button class
Try Run, %Input96%
Try	
{
	clipboard =
	FileRead, clipboard, %Input99%
	clipwait, 1
}
IfWinExist, %Input94% %Input95%	
{	WinActivate
	MouseGetPos, CurX, CurY
	ControlClick,%EditInput127%	, , , %Input100%
	SendInput  , % Input97
	MouseMove %CurX%, %CurY% ,0
	return
}	else	{
	return
}
return

Restore:
Clipboard := ClipSaved   
ClipSaved := ""
SetTimer, Restore,  Off
return 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;; method 2 ;;;;;;;;;;;;;;;;;;;;;;;;;
; in the script that launches these macro's from a button on top
#Persistent
OnClipboardChange("ClipChanged")
return

Label1:
ClipSaved := ClipboardAll
Start() ; related to my button class
Try Run, %Input96%
Try	
{
	clipboard =
	FileRead, clipboard, %Input99%
	clipwait, 1
}
IfWinExist, %Input94% %Input95%	
{	WinActivate
	MouseGetPos, CurX, CurY
	ControlClick,%EditInput127%	, , , %Input100%
	SendInput  , % Input97
	MouseMove %CurX%, %CurY% ,0
	return
}	else	{
	return
}
return

ClipChanged() {
	Sleep 5000
     Clipboard := ClipSaved   
	ClipSaved := ""
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;; method 3 ;;;;;;;;;;;;;;;;;;;;;;;;;
Label1:
FileAppend, %ClipboardAll% , Setup/Settings/Temp.clip
SetTimer, Restore, 5000 
Start()
Try Run, %Input96%
Try	
{
	clipboard =
	FileRead, clipboard, %Input99%
	clipwait, 1
}
IfWinExist, %Input94% %Input95%	
{	WinActivate
	MouseGetPos, CurX, CurY
	ControlClick,%EditInput127%	, , , %Input100%
	SendInput  , % Input97
	MouseMove %CurX%, %CurY% ,0
	return
}	else	{
	return
}
return

Restore:
FileRead, Clipboard, *c Setup/Settings/Temp.clip  
SetTimer, Restore,  Off
return 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;; method 4 ;;;;;;;;;;;;;;;;;;;;;;;;;
; here i simply tried to do it after i send ^v using the macro or use ctrl+v on my keyboard
~^v::
Send,  ^v
Sleep, 5000
FileRead, Clipboard, *c Setup/Settings/Temp.clip 
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
any help would be appreciated
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Re: Restoring my clipboard after set time  Topic is solved

30 Dec 2019, 16:27

i solved it myself here is what i did

Code: Select all

Restore:
	SoundPlay,  %TimerSound%
	FileRead, Clipboard, *c Setup/Settings/Temp.clip
	SetTimer, Restore,  Off 
	return 
	
Setup_Restore_Clipboard()	{ 
	FileDelete,  Setup/Settings/Temp.clip
	FileAppend, %ClipboardAll% , Setup/Settings/Temp.clip
	SetTimer, Restore, %ClipboardTimer% 
	}
Setup_Restore_Clipboard() ; i just call this from my other code

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark and 109 guests