Jump to content
Macro Express Forums

acantor

Members
  • Content Count

    850
  • 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

574 profile views
  1. 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%"
  2. 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%"
  3. 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/>
  4. 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/>
  5. 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.
  6. 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
  7. 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?
  8. I've never used Macro Express to interface with the Windows Registry. But now I have an idea for a script that would "remember" a setting from the previous run time. Are there certain areas of the Registry I should avoid reading and writing values to? Are some areas "safer" than others? For example, could I add a key called "My Values" here without causing problems? HKEY_CURRENT_USER\Software\Insight Software Solutions\Macro Express 6\My Values
  9. Definitely take advantage of the 30 day free trial. If you discover that Macro Express saves you significant time and headache, perhaps $49 will seem like a modest sum. It is hard to imagine the amount even partially covers the cost of developing the program. When I first began using Macro Express about 20 years ago, I figure I recovered the cost, in terms of increased speed and accuracy, in under an hour.
  10. Check Version 3.10 help to find out whether it supports arrays. If it doesn't, you will need to update to Version 5 or 6. If it does support arrays, you can use my code sample as a starting point, but you will need to rename all of the variables: Text variables, such as %Target% and %Group[x], to T[1]. T[2], etc.; and the integer variable %Count% as %N[1]%.
  11. Perhaps something like this... // Set URLs for Facebook groups here... Variable Set String %Group[1]% to "/facebook.com/AAAAA" Variable Set String %Group[2]% to "/facebook.com/BBBB" Variable Set String %Group[3]% to "/facebook.com/CCC" // Etcetera Variable Set Integer %Count% to 1 Repeat Start (Repeat 3 times) Variable Set String %Target% to "%Group[%Count%]%" // The next line confirms the macro is on track... Text Box Display: %Target% Variable Modify Integer %Count%: Increment // Do something with the URLs... End Repeat
  12. Good catch. I am noting the same behaviour. Not sure whether this issue rises to the status of "bug," but there is no harm in reporting it. I agree that maintaining the integrity of dates when moving macros between categories would be ideal. However, the problem may be more of an unfortunate user interface hiccough than a programming error. But if it's fixable, I'm sure the good folks at Insight would consider taking it on. They have repaired many quirks that I have reported over the years -- and some of those quirks affect few users.
  13. On the right edge of the Script Editor, near the top, there are four small buttons. The top two are "Move command up" and "Move command down." To change the order of commands in the script, select a line (or more) and then click the button to perform the action you want. In addition, the are keyboard shortcuts to move lines up and down: Ctrl + Arrow Up Ctrl + Arrow Down I have a hazy recollection that on a computer I once used, I had to include the Shift key as part of these shortcuts: Shift + Ctrl + Arrow Up Shift + Ctrl + Arrow Down
  14. I use blank comments to separate areas of my Macro Express code. I also use a yellow as a background colour to mark the first line of a new section.
×
×
  • Create New...