Jump to content
Macro Express Forums

terrypin

Members
  • Content Count

    2,015
  • Joined

  • Last visited

  • Days Won

    17

Everything posted by terrypin

  1. Is 1 second long enough to allow a complex app like CASPER to open and stabilise? Try adding a Wait for Window Title.
  2. As for my intended approach, getting the 7-character groups into an array proved easy enough. But my assumption that the subsequent manipulation of these would be easy was over optimistic! Your solution, Alan, incorporating @rberg’s substitution logic looks great to me, well done, and thanks for an interesting thread. (Trivial point: it seems you switched to using A instead of L for alphabetic characters, so your introductory comment needs editing.) But wish I had learnt VBS 😉
  3. @rberg: Neat! Could you post the code so I can explore it further please, as I haven't grasped how it handles an address containing special chars.
  4. Hi Alan, I'm sorely tempted, but that would mean raising the task several places up my To Do list! Another excuse is that because MXPro sadly lacks Regular Expression features I would always tackle this sort of requirement with assistance from another application, usually my text editor, TextPad. Your challenge is akin to asking me to attach a screw without using a screwdriver. And yet another reason is that I expect you already have a brilliant solution 😉 But if curiosity does get the better of me, then I think I might start as follows: // @acantor's challenge to extract a single post code from a line of text. // No external applications are allowed. // Assumption: a reasonable max length of a single address line like the examples provided is 100 characters. Variable Set String %tResult% to "" // Just in case. Variable Set String %tInput%: Prompt // (Disabled for testing) Variable Set String %tInput% to "1234 Chaplin Dr. Twr. 1- 6th floor , Mississauga, ON L4Q 5Z3 Canada" Variable Set Integer %nLength% to the length of variable %tInput% // A line of that length contains (nLength-6) groups of 7 characters. // So my first approach will be to test every group until I find one with the post code format LDL DLD. // The parsing of that should then be straightforward. Terry
  5. Yes, I’ve always had to write my own ‘wait until ready’ code for Firefox and later Waterfox. That failed occasionally and I no longer bother, usually inserting long delays before I attempt manipulation. A command that will work for those and Chrome, Opera, Edge (Microsoft’s replacement for IE) would be handy. I would prefer to see extra web-work functionality within MXPro. But I’m not into web stuff much these days so probably not a typical prospect.
  6. Hi Joe, pleased to hear from you after such a long time. I’m no programmer, but yes I would indeed like to see MXPro offer improved power and flexibility for web stuff, if that’s what you’re asking. A start would be to get a reliable command that would detect when a site is in a ready state to accept further commands. For any browser. Still occasionally dipping into your excellent book - but how about an update for MXPro under Win 10? 🙂 Terry, UK
  7. OK, pleased to see you appear to have now got the hang of it 😉 BTW, I never had an answer my question about the macro I exported? That would have avoided your difficulty with understanding what to paste. (Although it would admittedly have required learning how to import!)
  8. Invest a little time learning some basics, both about ME Pro and using this forum. In particular, learn how to quote messages. With text, using the Quote tool, not screenshots. I’ve no idea what your latest post is meant to show us. Perhaps others with more patience will step in, but as they say on ‘Dragons Den’, I’m out!
  9. I recommend you use ME Pro’s excellent Help to understand this sort of very basic stuff. Here’s an extract: Copy Command Text - (Script Editor Only) Highlight one or more lines of the macro script. Then click on Edit | Copy Command Text. This option copies the lines of script to the Windows clipboard. Paste the script into another application and the contents are displayed shown in the Script Editor. Typically the contents display in a macro format similar to the Direct Editor script when copying the script to the clipboard and pasting. Use the Copy Command Text function to display the contents exactly as they are shown in the Script Editor. Did you also try to import and run the macro?
  10. That’s easy enough: copy the code section (not the command text), open a new empty macro, and paste it in. Or you can just import the finished macro I exported and attached for you, and run that directly.
  11. Hover over each and read what they do: Rectangular, Window, Freeform, and Full Screen. Just the same as using the Mode button in the old Snipping Tool. I assume you are saying you definitely want to remain with the old, unsupported tool called Snipping Tool, so that you can immediately save to a chosen location as before? If so then the following macro works for me: // Open the Start/Search box Text Type (Simulate Keystrokes): <WIND> Delay: 0.1 seconds Text Type (Simulate Keystrokes): <WINU> Delay: 0.1 seconds Text Type (Simulate Keystrokes): Snipping Tool Delay: 0.5 seconds Text Type (Simulate Keystrokes): <ENTER> // This opens the highlighted entry from your Search, which should by default be 'Snipping Tool'. Wait for Window Title: Snipping Tool Text Type (Simulate Keystrokes): <ALT>n // Select 'New' Delay: 0.1 seconds // Now proceed manually as advised, i.e. select and then save your target. <COMMENT Value="Open the Start/Search box"/> <TEXT TYPE Action="0" Text="<WIND>"/> <DELAY Flags="\x01" Time="0.1"/> <TEXT TYPE Action="0" Text="<WINU>"/> <DELAY Flags="\x01" Time="0.1"/> <TEXT TYPE Action="0" Text="Snipping Tool"/> <DELAY Flags="\x01" Time="0.5"/> <TEXT TYPE Action="0" Text="<ENTER>" _COMMENT="This opens the highlighted entry from your Search, which should by default be 'Snipping Tool'."/> <WAIT FOR WINDOW TITLE Title="Snipping Tool" Partial="FALSE" Wildcards="FALSE" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/> <TEXT TYPE Action="0" Text="<ALT>n" _COMMENT="Select 'New'"/> <DELAY Flags="\x01" Time="0.1"/> <COMMENT Value="Now proceed manually as advised, i.e. select and then save your target."/> Snipping Tool - New File.mex
  12. "...I'm really just a layperson here." Not in my opinion! I'm not a programmer and my experience with Python has been confined to using PaintShop Pro scripts: 95% content from those who DO know the language, plus adaptation/experiment myself. And even that was a few years ago. I reckon that Samrae's suggestions are likely to give you what you need. The registry would be my preference, as I gather there are several relevant Python commands, e.g: https://docs.python.org/3/library/winreg.html#access-rights Alternatively, going the API route, VBA should be the closest match. You might even be able to use one of the conversion tools to change your VBA code to Python. But FWIW the following is an example of the much cruder method I used to exchange variable data between PSP Python and ME Pro. In summary, the MEP macro first runs a submacro ('Script Open') and then runs a specific Python script. Very ponderous. But it worked for me (daunted by Python's learning curve) to automate a score or so of PSP tasks that I couldn't perform reliably and quickly with ME Pro alone. ==================== MACRO: Script run - Elev-GPSU-Miles Delay: 0.1 seconds Macro Run: Script Open Delay: 0.5 seconds Text Type (Use Clipboard and Paste Text): Elev-GPSU-Miles.PspScript // Elevation Edit Delay: 0.5 seconds Variable Modify String %tMiles%: Trim Variable Modify String: Save %tMiles% to the clipboard Delay: 0.5 seconds Text Type (Simulate Keystrokes): <ENTER> // Run that script. Delay: 0.1 seconds -------------------- MACRO: Script Open // Open Scripts folder // Runs from PSP 8, which must be active. Macro Playback Speed: 0.50 times faster than normal Keystroke Speed: 20 milliseconds Text Type (Simulate Keystrokes): <ALT>f Delay: 0.1 seconds Text Type (Simulate Keystrokes): r Delay: 0.1 seconds Text Type (Simulate Keystrokes): <ENTER> Delay: 0.4 seconds Text Type (Simulate Keystrokes): <ALT>n // Cursor to empty name box Delay: 0.2 seconds Text Type (Use Clipboard and Paste Text): C:\Users\terry\My PSP8 Files\Scripts-Trusted\ // Cursor to empty name box Delay: 0.5 seconds Text Type (Simulate Keystrokes): <ENTER> Delay: 0.2 seconds -------------------- PAINTSHOP PRO PYTHON SCRIPT: Elev-GPSU-Miles.PspScript from JascApp import * from Tkinter import Tk def ScriptProperties(): return { 'Author': u'Terry Pinnell', 'Copyright': u'', 'Description': u'', 'Host': u'Paint Shop Pro', 'Host Version': u'8.10' } def Do(Environment): # EnableOptimizedScriptUndo App.Do( Environment, 'EnableOptimizedScriptUndo', { }) # ASSUMES THAT VALUE OF MILES (%tMiles%) IS ON CLIPBOARD # ****************************************************** # Text App.Do( Environment, 'Text', { 'CreateAs': App.Constants.CreateAs.Vector, 'Segments': [{ 'Bold': App.Constants.Boolean.true, 'Fill': { 'Color': (0,0,0), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Identity': u'Material' }, 'Font': u'Arial', 'LineStyle': { 'Name': u'', 'FirstCap': (u'Butt',0.25,0.25), 'LastCap': (u'Butt',0.25,0.25), 'FirstSegCap': (u'',0.25), 'LastSegCap': (u'',0.25), 'UseSegmentCaps': App.Constants.Boolean.false, 'Segments': [] }, 'LineWidth': 0, 'PointSize': 36, 'Start': (1460.5,314.5), 'Stroke': { 'Color': None, 'Pattern': None, 'Gradient': None, 'Texture': None, 'Identity': u'Material' } },{ 'Antialias': App.Constants.Boolean.true, 'WarpText': App.Constants.Boolean.true, 'AutoKern': App.Constants.Boolean.true, 'Bold': App.Constants.Boolean.true, 'Kerning': 0, 'Leading': 0, 'Fill': { 'Color': (0,0,0), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Identity': u'Material' }, 'Font': u'Arial', 'Italic': App.Constants.Boolean.false, 'Join': App.Constants.JointStyle.Miter, 'LineStyle': { 'Name': u'', 'FirstCap': (u'Butt',0.25,0.25), 'LastCap': (u'Butt',0.25,0.25), 'FirstSegCap': (u'',0.25), 'LastSegCap': (u'',0.25), 'UseSegmentCaps': App.Constants.Boolean.false, 'Segments': [] }, 'LineWidth': 0, 'MiterLimit': 10, 'PointSize': 36, 'SetText': App.Constants.Justify.Left, 'Start': (1460.5,314.5), 'Strikethru': App.Constants.Boolean.false, 'Stroke': { 'Color': (255,255,255), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Identity': u'Material' }, 'Underline': App.Constants.Boolean.false },{ 'Characters': getText() }], 'SavedText': None, 'FinalApply': App.Constants.Boolean.false, 'Matrix': None, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) # SelectNone App.Do( Environment, 'SelectNone', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) def getText(): r = Tk() text = r.selection_get(selection='CLIPBOARD') r.withdraw() r.update() r.destroy() return text -------------------- Good luck! Terry, UK
  13. @mikecox The easiest way to open Snip & Sketch is to use the keyboard shortcut combination Shift+Win+S. You can then use its four capture tools by clicking the appropriate icon. If you still need help to write a macro then please specify exactly what it should do once Snip & Sketch is open. P.S: After posting a query, in my experience you cannot rely on receiving a 'notification'. Just check back regularly.
  14. Samrae, Thanks, an interesting folder I hadn't come across before. About 6 GB here. But from the first article I read, guess I'll leave it alone!
  15. Is there a particular reason you want to use Snipping Tool rather than its replacement a year or so ago by Snip & Sketch? I tried both and found the update superior in all respects. Here's a comparison: https://www.guidingtech.com/snipping-tool-vs-snip-sketch-difference/ Did you also see the 18th April post about this topic? If you do explicitly want the outdated tool, this is the target: C:\Windows\System32\SnippingTool.exe Terry, UK
  16. Did you try my suggestion about your Delay commands? Try adding a Wait for Window Title afer activating Act! Try adding a 0.1 s delay after typing <Alt + I>. Try using Waits for Text Playback after the TextType. Try using mouse move and click commands. Is it only <Alt + I> that fails? Best to confine all subsequent example macros to this single issue, as you’ve just done in your lat post.
  17. Did you try the suggestion from Samrae to use <ALTD>i<ALTU>? i would also use the regular Delay command. I agree about not getting into Controls at this stage of your experience. To narrow the diagnostic focus, have you tried a simple local macro, not remote, using that keystroke successfully?
  18. You don't need a macro to launch Snip & Sketch. The KB shortcut Win + Shift + S opens it directly and displays four options for selecting your screenshot.
  19. You normally RIGHT click a tray icon to access its options. Does that not happen with Avast?
  20. I've corrected a careless mistake and the edited macro now works consistently here. Terry, East Grinstead, UK
  21. I think I see what’s wrong and I’ll fix when I get back to my PC in the morning. Terry 23:45 UK time, from my iPad.
  22. Here's one way to do it: EDITED // Two cols of info, User ID and Name, separated by a tab, are stored in G:\Traffic\IBS\Other\id.txt. This macro prompts for a user id. If it is found it displays the name. Otherwise it displays an appropriate message and ends the macro. // I've defined Use ID as a string variable. That not only allows future flexibility but simplifies the script. And unless you intend to do arithmetic on the User ID it's unnecessary to set it as an integer. // Note: I prefix my string variables with 't' (for 'text'), and integer variables with 'n' (for 'number'). Variable Set String %tUser%: Prompt ASCII File Begin Process: "G:\Traffic\IBS\Other\id.txt" (Tab Delimited Text (.txt)) If Variable %tUser% Equals "%tLine[1]%" // This is a match. Text Box Display: User %tUser% is: Variable Set String %tResult% to "Matched" Macro Stop End If ASCII File End Process If Variable %tResult% Does not Equal "Matched" // There was no match Text Box Display: User %tUser% is: End If CODE: <COMMENT Value="Two cols of info, User ID and Name, separated by a tab, are stored in G:\\Traffic\\IBS\\Other\\id.txt.\r\nThis macro prompts for a user id. If it is found it displays the name. Otherwise it displays an appropriate message and ends the macro."/> <COMMENT Value="I've defined Use ID as a string variable. That not only allows future flexibility but simplifies the script. And unless you intend to do arithmetic on the User ID it's unnecessary to set it as an integer."/> <COMMENT Value="Note: I prefix my string variables with 't' (for 'text'), and integer variables with 'n' (for 'number')."/> <COMMENT/> <VARIABLE SET STRING Option="\x01" Destination="%tUser%" Prompt="Enter the target User ID." Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/> <ASCII FILE BEGIN PROCESS Filename="G:\\Traffic\\IBS\\Other\\id.txt" Format="Tab" Start_Record="1" Process_All="TRUE" Records="1" Variable="%tLine%" Start_Index="1" Parse_Blank_Lines="FALSE" Clear_Array="TRUE"/> <IF VARIABLE Variable="%tUser%" Condition="\x00" Value="%tLine[1]%" IgnoreCase="FALSE" _COMMENT="This is a match."/> <TEXT BOX DISPLAY Title="User %tUser% is:" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 %tLine[2]%\\f1 \r\n\\par }\r\n" Left="689" Top="334" Width="378" Height="138" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <VARIABLE SET STRING Option="\x00" Destination="%tResult%" Value="Matched" NoEmbeddedVars="FALSE"/> <MACRO STOP/> <END IF/> <ASCII FILE END PROCESS/> <IF VARIABLE Variable="%tResult%" Condition="\x01" Value="Matched" IgnoreCase="FALSE" _COMMENT="There was no match"/> <TEXT BOX DISPLAY Title="User %tUser% is:" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 Not on record.\\f1 \r\n\\par }\r\n" Left="689" Top="334" Width="378" Height="138" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END IF/> Terry, UK MacromanDemo-Edited.mex
  23. Thanks for the further details. Yes, I would use ASCll File Begin Process. Personally I would separate the two cols with a tab, to minimise any ambiguity with the Name (which contains a comma). Seeing the variable 'V1' I assume you are using ME Pro? If so I suggest you name your variables meaningfully, especially when arrays are involved. Note that your macro will fail because N2 is an integer but V1 is a string. You'd have to convert N2 first, using Variable Modify Intger > Convert to Text String. I'll suggest a macro shortly. Terry, East Grinstead, UK
×
×
  • Create New...