Jump to content
Macro Express Forums

acantor

Members
  • Posts

    1,534
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by acantor

  1. Another possible solution: In Firefox's about:config browser.backspace_action --> 0 Changing the value to zero will re-enable support for Backspace key as a Back button.
  2. I'm with Terry. Backspace is too pervasive, and it's used by too many applications, sometimes to do different things. (For example, in most browsers, pressing Backspace is the same as clicking the Back button.) I would think twice about using Backspace as a macro trigger, just like I would hesitate to use "E" or the down arrow or the spacebar. How about using Shift + Backspace? or Ctrl + Alt + Backspace?
  3. Hi Terry, I've been ignoring the notifications, and I haven't tried to chase down the source as Macro Express has continued to work. My sense is that the notifications are associated with certain scripts, but I'm not sure. I first noticed these notifications a couple of weeks ago. Next time it happens, I'll check further and report back.
  4. I'm not sure why you're having trouble with Text Type, but it sounds like you're finding it and using it. Wherever you are going to type "WIN F12" etc., return to the same screen and change it to this: <WIN><F12><WIN><F12><WIN><F12>
  5. Hi Terry, I've noticed the identical message recently, although the messages have not, so far, prevented me from continuing on with whatever I was doing.
  6. Here is a refined version: The macro now reports the number of contained files and subfolders as well as the total size of the parent folder. It reformats the text to improve legibility in the message box. For example, the macro displays size in GB, not in bytes. I tweaked the logic, renamed variables to make them (hopefully) easier to understand, etc. This macro was supposed to be for a client, but I think I'll make more use of it than he will! // In File Explorer, for the selected folder, display in a message box: // 1. The number of files and folders it contains // 2. The total size of all subfolders and files contained in the folder // Start with a *folder* selected in File Explorer -- selecting a file may or may not work Text Type (Simulate Keystrokes): <ALT><ENTER> // Open the "Properties" screen for the selected item Delay: 500 milliseconds // Wait for the "Properties" screen to open Variable Set String %WinTitle% to topmost window title // Get the title bar of the "Properties" screen // The script cannot handle this situation! If Variable %WinTitle% Contains "OS (" MessageBox: Cannot get the size! Macro Stop End If // The macro clicks in the centre of the "Size" field. Later, it clicks in the centre of the "Contains" field. // The horizontal centre of the "Size" field is 45% of the screen width from the left edge. // The vertical centre varies. Depending on the height of the "Properties" window... // ...the "Size" field is in one of two locations: 37% or 40% of the distance from the top. // The horizontal centre of the "Contains" field is 30% of the screen width from the left edge. // The vertical centre varies. Depending on the height of the "Properties" window... // ...the "Contains" field is in one of two locations: 48% or 50% of the distance from the top. // So set two "fudge factors" to use to calculate y-coordinates of the two fields // The most common fudge factors: Variable Set Decimal %SizeFudgeFactor% to 0.37 Variable Set Decimal %ContainsFudgeFactor% to 0.48 // Less common fudge factors: If Variable %WinTitle% Equals "Documents Properties" OR If Variable %WinTitle% Equals "Music Properties" OR If Variable %WinTitle% Equals "Videos Properties" OR If Variable %WinTitle% Equals "Pictures Properties" Variable Set Decimal %SizeFudgeFactor% to 0.4 Variable Set Decimal %ContainsFudgeFactor% to 0.5 End If // Get the width and height of the "Properties" screen Variable Set Integer %Width%: Set to the Current Window's Width Variable Set Integer %Height%: Set to the Current Window's Height // Convert to decimal so values can be muliplied by fudge factors (which are fractions) Variable Modify Integer %Width%: Convert to Decimal (%WidthDecimal%) Variable Modify Integer %Height%: Convert to Decimal (%HeightDecimal%) // Estimate coordinates for the centre of the "Size" field Variable Modify Decimal: %SizeXDecimal% = %WidthDecimal% * 0.45 Variable Modify Decimal: %SizeYDecimal% = %HeightDecimal% * %SizeFudgeFactor% Variable Modify Decimal %SizeXDecimal%: Truncate to Integer (%SizeXInteger%) Variable Modify Decimal %SizeYDecimal%: Truncate to Integer (%SizeYInteger%) // Estimate coordinates for the centre of the "Contains" field Variable Modify Decimal: %ContainsXDecimal% = %HeightDecimal% * 0.3 Variable Modify Decimal: %ContainsYDecimal% = %HeightDecimal% * %ContainsFudgeFactor% Variable Modify Decimal %ContainsXDecimal%: Truncate to Integer (%ContainsXInteger%) Variable Modify Decimal %ContainsYDecimal%: Truncate to Integer (%ContainsYInteger%) // Check every 0.5 second for 20 seconds to see if the "Size" field has changed Variable Set String %FieldCapture2% to "" Repeat Start (Repeat 40 times) Mouse Move: %SizeXInteger%, %SizeYInteger% Relative to Current Window // Centre of the "Size" field Mouse Left Click Text Type (Simulate Keystrokes): <HOME><SHIFT><END> // Select the "Size" field Text Type (Simulate Keystrokes): <CONTROL>c Delay: 50 milliseconds Variable Set String %FieldCapture1% from the clipboard contents Delay: 50 milliseconds If Variable %FieldCapture1% Equals "%FieldCapture2%" // Is "Size" field unchanged after two consecutive loops? Variable Set Bool %IsSizeFound% to "True" // Then we've captured the size! Repeat Exit Else Variable Set String %FieldCapture2% to "%FieldCapture1%" Delay: 500 milliseconds End If End Repeat If Variable %IsSizeFound% Equals "True" // Capture content of "Contains" field Mouse Move: %ContainsXInteger%, %ContainsYInteger% Relative to Current Window // Centre of the "Contains" field Mouse Left Click Text Type (Simulate Keystrokes): <HOME><SHIFT><END> // Select the "Contains" field Text Type (Simulate Keystrokes): <CONTROL>c Delay: 50 milliseconds Variable Set String %Contains% from the clipboard contents Text Type (Simulate Keystrokes): <ESC> // Close the "Properties" window // Reformat "Size" to delete everything inside parentheses Variable Set String %Size% to "%FieldCapture1%" Variable Set Integer %LengthSize% to the length of variable %Size% Variable Set Integer %OpenParenPos% to the position of "(" in %Size% Variable Modify String: Delete part of text from %Size% starting at %OpenParenPos% and %LengthSize% characters long // Reformat "Contains" so Files and Folders are on separate lines Variable Modify String: Replace "Files, " in %Contains% with "Files " // Output result MessageBox: Info from "%WinTitle%" Else // Report that we couldn't get solutions MessageBox: The macro failed! End If <COMMENT Value="In File Explorer, for the selected folder, display in a message box: "/> <COMMENT/> <COMMENT Value="1. The number of files and folders it contains"/> <COMMENT Value="2. The total size of all subfolders and files contained in the folder"/> <COMMENT/> <COMMENT Value="Start with a *folder* selected in File Explorer -- selecting a file may or may not work"/> <TEXT TYPE Action="0" Text="<ALT><ENTER>" _COMMENT="Open the \"Properties\" screen for the selected item"/> <DELAY Flags="\x02" Time="500" _COMMENT="Wait for the \"Properties\" screen to open"/> <COMMENT/> <VARIABLE SET STRING Option="\x05" Destination="%WinTitle%" _COMMENT="Get the title bar of the \"Properties\" screen"/> <COMMENT/> <COMMENT Value="The script cannot handle this situation!"/> <IF VARIABLE Variable="%WinTitle%" Condition="\x06" Value="OS (" IgnoreCase="FALSE"/> <MESSAGEBOX Caption="Cannot get the size!" Message="This script doesn't work in \"%WinTitle%\"!" Icon="4"/> <MACRO STOP/> <END IF/> <COMMENT/> <COMMENT Value="The macro clicks in the centre of the \"Size\" field. Later, it clicks in the centre of the \"Contains\" field."/> <COMMENT/> <COMMENT Value="The horizontal centre of the \"Size\" field is 45% of the screen width from the left edge."/> <COMMENT Value="The vertical centre varies. Depending on the height of the \"Properties\" window..."/> <COMMENT Value="...the \"Size\" field is in one of two locations: 37% or 40% of the distance from the top."/> <COMMENT/> <COMMENT Value="The horizontal centre of the \"Contains\" field is 30% of the screen width from the left edge."/> <COMMENT Value="The vertical centre varies. Depending on the height of the \"Properties\" window..."/> <COMMENT Value="...the \"Contains\" field is in one of two locations: 48% or 50% of the distance from the top."/> <COMMENT/> <COMMENT Value="So set two \"fudge factors\" to use to calculate y-coordinates of the two fields"/> <COMMENT/> <COMMENT Value="The most common fudge factors:"/> <VARIABLE SET DECIMAL Option="\x00" Destination="%SizeFudgeFactor%" Value="0.37"/> <VARIABLE SET DECIMAL Option="\x00" Destination="%ContainsFudgeFactor%" Value="0.48"/> <COMMENT/> <COMMENT Value="Less common fudge factors:"/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Documents Properties" IgnoreCase="FALSE"/> <OR/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Music Properties" IgnoreCase="FALSE"/> <OR/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Videos Properties" IgnoreCase="FALSE"/> <OR/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Pictures Properties" IgnoreCase="FALSE"/> <VARIABLE SET DECIMAL Option="\x00" Destination="%SizeFudgeFactor%" Value="0.4"/> <VARIABLE SET DECIMAL Option="\x00" Destination="%ContainsFudgeFactor%" Value="0.5"/> <END IF/> <COMMENT/> <COMMENT Value="Get the width and height of the \"Properties\" screen"/> <VARIABLE SET INTEGER Option="\x0A" Destination="%Width%"/> <VARIABLE SET INTEGER Option="\x0B" Destination="%Height%"/> <COMMENT/> <COMMENT Value="Convert to decimal so values can be muliplied by fudge factors (which are fractions)"/> <VARIABLE MODIFY INTEGER Option="\x05" Destination="%Width%" Variable="%WidthDecimal%"/> <VARIABLE MODIFY INTEGER Option="\x05" Destination="%Height%" Variable="%HeightDecimal%"/> <COMMENT/> <COMMENT Value="Estimate coordinates for the centre of the \"Size\" field"/> <VARIABLE MODIFY DECIMAL Option="\x02" Destination="%SizeXDecimal%" Value1="%WidthDecimal%" Value2="0.45"/> <VARIABLE MODIFY DECIMAL Option="\x02" Destination="%SizeYDecimal%" Value1="%HeightDecimal%" Value2="%SizeFudgeFactor%"/> <COMMENT/> <VARIABLE MODIFY DECIMAL Option="\x06" Destination="%SizeXDecimal%" Variable="%SizeXInteger%"/> <VARIABLE MODIFY DECIMAL Option="\x06" Destination="%SizeYDecimal%" Variable="%SizeYInteger%"/> <COMMENT/> <COMMENT Value="Estimate coordinates for the centre of the \"Contains\" field"/> <VARIABLE MODIFY DECIMAL Option="\x02" Destination="%ContainsXDecimal%" Value1="%HeightDecimal%" Value2="0.3"/> <VARIABLE MODIFY DECIMAL Option="\x02" Destination="%ContainsYDecimal%" Value1="%HeightDecimal%" Value2="%ContainsFudgeFactor%"/> <COMMENT/> <VARIABLE MODIFY DECIMAL Option="\x06" Destination="%ContainsXDecimal%" Variable="%ContainsXInteger%"/> <VARIABLE MODIFY DECIMAL Option="\x06" Destination="%ContainsYDecimal%" Variable="%ContainsYInteger%"/> <COMMENT/> <COMMENT Value="Check every 0.5 second for 20 seconds to see if the \"Size\" field has changed"/> <VARIABLE SET STRING Option="\x00" Destination="%FieldCapture2%" NoEmbeddedVars="FALSE"/> <COMMENT/> <REPEAT START Start="1" Step="1" Count="40" Save="TRUE" Variable="%Count%"/> <MOUSE MOVE Option="\x02" X="%SizeXInteger%" Y="%SizeYInteger%" Control="%PropertyControl%" _PROMPT="0x000A" _COMMENT="Centre of the \"Size\" field"/> <MOUSE LEFT CLICK/> <TEXT TYPE Action="0" Text="<HOME><SHIFT><END>" _COMMENT="Select the \"Size\" field"/> <TEXT TYPE Action="0" Text="<CONTROL>c"/> <DELAY Flags="\x02" Time="50"/> <VARIABLE SET STRING Option="\x02" Destination="%FieldCapture1%" NoEmbeddedVars="FALSE"/> <DELAY Flags="\x02" Time="50"/> <COMMENT/> <IF VARIABLE Variable="%FieldCapture1%" Condition="\x00" Value="%FieldCapture2%" IgnoreCase="FALSE" _COMMENT="Is \"Size\" field unchanged after two consecutive loops?"/> <VARIABLE SET BOOL Destination="%IsSizeFound%" Command="263" Value="TRUE" _COMMENT="Then we've captured the size!"/> <REPEAT EXIT/> <ELSE/> <VARIABLE SET STRING Option="\x00" Destination="%FieldCapture2%" Value="%FieldCapture1%" NoEmbeddedVars="FALSE"/> <DELAY Flags="\x02" Time="500"/> <END IF/> <COMMENT/> <END REPEAT/> <COMMENT/> <IF VARIABLE Variable="%IsSizeFound%" Condition="\x00" Value="True" IgnoreCase="FALSE"/> <COMMENT Value="Capture content of \"Contains\" field"/> <MOUSE MOVE Option="\x02" X="%ContainsXInteger%" Y="%ContainsYInteger%" Control="%PropertyControl%" _PROMPT="0x000A" _COMMENT="Centre of the \"Contains\" field"/> <MOUSE LEFT CLICK/> <TEXT TYPE Action="0" Text="<HOME><SHIFT><END>" _COMMENT="Select the \"Contains\" field"/> <TEXT TYPE Action="0" Text="<CONTROL>c"/> <DELAY Flags="\x02" Time="50"/> <VARIABLE SET STRING Option="\x02" Destination="%Contains%" NoEmbeddedVars="FALSE"/> <COMMENT/> <TEXT TYPE Action="0" Text="<ESC>" _COMMENT="Close the \"Properties\" window"/> <COMMENT/> <COMMENT Value="Reformat \"Size\" to delete everything inside parentheses"/> <VARIABLE SET STRING Option="\x00" Destination="%Size%" Value="%FieldCapture1%" NoEmbeddedVars="FALSE"/> <VARIABLE SET INTEGER Option="\x0D" Destination="%LengthSize%" Text_Variable="%Size%"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%OpenParenPos%" Text_Variable="%Size%" Text="(" Ignore_Case="FALSE"/> <VARIABLE MODIFY STRING Option="\x0A" Destination="%Size%" Start="%OpenParenPos%" Count="%LengthSize%"/> <COMMENT/> <COMMENT Value="Reformat \"Contains\" so Files and Folders are on separate lines"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%Contains%" ToReplace="Files, " ReplaceWith="Files\r\n" All="FALSE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <COMMENT/> <COMMENT Value="Output result"/> <MESSAGEBOX Caption="Info from \"%WinTitle%\"" Message="%Contains%\r\n\r\n%Size%\r\n\r\n(Iterations: %Count%)" Icon="2"/> <ELSE/> <COMMENT Value="Report that we couldn't get solutions"/> <MESSAGEBOX Caption="The macro failed!" Message="Best guess for size: %FieldCapture1%\r\n\r\n(Iterations: %Count%)" Icon="4"/> <END IF/>
  7. I keep that checkbox unticked. I receive no prompts or notifications when I create new variables. Macro Express almost always correctly guesses the variable type, so not getting prompted is a time saver. But when the guess is wrong, it's quick to fix.
  8. I'm not sure what the difference is between "Size" and "Size on Disk," but the two values do not appear to be exactly the same. Could that account for the discrepancy? Now that I'm actually using this macro myself, I'm realizing it might be handy if it also reported the number of folders and files inside the folder, as well as the size of all those files and sub-folders
  9. My macro also reports how many times the macro cycled through the repeat loop: It says nine iterations. I'd estimate each loop takes 1.5 seconds, so total was close to 15 seconds. The value exactly matches the value on the "Properties" screen.
  10. I consider this an interim solution... the shell method seems like it would be far less flaky. Nevertheless, it's fun to witness this macro monitoring the "Size" field... // In File Explorer, display the size of the selected folder in a message box // Set File Explorer to display the full path in the title bar! // Start with a *folder* selected in File Explorer -- selecting a file may or may not work Text Type (Simulate Keystrokes): <ALT><ENTER> // Open Properties for the selected item Delay: 500 milliseconds // Wait for the Properties screen to open Variable Set String %WinTitle% to topmost window title // Get the full path from the title bar If Variable %WinTitle% Contains "OS (" // The script cannot handle this situation! MessageBox: Cannot get the size! Macro Stop End If // Prepare to click in the centre of the "Size" field. // The centre of the "Size" field, horizontally, is about 45% of the screen width from the left edge. // But the vertical position varies. Depending on which Properties window opens... // ...the "Size" field can be in one of two locations: 37% or 40% of the distance from the top. // So set a "fudge factor" based on the window title and calculate the y-coordinate. Variable Set Decimal %FudgeFactor% to 0.37 // This is the most common fudge factor If Variable %WinTitle% Equals "Documents Properties" OR If Variable %WinTitle% Equals "Music Properties" OR If Variable %WinTitle% Equals "Videos Properties" OR If Variable %WinTitle% Equals "Pictures Properties" Variable Set Decimal %FudgeFactor% to 0.4 End If // Calculate where to click relative to the height and width of a "Properties" screen Variable Set Integer %Width%: Set to the Current Window's Width Variable Set Integer %Height%: Set to the Current Window's Height Variable Modify Integer %Width%: Convert to Decimal (%WidthDecimal%) Variable Modify Integer %Height%: Convert to Decimal (%HeightDecimal%) Variable Modify Decimal: %TargetXDecimal% = %WidthDecimal% * 0.45 Variable Modify Decimal: %TargetYDecimal% = %HeightDecimal% * %FudgeFactor% Variable Modify Decimal %TargetXDecimal%: Truncate to Integer (%TargetXInteger%) Variable Modify Decimal %TargetYDecimal%: Truncate to Integer (%TargetYInteger%) // Check once a second for 20 seconds to see if the "Size" field has changed Variable Set String %FieldCapture2% to "" Repeat Start (Repeat 20 times) Mouse Move: %TargetXInteger%, %TargetYInteger% Relative to Current Window // Centre of the "Size" field Mouse Left Click Text Type (Simulate Keystrokes): <HOME><SHIFT><END> // Select the field Text Type (Simulate Keystrokes): <CONTROL>c Delay: 50 milliseconds Variable Set String %FieldCapture1% from the clipboard contents Delay: 50 milliseconds If Variable %FieldCapture1% Equals "%FieldCapture2%" // Are values equal after consecutive loops? Then done! Text Type (Simulate Keystrokes): <ESC> // Close the "Properties" window MessageBox: Size of Folder Macro Stop End If Variable Set String %FieldCapture2% to "%FieldCapture1%" Delay: 1000 milliseconds End Repeat MessageBox: Best Guess of the Size of Folder <COMMENT Value="In File Explorer, display the size of the selected folder in a message box"/> <COMMENT Value="Set File Explorer to display the full path in the title bar!"/> <COMMENT/> <COMMENT Value="Start with a *folder* selected in File Explorer -- selecting a file may or may not work"/> <TEXT TYPE Action="0" Text="<ALT><ENTER>" _COMMENT="Open Properties for the selected item"/> <DELAY Flags="\x02" Time="500" _COMMENT="Wait for the Properties screen to open"/> <COMMENT/> <VARIABLE SET STRING Option="\x05" Destination="%WinTitle%" _COMMENT="Get the full path from the title bar"/> <COMMENT/> <IF VARIABLE Variable="%WinTitle%" Condition="\x06" Value="OS (" IgnoreCase="FALSE" _COMMENT="The script cannot handle this situation!"/> <MESSAGEBOX Caption="Cannot get the size!" Message="This script doesn't work in \"%WinTitle%\"!" Icon="4"/> <MACRO STOP/> <END IF/> <COMMENT/> <COMMENT Value="Prepare to click in the centre of the \"Size\" field."/> <COMMENT Value="The centre of the \"Size\" field, horizontally, is about 45% of the screen width from the left edge."/> <COMMENT Value="But the vertical position varies. Depending on which Properties window opens..."/> <COMMENT Value="...the \"Size\" field can be in one of two locations: 37% or 40% of the distance from the top."/> <COMMENT Value="So set a \"fudge factor\" based on the window title and calculate the y-coordinate."/> <VARIABLE SET DECIMAL Option="\x00" Destination="%FudgeFactor%" Value="0.37" _COMMENT="This is the most common fudge factor"/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Documents Properties" IgnoreCase="FALSE"/> <OR/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Music Properties" IgnoreCase="FALSE"/> <OR/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Videos Properties" IgnoreCase="FALSE"/> <OR/> <IF VARIABLE Variable="%WinTitle%" Condition="\x00" Value="Pictures Properties" IgnoreCase="FALSE"/> <VARIABLE SET DECIMAL Option="\x00" Destination="%FudgeFactor%" Value="0.4"/> <END IF/> <COMMENT/> <COMMENT Value="Calculate where to click relative to the height and width of a \"Properties\" screen"/> <VARIABLE SET INTEGER Option="\x0A" Destination="%Width%"/> <VARIABLE SET INTEGER Option="\x0B" Destination="%Height%"/> <COMMENT/> <VARIABLE MODIFY INTEGER Option="\x05" Destination="%Width%" Variable="%WidthDecimal%"/> <VARIABLE MODIFY INTEGER Option="\x05" Destination="%Height%" Variable="%HeightDecimal%"/> <COMMENT/> <VARIABLE MODIFY DECIMAL Option="\x02" Destination="%TargetXDecimal%" Value1="%WidthDecimal%" Value2="0.45"/> <VARIABLE MODIFY DECIMAL Option="\x02" Destination="%TargetYDecimal%" Value1="%HeightDecimal%" Value2="%FudgeFactor%"/> <COMMENT/> <VARIABLE MODIFY DECIMAL Option="\x06" Destination="%TargetXDecimal%" Variable="%TargetXInteger%"/> <VARIABLE MODIFY DECIMAL Option="\x06" Destination="%TargetYDecimal%" Variable="%TargetYInteger%"/> <COMMENT/> <COMMENT Value="Check once a second for 20 seconds to see if the \"Size\" field has changed"/> <VARIABLE SET STRING Option="\x00" Destination="%FieldCapture2%" NoEmbeddedVars="FALSE"/> <COMMENT/> <REPEAT START Start="1" Step="1" Count="20" Save="TRUE" Variable="%Count%"/> <MOUSE MOVE Option="\x02" X="%TargetXInteger%" Y="%TargetYInteger%" Control="%PropertyControl%" _PROMPT="0x000A" _COMMENT="Centre of the \"Size\" field"/> <MOUSE LEFT CLICK/> <TEXT TYPE Action="0" Text="<HOME><SHIFT><END>" _COMMENT="Select the field"/> <TEXT TYPE Action="0" Text="<CONTROL>c"/> <DELAY Flags="\x02" Time="50"/> <VARIABLE SET STRING Option="\x02" Destination="%FieldCapture1%" NoEmbeddedVars="FALSE"/> <DELAY Flags="\x02" Time="50"/> <COMMENT/> <IF VARIABLE Variable="%FieldCapture1%" Condition="\x00" Value="%FieldCapture2%" IgnoreCase="FALSE" _COMMENT="Are values equal after consecutive loops? Then done!"/> <TEXT TYPE Action="0" Text="<ESC>" _COMMENT="Close the \"Properties\" window"/> <MESSAGEBOX Caption="Size of Folder" Message="%FieldCapture1%\r\n\r\n(Iterations: %Count%)" Icon="2"/> <MACRO STOP/> <END IF/> <VARIABLE SET STRING Option="\x00" Destination="%FieldCapture2%" Value="%FieldCapture1%" NoEmbeddedVars="FALSE"/> <DELAY Flags="\x02" Time="1000"/> <END REPEAT/> <MESSAGEBOX Caption="Best Guess of the Size of Folder" Message="%FieldCapture1%\r\n\r\n(Iterations: %Count%)" Icon="2"/>
  11. OK, I give up! Using Macro Express, how did you shell out to the prompt AND send a command to the command line AND exit cmd.exe?
  12. Hi Terry, My original version used <ALT><ENTER> to open the "Properties" window instead of a simulated right click; and my version clicks in the centre of the "Size" field and presses <HOME><SHIFT><END> to select the field. Otherwise, our scripts are more-or-less identical. (This is a good example of great minds thinking alike! ) Based on the similarity of our scripts, I'm confident that yours will not report accurate information when you request the size of a folder that contains many subfolders and files. Try it, for example, with c:\Windows Also, compare the results with any of the folders that are here: C:\Users\[your user name] with any of the folders that are here: C:\Users\[your user name]\Documents My current solution has workarounds for these kinds of problems... but dammit, I will try a solution based on DOS commands!
  13. Terry, your solution is similar to my first attempt. My script worked nicely. With use, I discovered three circumstances that caused my script to fail: 1. The time to populate the "Size" field ranges from almost instantaneously, to ten or more seconds. The lag is related to the number of subfolders and files that are inside the folder. 2. The layout of various "Properties" screens differs, which means the "Size" field isn't always in the same place. So clicking on fixed coordinates sometimes succeeds, sometimes fails. 3. There is at least one "Properties" screen that doesn't allow fields to be selected! Argg!! I think I solved the first and second failures, but the third may not be amenable to a solution based on grabbing information from the Properties screen. The alternative technique originally suggested by rberq is starting to look more and more appealing.
  14. Hi Terry, I hope these clarifications help. Make the macro act on the one folder a user has selected in File Explorer. He uses two methods to select files and folders in Windows File Explorer. 1. Press arrow keys; and 2. Use the incremental search built-into the list view: quickly type the first characters of the file or folder he wants to reach For both methods, it helps if File Explorer "View" is set to "Details." (Changing the view is not mandatory, but screen reader navigation is generally easier if the folder view is set to either "Details" or "List.") For the purpose of this challenge, there's no need to deep-dive into Jaws capabilities. So my answer is a simplification: Jaws can easily read text that can be given focus as a result of pressing sequences of: the four arrow keys; Tab; the alphanumeric keys; space bar; Enter; Shift, Ctrl, and Alt; and a handful of other keys. Applied to File Explorer: use the arrow keys to navigate through the list of folders. Press Enter to open a folder. It's not possible to use these keys to give focus to a tooltip. So Jaws cannot easily read tooltips. (It can be done… but it's complex!) Jaws can read columnar information in applications that have been designed with accessibility in mind. Not sure TreeSize is one of those! And even if it was, and even if my client might be better served by switching to a better file manager, the challenge is to come up with a solution for File Explorer!
  15. Ah... The two numbers almost match when I change the DOS command to this... dir /s c:/windows | find "(s)" However, there are hundreds of matches to (s) so the approach is still going to take string manipulation.
  16. I'm not sure rberq's and terry's clever solution is giving accuracy results! I checked the folder size for c:\windows in two ways: 1. From the command line: dir c:\windows | find "(s)" 2. From the Properties screen for c:\Windows Here are the results: Any ideas about which value is correct? Perhaps both are wrong??
  17. JAWS is not an easy program to learn, never mind master. And to begin to climb that steep learning curve, there is a prerequisite: the ability to perform everyday tasks using only the keyboard. In other words, drop the mouse behind your desk, and don't touch it! When I was learning JAWS, I found it helpful to close my eyes – a lot. For those of us who have habituated to performing computer tasks visually, I found that watching the screen interfered with learning the skills necessary to control a computer auditorily.
  18. That would be a far more elegant solution than mine... But will it work?
  19. One of my clients is a tech-savvy blind guy. He accesses his computer via JAWS, a screen reader application. A screen reader is software, driven by pressing keys, that reads screen content out loud. He uses the Windows File Explorer to manage his folders and files. He has set File Explorer to always be in "Details" view. When configured this way, he can easily read the names of all documents and folders contained in a folder, the last date a file or folder was modified, and the file type: Although he needs to keep track of the sizes of files and folders, File Explorer only shows the size of files. It does not show the size of folders. (See red box, above.) The reason: performance. If folder sizes were displayed, every time a user navigates through a folder structure, Windows would need to scan subfolders and files, record the sizes of every object, and sum them. This would require significant processor overhead. The way to obtain the size of a folder is to open its "Properties" window. When Properties opens, Windows starts scanning the folder. On my computer, it takes nine or ten seconds to calculate the size of a folder that contains many subfolders and files. The Properties window is challenging to navigate with a screen reader. Why? The short explanation is that it's not possible to reach the "Size" field by pressing the Tab key. (It can be done, but requires more work.) The challenge: Use Macro Express to write a hotkey macro for the main File Explorer User Interface that reports, in a message box, the size of the selected folder:
  20. Sigh. You're probably right, rberq. I guess there's nothing wrong with boundary conditions and special cases, especially when they are inherent to a problem! I did think of two workarounds; but as you point out, workarounds have the potential to introduce additional complexity and convoluted logic: 1. Deal with the first character, and then move on to the main repeat loop to deal with the second through to the last character. 2. Parse the string from the end instead of the beginning. But that would mean spitting out the result in reverse order, which is do-able with Macro Express; but then we've added complexity. Or I can imagine strings that consist of an odd number of characters may need to be handled differently than strings than consist of an even number of characters. All of a sudden, that single space I slipped into the beginning of the string doesn't seem so bad. Me too!
  21. Here's my solution. I had two aha! "lightbulb" moments as I worked on the problem. 1. I realized that characters are either alphabetical letters, or they are not alphabetical letters. Call the first group "letters" and the second group "non-letters." The latter includes punctuation, symbols, spaces, Tabs, CRs, etc. A word always starts with a "non-letter" before a "letter": "Hello (Hello [space]Hello [Tab]Hello [New Line]Hello 2. I realized that it isn't necessary to convert characters to ASCII codes. Instead, I defined a list of alphabetical characters: Let %Alphabet% = "abc...xyz" Test if %Alphabet% CONTAINS a character. For example, if %Alphabet% contains "m" then the character must be a letter. If %Alphabet% doesn't contain a "letter" -- e.g., a space, digit, or punctuation mark -- it must be a non-letter. Eventually, I expanded %Alphabet% to include letters that appear in borrow-words like voilà, über, and señor. The "cringe-worthy" concession was being forced to add a non-letter to the start of the string. The macro inspects each character; if a character is a "letter," then it inspects the previous character. But while the script is inspecting the first character in the string, there is no previous character. So the character must be added to the left before the string is processed, and stripped off after the string has been processed. It's ugly, but I couldn't think of a clean workaround! This script has at least one limitation. A convention in academic writing is to use brackets or parentheses in the middle of a word to denote letter substitutions. Usually the capitalization has been changed in a quotation. For example: Smith wrote, "[t]here is no way." The macro changes it to S w, "[t]h i n w." instead of S w, "[t] i n w." But I view this "failure" as totally inconsequential for the needs of my friend the storyteller! My first effort, before the aha! moments, involved about 50 lines of spaghetti code. This version has only 21. I came up with a 19-line version, but it was harder to follow. I decided clarity should trump brevity. // Delete all but the first letter of every word. Preserve spaces, digits, punctuation, line breaks, etc. // How this script decides a character is the first letter in a word // Assume every character belongs to one of two groups: // 1. "Letters." I've included 54 letters from English, French, Spanish, Italian, German, & Dutch alphabets // 2. "Non-letters." Everything that is not a letter: digits, punctuations, spaces, CRs, LFs, etc. // The first character of a word is always a "letter" and // The character to its left is a "non-letter" Variable Set String %Alphabet% to "abcedefghijklmnopqrstuvwxyzáàâäæçéèêëíìîïñóòôöœßúùûüýÿ" Clipboard Copy Variable Set String %Clip% from the clipboard contents Variable Set String %Clip% to " %Clip%" // Prepend a space: need a non-letter to the left of character 1 // Check each character, one at a time, from left to right Variable Set Integer %NumberOfCharacters% to the length of variable %Clip% Repeat Start (Repeat %NumberOfCharacters% times) Variable Modify String: Copy part of text in %Clip% starting at %Count% and 1 characters long to %Char% If Variable %Alphabet% Contains "%Char%" // The CURRENT character is a letter, so check the PREVIOUS character Variable Modify Integer: %PrevCount% = %Count% - 1 Variable Modify String: Copy part of text in %Clip% starting at %PrevCount% and 1 characters long to %PrevChar% If Variable %Alphabet% Does not Contain "%PrevChar%" // The PREVIOUS character is a non-letter. Ergo, the CURRENT character is the first letter of a word Variable Set String %Result% to "%Result%%Char%" // Append current character to %Result% End If Else // The CURRENT character is not a letter, so we want to keep it Variable Set String %Result% to "%Result%%Char%" // Append current character to %Result% End If Variable Modify Integer %Count%: Increment End Repeat Variable Modify String: Delete part of text from %Result% starting at 1 and 1 characters long // Delete the space added above Text Type (Simulate Keystrokes): <ARROW RIGHT><ENTER><ENTER> // Deselect and add two blank lines Text Type (Use Clipboard and Paste Text): %Result% <COMMENT Value="Delete all but the first letter of every word. Preserve spaces, digits, punctuation, line breaks, etc."/> <COMMENT/> <COMMENT Value="How this script decides a character is the first letter in a word"/> <COMMENT Value="Assume every character belongs to one of two groups:"/> <COMMENT Value="1. \"Letters.\" I've included 54 letters from English, French, Spanish, Italian, German, & Dutch alphabets"/> <COMMENT Value="2. \"Non-letters.\" Everything that is not a letter: digits, punctuations, spaces, CRs, LFs, etc."/> <COMMENT/> <COMMENT Value="The first character of a word is always a \"letter\" and"/> <COMMENT Value="The character to its left is a \"non-letter\""/> <COMMENT/> <VARIABLE SET STRING Option="\x00" Destination="%Alphabet%" Value="abcedefghijklmnopqrstuvwxyzáàâäæçéèêëíìîïñóòôöœßúùûüýÿ" NoEmbeddedVars="FALSE"/> <COMMENT/> <CLIPBOARD COPY/> <COMMENT/> <VARIABLE SET STRING Option="\x02" Destination="%Clip%" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%Clip%" Value=" %Clip%" NoEmbeddedVars="FALSE" _COMMENT="Prepend a space: need a non-letter to the left of character 1"/> <COMMENT/> <COMMENT Value="Check each character, one at a time, from left to right"/> <VARIABLE SET INTEGER Option="\x0D" Destination="%NumberOfCharacters%" Text_Variable="%Clip%"/> <COMMENT/> <REPEAT START Start="1" Step="1" Count="%NumberOfCharacters%" Save="TRUE" Variable="%Count%"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Clip%" Start="%Count%" Count="1" NoEmbeddedVars="FALSE"/> <IF VARIABLE Variable="%Alphabet%" Condition="\x06" Value="%Char%" IgnoreCase="TRUE"/> <COMMENT Value="The CURRENT character is a letter, so check the PREVIOUS character"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%PrevCount%" Value1="%Count%" Value2="1"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%PrevChar%" Variable="%Clip%" Start="%PrevCount%" Count="1" NoEmbeddedVars="FALSE"/> <IF VARIABLE Variable="%Alphabet%" Condition="\x07" Value="%PrevChar%" IgnoreCase="TRUE"/> <COMMENT Value="The PREVIOUS character is a non-letter. Ergo, the CURRENT character is the first letter of a word"/> <VARIABLE SET STRING Option="\x00" Destination="%Result%" Value="%Result%%Char%" NoEmbeddedVars="FALSE" _COMMENT="Append current character to %Result%"/> <END IF/> <ELSE/> <COMMENT Value="The CURRENT character is not a letter, so we want to keep it"/> <VARIABLE SET STRING Option="\x00" Destination="%Result%" Value="%Result%%Char%" NoEmbeddedVars="FALSE" _COMMENT="Append current character to %Result%"/> <END IF/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%Count%"/> <END REPEAT/> <COMMENT/> <VARIABLE MODIFY STRING Option="\x0A" Destination="%Result%" Start="1" Count="1" _COMMENT="Delete the space added above"/> <COMMENT/> <TEXT TYPE Action="0" Text="<ARROW RIGHT><ENTER><ENTER>" _COMMENT="Deselect and add two blank lines"/> <TEXT TYPE Action="1" Text="%Result%"/>
  22. Wow! What a lot of work you funneled into this challenge. It's impressive that you managed to hold so much complexity together. I tested your code with real-world examples, and it worked... except for one tiny miss. Not all digits are getting preserved. Your script seems to treat a string of digits like a string of letters, so "1234 Main St." emerges as "1 M S." instead of "1234 M S." Your approach of appending a "garbage" string to the end of a text, and then processing the text until the garbage string is reached, is eminently steal-able. Clever. I'm going to try that!
  23. You're so close! My first attempts had similar problems. After many tweaks, I finally managed to get the macro to work. But when I reviewed my code later, I couldn't follow the logic. The script had degenerated into a twisted mess of cascading IF-THEN statements, ranges of ASCII values, and multiple Boolean variables. I tinkered with the code in an effort to render it understandable, but every simplification "broke" the macro. I awoke the next morning with an idea for a different method, similar to Cory's. When I tried it, my new macro ALMOST worked. I made one (ugly) change and it worked. Compared to the original, the new macro has half the code and runs a little faster.
  24. Could you give an example of a text that does NOT transform properly? Reading your post makes me nervous that I didn't test my solution carefully enough! Although I didn't say this when issuing this challenge, perhaps this clarification is in order. Before abbreviation, the text should follow English-language rules for punctuation, spacing, use of symbols, etc. In other words, there's no expectation that the macro will work on non-standard mashups of symbols, punctuation marks, numbers, and letters, like this: %g 4,/rtR< +G.$p ?t'9
×
×
  • Create New...