Debug Script That Uses Active Window

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
KenHadley
Junior Coder
Posts: 28
Joined: Thu Jul 14, 2011 5:02 pm

Debug Script That Uses Active Window

Post by KenHadley » Thu Oct 08, 2015 5:13 pm

How does one debug a script that uses GetActiveWindow? If I insert modal messages into the code below, and then run the script outside the debugger, it works fine. (I.e., num_matches = 1) I love the debugging tool, but it obviously thinks the MS Editor is the active window and so will not correctly run the script. (I.e., it shows num_mathces =0). Is there a switch somewhere or a workaround, so that the debugger does not view itself as the active window?

Code: Select all

Let>IGNORESPACES=1
Let>WIN_REGEX=1
GetActiveWindow>strTitle,nXPos,nYPos,,
Let>pattern=\A.*Transaction.*\z
RegEx>pattern,0,strTitle,matches,num_matches,0


Thank you.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Debug Script That Uses Active Window

Post by JRL » Thu Oct 08, 2015 8:55 pm

One way would be:
Move the editor over so you can see the window, set up a mouse move and mouse click to pick the window, then use a **BREAKPOINT** and F9 rather than F8 to step through a small portion of the script. All of your values will show in the Watch List.

Code: Select all

//Pressing F8 as usual

Let>IGNORESPACES=1
Let>WIN_REGEX=1

//Press F9 here

MouseMove>100,100
Lclick
Wait>1

GetActiveWindow>strTitle,nXPos,nYPos,,

**BREAKPOINT**

//Pressing F8 again

Let>pattern=\A.*Transaction.*\z
RegEx>pattern,0,strTitle,matches,num_matches,0

KenHadley
Junior Coder
Posts: 28
Joined: Thu Jul 14, 2011 5:02 pm

Re: Debug Script That Uses Active Window

Post by KenHadley » Thu Oct 08, 2015 11:33 pm

Thank you, JRL. That's great. I couldn't figure out a way to see the Watch List when using Modal Messages, so your solution is perfect.

Ken

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: Debug Script That Uses Active Window

Post by armsys » Fri Oct 09, 2015 12:59 am

Is there a way/solution to dump the entire watch (a snapshot) list to a text file?

KenHadley
Junior Coder
Posts: 28
Joined: Thu Jul 14, 2011 5:02 pm

Re: Debug Script That Uses Active Window

Post by KenHadley » Sun Oct 11, 2015 6:02 pm

armsys,

Great question. I would like to know that as well.

Ken

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Debug Script That Uses Active Window

Post by hagchr » Sun Oct 11, 2015 7:02 pm

If you use logging and use Let>_DUMP_VARS=1 then the variables will be dumped to your log file at that time (it seems).

KenHadley
Junior Coder
Posts: 28
Joined: Thu Jul 14, 2011 5:02 pm

Re: Debug Script That Uses Active Window

Post by KenHadley » Mon Oct 12, 2015 10:17 pm

Great! I'll give it a try. Thank you.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: Debug Script That Uses Active Window

Post by armsys » Mon Oct 12, 2015 11:25 pm

Hi hagchr,
Thanks for your time-saving tip.

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