Jump to content
Macro Express Forums

Maintaning Focus


alexmih
 Share

Recommended Posts

I have created a playable macro that is called in my trading charts. When a certain condition exists, the javaScrpt code shells out and runs the MXE file, and the trading chart window, which has just gained focus from whatever other window I was in, is minimized. The macro ends with the trading chart window minimized.

 

The problem is that the window I was working in (my trading windows all work by themselves and need not have focus to work), has now lost focus.

 

Can I write a macro that FIRST gets the CURRENT FOCUSED window (which may not be a trading chart), save it, and then work on the window it was called from to set focus to it, and minmize it, **and then** return focus back to the very FIRST window (which it saved somehow).

 

is this doable? In other words, the macro ends not when the trading chart is minimized, but when the window that had focus before the trading chart was minimized, is returned focus.

Link to comment
Share on other sites

Sure you can. At least if I understand you correctly. I didn’t follow your explanation completely but you can use ME’s various window manipulation commands to do these things. For instance when ME runs you could have it save the name of the top most (focused) window to a variable that you can then use to minimize or what have you and later reactivate. Check out the commands Variable Set String > Set Value to Topmost Window Title and all of the Windows Programs category.

 

Also I would like to suggest that you leave ME running all the time with all your macros in there instead of storing them in MXE files. I was tempted for a while to save things in individual files but later realized life was much easier if I kept them all organized in one file which was forever active. To launch them from a command line you can use the MEProc.exe but I think one might also be able to use API calls. I’m not a programmer but I know other people here could probably elaborate on that.

Link to comment
Share on other sites

Sure you can. At least if I understand you correctly. I didn’t follow your explanation completely but you can use ME’s various window manipulation commands to do these things. For instance when ME runs you could have it save the name of the top most (focused) window to a variable that you can then use to minimize or what have you and later reactivate. Check out the commands Variable Set String > Set Value to Topmost Window Title and all of the Windows Programs category.

 

Also I would like to suggest that you leave ME running all the time with all your macros in there instead of storing them in MXE files. I was tempted for a while to save things in individual files but later realized life was much easier if I kept them all organized in one file which was forever active. To launch them from a command line you can use the MEProc.exe but I think one might also be able to use API calls. I’m not a programmer but I know other people here could probably elaborate on that.

>Check out the commands Variable Set String > Set Value to Topmost Window Title and all of the Windows Programs category.

 

Yes. this is exactly what I was looking for. I was looking under Windows for this and found nothing

 

Thanks

Link to comment
Share on other sites

Yeah the arrangement of the categories is mostly good but sometimes I find the arrangement 'hides' some things. Like the Text Type option to push to a control can not be found anywhere in the controls section and yet it’s one of the most useful commands you could categorize as control. I think we have all had a period of discovery where we get into the scripting aspect of ME and it takes a while to familiarize oneself with all the commands. If you haven’t already check out Joe’s book. It does a pretty good job of it.

Link to comment
Share on other sites

Was that to me or Alex? If to me, yeah I was aware. I tried rearranging things but since I work on various machines it became confusing and inefficient. Also I quickly discovered their arrangement is pretty good and now that I know where everything is it doesn’t help.

Link to comment
Share on other sites

Here are a couple of tips (off-topic):

 

I rarely select a command from the category list. I press Alt-Down Arrow to get to the Search box and then type the first part of the command. When the correct command gets highlighted in the command category list, I press Enter. But, I know the name of all or most of the commands.

 

Two of my favorite preference settings are:

 

'Command Insertion' - Insert After Highlighted Command'

This causes the macro commands to be inserted after the highlighted macro command in the Script Editor. To set this, open the Script Editor, click Options, Command Insertion and Insert After Highlighted Command.

 

'Switch focus to script when adding a command'

This causes focus to be set to the macro script pane after you add a command. This way you can immediately use the arrow keys to move up and down through the script. To set this, click Options, Preferences, Miscellaneous and check 'Switch focus to script when adding a command'.

Link to comment
Share on other sites

The command insertion thing I already do. But I didn’t understand about the preference to set focus back to the script. That’s hot! I’ve never used the command selection trick either. I’ll have to try that since I have all my common commands memorized. Thanks Kevin!

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...
 Share

×
×
  • Create New...