GetActiveWindow in Citrix problem

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
dglancy
Newbie
Posts: 12
Joined: Mon Aug 09, 2004 4:39 pm

GetActiveWindow in Citrix problem

Post by dglancy » Wed Mar 28, 2007 4:37 pm

I am running MS ver. 9.0.053 in citrix. GetActiveWindow seems to be inconsistent in returning the full window title. I am running the GAW command in a loop looking for a new window to appear.

here is the end of the log file:
3/27/2007 14:54:24:338 - mousemove>144,562
3/27/2007 14:54:24:369 - lclick
3/27/2007 14:54:24:416 - GetActiveWindow>active,x1,y1
3/27/2007 14:54:24:447 - press menukey
3/27/2007 14:54:24:979 - wait>0.5
3/27/2007 14:54:25:119 - send>o
3/27/2007 14:54:25:666 - wait>0.5
3/27/2007 14:54:25:822 - send>o
3/27/2007 14:54:25:869 - srt>test_for_new_screen
3/27/2007 14:54:25:901 - label>look_again
3/27/2007 14:54:25:947 - GetActiveWindow>active_1,x1,y1,,
3/27/2007 14:54:25:994 - if>Procedures and Safety 2009 - General Information=Procedures and Safety 2009 - General Information
3/27/2007 14:54:28:025 - wait>2
3/27/2007 14:54:28:072 - label>look_again
3/27/2007 14:54:28:166 - GetActiveWindow>active_1,x1,y1,,
3/27/2007 14:54:28:213 - endif
3/27/2007 14:54:28:260 - endif
3/27/2007 14:54:30:557 - 'messagemodal>new screen is Microsoft Excel
3/27/2007 14:57:50:937 - setfocus>Microsoft Excel
3/27/2007 14:57:50:968 - Finished Macro : Print_MWO_main_rev03

Setfocus fails because the actual window title is
Microsoft Excel - Worksheet in Procedures and Safety 2009

any thoughts?

Dennis

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 28, 2007 4:50 pm

Use:

SetFocus>Microsoft Excel -*
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

dglancy
Newbie
Posts: 12
Joined: Mon Aug 09, 2004 4:39 pm

Post by dglancy » Wed Mar 28, 2007 5:03 pm

Sorry, I did not explain this very well. I am using the GAW command to account for different windows that may open, excel, word, etc...

Setfocus>active_1 is the command line that at times has the full window title and at other times has a partial window title.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 28, 2007 5:12 pm

According to your log file active_1 can only ever have a full window title.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

dglancy
Newbie
Posts: 12
Joined: Mon Aug 09, 2004 4:39 pm

Post by dglancy » Wed Mar 28, 2007 5:21 pm

that is what I thought also, but it doesn't always. I do have a jpeg of the screen when the setfocus command failed. Not sure where to store it for your access, if that would be of help.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 28, 2007 5:31 pm

GAW could at times be getting an invisible or minimized window. SetFocus will return an error if it fails saying window does not exist. Did you get this? Have you tried setting WF_TYPE?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

dglancy
Newbie
Posts: 12
Joined: Mon Aug 09, 2004 4:39 pm

Post by dglancy » Wed Mar 28, 2007 9:03 pm

Added in WF_TYPE=2

same problem. Here is the log file and script. Basically, just going through a list of records on screen, opening each record which can have different titles and looking to see if there is a new window open.

Notice that the last setfocus> command below appears to have a null value.

3/28/2007 15:50:21:786 - Started Macro : Print_MWO_main_rev04
3/28/2007 15:50:21:817 - let>SK_DELAY=100
3/28/2007 15:50:21:817 - GetScreenRes>xres,yres
3/28/2007 15:50:21:817 - Let>WF_TYPE=2
3/28/2007 15:50:21:832 - let>window=FBC Task Cab*
3/28/2007 15:50:21:832 - let>task_window=FBC Task Cab*
3/28/2007 15:50:21:832 - SRT>setup_window
3/28/2007 15:50:21:848 - setfocus>FBC Task Cab*
3/28/2007 15:50:22:348 - wait>0.5
3/28/2007 15:50:22:348 - movewindow>FBC Task Cab*,0,0
3/28/2007 15:50:22:848 - wait>0.5
3/28/2007 15:50:22:864 - resizewindow>FBC Task Cab*,600,600
3/28/2007 15:50:23:395 - wait>0.5
3/28/2007 15:50:23:426 - resizewindow>FBC Task Cab*,800,600
3/28/2007 15:50:23:926 - wait>0.5
3/28/2007 15:50:23:926 - END>setup_window
3/28/2007 15:50:23:926 - let>number_to_process=9
3/28/2007 15:50:23:926 - setfocus>FBC Task Cab*
3/28/2007 15:50:24:426 - wait>0.5
3/28/2007 15:50:24:426 - Press down
3/28/2007 15:50:24:426 - press up * 20
3/28/2007 15:50:24:426 - label>process_MWOs
3/28/2007 15:50:24:426 - GetActiveWindow>active,x1,y1,,
3/28/2007 15:50:24:441 - setfocus>FBC Task Cabinet - Work Tasks Created Date Range
3/28/2007 15:50:24:457 - press alt
3/28/2007 15:50:24:957 - wait>0.5
3/28/2007 15:50:25:066 - send>s
3/28/2007 15:50:25:566 - wait>0.5
3/28/2007 15:50:25:676 - send>o
3/28/2007 15:50:26:191 - wait>0.5
3/28/2007 15:50:26:316 - send>f
3/28/2007 15:50:26:816 - wait>0.5
3/28/2007 15:50:26:816 - release alt
3/28/2007 15:50:26:816 - srt>test_for_new_screen
3/28/2007 15:50:26:816 - label>look_again
3/28/2007 15:50:26:832 - GetActiveWindow>active_1,x1,y1,,
3/28/2007 15:50:26:832 - if>FBC Task Cabinet - Work Tasks Created Date Range=FBC Task Cabinet - Work Tasks Created Date Range
3/28/2007 15:50:28:832 - wait>2
3/28/2007 15:50:28:832 - label>look_again
3/28/2007 15:50:28:832 - GetActiveWindow>active_1,x1,y1,,
3/28/2007 15:50:28:832 - endif
3/28/2007 15:50:42:252 - setfocus>
3/28/2007 15:50:42:252 - Finished Macro : Print_MWO_main_rev04

let>SK_DELAY=100
GetScreenRes>xres,yres
Let>WF_TYPE=2
let>window=FBC Task Cab*
let>task_window=FBC Task Cab*
gosub>setup_window
let>number_to_process=9
setfocus>%task_window%
wait>0.5
Press down
press up * 20
label>process_MWOs
GetActiveWindow>active,x1,y1,,
setfocus>%active%
press alt
wait>0.5
send>s
wait>0.5
send>o
wait>0.5
send>f
wait>0.5
release alt
gosub>test_for_new_screen
GetActiveWindow>work_order_window,x,y,w,h
let>window=%work_order_window%
gosub>setup_window
CloseWindow>%work_order_window%
wait>1
'*******************subtract and do another MWO
sub>number_to_process,1
if>number_to_process=0,stop
endif>
setfocus>%task_window%
wait>1
press down * 3
setfocus>%task_window%
goto>process_MWOs
label>stop


SRT>setup_window
setfocus>%window%
wait>0.5
movewindow>%window%,0,0
wait>0.5
resizewindow>%window%,600,600
wait>0.5
resizewindow>%window%,800,600
wait>0.5
END>setup_window

srt>test_for_new_screen
label>look_again
GetActiveWindow>active_1,x1,y1,,
if>%active%=%active_1%
wait>2
goto>look_again
endif
setfocus>%active_1%
end>test_for_new_screen

dglancy
Newbie
Posts: 12
Joined: Mon Aug 09, 2004 4:39 pm

Post by dglancy » Wed Mar 28, 2007 9:36 pm

Another issue. I just noticed that the editor is not updating the script file on the server when I make changes, exit and do a file save. Although when I did a file >saveas with a new file name, the new file did have the edited changes.

Dennis

dglancy
Newbie
Posts: 12
Joined: Mon Aug 09, 2004 4:39 pm

Post by dglancy » Wed Mar 28, 2007 9:59 pm

this modification to the subroutine seems to work. I just test for a null value.

srt>test_for_new_screen
label>look_again
GetActiveWindow>active_1,x1,y1,,
if>%active%=%active_1%
wait>2
goto>look_again
endif
if>%active_1%=
wait>2
goto>look_again
endif
setfocus>%active_1%
end>test_for_new_screen

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts