terrypin
-
Posts
2,232 -
Joined
-
Last visited
-
Days Won
23
Content Type
Profiles
Forums
Events
Posts posted by terrypin
-
-
47 minutes ago, mikecox said:
I will see if I can paste it in, otherwise I will add in manually.
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.- 1
-
5 hours ago, mikecox said:Quote
This shortcut pops up a row of unfamiliar icons,
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.
QuoteThe first thing I need is for the app to open the way it does when I click the icon
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."/>
- 1
-
"...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-rightsAlternatively, 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 Tkdef 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
-
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.
- 1
-
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!
-
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
-
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.
-
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?
-
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.
-
You normally RIGHT click a tray icon to access its options. Does that not happen with Avast?
-
Use the command Move Mouse to Tray Icon.
-
I've corrected a careless mistake and the edited macro now works consistently here.
Terry, East Grinstead, UK
-
I think I see what’s wrong and I’ll fix when I get back to my PC in the morning.
Terry23:45 UK time, from my iPad.
-
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
-
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
-
Are these two files TXT as your first post seems to indicate, or CSV as per your last post?
Please post the full macro you have so far and its code, not just the command text.
It would also be helpful to post both files, suitably edited if confidential.
Are you using ME3 or ME Pro?
As usual, the devil is in the details.
-
Thanks Alan, I'll explore that interesting approach. Do you think can it be applied in the example under discussion?
-
3 hours ago, Cory said:
I don't understand why you don't use the MEP file manipulation commands. It's much easier to conditionally handle exceptions with them. Much faster and more reliable. Since this is the way I handle files, I am not going to be of much help, but I urge you to try and use them instead.
When I things that could have a popup error I use the existence of the controls. Let's say that's a "Do you want to continue?" button. I define the control and use "if control exists". And I'd never type in file names, I'd use the controls to enter those values. And here again, checking of the controls exist are useful. What I'm saying is not only can you use the controls to do things, you can also use their existence and value to control the flow of your macro.
"I don't understand why you don't use the MEP file manipulation commands."
I'm not sure I've understood. Apart from If File Exists, which I mentioned, what other 'file manipulation commands' do you suggest to handle file saving when OS messages are displayed as in my example? Or maybe you're referring to the simple way I've handled the file processing in that? IOW, are you instead recommending a Repeat with Folder to build a variable holding all files? If so, I agree, and if this was a larger project with many more files involved that's probably how I'd do it. But this was just a simplified example to focus on the subject issue.
"I'd never type in file names..."
Do you mean you don't use string variables to enter data as in my example? What advantage would using Controls offer? Wouldn't that involve more steps, and the same variable?
"When I things that could have a popup error I use the existence of the controls."
How would you do that for my example? What would be the target of the Get Control command, for instance?
-
When running macros that save files they frequently fail because messages from the OS do not automatically pause the macro to allow user interaction before proceeding. A typical example:
// Now re-open the file in F2 mode and enter the new name Text Type (Simulate Keystrokes): <F2> Delay: 0.1 seconds Text Type (Simulate Keystrokes): %tFilename% Delay: 0.1 seconds Text Type (Simulate Keystrokes): <ENTER> Delay: 0.1 seconds Text Type (Simulate Keystrokes): <ARROW DOWN> Delay: 0.1 seconds End Repeat
After the ENTER command I might briefly see a message like "A file of this name already exists..." and be asked to choose a Yes or No option (e.g. to save with a suffixed name), but the macro continues regardless. Sometimes the fix is easy; for example when the message is asking whether to overwrite the previous file I can often safely insert a Text Type Y command. Or I can use If Window, specify 'Replace File', and add an appropriate action, such as a simple Pause. Or sometimes an If File Exists command is possible. But sometimes it's not so easy.
What techniques do others use please?
Terry, UK
-
Let's see if a few others from various countries can join the discussion!
I'm guessing it's a Windows OS setting?
-
-
On 2/29/2020 at 5:44 PM, acantor said:
Here is the MEP script I use to change the background colour of selected lines to yellow
Hi Alan,
This command caused failure for me:
Wait for Window Title: Color
That has me fascinated, especially as I see that you personally spell 'colour' the same as I do!
Is your version of MEP indeed AmericaniZed in that way?
Using 6.1.3.1 here, and your macro works fine when I use the correct spelling 🙂
Terry
-
39 minutes ago, John Welch said:
Yes, thanks. In this case window and screen are always the same.
Your original screenshot shows that your 1920 x 1080 screen was on that occasion not occupied by your maximised program. So that's a possible cause of earlier confusion about your Mouse Locator readings.
-
Quote
Since I reduced the delay time from 800ms to 100ms, I have not had a problem with the button being selected.
Pleased to hear that's apparently fixed it.
Can't Launch SnippingTool
in Macro Express and Macro Express Pro
Posted
No.