Assign test back to clipboard?

Discuss RoboTask here

Assign test back to clipboard?

Postby kunkel321 » Sun Apr 12, 2020 1:40 am

It looks like I can assign the text contents to a variable by way of Set Variable OldClipBrd with {ClipBoardContent}.
But then later can I put that text back on the clipboard?
I tried it like in the img, but it didn't seem to work.

Image
kunkel321
 
Posts: 30
Joined: Sun Mar 15, 2020 5:23 pm

Re: Assign test back to clipboard?

Postby Oleg » Sun Apr 12, 2020 7:15 am

All system variables are read-only. So you can read the value but can not write new value.
In other words, system variables are some functions that return a value upon request.

To set new clipboard content use Put Text action
Oleg Yershov
Oleg
Site Admin
 
Posts: 2586
Joined: Thu Jan 01, 1970 1:00 am

Re: Assign test back to clipboard?

Postby kunkel321 » Sun Apr 12, 2020 11:55 pm

Oleg wrote:To set new clipboard content use Put Text action


That makes sense. Thanks Oleg. Hey can you (or somebody) please test this script? I think I might not be using Put Text correctly(?)

Assign a hotkey for a trigger. Then before running the Task, makes sure some original text is on your Windows clipboard. Then select a different second string of text, and activate the script. It should show three dialogs:

1. The original clipboard text,
2. Then the different second string,
3. Then the original clipboard text again.

Steps 1 and 2 work as expected, but step three is showing {myVar} again.

Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|327331060
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task3"
Hide=INTEGER|0
ID=INTEGER|2005690827
LogOnAsUser=INTEGER|1
Name=STRING|"Clipboard Tester"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Stuff first on clipboard: {ClipBoardContent}"""
Params=FOLDER

[Actions\Action1\Params]
icon=STRING|"1"
msg0=STRING|"Stuff first on clipboard: {ClipBoardContent}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""OLDCLIPBRD"" with value ""{ClipBoardContent}"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"OLDCLIPBRD"
varvalue=STRING|"{ClipBoardContent}"

[Actions\Action3]
ActionID=STRING|"A_CLIPBOARD_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy"
Params=FOLDER

[Actions\Action3\Params]
mode=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_CLIPBOARD_GET"
Enabled=INTEGER|-1
Name=STRING|"Get Text"
Params=FOLDER

[Actions\Action4\Params]
variable=STRING|"MyVar"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Stuff just copied to clipboard: {MyVar}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"Stuff just copied to clipboard: {MyVar}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_CLIPBOARD_PUT"
Enabled=INTEGER|-1
Name=STRING|"Put OldClipBrd back on Clipboard"
Params=FOLDER

[Actions\Action6\Params]
line0=STRING|"{OLDCLIPBRD}"
linecount=STRING|"1"
sourcetext=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Original stuff on clipboard? {ClipBoardContent}"""
Params=FOLDER

[Actions\Action7\Params]
icon=STRING|"1"
msg0=STRING|"Original stuff on clipboard? {ClipBoardContent}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_HOTKEY"
Name=STRING|"Shift+Ctrl+Alt+T"
Params=FOLDER
UniqueID=INTEGER|-581013023

[Events\Event1\Params]
hotkey=STRING|"57428"

kunkel321
 
Posts: 30
Joined: Sun Mar 15, 2020 5:23 pm

Re: Assign test back to clipboard?

Postby Oleg » Mon Apr 13, 2020 9:16 am

corrected task below.
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task216"
Hide=INTEGER|0
ID=INTEGER|2005690827
LogOnAsUser=INTEGER|1
Name=STRING|"Clipboard Tester (v2)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Stuff first on clipboard: {#ClipBoardContent}"""
Params=FOLDER

[Actions\Action1\Params]
icon=STRING|"1"
msg0=STRING|"Stuff first on clipboard: {#ClipBoardContent}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""OLDCLIPBRD"" with value ""{#ClipBoardContent}"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"1"
varname=STRING|"OLDCLIPBRD"
varvalue=STRING|"{#ClipBoardContent}"

[Actions\Action3]
ActionID=STRING|"A_CLIPBOARD_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy"
Params=FOLDER

[Actions\Action3\Params]
mode=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_CLIPBOARD_GET"
Enabled=INTEGER|-1
Name=STRING|"Get Text"
Params=FOLDER

[Actions\Action4\Params]
variable=STRING|"MyVar"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Stuff just copied to clipboard: {#MyVar}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"Stuff just copied to clipboard: {#MyVar}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_CLIPBOARD_PUT"
Enabled=INTEGER|-1
Name=STRING|"Put OldClipBrd back on Clipboard"
Params=FOLDER

[Actions\Action6\Params]
line0=STRING|"{#OLDCLIPBRD}"
linecount=STRING|"1"
sourcetext=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Original stuff on clipboard? {#ClipBoardContent}"""
Params=FOLDER

[Actions\Action7\Params]
icon=STRING|"1"
msg0=STRING|"Original stuff on clipboard? {#ClipBoardContent}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_HOTKEY"
Name=STRING|"Shift+Ctrl+Alt+T"
Params=FOLDER
UniqueID=INTEGER|1972981168

[Events\Event1\Params]
hotkey=STRING|"57428"


  1. Look at the step #2.
    You should turn on Expand Variable now option
  2. Look at the steps #1, #2, #5, #6, #7
    You should use # symbol before variable name. This is necessary to limit the depth of expanding variable. >>Read here please about this<<
    The problem is that the variable contains the text with other variables it can break the original text.
    Pay attention that step#4 copies to clipboard the text of current task. The task contains variable OLDCLIPBRD which already contains some other text. This text can contain variables too, and so on
Oleg Yershov
Oleg
Site Admin
 
Posts: 2586
Joined: Thu Jan 01, 1970 1:00 am

Re: Assign test back to clipboard?

Postby kunkel321 » Fri Jul 24, 2020 9:44 pm

Thanks for this by the way Oleg -- I'm only now having time to work on my project again. :D
kunkel321
 
Posts: 30
Joined: Sun Mar 15, 2020 5:23 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 26 guests