Jump to content
Macro Express Forums

Applying Controls to MEP?


Recommended Posts

Am I right in assuming that ME Pro itself sets a good example by supporting Controls?

 

If so, what is wrong with this 2-line macro that uses Get Control to click the Comments button in the Script Editor.

 

Get Control: (MACSCRIPT.EXE) -> %cCommentButton%
Mouse Click on Control %cCommentButton%

 

<GET CONTROL Flags="1" Program_Name="MACSCRIPT.EXE" Class="TMainWin" Title="Macro Express Pro - Script Editor [Comment - insert above current line]" Control="\"TNotebook\",\"11\",\"TPage\",\"1\",\"TPanel\",\"1\"" Variable="%cCommentButton%" Caption="Macro Express Pro - Script Editor [" Partial="TRUE" Wildcards="FALSE"/>
<MOUSE CLICK ON CONTROL Clicks="\x01" Control="%cCommentButton%" Button="\x00" Center="TRUE"/>

 

--

Terry, East Grinstead, UK

Controls in MEPro Script Editor.mex

Link to comment
Share on other sites

That will not work as you have it. The button by itself is not a control. The whole editing area is one big control. If you notice when using the utility it draws a box around the controls. The only way you could get this to work is to use the advanced option and click relative to the control. However the button is anchored to the right side so you would have to get the width and do some math. Alan's suggestion is much better.

Link to comment
Share on other sites

You may need a time delay... or you could press Ctrl + Alt + C!

 

Thanks Alan! Sure beats the mouse-moving method I used. ;)

 

I'm surprised there's nothing in Help on such KB shortcuts. There's no entry in Help > Index under 'Keyboard' or 'Keyboard Shortcuts', or any hits with Help > Search. Nor does the description in Help > Index > Comments mention it. I've never used Edit > Comment to enter a comment, so remained unaware of it until your post got me hunting for the source.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Thanks Alan! Sure beats the mouse-moving method I used. ;)

 

I'm surprised there's nothing in Help on such KB shortcuts. There's no entry in Help > Index under 'Keyboard' or 'Keyboard Shortcuts', or any hits with Help > Search. Nor does the description in Help > Index > Comments mention it. I've never used Edit > Comment to enter a comment, so remained unaware of it until your post got me hunting for the source.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

That will not work as you have it. The button by itself is not a control. The whole editing area is one big control. If you notice when using the utility it draws a box around the controls. The only way you could get this to work is to use the advanced option and click relative to the control. However the button is anchored to the right side so you would have to get the width and do some math. Alan's suggestion is much better.

 

Thanks Cory. Very few of my applications do, but I'd hoped MEP might have a more generous number of controls.

 

The method I used included setting the width of the Favorites pane (in case it had changed), in order to click the appropriate green button. That KB shortcut Alan pointed out makes the macro redundant, of course!

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Not every application lends itself to control-centric macros. I have attempted many for Macro Express, and in almost every case, I have gone back to sending keystrokes and/or performing mouse manipulations.

 

I have had more success in applications such as Outlook. But even so, these macros take a lot of testing and debugging. In one case, a script failed five or 10% of the time. It took me a long time to figure out that a short delay was needed at one point in the process.

 

It's extremely useful to be able to create control centric scripts, but the learning curve is steep!

Link to comment
Share on other sites

In the Macro Express Pro - Script Editor click on the 'Edit' menu item. A list of commands and shortcuts is displayed. Note 'Comment _ Ctrl+Alt+C'.

 

I repeat: "I'm surprised there's nothing in Help on such KB shortcuts."

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

The method I used included setting the width of the Favorites pane (in case it had changed), in order to click the appropriate green button. That KB shortcut Alan pointed out makes the macro redundant, of course!

 

--

Terry, East Grinstead, UK

 

On closer study, I was wrong. That handy KB shortcut doesn't actually help in this case. My macro is to add a new stand-alone comment, but <Ctl+Alt+c> opens the Comment dialog for an existing command.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

<TEXT TYPE Action="0" Text="<ALT>n"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<TEXT TYPE Action="0" Text="<ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT>"/>
<TEXT TYPE Action="0" Text="<TAB><TAB>"/>
<TEXT TYPE Action="0" Text="all"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<TEXT TYPE Action="0" Text="l<ARROW DOWN><ARROW RIGHT><ARROW DOWN><ARROW DOWN><ENTER>"/>

 

This will do it... you may need to tweak the code a little...

 

Set the scope to Window specific: "- Script Editor"

 

Sorry for the lack of comments. Essentially, what it does is this:

 

1. Navigate to the Nickname field.

2. Use brute force to ensure that the "Script" tab is focused.

3. Tab to the drop down list, and force it to select "All Commands"

4. Tab to the tree-view of all commands

5. Send the sequence of keystrokes to navigate to "Remarks," and open it.

Link to comment
Share on other sites

<TEXT TYPE Action="0" Text="<ALT>n"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<TEXT TYPE Action="0" Text="<ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT>"/>
<TEXT TYPE Action="0" Text="<TAB><TAB>"/>
<TEXT TYPE Action="0" Text="all"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<TEXT TYPE Action="0" Text="l<ARROW DOWN><ARROW RIGHT><ARROW DOWN><ARROW DOWN><ENTER>"/>

 

This will do it... you may need to tweak the code a little...

 

Set the scope to Window specific: "- Script Editor"

 

Sorry for the lack of comments. Essentially, what it does is this:

 

1. Navigate to the Nickname field.

2. Use brute force to ensure that the "Script" tab is focused.

3. Tab to the drop down list, and force it to select "All Commands"

4. Tab to the tree-view of all commands

5. Send the sequence of keystrokes to navigate to "Remarks," and open it.

 

Thanks Alan. That works fine here when I start from Favorites (which I usually do). But it fails if the currently selected command is in All Commands. (Which is for example the case if you run it twice in succession, as well as when you're looking for a command not presently in Favorites.) The following minor revision seems to fix that.

 

<TEXT TYPE Action="0" Text="<ALT>n"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<TEXT TYPE Action="0" Text="<ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT>"/>
<TEXT TYPE Action="0" Text="<TAB><TAB>"/>
<TEXT TYPE Action="0" Text="all"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<COMMENT Value="Extra 3 lines to ensure macro works when a command category is in an expanded state."/>
<TEXT TYPE Action="0" Text="<HOME>"/>
<TEXT TYPE Action="0" Text="mac"/>
<TEXT TYPE Action="0" Text="<ARROW LEFT>"/>
<TEXT TYPE Action="0" Text="l<ARROW DOWN><ARROW RIGHT><ARROW DOWN><ARROW DOWN><ENTER>"/>

 

I usually add delays between all my Text Type commands (50-100ms, maybe more for ctl+c or ctl+v). And sometimes a Keystroke Speed (10/20 ms) up front. So I was surprised that your macro ran fine without them. I may need to reconsider that habit completely. (FWIW, I currently have Delay after keystrokes in the Text Type command set to 1000 microseconds / 1 ms.)

 

The macro I was using to add a new empty comment below the current line is partially mouse-based. (I've not shown its code as it would need adapting for individual users.) One refinement I intend to add is to have it detect whether the current line is the top one, and in that case to prompt for text and insert it above, as a 'header' comment. I'll also change it to incorporate your smarter key-based method of getting into the command pane, instead of mouse-clicking the top left corner of that area, as I am at present.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

I usually add delays between all my Text Type commands (50-100ms, maybe more for ctl+c or ctl+v). And sometimes a Keystroke Speed (10/20 ms) up front. So I was surprised that your macro ran fine without them. I may need to reconsider that habit completely.

 

Hi Terry,

 

I don't remember the last time I modified the keystroke speed. I haven't found it necessary.

 

I use timed delays sparingly: for example, when sending keystrokes to open a dialog box, I might insert a very short delay. (Scripts run slower when I insert a wait for window title command, even though this is the more elegant and reliable solution.) But if I am sending keystrokes to, say, choose an item located at the bottom of a sub-sub menu, delays do not seem to make a difference: <ALT>AB<End><Enter> works fine.

 

I will often insert delays while debugging a script. But once I have nailed the logic, I often discover that the delays are no longer needed. There are exceptions!

 

I find delays helpful when doing stuff with the clipboard, but I sometimes workaround the delays by inserting code that chews up a little time:

 

Clipboard Copy

Run Macro to move focus to the first field

Clipboard Paste

Link to comment
Share on other sites

  • 4 weeks later...

I usually add delays between all my Text Type commands (50-100ms, maybe more for ctl+c or ctl+v). And sometimes a Keystroke Speed (10/20 ms) up front. So I was surprised that your macro ran fine without them. I may need to reconsider that habit completely. (FWIW, I currently have Delay after keystrokes in the Text Type command set to 1000 microseconds / 1 ms.)

Instead of adding delays after each one, I would suggest using the "Wait Text Playback" between Text Types that do different functions (moving between fields, changing a drop down, and typing out text) and before you move on to another function (like grabbing a Control) to make sure it has finished. I find that most applications receive the text type just fine, but if there is a lot of text it gets "queued up" or "stacked" and the type out hasn't finished before it moves on to the next step in the macro and the "Wait Text Playback" is a great way to have it slow down just for that moment (instead of slowing down all of the text type outs using the keystroke speed).

 

Example:

 

Text Type: <CTRLD>b<CTRLU>NOTE<CTRLD>b<CTRLU>: Type out this text.
Wait Text Playback
Text Type: <TAB><SPACE>
Wait Text Playback
Set Focus to %C2%

 

NOTE: Some applications still don't play nice with this and keystroke speed is needed, but almost all of the ones I interact with work just fine just using "Wait Text Playback".

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