Jump to content
Macro Express Forums

acantor

Members
  • Content Count

    858
  • Joined

  • Last visited

  • Days Won

    5

acantor last won the day on April 11 2019

acantor had the most liked content!

Community Reputation

8 Neutral

About acantor

  • Rank
    Master

Contact Methods

  • Website URL
    www.cantoraccess.com
  • ICQ
    0

Profile Information

  • Location
    Toronto

Recent Profile Visitors

596 profile views
  1. I would report the issue to Insight Software. It might be a bug.
  2. Not sure if this MEP setting simplifies the process, but I'll put it out there. Years ago, I unchecked this checkbox, and haven't missed the extra prompt every time I create a variable. MEP almost always correctly guesses the type of variable: I uncheck "Prompt the user to create a variable that is not defined."
  3. Hi Terry, I just tested, and it worked for me. I made a new macro, created six text variables, deleted four lines that contained four variables. Then... 1. I selected the entire script in the Script Editor. 2. I copied it. 3. Closed the Script Editor. 4. Created a new macro. 5. Pasted the old script into the Script Editor. In the new macro, I checked the Variables page, and only the two text variables that I had not deleted were there.
  4. This was a fun assignment! Here's my version: Variable Set String %Results% to "" Variable Set String %Input%: Prompt Variable Set Integer %Length% to the length of variable %Input% Switch( %Length% ) Case: 0 Text Box Display: Nothing to do! End Case Case: 1 // Simple case: just output the input! Variable Set String %Results% to "%Input%" End Case Case: 2 // Change "XY" to "X and Y" Variable Modify String: Copy part of text in %Input% starting at 1 and 1 characters long to %Char% Variable Modify String %Results%: Append Text (%Char% and ) Variable Modify String: Copy part of text in %Input% starting at 2 and 1 characters long to %Char% Variable Modify String %Results%: Append Text (%Char%) End Case Default Case // Change "ABC...XYZ" into "A, B, C, ... X, Y, and Z" Repeat Until %Length% Equals "2" Variable Modify String: Copy part of text in %Input% starting at 1 and 1 characters long to %Char% Variable Modify String %Results%: Append Text (%Char%, ) Variable Modify String: Delete part of text from %Input% starting at 1 and 1 characters long Variable Set Integer %Length% to the length of variable %Input% End Repeat Variable Modify String: Copy part of text in %Input% starting at 1 and 1 characters long to %Char% // Handle penultimate character Variable Modify String %Results%: Append Text (%Char%, and ) Variable Modify String: Copy part of text in %Input% starting at 2 and 1 characters long to %Char% // Handle final character Variable Modify String %Results%: Append Text (%Char%) End Case End Switch Text Box Display: %Results% <VARIABLE SET STRING Option="\x00" Destination="%Results%" NoEmbeddedVars="FALSE"/> <COMMENT/> <VARIABLE SET STRING Option="\x01" Destination="%Input%" Prompt="Enter characters to output with grammaticalcommas and an \"and\"" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/> <VARIABLE SET STRING Option="\x00" Destination="%Input%" Value="1" NoEmbeddedVars="FALSE" _ENABLED="FALSE" _COMMENT="The three lines speed up testng of this script"/> <VARIABLE SET STRING Option="\x00" Destination="%Input%" Value="12" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%Input%" Value="12345" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/> <COMMENT/> <VARIABLE SET INTEGER Option="\x0D" Destination="%Length%" Text_Variable="%Input%"/> <COMMENT/> <SWITCH Variable="%Length%"/> <CASE Value="0"/> <TEXT BOX DISPLAY Title="Nothing to do!" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \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="1" _COMMENT="Simple case: just output the input!"/> <VARIABLE SET STRING Option="\x00" Destination="%Results%" Value="%Input%" NoEmbeddedVars="FALSE"/> <END CASE/> <COMMENT/> <CASE Value="2" _COMMENT="Change \"XY\" to \"X and Y\""/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Input%" Start="1" Count="1" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Results%" Value="%Char% and " NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Input%" Start="2" Count="1" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Results%" Value="%Char%" NoEmbeddedVars="FALSE"/> <END CASE/> <COMMENT/> <DEFAULT CASE _COMMENT="Change \"ABC...XYZ\" into \"A, B, C, ... X, Y, and Z\""/> <REPEAT UNTIL Variable="%Length%" Condition="\x00" Value="2"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Input%" Start="1" Count="1" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Results%" Value="%Char%, " NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x0A" Destination="%Input%" Start="1" Count="1"/> <VARIABLE SET INTEGER Option="\x0D" Destination="%Length%" Text_Variable="%Input%"/> <END REPEAT/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Input%" Start="1" Count="1" NoEmbeddedVars="FALSE" _COMMENT="Handle penultimate character"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Results%" Value="%Char%, and " NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Input%" Start="2" Count="1" NoEmbeddedVars="FALSE" _COMMENT="Handle final character"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Results%" Value="%Char%" NoEmbeddedVars="FALSE"/> <END CASE/> <END SWITCH/> <COMMENT/> <TEXT BOX DISPLAY Title="%Results%" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
  5. Might it work to copy the entire script, and paste the code into a new script? I assume the variables in use would come along for the ride, but not the extra ones.
  6. There may be a workaround. The most elegant, if you can get it to work, is to capture the window control of the message. Maybe something like this will get you started. But you will probably need to do a lot of trial-and-error experimentation to get it to work, if it works! Get Control: (ProgramName.EXE) Using z-order -> %x% Get Control Class from %x% into %xClass% Get Control Text from %x% into %xText% Text Box Display: Class = %xClass% Text Box Display: Text = %xText% If the information you want is in xClass or xText, you may need instructions to parse it.
  7. No, but Macro Express IF statements can test a variable to find out whether it CONTAINS something: If Variable %x% Contains "Hello!" If Variable %x% Contains "Goodbye?" If Variable %x% Contains "!" If Variable %x% Contains "?" If Variable %x% Contains "H" If Variable %x% Contains "G" If Variable %x% Contains " " So, if %x% = "Hello! Goodbye?" then all of the above statements will return TRUE.
  8. Hi Terry, Another thought. Since we've figured out a way to get Macro Express to keep track of windows that need to be re-opened, perhaps the same data could be used to close the windows before reopening them. By using an array to store the titles of File Explorer windows, it's not necessary to store them externally in a file. // This macro closes every instance of File Explorer, and then re-opens them all // If a window's title bar contains :\ we assume it is an instance of the File Explorer // FOR THIS MACRO TO WORK... // Set File Explorer options to display the full path in the title bar // LIMITATIONS // Testing for :\ may not be a foolproof way to determine if the window is an instance of File Explorer // 1. Gather titles for every instance of File Explorer Variable Set Integer %Count% to 0 Repeat with Windows: Visible Windows: Store in variable %TitleBar% If Variable %TitleBar% Contains ":\" Variable Modify Integer %Count%: Increment Variable Set String %Result[%Count%]% to "%TitleBar%" End If End Repeat // If there are no instances of File Explorer, stop If Variable %Count% Equals "0" MessageBox: Sorry! Macro Stop End If // 2. Close every instance... Variable Set Integer %x% to 1 Repeat Start (Repeat %Count% times) Window Close: %Result[%x%]% Variable Modify Integer %x%: Increment End Repeat // 3. Re-open every instance... Variable Set Integer %x% to 1 Repeat Start (Repeat %Count% times) Open Folder to "%Result[%x%]%" Variable Modify Integer %x%: Increment End Repeat <COMMENT Value="This macro closes every instance of File Explorer, and then re-opens them all"/> <COMMENT Value="If a window's title bar contains :\\ we assume it is an instance of the File Explorer"/> <COMMENT/> <COMMENT Value="FOR THIS MACRO TO WORK..."/> <COMMENT Value="Set File Explorer options to display the full path in the title bar"/> <COMMENT/> <COMMENT Value="LIMITATIONS"/> <COMMENT Value="Testing for :\\ may not be a foolproof way to determine if the window is an instance of File Explorer"/> <COMMENT/> <COMMENT Value="1. Gather titles for every instance of File Explorer"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Count%" Value="0"/> <REPEAT WITH WINDOWS ToRetrieve="\x01" SortOrder="\x00" Destination="%TitleBar%"/> <IF VARIABLE Variable="%TitleBar%" Condition="\x06" Value=":\\" IgnoreCase="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%Count%"/> <VARIABLE SET STRING Option="\x00" Destination="%Result[%Count%]%" Value="%TitleBar%" NoEmbeddedVars="FALSE"/> <END IF/> <END REPEAT/> <COMMENT/> <COMMENT Value="If there are no instances of File Explorer, stop"/> <IF VARIABLE Variable="%Count%" Condition="\x00" Value="0" IgnoreCase="FALSE"/> <MESSAGEBOX Caption="Sorry!" Message="There are no instances of File Explorer" Icon="2"/> <MACRO STOP/> <END IF/> <COMMENT/> <COMMENT Value="2. Close every instance..."/> <VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/> <REPEAT START Start="1" Step="1" Count="%Count%" Save="TRUE" Variable="%x%"/> <WINDOW CLOSE Option="\x01" Title="%Result[%x%]%" Partial="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%"/> <END REPEAT/> <COMMENT/> <COMMENT Value="3. Re-open every instance..."/> <VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/> <REPEAT START Start="1" Step="1" Count="%Count%" Save="TRUE" Variable="%x%"/> <OPEN FOLDER Path="%Result[%x%]%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%"/> <END REPEAT/> This version gathers the titles of File Explorer windows, one after another. Then the script closes each window in the order they were discovered. Then the script reopens them sequentially in the same order they were found. It might be possible to simplify the process by closing each window, and immediately re-opening it. This "innovation" might introduce timing issues that don't seem to exist now, but it would eliminate the need for the last repeat loop. (I haven't tried it.) // 2. Close AND reopen every instance... Variable Set Integer %x% to 1 Repeat Start (Repeat %Count% times) Window Close: %Result[%x%]% Open Folder to "%Result[%x%]%" Variable Modify Integer %x%: Increment End Repeat // Done!
  9. Interesting how progress on these projects is iterative. If I were doing it again, the code could be easier to read (and a bit less opaque) by doing this instead: Variable Set String %ResultsFile% to "C:\Users\tmp\All Results.txt" Variable Set String %ResultsBackup% to "C:\Users\tmp\All Results Backup.txt" And then... Delete File/Files: "%ResultsFile%" Rename File/Files: "%ResultsBackup%" to "%ResultsFile%"
  10. Hi Terry, it's looking good! Here is another thought: Instead of opening All Results.txt, selecting all, deleting, and resaving the file, maybe store an empty file in the same folder called, for example, "All Results Backup.txt". Start by splitting up the path and file name so they are separate variables: Variable Set String %ResultsPath% to "C:\Users\tmp\" Variable Set String %ResultsFile% to "All Results.txt" Then you could do this: Delete File/Files: "%ResultsPath%%ResultsName%" Rename File/Files: "%ResultsPath%All Results Backup.txt" to "%ResultsPath%%ResultsName%"
  11. Here is a way to simplify the script: only one repeat loop instead of two, and no arrays. This version ends by opening the file containing the list. // This macro checks each window. // If its title bar contains :\ we assume the window is an instance of the File Explorer // We extract the path and store it in a file: Variable Set String %ResultsFile% to "C:\Users\DELL\Documents\Alan\tmp\All Results.txt" // FOR THIS MACRO TO WORK... // 1. Set File Explorer options to display the full path in the title bar // LIMITATIONS // Testing for :\ may not be a foolproof way to determine if the window is an instance of File Explorer Variable Set Integer %Count% to 0 // Keep track of the number of matches Repeat with Windows: Visible Windows: Store in variable %Title% If Variable %Title% Contains ":\" Variable Modify Integer %Count%: Increment Variable Modify String: Append %Title% to text file, "%ResultsFile%" End If End Repeat If Variable %Count% Equals "0" MessageBox: Sorry! Else Program Launch: "notepad.exe" (Maximized) Parameters: %ResultsFile% End If <COMMENT Value="This macro checks each window. "/> <COMMENT Value="If its title bar contains :\\ we assume the window is an instance of the File Explorer"/> <COMMENT Value="We extract the path and store it in a file:"/> <VARIABLE SET STRING Option="\x00" Destination="%ResultsFile%" Value="C:\\Users\\DELL\\Documents\\Alan\\tmp\\All Results.txt" NoEmbeddedVars="FALSE"/> <COMMENT/> <COMMENT Value="FOR THIS MACRO TO WORK..."/> <COMMENT Value="1. Set File Explorer options to display the full path in the title bar"/> <COMMENT/> <COMMENT Value="LIMITATIONS"/> <COMMENT Value="Testing for :\\ may not be a foolproof way to determine if the window is an instance of File Explorer"/> <COMMENT/> <VARIABLE SET INTEGER Option="\x00" Destination="%Count%" Value="0" _COMMENT="Keep track of the number of matches"/> <COMMENT/> <REPEAT WITH WINDOWS ToRetrieve="\x01" SortOrder="\x00" Destination="%Title%"/> <IF VARIABLE Variable="%Title%" Condition="\x06" Value=":\\" IgnoreCase="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%Count%"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%Title%" Filename="%ResultsFile%" Strip="TRUE" NoEmbeddedVars="FALSE"/> <END IF/> <END REPEAT/> <COMMENT/> <IF VARIABLE Variable="%Count%" Condition="\x00" Value="0" IgnoreCase="FALSE"/> <MESSAGEBOX Caption="Sorry!" Message="There are no instances of File Explorer" Icon="2"/> <ELSE/> <PROGRAM LAUNCH Path="C:\\Windows\\notepad.exe" Mode="\x02" Parameters="%ResultsFile%" Default_Path="TRUE" Wait="1" Get_Console="FALSE"/> <END IF/>
  12. Hi Terry, Hopefully this will get you started. No guarantees, as I did this because I thought it might make for a fun project this evening. No doubt the code can be improved, and perhaps someone else will come up with a more reliable way to test if a window is actually an instance of the File Explorer. (My script checks for ":\" in the title bar, as in "c:\Users" or x:\tmp\hello" // This macro checks each window. // If its title bar contains :\ we assume the window is an instance of the File Explorer // We extract the path and store it in a file: Variable Set String %ResultsFile% to "C:\Users\DELL\Documents\Alan\tmp\All Results.txt" // FOR THIS MACRO TO WORK... // 1. Set File Explorer options to display the full path in the title bar // LIMITATIONS // Testing for :\ may not be a foolproof way to determine if the window is an instance of File Explorer Variable Set Integer %Count% to 0 Repeat with Windows: Visible Windows: Store in variable %Title% If Variable %Title% Contains ":\" Variable Modify Integer %Count%: Increment Variable Set String %Result[%Count%]% to "%Title%" Text Box Display: Result[%Count%] = %Title% End If End Repeat Switch( %Count% ) Case: 0 // There are zero instances open MessageBox: Sorry! End Case Default Case // There is at least one instance Variable Set Integer %x% to 1 Repeat Start (Repeat %Count% times) Variable Modify String: Append %Result[%x%]% to text file, "%ResultsFile%" Variable Modify Integer %x%: Increment End Repeat End Case End Switch <COMMENT Value="This macro checks each window. "/> <COMMENT Value="If its title bar contains :\\ we assume the window is an instance of the File Explorer"/> <COMMENT Value="We extract the path and store it in a file:"/> <VARIABLE SET STRING Option="\x00" Destination="%ResultsFile%" Value="C:\\Users\\DELL\\Documents\\Alan\\tmp\\All Results.txt" NoEmbeddedVars="FALSE"/> <COMMENT/> <COMMENT Value="FOR THIS MACRO TO WORK..."/> <COMMENT Value="1. Set File Explorer options to display the full path in the title bar"/> <COMMENT/> <COMMENT Value="LIMITATIONS"/> <COMMENT Value="Testing for :\\ may not be a foolproof way to determine if the window is an instance of File Explorer"/> <COMMENT/> <VARIABLE SET INTEGER Option="\x00" Destination="%Count%" Value="0"/> <REPEAT WITH WINDOWS ToRetrieve="\x01" SortOrder="\x00" Destination="%Title%"/> <IF VARIABLE Variable="%Title%" Condition="\x06" Value=":\\" IgnoreCase="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%Count%"/> <VARIABLE SET STRING Option="\x00" Destination="%Result[%Count%]%" Value="%Title%" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Result[%Count%] = %Title%" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <END IF/> <END REPEAT/> <COMMENT/> <SWITCH Variable="%Count%"/> <CASE Value="0" _COMMENT="There are zero instances open"/> <MESSAGEBOX Caption="Sorry!" Message="There are no instances of File Explorer" Icon="2"/> <END CASE/> <DEFAULT CASE _COMMENT="There is at least one instance"/> <VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/> <REPEAT START Start="1" Step="1" Count="%Count%" Save="TRUE" Variable="%x%"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%Result[%x%]%" Filename="%ResultsFile%" Strip="TRUE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%"/> <END REPEAT/> <END CASE/> <END SWITCH/>
  13. I don't have Windows 10, so can't check this. In earlier versions of Windows, it was possible to display the full path in the title bar in Windows Explorer under Tools > Folder Options > View If you can do this in Windows 10, then maybe you could loop through the open Explorer windows and use this: Variable Set String %Win[1]% to topmost window title Alternatively, you might be able to extract the full path from the "Address" line of each instance of the File Explorer, although this would be a less reliable method than the aforementioned example.
  14. Hi Terry, I created a new key in the registry and the macro has been saving the retrieving the data as I hoped it would. But now I realize I could also save the data in a file, which would be less risky. Variable Modify String: Save %SavedValue% to "C:\Users\Me\Documents\Test.txt" Variable Set String set %SavedValue% to the contents of C:\Users\Me\Documents\Test.txt
  15. So you suggest adding a key (with several sub-keys) in HKEY_CURRENT_USER\... Any advantages or drawbacks of burying my custom settings deeper in the hierarchy?
×
×
  • Create New...