Hello. I am quite new to robotask and I find it very
accurate.
In order to save me same time can you please advise how a
single key can send different keystrokes according to active window/program.
For example I want the ` key to send keystrokes ^({F4}) (CTRL+F4)
when the active window is Mozilla Firefox and the same ` key to send keystrokes
%({F4}) (ALt+F4) when the active window is Internet Explorer.
Program Specific Hot Keys
Program Specific Hot Keys
Last edited by Active on Sat Oct 29, 2005 8:49 am, edited 1 time in total.
Program Specific Hot Keys
See task below. Don't forget to enable the task after importing.
By the way: what do Ctrl-F4 key in Mozilla? I think that you want to close window of browser. Therefore Alt-F4 is valid for Mozilla too.
;**********************
;* RoboTask Task file *
;* Do not edit! *
;**********************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2013454187
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task172"
Hide=INTEGER|0
ID=INTEGER|1396778969
Name=STRING|"IE or Mozilla"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
[Actions\Action1]
ActionID=STRING|"A_WINDOW_CHECK"
Enabled=INTEGER|-1
Name=STRING|"Check for Window"
Params=FOLDER
[Actions\Action1\Params]
abortif=STRING|"0"
action=STRING|"1"
checkfor=STRING|"1"
exact=STRING|"0"
variable=STRING|"IE_ACTIVE"
wincaption=STRING|"- Microsoft Internet Explorer"
[Actions\Action2]
ActionID=STRING|"A_WINDOW_CHECK"
Enabled=INTEGER|-1
Name=STRING|"Check for Window"
Params=FOLDER
[Actions\Action2\Params]
abortif=STRING|"0"
action=STRING|"1"
checkfor=STRING|"1"
exact=STRING|"0"
variable=STRING|"mozilla_ACTIVE"
wincaption=STRING|"- Mozilla Firefox"
[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action3\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{ie_active}"
[Actions\Action4]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Send keys to active window"
Params=FOLDER
[Actions\Action4\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"1"
keylayout=STRING|"0"
keys=STRING|"%({F4})"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"
[Actions\Action5]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action6]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action6\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{mozilla_active}"
[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|"1"
keylayout=STRING|"0"
keys=STRING|"^({F4})"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"
[Actions\Action8]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Events]
Event1=FOLDER
[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_HOTKEY"
Params=FOLDER
[Events\Event1\Params]
hotkey=STRING|"192"
By the way: what do Ctrl-F4 key in Mozilla? I think that you want to close window of browser. Therefore Alt-F4 is valid for Mozilla too.
;**********************
;* RoboTask Task file *
;* Do not edit! *
;**********************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2013454187
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task172"
Hide=INTEGER|0
ID=INTEGER|1396778969
Name=STRING|"IE or Mozilla"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
[Actions\Action1]
ActionID=STRING|"A_WINDOW_CHECK"
Enabled=INTEGER|-1
Name=STRING|"Check for Window"
Params=FOLDER
[Actions\Action1\Params]
abortif=STRING|"0"
action=STRING|"1"
checkfor=STRING|"1"
exact=STRING|"0"
variable=STRING|"IE_ACTIVE"
wincaption=STRING|"- Microsoft Internet Explorer"
[Actions\Action2]
ActionID=STRING|"A_WINDOW_CHECK"
Enabled=INTEGER|-1
Name=STRING|"Check for Window"
Params=FOLDER
[Actions\Action2\Params]
abortif=STRING|"0"
action=STRING|"1"
checkfor=STRING|"1"
exact=STRING|"0"
variable=STRING|"mozilla_ACTIVE"
wincaption=STRING|"- Mozilla Firefox"
[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action3\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{ie_active}"
[Actions\Action4]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Send keys to active window"
Params=FOLDER
[Actions\Action4\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"1"
keylayout=STRING|"0"
keys=STRING|"%({F4})"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"
[Actions\Action5]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action6]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action6\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{mozilla_active}"
[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|"1"
keylayout=STRING|"0"
keys=STRING|"^({F4})"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"
[Actions\Action8]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Events]
Event1=FOLDER
[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_HOTKEY"
Params=FOLDER
[Events\Event1\Params]
hotkey=STRING|"192"
Program Specific Hot Keys
Oleg wrote:By the way: what do Ctrl-F4 key in Mozilla? I think
that you want to close window of browser. Therefore Alt-F4 is valid for
Mozilla too.
Thanks a lot for your reply.
The CTRL+F4 is closing the present tab in Firefox and I just
want to assign different uses of the certain key.
The script you appended is working as wished.
Is there a form to work on it if I want to repeat this
process with other programs/hotkeys?
I mean, for example, use F2 to send keystrokes with my name when
MS Word is active, but when my antivirus is active I want to use F2 to update
it.
Can I use a form, in order same hotkeys have different
actions depending of the active window?
Thanks
Program Specific Hot Keys
You can write another task like this example, and use hot key F2 in triggering event. But remember that RoboTask intercept a hot key, and application don't receive this key combination. I think that better to do so:
if MsWord is active then
send My Name
else
if Antivirus is active then
send Key combination to update
else
send F2 // sending Hot Key if another application
end if
end if
if MsWord is active then
send My Name
else
if Antivirus is active then
send Key combination to update
else
send F2 // sending Hot Key if another application
end if
end if