patrickbarrett Posted May 26, 2010 Report Share Posted May 26, 2010 Hello all, I'm running ME 3.5.5.2 and I use Control extensively in multiple applications. My company is moving to a new program here shortly and I am having a few issues translating our current macros over to it. It seems that the Controls that change depending on the number of windows you have open is very random, where as other applications tend to have a select few it cycles through (like MS Outlook and the Controls for a Subject line). I'm trying to see if there is a way to place a variable in the Control Details, so I can programmatically search for the correct Control in current window. Here is an example Control I have: - AppName.Exe - %T99% - [sWT_Window0] - SWT_Window0 - [index: 19] - SWT_Window0 - [index: 1] - SWT_Window0 - [index: 3] - SWT_Window0 - [index: 13] - SWT_Window0 - [index: 1] - SWT_Window0 - [index: 2] - SWT_Window0 - [index: 5] - SWT_Window0 - [index: 4] - SWT_Window0 - [index: 1] - SWT_Window0 - [index: 6] - SWT_Window0 - [index: 1] - Edit - [index: 2] Where %T99% is the Window Header name (that I grab at the beginning of the macro, to make sure I always stick to the window the macro was triggered on and not other windows that might be open). I'd like to do something like this: - AppName.Exe - %T99% - [sWT_Window0] - SWT_Window0 - [index: 19] - SWT_Window0 - [index: 1] - SWT_Window0 - [index: 3] - SWT_Window0 - [index: %N10%] - SWT_Window0 - [index: 1] - SWT_Window0 - [index: 2] - SWT_Window0 - [index: 5] - SWT_Window0 - [index: 4] - SWT_Window0 - [index: 1] - SWT_Window0 - [index: 6] - SWT_Window0 - [index: 1] - Edit - [index: 2] So I could loop through until I found the correct control. If this isn't possible in 3.5.5.2, can you do this in ME Pro? Quote Link to comment Share on other sites More sharing options...
monpasdg Posted May 27, 2010 Report Share Posted May 27, 2010 Since you said the control number you are trying to predict is random, won't looping through cause ME to error? If say the number you're guessing doesn't exist? I don't believe ther is any error catching logic with controls so each "loop" would have to exist already. As to the professional, I haven't used it sorry Quote Link to comment Share on other sites More sharing options...
kevin Posted May 27, 2010 Report Share Posted May 27, 2010 I'm trying to see if there is a way to place a variable in the Control Details, so I can programmatically search for the correct Control in current window. You might be able to accomplish this using the Run Macro In Variable command. These are the steps I would take to try it: Look at the Get Control command in the Direct Editor While in the Direct Editor copy the Get Control command to the clipboard Switch to the Script Editor Add a Variable Set String command Paste the Get Control command into the Initial Value field of the Variable Set String command Change the appropriate spot to %N10% Run using the Run Macro In Variable command This may work but I have not tried it. If you try it please let us know how it works. An easier way to handle this would be to do something like this: Get Control: (TESTT.EXE) -> %C[7]% If Control "%C[7]%" Does Not Exist Get Control: (TESTT.EXE) -> %C[7]% End If If Control "%C[7]%" Does Not Exist Get Control: (TESTT.EXE) -> %C[7]% End If If Control "%C[7]%" Does Not Exist Get Control: (TESTT.EXE) -> %C[7]% End If If Control "%C[7]%" Does Not Exist Get Control: (TESTT.EXE) -> %C[7]% End If Mouse Click on Control %C[7]% Each time you run the macro and get a Control Not Found message, edit the macro to add a new Get Control block. Eventually (hopefully) all possible controls will be in your macro. This technique has worked for me. If this isn't possible in 3.5.5.2, can you do this in ME Pro? Neither Macro Express or Macro Express Pro has the ability to directly put a variable into the content of the control. You could use the Run Macro In Variable technique in either version. Macro Express Pro does have the On Error command that might come in handy in this case. Quote Link to comment Share on other sites More sharing options...
patrickbarrett Posted June 2, 2010 Author Report Share Posted June 2, 2010 Thanks Kevin! That's a great idea. I had no clue I could use "Run Macro in Variable" in that way. I was thinking of using it more like this: Repeat Until %T2% = "ANYTHING" Variable Modify Integer: %N1% = %N1% + 1 Variable Set String %T2% "<GETCONTROL2:01:JAVAW.EXE:SWT_Window0\sWindowHeaderHere\s012:19\sSWT_Window0\s1\sSWT_Window0\s3\sSWT_Window0\s%N1%\sSWT_Window0\s1\sSWT_Window0\s2\sSWT_Window0\s5\sSWT_Window0\s4\sSWT_Window0\s1\sSWT_Window0\s6\sSWT_Window0\s1\sSWT_Window0\s2\sEdit\s>" Run Macro in Variable %T2% If Control %C1% Enabled Repeat Exit End If Repeat End Variable Get Control Text: %C1% to %T1% NOTE: I replaced "" with "/s" for the separator character in the Get Control. "<GETCONTROL2:01:JAVAW.EXE:SWT_Window0\sWindowHeaderHere\s012:19\sSWT_Window0\s1\sSWT_Window0\s3\sSWT_Window0\s%N1%\sSWT_Window0\s1\sSWT_Window0\s2\sSWT_Window0\s5\sSWT_Window0\s4\sSWT_Window0\s1\sSWT_Window0\s6\sSWT_Window0\s1\sSWT_Window0\s2\sEdit\s>" So if you know which ID is changing in the Control, you can loop through until the one currently active is found and then exit the loop and move on with the macro. Although I did get this to work, just not in the situation I'm working on at the moment, as the application is changing two IDs in the Control and if you have multiple windows open, some times the Control is there, just not in the active window. I'll have to do more testing to see if I can get around this (I tried using "Variable Modify Control %C1%: Modify Top-Level Window Title") to no avail. As for: "...An easier way to handle this would be to do something like this:..." Yes, I've used that method for years to get controls in other applications, but it doesn't work properly with this new application. It seems that depending on the number of tabs open and the order of the tabs in the application the Controls change. When I use this method, it works sometimes, but if I re-order the Tabs or open a new one the Controls shift and the ones I'm searching for are there, just not in the active window. -Patrick Quote Link to comment Share on other sites More sharing options...
patrickbarrett Posted June 2, 2010 Author Report Share Posted June 2, 2010 Hello monpasdg, Yes you can use something like this to go through multiple Controls: Get Control %C1% If Not Control %C1% Enabled Get Control %C1% End If If Not Control %C1% Enabled Get Control %C1% End If ... If Not Control %C1% Enabled Error Message If Nothing Found End If Or maybe use the other code I posted above in reply to Kevin. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.