Jump to content
Macro Express Forums

Dynamicly Numbered Controls


Linda
 Share

Recommended Posts

We're still using MacroEpress 3.0.4.1, and that's outside my power to change in the near future.

 

The "Control" comands in ME assume statically allocated controls- that the ID the control has with a test-run will always be it's ID. But the primary peice of enterprise software that I'm writing macros for has dynamically allocated controls- the ID number for the control changes each time the application is run.

 

Lacking a static ID , I've been finding controls by tabbing between them and checking the control text to see if its what I'm looking for:blink: There has to be a more elegant (and somewhat faster!) method to deal with dynamically allocated controls. Has anyone else found it?

 

 

 

 

EDIT: Aside from the inherent awkwardness of the text-checking method, If I grab a null control (such as the in-focus control when there is no focus, or a control that no longer exists) MacroExpress crashes- doesn't just give me an error and stop the running macro, but actually crashes :o , complicating debugging.

 

Is there a better way that I'm overlooking?

Link to comment
Share on other sites

Linda,

 

Maybe something you could do after your function launches the application is to have a routine that uses the Capture Control command to get the Control info at specific coordinates on your display rather than tabbing to them. You would need to control how and where the application is placed on the screen each time it is launched, but this is easily done.

 

There have been a lot of changes to the Window Control commands since version 3.0d. Here is a list of them:

 

Version 3.0d

  • Made a modification to the controls so that they won't stall if a program has stalled.
  • Made some modifications to the window controls to hopefully improve their reliability.
  • Fixed an access violation that occasionally occurred when loading a control-activated macro.

Version 3.0e

  • Removed the hyperlink stating that the Control Focused was not available on Windows NT and Windows 95. This was incorrect as this functionality was enhanced some time ago to work on all versions of Windows.
  • Added an error message when a command attempts to find a control and the control cannot be located. The macro will abort.
  • After using the "Get Control" utility and hiding Macro Express, Macro Express will reappear in its previous state.

Version 3.2

  • Window and control macros are no longer checked when Macro Express is suspended.
  • Fixed a crash that occurs when using controls.
  • Added the ability for the Text Type command to send text directly to a control instead of the focused window.
  • Added the ability to select "Variable Set Integer to Control xxx" directly from the editor without having to hunt down the appropriate commands.

Version 3.4

  • Made an adjustment so that Macro Express will wait for a window to become ready prior to using a control that is contained in that window.
  • Added "Variable Get Control Class". This command will get the class name of the specified control, if the control exists.
  • Made an adjustment to prevent a crash that occasionally occurred when Macro Express was checking for control-activated macros.
  • Made an adjustment so that the "Get Control" utility will remember its position correctly when used with multiple monitors.
  • Reduced the amount of CPU cycles used when using the Control Utility in the "Get Control" command.

Version 3.4a

  • Removed code that caused some problems with the Control commands.

Version 3.4b

  • Made a change to the Capture Control utility so that it can get controls that are disabled.
  • Modified the "Control Details" dialog so that it is resizable.
  • Modified the window control commands such that they can handle a window with "AFX:" in its class correctly.
  • Fixed a range check error that would occasionally occur when using window controls.

Version 3.5

  • Modified the display of the "Get Control" command in the Script Editor so that information about the control is displayed.
  • Fixed a crash that occurred if the user attempted to modify a control variable without first having defined it.
  • Fixed a crash that occurred when attempting to update a control-activated macro in the editor.
  • Fixed a crash that could occur when using the Variable Set Control Text command.
  • Fixed a crash that occurred when using the "Variable Modify Control" command in conjunction with the "Capture Control" command.
  • Fixed a bug in the "Capture Control" command where it did not always return the correct information to any command that used the control.

I mention them only because one of them might solve your other problem. Would it be possible just to download and install a trial version of the latest release just to test if it solves the problem?

Link to comment
Share on other sites

Thanks for the info! We're working on getting MacroExpress updated, but between the testing and beauracratic requirements, it may take a while, so I have to work with what I've got for now.

 

Hmm... the "co-ordinates on the screen" seems even riskier than the tabbing-and-text-check method. I don't know the work habits and screen sizes of everyone who will be using these macros, so I want to make them as un-dependent on external factors as possible.

 

But I'll pull that in if I need to. The easy part is buttons with command-key equivilents- just use the keystroke. The hard part is edit-text boxes with no initial text in them...

 

Anyway, thanks for the info/help! B)

Link to comment
Share on other sites

Linda,

 

Yes, it may be riskier. I only mention it because I remember having the same problem as you are encountering. There was a program application that we had to create macros for, which every time it launched, the index IDs changed. It was a small app with only two dialogs, run by just a handful of users. Different users, however, meant different display resolutions (as you are aware). So the macro did the following (if I remember back that far):

  1. Saved screen resolution to vars.
  2. Closed the app if it was running.
  3. Launched the app.
  4. Saved the app's window size and position.
  5. Maximized the app.
  6. Used the coordinate system to capture Controls based on the screen resolution.
  7. Switched to the 2nd dialog.
  8. Used the coordinate system to capture Controls based on the screen resolution.
  9. Switched back to the 1st dialog.
  10. Normalized the app.
  11. Moved it back into the same position as when it was first launched.

This procedure never failed because we controlled the size and positioning of the app initially to capture the Controls, then put it all back as it was when first launched.

Link to comment
Share on other sites

Thanks again for the help!

 

Most of the macros I'm working on are for use inside a complex industry-specific enterprise database program, so closing and relaunching the application, logging in, finding the correct section of the application, correct pane, correct tab, correct record, and reproducing the workflow up to that point make steps 2 and 3 a little bit difficult :huh:

 

But there are always exceptions- never know when that trick would come in handy! B)

Link to comment
Share on other sites

Linda,

 

If your macro has already 'tabbed' to the correct field, you should be able to use these macro commands to use the Capture Control command:

Mouse Move To Text Cursor Position
Variable Set Integer %N1% from Mouse X Position
Variable Set Integer %N2% from Mouse Y Position
Capture Control to %C1%

 

Use %N1% and %N2% in the X and Y coordinates fields. As long as your commands to tab to a specific field work, this technique will work regardless of the screen resolution.

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