Jump to content
Macro Express Forums

Need A Command To Change Highlighted (Number) Text


Recommended Posts

Hello. I am looking for the command to change a highlighted number to a certain number.

 

Example:

I have a Macro that ends up highlighting a number. Once the number gets highlighted, if it is in between 1280 & 1599, then it will replace that highlighted number to 1280. If that number is greater than 2560 (say it's 5460), then that highlighted number will be replaced with 2560. Which command can I use to accomplish this? 

 

Thanks 

 

image.png.a06339ca5bc0a91913b42539e47f88fc.png

 

Link to comment
Share on other sites

I would create a Windows Controls command to read the value in do the logic, and set the new value and click the OK button. If you don't want to use Windows Control you can simply use tabs and your clipboard.

Link to comment
Share on other sites

Clipboard Copy
Variable Set Integer %Clip%: Set to the Clipboard Value
 
If Variable %Clip% Is Greater Than or Equal To "1280"
  AND
If Variable %Clip% Is Less Than or Equal To "1599"
  Text Type (Simulate Keystrokes): 1280
  Macro Stop
End If
 
If Variable %Clip% Is Greater Than or Equal To "2560"
  Text Type (Simulate Keystrokes): 2560
  Macro Stop
End If
 
MessageBox: %Clip% is not handled

 

Link to comment
Share on other sites

Cool! Thank you for the replies. And thanks so much Acantor. By using your example, I was able to expand on a few more things that were part of the script. I did some test and trialing, and it all seems to work so nicely!! I'm sure there's a way I can compress it, (I think I can keep the variable as one name, no need to define all the ones I did in the script, but it's okay. It's more descriptive this way so I can analyze it easily if I need to edit it). Here's the part of the script that's relevant:

 

image.thumb.png.ee76de3a1a55dc1e735e548b1615c530.png

Link to comment
Share on other sites

I agree with Cory. Using Windows controls is the best way to accomplish this.

 

But not all applications support controls, e.g., web apps. (But my guess is  the dialog box shown would contain controls that Macro Express can interact with.)

 

Controls can be unreliable, probably due to software upgrades, which means the macros stop working and need to be revised.

 

Novice macro writers might find controls a little hard to understand. I "get" them at a basic level, but I have zero idea how to use some Macro Express control features, e.g., "Modify the top-level window title." I've read the Help screen dozens of times, and my eyes still glaze over.

 

Link to comment
Share on other sites

I spent years avoiding controls. Then once I did it I realized I had wasted hundreds of hours and made inferior macros all that time that caused all kinds of complexity that could have been avoided using controls, especially for timing. A huge regret.

The biggest problem I had was why the "Get Control" command. But once I realized that all controls have a unique address that is unpredictably assigned and the command really should be somehting like "Get Control Address", then it clicked. 

No more delays for timing, no more flow control. No more issues with tab sequences getting out of whack. 

Link to comment
Share on other sites

Get the control, create the variables. And then "Get Control from Text. These 3 commands will do. But this is with one of my programs so you need to change the Get Control for yours. 
 

<GET CONTROL Flags="1" Program_Name="HTML FOLDER SCANNER.EXE" Class="WindowsForms10.Window.8.app.0.141b42a_r7_ad1" Title="HTML Folder Scanner" Control="\"WindowsForms10.EDIT.app.0.141b42a_r7_ad1\",\"3\"" Variable="%Horizontal%" Caption="HTML Folder Scanner" Partial="FALSE" Wildcards="FALSE"/>
<GET CONTROL TEXT TextVar="%strHorizontal%" ControlVar="%Horizontal%"/>
<TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %strHorizontal%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

Link to comment
Share on other sites

I assume this is a dialog box in Paint.

 

Get Control: (MSPAINT.EXE) Using z-order -> %TopSideControl%
Get Control Class from %TopSideControl% into %TopSideClass%
Get Control Text from %TopSideControl% into %TopSideText%
Text Box Display: Results

 

<GET CONTROL Flags="1" Program_Name="MSPAINT.EXE" Class="#32770" Title="Resize and Skew" Control="\"Button\",\"1\"" Variable="%TopSideControl%" Caption="Resize and Skew" Partial="FALSE" Wildcards="FALSE"/>
<GET CONTROL CLASS TextVar="%TopSideClass%" ControlVar="%TopSideControl%"/>
<GET CONTROL TEXT TextVar="%TopSideText%" ControlVar="%TopSideControl%"/>
<TEXT BOX DISPLAY Title="Results" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\lang4105\\f0\\fs20 Class = \\lang1033\\f1 [%TopSideClass%]\r\n\\par \\lang4105\\f0 Text = \\lang1033\\f1 [%TopSide\\lang4105\\f0 Text\\lang1033\\f1 %]\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

I tried to capture control information for the two radio buttons (Percentage and Pixels), the two fields (Horizontal and Vertical), and the Maintain Aspect Ratio checkbox.

 

I immediately got stuck. When I used the Macro Express' "Capture Window Control" utility, I learned the controls that make up the "Resize" container is a single control, not several different controls.

 

I tried anyways. I extracted the Class and Text from the control I had captured. The Class is "Button" and the Text is "Resize." Not useful information!

 

It might be possible to give focus to the various parts of the control by sending key sequences (e.g., Tab, Alt + H, Alt + V, etc.), but there's no advantage. If I want focus to go to the "Horizontal" field, a macro could simply send Alt+H.

image.png.6c8638742e748ace5c923d614742cabd.png

 

If there is a way to cause Macro Express to interact programmatically with the elements in this dialog box, I would love to know.

Link to comment
Share on other sites

I see. The Windows Control method seems pretty complex. It has a lot of stuff that I don't know much about. It looks more like something which I would need some basic understanding of programming. Dunno anything about programming. The method that I used is using logic & steps. It seems to be the best for me, and also, I have set up the steps for my project, and the steps seem to work pretty nicely so far. Also I am, at times, making slight changes to my method that I set up. I understand all my steps, and am able to easily modify certain parts to "perfectify" my script.

 

And I use Microsoft Paint, because this project works really much better with Microsoft Paint. I've tried Irfanview, and I prefer Paint much more.

 

 

For now, my question has been answered. Thanks.

Link to comment
Share on other sites

Complex? 2 commands is much less complex that what you will end up with. And no need to know programming. Just point at the control you want with the utility. 

Having said that, I can see that the individual control is that whole resize box so it's not going to work in this case. 

Link to comment
Share on other sites

I think you will be happy to learn it if you work with any WinForm apps. There was in the sample MEX file or on the webpage an example of doing controls with Windows Calculator. However I think Calculator is UWP and will not work for controls. What you want to do is launch the Get Control command dialog and click the Launch Utility button. Take that blue X and drag it over your program and you will see what controls are available. If none of your apps are traditional WinForm apps, then it's not worth learning. 

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...
×
×
  • Create New...