Jump to content
Macro Express Forums

acantor

Members
  • Posts

    1,532
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by acantor

  1. The standard method to give keyboard input focus to the menu bar is to press either Alt or F10. If the menu bar (or ribbon) can be interacted with via keyboard, focus will jump there, and you will see it. Then menu items can be activated via arrow keys and/or "accelerator" keys. For example, for the File menu, pressing Alt or F10 will change the appearance of File: the "F" will be highlighted, or underlined. If this method works, a macro to navigate through menus can be simple. In pseudo code: Type F10 // Activate the menubar Type F // Choose the _F_ile menu Type A // Choose Save _A_s Sometimes you will need to insert a short delay between certain steps. 100 to 200 milliseconds is usually enough.
  2. Look for a file with the .wcfg extension. That's were Macro Express stores configuration information. The file might be in the folder as the .mex file. Or the file might be in a subfolder of that folder. Exit Macro Express. Rename or delete the configuration file. Restart Macro Express. Choose your Macro Express Preferences. Export the configuration file.
  3. I don't know about coupons, but I recover the cost of Macro Express, in terms of time-savings, at least once a day. I've been using Macro Express for about 20 years, which is about 7000 days. To calculate my savings, multiply the number of days by the cost of the product, which is currently $70. So the value of a coupon that I have been redeeming daily by using Macro Express is about $49,000!
  4. After you copy the text to the clipboard, you will need to do three things: 1. Transfer the contents of the clipboard into a variable. 2. Do as Cory suggests: "trim" the variable. Trim means to delete spaces from the start and end. 3. Transfer the contents of the variable back to the clipboard. For example, if this is in your clipboard at the start: " Hello World " The clipboard will be there after you've completed the three steps: "Hello World" The Macro Express code looks something like this: // 1. Transfer clipboard to string variable %Clip% Variable Set String %Clip% from the clipboard contents // 2. Trim %Clip% Variable Modify String %Clip%: Trim // 3. Transfer %Clip% to the clipboard Clipboard Start Copy Text Type (Simulate Keystrokes): %Clip% Clipboard End Copy
  5. There's the "Restart Macro Express" instruction, which closes and relaunches the program in a couple of seconds. But I encourage you to submit a feature request: update the monitor count without the need to exit and restart MEP.
  6. I think Cory is right. Macro Express doesn't "know" which .mex file to load. Perhaps you renamed the .mex file on your old computer, or you created an entirely new .mex file. In both cases, you'll need to find the .mex file on your new computer, and then open it. Macro Express loads the most recently-opened .mex file by default. If you don't know or don't remember the name of your .mex file, open the Macro Express Explorer on your old computer. The name of the .mex file displays near the top-left corner:
  7. This little script seems to work without rebooting or restarting Macro Express: Variable Set Integer %x%: Set to Number of Monitors Text Box Display: %x% It can be activated by pressing a hotkey, some kind of fancy mouse click, etc. But maybe for your group, the "safest" option would be to schedule it to run every, say, five or ten minutes.
  8. Like Cory, I've written macros for tasks like these, but I've found built-in methods, like Mail Merge, usually accomplish much the same thing much easier. If you don't want to use Mail Merge, there may be ways to semi-automate the process without using macros. For example, prepare an outgoing message that includes the two attachments. Save it as a draft. Go into the "Drafts" folder. Copy the message, and paste it repeatedly until you have pasted in the number of messages you need. You will still need to go into each message and insert email addresses. But if the number of messages is relatively small, these kinds of "tricks" significantly reduce the effort.
  9. If the point of this macro is to automate the collection of information to a file, I think I would want that file to remain open. I wouldn't want to open and close the file every time I activated the macro. This version displays the file for one second after the paste operation -- just enough time to visually check the copied text has arrived -- and then switches back to the original window. Variable Set String %WinTitle% to topmost window title Clipboard Copy Window Activate: test.txt - Notepad // File that contains the copied information Text Type (Simulate Keystrokes): <CONTROL><END><ENTER> // Go to end of file and start a new line Text Type (Simulate Keystrokes): <CONTROL>v // Paste Delay: 50 milliseconds Text Type (Simulate Keystrokes): <CONTROL>s // Save Delay: 1000 milliseconds Window Activate: %WinTitle% <VARIABLE SET STRING Option="\x05" Destination="%WinTitle%"/> <CLIPBOARD COPY/> <COMMENT/> <WINDOW ACTIVATE Title="test.txt - Notepad" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006" _COMMENT="File that contains the copied information"/> <COMMENT/> <TEXT TYPE Action="0" Text="<CONTROL><END><ENTER>" _COMMENT="Go to end of file and start a new line"/> <TEXT TYPE Action="0" Text="<CONTROL>v" _COMMENT="Paste"/> <DELAY Flags="\x02" Time="50"/> <COMMENT/> <TEXT TYPE Action="0" Text="<CONTROL>s" _COMMENT="Save"/> <DELAY Flags="\x02" Time="1000"/> <COMMENT/> <WINDOW ACTIVATE Title="%WinTitle%" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
  10. This seems to work and runs relatively quickly. The delays may need to be increased. (It might be possible to reduce them.) You'll want to change the file name that receives information from the clipboard. Clipboard Copy Variable Set String %WinTitle% to topmost window title Program Launch: "notepad.exe" (Maximized) Parameters: c:\tmp\test.txt Wait for File to be Ready: C:\Tmp\test.txt Text Type (Simulate Keystrokes): <CONTROL><END><ENTER> // Go to end of file and start a new line Clipboard Paste Delay: 50 milliseconds Text Type (Simulate Keystrokes): <CONTROL>s // Save the Notepad file Delay: 50 milliseconds Window Close: test.txt - Notepad Window Activate: %WinTitle% <CLIPBOARD COPY/> <VARIABLE SET STRING Option="\x05" Destination="%WinTitle%"/> <PROGRAM LAUNCH Path="notepad.exe" Mode="\x02" Parameters="c:\\tmp\\test.txt" Default_Path="TRUE" Wait="1" Get_Console="FALSE"/> <WAIT FOR FILE TO BE READY Filename="C:\\Tmp\\test.txt" Time="0" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="1"/> <TEXT TYPE Action="0" Text="<CONTROL><END><ENTER>" _COMMENT="Go to end of file and start a new line"/> <CLIPBOARD PASTE/> <DELAY Flags="\x02" Time="50"/> <TEXT TYPE Action="0" Text="<CONTROL>s" _COMMENT="Save the Notepad file"/> <DELAY Flags="\x02" Time="50"/> <WINDOW CLOSE Option="\x01" Title="test.txt - Notepad" Partial="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <WINDOW ACTIVATE Title="%WinTitle%" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
  11. This can done via Macro Express, but you won't be able to programmatically save information to the file that contains clipboard data. You'll need to do everything "manually," perhaps like this: 1. Capture the name of the current window: Variable Set String %WinTitle% to topmost window title 2. Copy the selected text to the clipboard. 3. Open the file that contains the clipboard data: Program Launch: "notepad.exe" (Normal) Parameters: c:\tmp\test.txt 4. Wait for the file to open. 5. Go to the end (Ctrl + End), type Enter, and paste: Text Type (Simulate Keystrokes): <CONTROL><END><ENTER><CONTROL>v 6. Save the file. 7. Close the file. 8. Switch to the window that has the name captured in step 1: Window Activate: %WinTitle% Although possible with Macro Express, it'll take work, and refining the script to work reliably might take some tinkering. There are a lot of moving parts. If you get the macro to work, you'll have expanded your Macro Express skills! Too bad Macro Express can't handle Unicode!
  12. Congratulations! You've discovered a Macro Express bug. Your macro works for English-language characters and for accented French characters, but not for Cyrillic characters. (I didn't test any other languages or character sets. In French, I only tested é.) I tried a workaround, but this failed, too, in exactly the same way: Clipboard Copy Variable Set String %Clip% from the clipboard contents Variable Modify String: Save %Clip% to "C:\Whatever\test.txt" Please submit a bug report to ISS.
  13. Hi Terry. I'm using the latest version of Pro, version 6.xx. I haven't checked CPU usage in a long time, so I'm unable report changes. I've used timed delays for eons. I don't remember why or when I stopped using regular delays. My hazy recollection is that they made it harder to abort a running macro, but I can't be sure.
  14. I also saw high CPU-usage with the delay, and little (or no) effect with the timed delay.
  15. 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. If there is a way to cause Macro Express to interact programmatically with the elements in this dialog box, I would love to know.
  16. Some folks on this forum prefer this method, which separates key down from key up events: Text Type (Simulate Keystrokes): <CTRLD>s<CTRLU> I don't usually find I need to do this, but once in awhile, it's the only approach that works. Normally I do this: Text Type (Simulate Keystrokes): <CONTROL>s In some situations, one might have to slow down output by doing something like this (although I don't think I've ever done it). Text Type (Simulate Keystrokes): <CTRLD> Delay: 100 milliseconds Text Type (Simulate Keystrokes): s Delay: 100 milliseconds Text Type (Simulate Keystrokes): <CTRLU>
  17. 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.
  18. 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
  19. Would this Macro Express command allow you to activate a macro directly? Macro Run: Test macro
  20. There must be a more elegant solution than this -- I'm bothered by the apparent need to convert an integer variable to a string variable -- but it seems to work. Perhaps someone else can refine it. The first script saves the Mode in a file on the hard drive. The second script reads the file, and then decides what to do based on whether the Mode is 1, 2, or 3. Script to switch modes and save current Mode in a file: Variable Restore: Restore Integer Variables Switch( %Mode% ) Case: 1 Variable Set Integer %Mode% to 2 End Case Case: 2 Variable Set Integer %Mode% to 3 End Case Case: 3 Variable Set Integer %Mode% to 1 End Case Default Case Variable Set Integer %Mode% to 1 End Case End Switch Variable Modify Integer %Mode%: Convert to Text String (%ModeString%) Variable Modify String: Save %ModeString% to "C:\tmp\ModeFile.txt" Text Box Display: Current Mode = %Mode% Variable Save: Save Integer Variables <VARIABLE RESTORE Option="\x02"/> <SWITCH Variable="%Mode%"/> <COMMENT/> <CASE Value="1"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="2"/> <END CASE/> <COMMENT/> <CASE Value="2"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="3"/> <END CASE/> <COMMENT/> <CASE Value="3"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/> <END CASE/> <COMMENT/> <DEFAULT CASE/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/> <END CASE/> <COMMENT/> <END SWITCH/> <COMMENT/> <VARIABLE MODIFY INTEGER Option="\x04" Destination="%Mode%" Variable="%ModeString%"/> <VARIABLE MODIFY STRING Option="\x11" Destination="%ModeString%" Filename="C:\\tmp\\ModeFile.txt" Strip="FALSE" NoEmbeddedVars="FALSE"/> <COMMENT/> <TEXT BOX DISPLAY Title="Current Mode = %Mode%" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\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"/> <VARIABLE SAVE Option="\x02"/> Script to perform different tasks depending the current Mode: Variable Set String set %Mode% to the contents of C:\tmp\ModeFile.txt Switch( %Mode% ) Case: 1 // Insert instructions for Mode 1 Text Box Display: Mode 1 End Case Case: 2 // Insert instructions for Mode 2 Text Box Display: Mode 2 End Case Case: 3 // Insert instructions for Mode 3 Text Box Display: Mode 3 End Case End Switch <VARIABLE SET STRING Option="\x03" Destination="%Mode%" Filename="C:\\tmp\\ModeFile.txt" Strip="FALSE" NoEmbeddedVars="FALSE"/> <COMMENT/> <SWITCH Variable="%Mode%"/> <COMMENT/> <CASE Value="1"/> <COMMENT Value="Insert instructions for Mode 1"/> <TEXT BOX DISPLAY Title="Mode 1" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\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"/> <END CASE/> <COMMENT/> <CASE Value="2"/> <COMMENT Value="Insert instructions for Mode 2"/> <TEXT BOX DISPLAY Title="Mode 2" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\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"/> <END CASE/> <COMMENT/> <CASE Value="3"/> <COMMENT Value="Insert instructions for Mode 3"/> <TEXT BOX DISPLAY Title="Mode 3" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\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"/> <END CASE/> <COMMENT/> <END SWITCH/>
  21. The names of the sound files are missing their extensions. 1.xxx 2.xxx 3.xxx You'll need to check the files themselves to discover what the extensions are. Maybe look at their properties. The extensions will probably be three or four characters.
  22. Here's a way to switch between three modes: 1 --> 2 --> 3 --> 1 --> and so on. The macro saves the value of %Mode%, which is remembered the next time the macro is run. I tried to create a second macro to make decisions based on the current value of %Mode% but I couldn't make it work. Variable Restore: Restore Integer Variables Switch( %Mode% ) Case: 1 Variable Set Integer %Mode% to 2 End Case Case: 2 Variable Set Integer %Mode% to 3 End Case Case: 3 Variable Set Integer %Mode% to 1 End Case Default Case Variable Set Integer %Mode% to 1 End Case End Switch Text Box Display: Current Mode = %Mode% Variable Save: Save Integer Variables <VARIABLE RESTORE Option="\x02"/> <SWITCH Variable="%Mode%"/> <COMMENT/> <CASE Value="1"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="2"/> <END CASE/> <COMMENT/> <CASE Value="2"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="3"/> <END CASE/> <COMMENT/> <CASE Value="3"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/> <END CASE/> <COMMENT/> <DEFAULT CASE/> <VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/> <END CASE/> <COMMENT/> <END SWITCH/> <COMMENT/> <TEXT BOX DISPLAY Title="Current Mode = %Mode%" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\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"/> <VARIABLE SAVE Option="\x02"/>
  23. Lunch is important! There are probably better ways to handle the situation via controls. I just wanted to see if I could build a proof-of-concept. My initial idea was to "repeat until" the control text or the control class matched a certain value. But I try to avoid repeats that might turn into infinite loops, unless I can incorporate a "failsafe." There is a built-in failsafe. With only three controls on the screen, there should be no reason to check controls more than three times. But rather than repeat three times, I opted for two IF statements. There might be an issue sending <TAB><SPACE> if the Cancel button happens to be focused. Focus will go to the text field, and the macro will add a space to whatever is in the field. Rather than complicated workarounds, I would prefer an option in Macro Express to accept carriage returns in the field, or to cause Enter to activate the OK button. On the other hand, I find these kinds of workarounds entertaining!
  24. I thought of another workaround. It also involves two macros: The main macro waits for you to input something, maybe something like this: Variable Set String %x%: Prompt Text Box Display: Value of x Create a second macro with hotkey activation. Select "Enter" as the hotkey. Set its scope to "Enter String Value" (exact match). When the "Enter String Value" window is open, pressing Enter triggers the second macro. The problem is that we don't know what is focused when we press Enter: the text field, the OK button, or the Cancel button. This version seems to work reliably: if the OK button has focus, pressing Enter activates the OK button. If the Cancel button has focus, pressing Enter activates the Cancel button (which cancels the operation). Otherwise, the second macro assumes the text field has focus, and presses Tab Space. Capture Control from Focused Control into %DialogBoxControl% Get Control Text from %DialogBoxControl% into %Text% If Variable %Text% Equals "OK" Text Type (Simulate Keystrokes): <SPACE> Macro Stop End If If Variable %Text% Equals "Cancel" Text Type (Simulate Keystrokes): <SPACE> Macro Stop End If Text Type (Simulate Keystrokes): <TAB><SPACE>
×
×
  • Create New...