Action "Windows Watcher" does not close all Outlook windows

Discuss RoboTask here
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Action "Windows Watcher" does not close all Outlook windows

Post by jan »

Good morning everyone and a good start to the new week,


In order for a certain robot task to work for me, I have to check if MS Office windows are displayed and then always confirm them. These windows ultimately allow a piece of software to access MS Outlook. Since there can be more than one window, I try to do this with a loop. I manage to confirm access for one window, but the second window is not automatically processed.

It would be sufficient to run this task 6 minutes after Windows starts.


Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task6"
Hide=INTEGER|0
ID=INTEGER|-873706518
LogOnAsUser=INTEGER|1
Name=STRING|"Process Window of MS Office"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
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

[Actions\Action1]
ActionID=STRING|"A_LOOP_WINDOW"
Enabled=INTEGER|-1
Name=STRING|"Window Loop"
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"MSHandle,MSName"
caption=STRING|"1"
captionexact=STRING|"1"
captionfilter=STRING|"1"
captionvalue=STRING|"Microsoft Outlook"
captionvariable=STRING|"MSName"
class=STRING|"0"
classexact=STRING|"1"
classfilter=STRING|"1"
classvalue=STRING|"#32770"
handlevariable=STRING|"MSHandle"
showchild=STRING|"0"
showhidden=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_WINDOW_COMMAND"
Enabled=INTEGER|-1
Name=STRING|"Focus window ""Microsoft Outlook"""
Params=FOLDER

[Actions\Action2\Params]
action=STRING|"0"
caption=STRING|"1"
child=STRING|"0"
class=STRING|"1"
classexact=STRING|"0"
exact=STRING|"1"
findmode=STRING|"0"
hidden=STRING|"0"
processall=STRING|"1"
wincaption=STRING|"Microsoft Outlook"
winclass=STRING|"#32770"

[Actions\Action3]
ActionID=STRING|"A_MOUSE_MOVETO"
Enabled=INTEGER|-1
Name=STRING|"Move Mouse To An Object"
Params=FOLDER

[Actions\Action3\Params]
bottom=STRING|"173"
controlclass=STRING|"Button"
controltext=STRING|"Erteilen"
ctrlclassexact=STRING|"1"
ctrltextexact=STRING|"1"
left=STRING|"55"
right=STRING|"131"
top=STRING|"150"
winclassexact=STRING|"1"
windowclass=STRING|"#32770"
windowtext=STRING|"Microsoft Outlook"
wintextexact=STRING|"1"
x=STRING|"44"
y=STRING|"11"

[Actions\Action4]
ActionID=STRING|"A_MOUSE_CLICK"
Enabled=INTEGER|-1
Name=STRING|"Click left button"
Params=FOLDER

[Actions\Action4\Params]
action=STRING|"0"
button=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Last edited by jan on Wed Jan 29, 2025 2:05 pm, edited 4 times in total.
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Processing MS Office windows

Post by Oleg »

... but the second window is not automatically processed.
Maye you have some error/warning messages?

Also I made some corrections in your task.
1. Use window handle. The loop can obtain window handle. It is an ID of window, so you don't need to find window again by caption and class
2. I put the pause between steps 300 ms, because you want to use interactive actions. Look at the Task editor->Settings tab->Pause between steps parameter
The pause is necessary to give the app time to react to your actions.

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
ExternalName=STRING|"Task1565"
Hide=INTEGER|0
ID=INTEGER|1059341744
LogOnAsUser=INTEGER|1
Name=STRING|"Process Window of MS Office (corrected)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|300
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

[Actions\Action1]
ActionID=STRING|"A_LOOP_WINDOW"
Enabled=INTEGER|-1
Name=STRING|"Window Loop"
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"MSHandle"
caption=STRING|"0"
captionexact=STRING|"1"
captionfilter=STRING|"1"
captionvalue=STRING|"Microsoft Outlook"
captionvariable=STRING|"MSName"
class=STRING|"0"
classexact=STRING|"1"
classfilter=STRING|"1"
classvalue=STRING|"#32770"
handlevariable=STRING|"MSHandle"
showchild=STRING|"0"
showhidden=STRING|"0"

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

[Actions\Action2\Params]
action=STRING|"0"
caption=STRING|"1"
child=STRING|"0"
class=STRING|"1"
classexact=STRING|"0"
exact=STRING|"1"
findmode=STRING|"1"
handle=STRING|"{MSHandle}"
hidden=STRING|"0"
processall=STRING|"1"
wincaption=STRING|"Microsoft Outlook"
winclass=STRING|"#32770"

[Actions\Action3]
ActionID=STRING|"A_MOUSE_MOVETO"
Enabled=INTEGER|-1
Name=STRING|"Move Mouse To An Object"
Params=FOLDER

[Actions\Action3\Params]
bottom=STRING|"173"
controlclass=STRING|"Button"
controltext=STRING|"Erteilen"
ctrlclassexact=STRING|"1"
ctrltextexact=STRING|"1"
left=STRING|"55"
right=STRING|"131"
top=STRING|"150"
winclassexact=STRING|"1"
windowclass=STRING|"#32770"
windowtext=STRING|"Microsoft Outlook"
wintextexact=STRING|"1"
x=STRING|"44"
y=STRING|"11"

[Actions\Action4]
ActionID=STRING|"A_MOUSE_CLICK"
Enabled=INTEGER|-1
Name=STRING|"Click left button"
Params=FOLDER

[Actions\Action4\Params]
action=STRING|"0"
button=STRING|"0"

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

Oleg Yershov
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Processing MS Office windows

Post by Oleg »

I don't know your goal, but maybe it's better to send ENTER key to active window instead of Move to object and Mouse click
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Processing MS Office windows

Post by jan »

Hello Oleg,

Thank you very much for your super-fast reply. I am attaching a picture of the window. "Grant" (in German "Erteilen") must be clicked in the window. Nothing else.

One question: Is it possible to monitor when the window appears or whether the window exists? If so, there would be no need to wait 6 minutes, but the window could be processed immediately after it appears.

Best regards from Munich
Ján
Attachments
MSOffice-Window.PNG
MSOffice-Window.PNG (11.5 KiB) Viewed 14448 times
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Processing MS Office windows

Post by Oleg »

I am attaching a picture of the window.
Maybe to send two keys to current window: LEFT ARROW and ENTER. Try this.
Is it possible to monitor when the window appears or whether the window exists?
Look at the Window Watcher trigger
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Processing MS Office windows

Post by jan »

Hello Oleg,

Thank you very much, I'm testing it. But it's not working yet.

Ján
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Processing MS Office windows

Post by Oleg »

But it's not working yet
Why? Can you do it manually?
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Processing MS Office windows

Post by jan »

Hello Oleg,

I had to put a trigger "Cyclic" (in this case 10 seconds) before the "Windows Watcher" so that all windows are processed. Unfortunately, after all windows have been processed, the trigger is useless and consumes resources. Is there another way to do this?

Best regards, Ján

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|1
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task2"
Hide=INTEGER|0
ID=INTEGER|-1438924388
LogOnAsUser=INTEGER|1
Name=STRING|"Allow ""Automatic Email Processor"" to access Outlook  (imported)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|1
StepPause=INTEGER|500
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_WINDOW"
Enabled=INTEGER|-1
Name=STRING|"Window Loop"
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"MSHandle"
caption=STRING|"0"
captionexact=STRING|"1"
captionfilter=STRING|"1"
captionvalue=STRING|"Microsoft Outlook"
captionvariable=STRING|"MSName"
class=STRING|"0"
classexact=STRING|"1"
classfilter=STRING|"1"
classvalue=STRING|"#32770"
handlevariable=STRING|"MSHandle"
showchild=STRING|"1"
showhidden=STRING|"1"

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

[Actions\Action2\Params]
action=STRING|"0"
caption=STRING|"1"
child=STRING|"0"
class=STRING|"1"
classexact=STRING|"0"
exact=STRING|"1"
findmode=STRING|"1"
handle=STRING|"{MSHandle}"
hidden=STRING|"0"
processall=STRING|"1"
wincaption=STRING|"Microsoft Outlook"
winclass=STRING|"#32770"

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

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

[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Events]
Event1=FOLDER
Event2=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_CYCLIC"
Name=STRING|"Cyclic (every 10 sec)"
Params=FOLDER
UniqueID=INTEGER|-1949175563

[Events\Event1\Params]
interval=STRING|"10"
notsatrtatactivation=STRING|"0"

[Events\Event2]
Enabled=INTEGER|-1
EventID=STRING|"E_WINDOW_WATCHER"
Name=STRING|"Window Watcher (Microsoft Outlook)"
Params=FOLDER
UniqueID=INTEGER|-1764923589

[Events\Event2\Params]
assignvariable=STRING|"0"
child=STRING|"1"
classexact=STRING|"1"
exact=STRING|"1"
hidden=STRING|"1"
usecaption=STRING|"1"
useclass=STRING|"1"
useparameter=STRING|"0"
watchfor=STRING|"1"
wincaption=STRING|"Microsoft Outlook"
winclass=STRING|"#32770"
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Processing MS Office windows

Post by Oleg »

Unfortunately, after all windows have been processed, the trigger is useless and consumes resources.
you can remove Window Watcher trigger from your task
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Processing MS Office windows

Post by jan »

Good morning Oleg,

I don't understand your recommendation. You recommend me to remove the trigger "Window Watcher" from the task, so that only the trigger "cyclic" is included in the task.

What I wanted to say with yesterday's post is, that processing the Outlook-windows works, but the trigger "cyclic" (here every 10 seconds), after it has fulfilled its task (which is about 30 seconds after Windows startup) is of no use anymore and unnecessarily costs computer resources. I therefore asked for a different solution and how often the "Windows Watcher" trigger checks whether a window is present.

Can you help me again? Many greetings wherever you are at home.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|1
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task2"
Hide=INTEGER|0
ID=INTEGER|-1438924388
LogOnAsUser=INTEGER|1
Name=STRING|"Allow ""Automatic Email Processor"" to access Outlook (10 s)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|1
StepPause=INTEGER|500
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_WINDOW"
Enabled=INTEGER|-1
Name=STRING|"Window Loop"
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"MSHandle"
caption=STRING|"0"
captionexact=STRING|"1"
captionfilter=STRING|"1"
captionvalue=STRING|"Microsoft Outlook"
captionvariable=STRING|"MSName"
class=STRING|"0"
classexact=STRING|"1"
classfilter=STRING|"1"
classvalue=STRING|"#32770"
handlevariable=STRING|"MSHandle"
showchild=STRING|"1"
showhidden=STRING|"1"

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

[Actions\Action2\Params]
action=STRING|"0"
caption=STRING|"1"
child=STRING|"0"
class=STRING|"1"
classexact=STRING|"0"
exact=STRING|"1"
findmode=STRING|"1"
handle=STRING|"{MSHandle}"
hidden=STRING|"0"
processall=STRING|"1"
wincaption=STRING|"Microsoft Outlook"
winclass=STRING|"#32770"

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

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

[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Events]
Event1=FOLDER
Event2=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_CYCLIC"
Name=STRING|"Cyclic (every 10 sec)"
Params=FOLDER
UniqueID=INTEGER|-1949175563

[Events\Event1\Params]
interval=STRING|"10"
notsatrtatactivation=STRING|"0"

[Events\Event2]
Enabled=INTEGER|-1
EventID=STRING|"E_WINDOW_WATCHER"
Name=STRING|"Window Watcher (Microsoft Outlook)"
Params=FOLDER
UniqueID=INTEGER|-1764923589

[Events\Event2\Params]
assignvariable=STRING|"0"
child=STRING|"1"
classexact=STRING|"1"
exact=STRING|"1"
hidden=STRING|"1"
usecaption=STRING|"1"
useclass=STRING|"1"
useparameter=STRING|"0"
watchfor=STRING|"1"
wincaption=STRING|"Microsoft Outlook"
winclass=STRING|"#32770"
Post Reply