How to Setfocus to a Help File

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

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

How to Setfocus to a Help File

Post by armsys » Thu Oct 22, 2015 8:18 am

How to setfocus to a help file such as MSCHED.chm?
The following code won't work.

Code: Select all

SetFocus>Macro Scheduler

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

Re: How to Setfocus to a Help File

Post by armsys » Thu Oct 22, 2015 8:28 am

Almost all help files available in the universe are suffixed with "Help".

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

Re: How to Setfocus to a Help File

Post by Marcus Tettmar » Thu Oct 22, 2015 11:00 am

That probably doesn't work because it's matching some other window - the main Macro Scheduler application window perhaps.

Try telling it to focus only visible windows:

Let>WF_TYPE=2
SetFocus>Macro Scheduler

Or after launching the help file from your script, use GetActiveWindow with use handles enabled so you get the handle of it. Once you have the handle you can use that.

Got to ask - what earthly reason do you have for making a macro focus the Macro Scheduler help window. Or is this just a made up example?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Re: How to Setfocus to a Help File

Post by armsys » Thu Oct 22, 2015 11:57 am

Hi Marcus,
Of course I have tried WF_TYPE=2, handles, regex, GetActiveWindow, EditIniFile,....etc, whatever you could remotely imagine. None works.
Would you please suffix the Help's window title with one magic word "Help", namely, "Macro Scheduler Help"?
Thank you.
Marcus Tettmar wrote:Got to ask - what earthly reason do you have for making a macro focus the Macro Scheduler help window. Or is this just a made up example?
I have a genuine need to open multiple help files such as RegexBuddy and EditPad for cross-reference. Except Macro Scheduler, ALL other help files can be setfocused with any glitch.

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

Re: How to Setfocus to a Help File

Post by Marcus Tettmar » Thu Oct 22, 2015 2:29 pm

Seems to work fine for me:

Code: Select all

ExecuteFile>msched.chm
Let>WF_TYPE=2
WaitWindowOpen>Macro Scheduler
MessageModal>test
SetFocus>Macro Scheduler
The message modal is to ensure focus is stolen. After I click OK the help window gets focused. So I know it works.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Re: How to Setfocus to a Help File

Post by Marcus Tettmar » Thu Oct 22, 2015 2:38 pm

Or this more technical method:

Code: Select all

ExecuteFile>msched.chm

Let>msched_help_handle=0
Label>wait_help_window
Let>WIN_USEHANDLE=1
GetWindowList>all_windows
Separate>all_windows,CRLF,handle_list
Let>k=0
Repeat>k
  Let>k=k+1
  Let>this_handle=handle_list_%k%
  GetWindowNames>this_handle,theTitle,theClass
  If>theTitle=Macro Scheduler
    If>theClass=HH Parent
        //this is the help window
        Let>msched_help_handle=this_handle
    ENdif
  Endif
Until>k=handle_list_count
If>msched_help_handle=0
  Goto>wait_help_window
Endif

//we now have the handle of the msched help window
MessageModal>test
Wait>2
SetFocus>msched_help_handle
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Re: How to Setfocus to a Help File

Post by armsys » Thu Oct 22, 2015 10:32 pm

Marcus Tettmar wrote:Or this more technical method:...
Hi Marcus,
Thank you for quick reply.
Thank you for taking time to write a robust, thorough, meticulous code for displaying msched.chm.
Your code ALWAYS works perfectly.
The core deficiency of all my previous attempts rests on my unknowing of the window class.
Embarrassingly, I forgot two critically important commands, namely, GetWindowList and GetWindowName.
Thank you again.
Please comment/critique my code based on yours for further optimization and improvement.

Code: Select all

ExecuteFile>C:\Program Files (x86)\Macro Scheduler 14\MSCHED.chm
Let>msched_help_handle=0
Label>wait_help_window
Let>WIN_USEHANDLE=1
GetWindowList>All_Windows
Separate>All_Windows,CRLF,Handle_List
Let>k=0
Repeat>k
  Let>k=k+1
  Let>TEMP_handle=Handle_List_%k%
  GetWindowNames>TEMP_handle,theTitle,theClass
  If>{(%theTitle%="Macro Scheduler") AND (%theClass%="HH Parent")}
    // Found the desired help window
    Let>msched_help_handle=TEMP_handle
  Endif
Until>k=Handle_List_count

If>msched_help_handle=0
  WaitProcessExists>hh.exe
  Goto>wait_help_window
Endif

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

Re: How to Setfocus to a Help File

Post by armsys » Thu Oct 22, 2015 11:32 pm

Hi Marcus,
Your previous post questioned my application of opening the msched.chm
Actually I program one of my mouse buttons to instantly pop up Macro Scheduler bible (aka msched.chm) on demand.
Again, thank you for your big help.

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