Jump to content
Macro Express Forums

acantor

Members
  • Posts

    1,531
  • Joined

  • Last visited

  • Days Won

    18

acantor last won the day on December 30 2023

acantor had the most liked content!

1 Follower

Contact Methods

  • Website URL
    www.cantoraccess.com
  • ICQ
    0

Profile Information

  • Location
    Toronto

Recent Profile Visitors

1,158 profile views

acantor's Achievements

  1. For testing purposes, set aside window title activation. What happens if you create a hotkey-activated macro that captures the window title and assigns the value to a string variable? Is the resulting string variable the truncated version of the window title, or the full window title?
  2. Can you also provide two or three examples of typical window titles? Cory might be correct that this is a Unicode issue, but let's make sure this is not a coding issue.
  3. Paste your Macro Express script here so we can have a look. (Select the relevant lines of your script, and to copy them, choose "Copy Command Text" from the Script Editor's "Edit" menu.) P
  4. Here's how it "works." Variable Set String %Title% to topmost window title Extract the title from the window and place it in string variable %Title%, e.g., "Hello Drink Tea Bye1234567 and Etcetera" Variable Set Integer %StartPositionOfID% to 20 Assume the ID always starts at the 20th character within the window title, e.g., "Hello Drink Tea Bye1234567 and Etcetera" Variable Set Integer %LengthOfID% to 7 Assume the ID is always seven characters long, e.g., "Hello Drink Tea Bye1234567 and Etcetera" Variable Modify String: Copy part of text in %Title% starting at %StartPositionOfID% and %LengthOfID% characters long to %ID% Copy seven characters starting at the 20th character and assign to string variable %ID% Text Box Display: ID = %ID% Display the ID! If the starting position of the ID and its length vary, you'd need other methods to zero-in on the ID. You gave this as an example of the title text: "ABC Processing Database ABCFrog User ZXCZX General ID 9876543" In this case, my starting point is that the ID begins immediately after the word "ID " (note the space after ID). If this is how the ID is always displayed, and the User name can be any length, you can calculate the start position this way: Variable Set Integer %StartPosition% to the position of "ID " in %Title% Variable Modify Integer: %StartPosition% = %StartPosition% + 4
  5. If the barcode pops up for a second, it may be possible to capture it via a macro. If the barcode appears as text, Macro Express may be able to parse it. But if the barcode appears as an image, I don't think Macro Express will be much help. Extracting and analyzing text from the window title still seems like the best bet.
  6. Perhaps the way forward is to set the activation to a partial match of the first part of the window title, e.g., "ABC Processing Database" The first thing the macro does is capture the window title as a string variable. (I've captured window titles using Macro Express that have up to 400 characters.) Then parse the string to extract the ID. Maybe something like this: Variable Set String %Title% to topmost window title Variable Set Integer %StartPositionOfID% to 20 Variable Set Integer %LengthOfID% to 7 Variable Modify String: Copy part of text in %Title% starting at %StartPositionOfID% and %LengthOfID% characters long to %ID% Text Box Display: ID = %ID%
  7. I'm not aware of a maximum number of characters that Macro Express inspects when activating a script based on a window title. However, Windows limits the number of characters in a file name to 256. The title bar text for applications usually includes the file name, so if I had to guess what Macro Express is doing, I would say 256 is the maximum. You can display the full title of a window using this script: Variable Set String %Title% to topmost window title Text Box Display: Title is %Title%
  8. Thank you, Cory, for that suggestion. I got it to work. My 90-line spaghetti-like script (which converted Date variables to and from Decimal variables and failed in puzzling ways), is now a super-reliable 40-line script which doesn't use Decimal variables.
  9. I wish I could add 65 minutes, but I think I can only add it to the current time, not a time I specify via a variable. Thanks for the answer! I see that 65 is the number of minutes, but where does "1440" come from?
  10. I'm working on a script that calculates future times. When the macro first runs, it notes the current time: Date/Time: Set %CurrentDateTimeDate% to the current date/time <DATE/TIME Flags="\xB0" Date="31-Mar-2024 3:48:26 p.m." Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%CurrentDateTimeDate%" IsDateVar="TRUE"/> Each time the macro runs, I want the script to advance the clock 65 minutes from the previous run time. I think the way to do this in Macro Express is to convert a Date variable into a Decimal variable, add a "fudge factor" to the Decimal variable, and then convert the Decimal variable back to a Date variable: Convert Date/Time to Decimal: %CurrentDateTimeDate% => %CurrentDateTimeDec% Variable Modify Decimal: %CurrentDateTimePlusDec% = %CurrentDateTimeDec% + .044 Convert Decimal to Date/Time: %CurrentDateTimePlusDec% => %CurrentDateTimePlusDate% Text Box Display: <CONVERT DATE/TIME TO DECIMAL Source="%CurrentDateTimeDate%" Dest="%CurrentDateTimeDec%"/> <VARIABLE MODIFY DECIMAL Option="\x00" Destination="%CurrentDateTimePlusDec%" Value1="%CurrentDateTimeDec%" Value2=".044"/> <CONVERT DECIMAL TO DATE/TIME Source="%CurrentDateTimePlusDec%" Dest="%CurrentDateTimePlusDate%"/> <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %CurrentDateTimeDate%\r\n\\par %CurrentDateTimePlusDate%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> Through trial-and-error experimentation, I've found that adding 0.044 to the Date variable adds about 65 minutes. I could do more trials to get closer to 65 minutes. But I'm hoping someone will know how to calculate the exact decimal amount. This would be easy if I want to add 65 minutes to the current time, rather than to the last run time. This does it nicely... but it's not what I need! Date/Time: Set %NextDateTimeDate% to an adjusted date/time <DATE/TIME Flags="\xB2" Date="31-Mar-2024 3:50:24 p.m." Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="65" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%NextDateTimeDate%" IsDateVar="TRUE"/>
  11. I tried running a global macro in MMC, and I tried creating a window-specific macro for MMC, as well. Neither script did anything! Perhaps try running Macro Express in Administrative mode?
  12. There's another option to improve the legibility of screen fonts: reduce the screen resolution. The Windows default resolution might work perfectly for a 20-year-old with 20:20 vision using a very large monitor. But I can almost guarantee it's not a good set-up for a middle-aged person working on a laptop.
  13. Here's another possibility: When running a macro, if there's an unrecoverable error, Macro Express displays a dialog box that looks something like this: The last line shows the line number. Press Ctrl + C when this dialog box has focus. This hotkey will copy the text to the clipboard. Create a new macro. Choose "Clipboard" as its activation. Choose to activate when the clipboard "contains" unique text from the error message. A good choice is "Line Number:" but another option is "The following error was encountered:" This script should extract the line number, place the value in a variable, and display it. Variable Set String %Clip% from the clipboard contents Variable Set Integer %ClipLength% to the length of variable %Clip% Variable Set Integer %TargetPosition% to the position of "Line Number:" in %Clip% Variable Modify Integer: %TargetPosition% = %TargetPosition% + 13 Variable Modify Integer: %CharactersToCopy% = %ClipLength% - %TargetPosition% Variable Modify String: Copy part of text in %Clip% starting at %TargetPosition% and %CharactersToCopy% characters long to %LineNumber% Variable Modify String %LineNumber%: Trim Text Box Display: Line Number = %LineNumber% <VARIABLE SET STRING Option="\x02" Destination="%Clip%" NoEmbeddedVars="FALSE"/> <COMMENT/> <VARIABLE SET INTEGER Option="\x0D" Destination="%ClipLength%" Text_Variable="%Clip%"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%TargetPosition%" Text_Variable="%Clip%" Text="Line Number:" Ignore_Case="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%TargetPosition%" Value1="%TargetPosition%" Value2="13"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%CharactersToCopy%" Value1="%ClipLength%" Value2="%TargetPosition%"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%LineNumber%" Variable="%Clip%" Start="%TargetPosition%" Count="%CharactersToCopy%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x00" Destination="%LineNumber%"/> <COMMENT/> <TEXT BOX DISPLAY Title="Line Number = %LineNumber%" 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"/>
  14. I don't think it's possible to capture the line number in a variable. But perhaps dividing the script into sections might accomplish something similar: Variable Set From Misc: "Name of Current Macro" into %CurrentMacro% Variable Set Integer %Section% to 1 If Window "Macro Express Pro" is focused Text Box Display: Check %CurrentMacro% at Section %Section% End If // Do something Variable Modify Integer %Section%: Increment If Window "Macro Express Pro" is focused Text Box Display: Check %CurrentMacro% at Section %Section% End If // Do something Variable Modify Integer %Section%: Increment If Window "Macro Express Pro" is focused Text Box Display: Check %CurrentMacro% at Section %Section% End If // Do something Variable Modify Integer %Section%: Increment If Window "Macro Express Pro" is focused Text Box Display: Check %CurrentMacro% at Section %Section% End If
  15. Or this: Variable Set String %FourLeftArrows% to "<ARROW LEFT><ARROW LEFT><ARROW LEFT><ARROW LEFT>" Text Type (Simulate Keystrokes): %FourLeftArrows%
×
×
  • Create New...