Send to previous active window

Discuss RoboTask here
Post Reply
fablefox
Posts: 5
Joined: Tue Jun 20, 2023 5:24 am

Send to previous active window

Post by fablefox »

Hi,

Previously I use a software called Fast Paste. Currently I'm testing robotask trial to see if it fit my need. however, i have a simple question.

For Fast Paste, how I use it was:

1) click on notepad ( or any other app)
2) click on fast paste. click to run any command.

Fast Paste will send keys to notepad (or any other app)

But apparently this style doesn't work with Robotask, since selecting robotask will make robotask the current app and any keystroke will be sent to itself.

How do I do this in robotask? currently i'm testing by using part of string in app name, but this will be an issue if i have multiple of the same app open. for example i have putty1, putty2 and putty3 and i want to sent keystroke to only putty3.

is there a way to send keystroke to previously selected windows?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Send to previous active window

Post by Oleg »

Look at my example below.
Select input field, press CTRL+SHIFT+V, select text and press Enter key
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.
Do not forget to enable the task after importing.

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
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task1040"
Hide=INTEGER|0
ID=INTEGER|585691058
LogOnAsUser=INTEGER|1
Name=STRING|"Insert common texts"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=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_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""WIN"" with value ""{CurrentWindowHandle}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varkind=STRING|"1"
varname=STRING|"WIN"
varvalue=STRING|"{CurrentWindowHandle}"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_CHOICE"
Enabled=INTEGER|-1
Name=STRING|"Choice Dialog"
Params=FOLDER

[Actions\Action2\Params]
_rt_variables_produced=STRING|"TXT"
autochoice=STRING|"0"
mode=STRING|"1"
nearcursor=STRING|"1"
result=STRING|"0"
savemode=STRING|"1"
stopifcancel=STRING|"0"
textsource=STRING|"1"
timeout=STRING|"10"
title=STRING|"Choose the text"
txtcount=STRING|"3"
txtline00000000=STRING|"Item 1"
txtline00000001=STRING|"Item 2"
txtline00000002=STRING|"Item 3"
variable=STRING|"TXT"

[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action3\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{TXT}"
value2=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_FLOW_EXIT"
Enabled=INTEGER|-1
Name=STRING|"Exit"

[Actions\Action5]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action6]
ActionID=STRING|"A_WINDOW_COMMAND"
Enabled=INTEGER|-1
Name=STRING|"Focus window by handle"
Params=FOLDER

[Actions\Action6\Params]
action=STRING|"0"
caption=STRING|"1"
child=STRING|"0"
class=STRING|"0"
classexact=STRING|"0"
exact=STRING|"0"
findmode=STRING|"1"
handle=STRING|"{win}"
hidden=STRING|"0"
processall=STRING|"0"

[Actions\Action7]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Send keys to active window"
Params=FOLDER

[Actions\Action7\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"{TXT}"
pause=STRING|"20"
release=STRING|"1"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Events]
Event1=FOLDER

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

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

Oleg Yershov
fablefox
Posts: 5
Joined: Tue Jun 20, 2023 5:24 am

Re: Send to previous active window

Post by fablefox »

I think this didn't work because when run, CurrentWindowHandle gets Robotask own handle, which means it will set itself to focus and send keys to itself?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Send to previous active window

Post by Oleg »

I think this didn't work because when run, CurrentWindowHandle gets Robotask own handle, ...
CurrentWindowHandle gets the handle of active window. If you activate Notepad before you press Hot-Key then it gets the handle of Notepad window.
By the way this example is the copy of my task I use to put some standard phrases into edit field.
Oleg Yershov
fablefox
Posts: 5
Joined: Tue Jun 20, 2023 5:24 am

Re: Send to previous active window

Post by fablefox »

Thanks, it worked by using hotkey. But this doesn't fit my workflow. I'm starting a new post to ask a new technique.
Post Reply