I'm trying to write a macro that ammends data within an application we use which involves accurately switching between different windows in this application and that's where I have a problem that I can't figure out a solution for.
There is one window that we constantly have to go in and out of which is called the Table of Contents editor which consists of 4 different tabs. However no matter what tab you select the title of the window remains the same.
This is the window in question:
In this screen grab everything is as I want it to be, the window has focus and the heading (page 45 in this exampel) is highlighted in blue.
Sometimes however when Macro Scheduler sets focus on this window, it looks like this:
What's happened here is that focus is actually on the Pages tab itself (see the outline around the word pages).
This is causing me a lot of problems because the next thing to do is to rename that page by pressing F2. If the page is correctly highlighted as per the first screen grab I only need to press F2. However if it's like the 2nd screen grab then I need to press Tab and then press F2.
Is there a way I can either detect the colour of the highlighted area and if it's not blue then to press Tab first or to simply make sure that when focus is set on the window its set on the contents of the tab rather than the tab itself?
Just in case this has any impact on what solutions I could use the contents of this window will change, the highlighted section will change each time the macro is run (the macro will be set to loop), I'd rather not use x,y co-ordinates to simply perform a left click in the box because this window could be anywhere on the screen and the amount of text shown in that window will vary and affect where on the screen you could click.
Hope that makes sense!
SetFocus problem
Moderators: Dorian (MJT support), JRL
Re: SetFocus problem
Hi RNIB,
Use the Image Capture Tool in MS to capture an image of that Page tab including the dashed lines around it. Those dashed lines indicate it has focus.
Use the FindImagePos> command to look for that needle image in the screen.
- if you find it, the Page tab has focus, send Tab then F2
- if you don't find it, the Page tab does not have focus, send only F2
Just a thought... let us know how it works for you.
If there will only ever be one of these windows on the screen at any one time, then you could make use of image recognition.RNIB wrote:If the page is correctly highlighted as per the first screen grab I only need to press F2. However if it's like the 2nd screen grab then I need to press Tab and then press F2.
Use the Image Capture Tool in MS to capture an image of that Page tab including the dashed lines around it. Those dashed lines indicate it has focus.
Use the FindImagePos> command to look for that needle image in the screen.
- if you find it, the Page tab has focus, send Tab then F2
- if you don't find it, the Page tab does not have focus, send only F2
Just a thought... let us know how it works for you.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -