Jump to content
Macro Express Forums

All Activity

This stream auto-updates     

  1. Last week
  2. 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%"
  3. Thanks Alan. Yes, that’s nice. And it might have reduced the problems I had with my text editor, TextPad, at one stage of development, warning me that “Another program has modified your file; do want to reload?” I was admittedly in a hurry - this was a digression from the VBA macro that’s preoccupying me - so my edit was a bit rough. I’ve learnt something from your approach, thanks for investing the time.
  4. 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%"
  5. Thanks Alan, that is a tidier one, although I'm happy enough with your original. After making the various mods I described I've used it several times since my last post, in conjunction with the other three macros I added. // Alan's macro plus my edits // 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\terry\Dropbox\Misc\All Results.txt" // Clear previous list of folders from text file Program Launch: "All Results.txt" (Normal) Parameters: Wait for Window Title: C:\Users\terry\Dropbox\Misc\All Results.txt] Text Type (Simulate Keystrokes): <CONTROL><HOME> // Go to start Delay: 0.1 seconds Text Type (Simulate Keystrokes): <CONTROL><SHIFT><END> // Select all text Delay: 0.1 seconds Text Type (Simulate Keystrokes): <DELETE> // Delete all text Delay: 0.1 seconds Text Type (Simulate Keystrokes): <CONTROL>s // Save the file // 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 "Latest -" Continue End If If Variable %Title% Contains ":\" Variable Modify Integer %Count%: Increment Variable Set String %Result[%Count%]% to "%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 // Save 'All Results.txt' End Switch Text Type (Simulate Keystrokes): <CONTROL>s // Save finished file
  6. 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/>
  7. Thanks both, much appreciated. Will explore your helpful ideas later, Cory. Meanwhile, Alan, I've just tested the macro you prepared while I slept! Looked solid to me. I duly set titles to show full path - that will need automating later if I go ahead with this little project - and created an empty file. My only edit was to line 5: Variable Set String %ResultsFile% to "C:\Users\terry\Dropbox\Misc\All Results.txt" But running it (from F9) gave a very interesting result here, which was consistent on repeating. It promptly closed ME Pro! Well, not quite; Script Editor and Explorer and the tray icon vanished but (on being unable to promptly restart) I found in Task Mgr that MacExp.exe was still loaded. One other exception I would be able to filter out easily: my text editor, TextPad, displays tiltles containing its 'child' windows, e.g: Latest - TextPad - [C:\Users\terry\Dropbox\Electronics\Arduino\WORKFLOW.txt] As you warn, there may be others. I'm going out soon but will pick it up again late today. -------------------- EDIT: Tuesday 14 January 2020, 0936 Alan: I should have postponed my testing until after breakfast, or at least my first coffee; your macro now works a treat! 🙂 When defining each of your variables after pasting, I'd failed to set %Result% as an array. I've added an IF to skip that TextPad folder and I'd also probably clear the text before each run. That would still leave steps to toggle the full folder title. But after sleeping on it I'm hesitating about proceeding. Background is that an Excel VBA macro I'm developing does not work properly under Win 10 due to some obscure bug in the latter's API (above my know how level), if there are any File Explorer folders open. Hence my thought of toggling them on and off. But I've since thought of a way of accomplishing that part of the VBA macro's objective by using an MEP macro instead. I've been trying hard to rise above my 'copy-paste-edit' mode of working with VBA. But it's a struggle for someone who has never learnt an object-orientated programming language. MEP macro writing is so much more intuitive ... although I do love the speed of VBA. Neat work Alan, thank you! EDIT: 14:00 Back home earlier than expected and went ahead after all. Even if not used for the originally intended purpose this could be useful for other work occasionally. So I now have macros to toggle the folder full title on, close all folders except TextPad, create All results.txt, restore folders, and toggle folder full title off. Thanks again for giving me a kick start.
  8. 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/>
  9. There is still an option to display the full path in the title bar. F4 will focus the address control and you could do Ctrl+A then clipboard copy. I'm guessing one could use a Macro Control commands also. But it might give the 'pretty' display text of the address control. You could also use the Copy Path command and drop the name of the file or folder selected. You could also fire off the Properties dialog and use the "Location" control.
  10. 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.
  11. Closing all Win 10 File Explorer folders at once is straightforward with this macro which simply uses the fixed position of the FE icon in the taskbar: Mouse Move: 164, 1182 Relative to Screen Delay: 0.1 seconds Mouse Right Click Delay: 0.3 seconds Mouse Move: 0, -38 Relative to Last Position Delay: 0.1 seconds Mouse Left Click Code: <MOUSE MOVE Option="\x01" X="164" Y="1182" _PROMPT="0x000A"/> <DELAY Flags="\x01" Time="0.1"/> <MOUSE RIGHT CLICK/> <DELAY Flags="\x01" Time="0.3"/> <MOUSE MOVE Option="\x03" X="0" Y="-38" _PROMPT="0x000A"/> <DELAY Flags="\x01" Time="0.1"/> <MOUSE LEFT CLICK/> But does anyone have any ideas on how to re-open them please? Presumably a matter of recording their full paths before they are closed, which eludes me right now. Half an hour searching the registry with targets like 'folders' and 'closed' found nothing relevant. Negative result from brief googling.
  12. Earlier
  13. There is nothing inherently risky about saving data in the registry as long as you know and remember which registry area (key) you use. Using the registry may be somewhat faster than reading from a file. However, depending on what your macro is doing, you may not notice the difference. There is a potential side effect of using values in the area of the registry (registry key) that Macro Express uses such as this: HKEY_CURRENT_USER\Software\Insight Software Solutions\Macro Express 6\My Values When you export the Macro Express settings (Tools, Export Program Configuration) and then import them either later (Tools, Import Program Configuration) Macro Express will display a warning about the registry keys and values that it does not recognize. It is pretty safe to use other areas of the registry such as HKEY_CURRENT_USER\Terry Work Area You could also use something like this: HKEY_CURRENT_USER\Software\Insight Software Solutions\Macro Express Data
  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. Hi Alan, I just found it easier to keep track by splitting into those two sub-keys. I've never tried other locations which instinctively seems risky!
  16. 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?
  17. Yes, me too. I chose a similar location, with separate keys for Integer and Text, and made it a 'Favorite' for fast access.
  18. 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
  19. 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.
  20. Yes to the compatibility question (although you may want to make some minor changes). You could also take advantage of the free 30 day trial. On a possible discount I’d check with Insight Support either by direct email or via their Support Request form if you don’t get a response from them here.
  21. I'm considering version 5. From what I see I'd need to pay the full $49 for version 5 and not a discounted upgrade from version 3. Is that correct? Not complaining just trying to understand. With version 5, I can still run all of my version 3 macros, Right?
  22. Gerry, I'd echo @acantor's suggestion to update to a current version. As you've discovered, 3.10 did not support arrays in the form we have now but in fact its entire variable structure was based on arrays. For example T[1], a unique string variable, was treated as the first in an array of 99. So if you do decide to stay with 3.10 then you could still follow the approach suggested, but it would be a little clumsier. Start with @cantor's code and tell us when you have difficulty progressing. Terry
  23. 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]%.
  24. I like your solution. Below is the commands for variables for ME 3.10. I didn't see array variable listed. I assume I can use one of the commands below to get this done. Can you give me some guidance? I've used ME for many years, but I'm still pretty basic in the macros I've created.
  25. 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
  26. Yes. There are several ways you could do it. For instance you could use an array variable set up to contain the group names and its index could match the count through the Repeat loop.
  1. Load more activity
×
×
  • Create New...