Jump to content
Macro Express Forums

How To Change The Focus Within A Program


burt

Recommended Posts

Hi,

 

I use a program with a layout of 3 childwindows docked in a main window.

Now I want to set the focus into a certain child window with a shortkey.

 

 

What I did:

 

Get Control %C1% (SOR - debit: AfxFrameOrView58s)
Set Focus to %C1%

 

It works, but only if I use "get control text" option.

 

But the problem is that the mentioned window is named "SOR - debit" now but when another document is opened it is named "SOR - credit" or else.

 

So I tried to change the "Top Level Window Caption" into "SOR" and checked "Partial Title"

 

Now it doesn't work anymore.

 

Isn't it possible to just set the name of the window (AfxFrameOrView58s) and use that for setting the focus?

 

 

Bye, Burt

Link to comment
Share on other sites

If you can predict what the title of the control will be, or if you can get the window title, you may be able to use the Variable Set Control command to change the text Control:

Variable Set Control Text %C1% to "SOR - debit: AfxFrameOrView58s"
//                        or
Variable Set Control Text %C1% to "SOR - credit: AfxFrameOrView58s"

 

Have you tried to get the Window title using the "Variable Set String %T1% from Window Title" command? It may be able to get the name of a docked Window if that window has focus.

 

For some macros I have used several Get Control commands to get several different controls (C1, C2, C3, etc.) and then used several "If Control" macro commands to determine which control is active.

 

And finally, you may have some success with the "Capture Control" command. If you can calculate specific coordinates you can use the 'Beneath Mouse' or 'Specific Coordinates' options. Or, you may be able to use the 'Control Focused' to get the control that currently has focus.

Link to comment
Share on other sites

Hello!

 

Not all controls that seem like controls can be captured. It strictly depends on how the application was written and what the designers had in mind. In your application you indicate that you can capture the three daughter windows as individual controls? Or are you referring to the container window itself?

 

Test if each of the daughter windows can actually be captured as a control. Capture each one to a separate control variable and see if you can set focus to them individually.

 

The Modify Top-Level Title of Control command is used in those situations where a certain control can be found in more than one window. You capture the control one time in one of the windows, and then use the command to change which window it is "in" as needed.

Link to comment
Share on other sites

Probably I'm just not experienced enough to make it work.

 

The capture tool seems to outline the needed frame successful within the program.

 

The frame/window I want to set the focus to belongs to a "tab". When I click on another tab next to it, the name of the frame is still AfxFrameOrView58s, but it has a parent with another name (name of the tab). Maybe that causes the problem.

 

So I thought just to set the focus to "AfxFrameOrView58s" without using the (parent) tab name. But it doesn't work yet.

What works is get the control name for each tab and make a long macro with "if/end if". But then I have to change the macro each time a new tab is added.

 

Thanks for the replys,

Burt

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...