Running macros by hotkey in PTFB Pro

Recent support queries have shown there’s a bit of confusion over the use of hotkeys in PTFB Pro, so I’m going to use this post to try to clear that up. There are two classes of things that can be hooked up to hotkeys in PTFB Pro:

  • assorted functions like the Run Now button, creation of a new item, and opening the main window
  • macros and single-press items themselves

Most confusion centers around the definition of a hotkey specifically for the Run Now button.

The important thing to remember here is that “Run Now” just runs the currently selected macro in the main window. If you define a hotkey for the Run Now button, then that hotkey will only ever run the currently selected macro. To put it another way, the hotkey is tied to the button only, not a particular macro.

This is made a little clearer when you visit the Hotkeys page in the PTFB Pro Configuration window (Options -> Configure):

The page is split into two sections: the top section shows hotkey definitions for PTFB functions (including Run Now – here called “Run current macro”) while the lower section shows hotkeys tied to specific macros. From the above screenshot you can see that I’ve tied CTRL + SHIFT + R to the Run Now function, and CTRL + SHIFT + O to the “Open main window” function in the upper section. In the lower section, I’ve tied CTRL + SHIFT + I  directly to my “Paste Wordprocess Image” macro (in case you’re wondering, that just wraps some html tags around an image URL to save typing in WordPress).

The above page is a great way to get an overview of what hotkeys are tied to which functions/items, and to change those associations as required. You can also tie hotkeys to macros directly within the Trigger page of a macro’s property screen. Here’s what the Trigger page looks like for the “Paste Wordprocess Image” macro I mentioned earlier:

As you can see, the hotkey trigger is enabled and CTRL + SHIFT + I is the associated key combination. If I were to change the key combination on this screen, it would also change it on the Hotkeys page in Options -> Configure, and vice versa.

You may also notice that I’ve turned OFF (unticked) the option to “Trigger spontaneously” at the top of the page. This is standard procedure if you’re going to trigger a macro on demand via a hotkey (you generally don’t want it firing on its own)!

I hope that makes things clearer; if you have any questions regarding this or other PTFB-related topics, please submit a ticket to our support page here: http://www.ptfbpro.com/support/ OR just use “Options -> Email Technical Support” in PTFB Pro itself.

 

Macro Re-Record and Windows 10 Lockscreen in PTFB Pro v5.1

By popular request, the ability to re-record macros has been added to the latest release of PTFB Pro, version 5.1.0.0. The new feature is available via the “Edit…” button on the main screen, and of course on the Editing tab of each macro’s property sheet.

By default the “Re-Record” command appends any new mouse / keyboard actions to the end of the macro, along with a comment line that notes when the re-record occurred. If instead you’d simply like to replace the entire contents of the macro, just use the “Clear All Actions” command that is also present in the Edit button’s drop-down menu. Incidently if you’re a heavy keyboard user, you’ll find the new release of PTFB Pro a little be easier to drive without using the mouse.

Also notable in the new release is that it implements the automatic workaround for the stubborn lockscreen that came with the Anniversary Update for Windows 10, as detailed in my previous post. People who find the Windows 10 lockscreen irritating might want to install PTFB’s optional workstation unlock service for that reason alone; just run the installer and tick the service option – you don’t even need to turn on workstation unlocking in Options -> Configure if you don’t want to.

Finally, the new release also helps PTFB Pro’s visual trigger to cope with Windows User Account Control dialogs. Ordinarily these screens are presented on a “secure desktop” which puts them out of reach, but there’s a tweak available in the local security policy editor (secpol) that changes this (Local Policies -> Security Options -> “User Account Control: Switch to the secure desktop when prompting for elevation”). The problem is that the UAC screens all bear the same title, and don’t allow PTFB Pro to read the text they contain. However, careful use of v5’s new visual trigger gives PTFB Pro a way to tell the screens apart.

Granted, the above is something of a niche case; most people (me included) run with UAC in its normal configuration. That said, the visual trigger facility is proving to be very handy for a wide range of screens that people want to handle automatically, but which resist standard identification methods such as title and text contents. Next time you run into difficult dialog or prompt, take a moment to consider whether the visual trigger could be just what you need.

Get the latest version of PTFB Pro from our download page here: http://ptfbpro.com/download.shtml

Disabling the lock screen in Windows 10 Anniversary Update for PTFB Pro

A while back I wrote an article about a registry tweak you could make in Windows 10 that disabled the lock screen; this forced Windows 10 to show only the login screen when the workstation was locked, and allowed PTFB Pro’s special “Unlock computer to press targets” feature to do its thing. BTW, if you weren’t even aware that PTFB had such a thing, check it out. You’ll find the feature in Options -> Configure; it enables PTFB to very briefly unlock a workstation to handle a screen that’s waiting for a response, then automatically relock your computer afterwards. It’s a great way to keep things running smoothly on your machine when you’re not in attendance.

Anyway, it’s now (finally) come to my attention that the Anniversary Update to Windows 10 broke the registry tweak, bringing the lock screen right back and in your face. Happily there is a new registry tweak that once again keeps that pesky (and in my opinion, largely redundant) lock screen from getting in the way; less happily, Windows 10 keeps resetting the tweak behind your back.

A guy called Sergey Tkachenko on the WinAero site wrote an article showing how to get Windows’ built-in Task Scheduler to reapply the registry tweak as often as necessary to keep the lock screen at bay. It’s an elegant solution, and for your convenience I’ll include the guts of the procedure here.

  1. Open up Task Scheduler (just type “Task Sched” into the search box on your taskbar; it should be the top find)
  2. Choose “Create Task…” from the right-hand “Actions” pane. (Note it is “Create Task” you want, rather than “Create Basic Task”)
  3. On the General tab of the resulting Create Task dialog, give your new task a meaningful name, tick the option marked “Run with highest privileges” and choose “Windows 10” from the “Configure for” dropdown list.
  4. Switch to the Triggers tab and two new triggers: “At logon” and “On workstation unlock”. Set them both to fire for “Any user” and take the defaults for everything else.


  5. Switch to the Actions tab, and set “reg.exe” as the program, then paste the following into the “Add Arguments” field (all one line):
    add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData /t REG_DWORD /v AllowLockScreen /d 0 /f 


  6. On the Conditions tab, you may wish to turn OFF the two power options that restrict the task to AC power if you’re using a portable device.
  7. Click OK to save your changes, then select your new task and choose “Run”from the actions pane to run it once.

The registry tweak that disables the lock screen (a setting “AllowLockScreen” with a value of zero) has now been applied. The next time you lock your PC, the lock screen won’t appear; instead you’ll just see the login screen. When you sign into your PC to unlock it, Windows will undo the registry tweak, but then the task will run (remember the “On workstation unlock” trigger?) and set it right back.

I’m going to try adding this tweak to PTFB Pro’s workstation unlock service component; if successful, the next release of PTFB will render the above lock screen task unnecessary. For right now however, the above process is an effective and elegant workaround.

 

Better handling of hotkey triggers in PTFB Pro v5.0.2.0

The latest release (v5.0.2.0) brings two small but useful improvements to PTFB Pro: better handling of hotkey triggers, and the ability to supply to text that prevents a match when looking for target windows for macros and single-press items.

The first change causes PTFB Pro to wait until the most important modifier keys (ALT, SHIFT and CTRL) are not still down before triggering a macro by hotkey. Previously the macro would trigger immediately – possibly while a modifier key was still in the “pressed” state on the keyboard. In some programs (MS Office particularly) this could cause a “sticky” key problem; by waiting for the modifier keys to come back up, the problem is eliminated. If for whatever reason you prefer the previous behavior you can bring it back: just head over to Options -> Configure and turn off “Wait for key-up on hotkey trigger”.

The second change concerns the “Identifying the Target” page of items like single-presses and window-based macros.  If you look at the top section of this page, you’ll now see an extra field titled “Exclude this text”..

This optional field – which can be a regular expression if required – specifies text which will prevent the macro firing if that text is present in the target window’s title (aka “caption”). This small addition provides a surprising amount of extra control over when a macro fires. For example, let’s say you’ve made a macro that automatically saves your work every few minutes in your favorite editing app. The problem is, the macro fires even when you’re editing a new (“Untitled”) document that hasn’t been saved yet. The solution is just to add “Untitled” to the “Exclude this text” field; now the macro makes an exception for untitled documents, but saves all your other work automatically.

This new functionality was requested recently by a new customer. If there’s something YOU would like to see added to PTFB please get in touch; I can’t guarantee that all requests will be implemented, but if it’s something that could benefit other PTFB users we’ll certainly consider it!

Running Macros and Passing Parameters via Powershell / Command Line

Last time I looked at the new trigger in PTFB Pro v5 that can react to changes in color, text, and even graphics. In this post, I’ll concentrate on new facilities that version 5 brings via the command line; they’re useful enough on their own, but they’re especially helpful if you want drive PTFB Pro from a powerful scripting engine such as Powershell.

Command Line Control of PTFB

Enable/Disable Macros or PTFB Pro as a whole

The /ENABLE or /DISABLE directives can be used to enable or disable either PTFB Pro as a whole, or a specific set of macros / press items. If your goal is to enable/disable macros, just specify the four-digit macro IDs in a space-separated list (you can get the IDs from the Triggers page for each of the items). Here are some examples:

"C:\Program Files (x86)\Technology Lighthouse\PTFB Pro\PTFBPro.exe" /ENABLE
"C:\Program Files (x86)\Technology Lighthouse\PTFB Pro\PTFBPro.exe" /DISABLE 1BF0 5C33 7EA0

The first line above (re) enables PTFB Pro, while the second disables three specific macros, so they can no longer run automatically.

Run a list of macros / presses

PTFB Pro v4 was able to launch up to two macros from the command line; in version 5 there’s no limit to the number of macros / presses that can be run, and they’ll be run in the order given. Just include the macro IDs in a space-separated list like so:

"C:\Program Files (x86)\Technology Lighthouse\PTFB Pro\PTFBPro.exe" 1AB0 83CB 2FF0

Waiting for completion

Sometimes when you’re running PTFB Pro from a script it’s handy to make the script wait until the actions you’ve requested have actually completed. That is now possible in version 5 thanks to the “/WAIT” directive. To use it, just include it as the first thing on the command line right after the path to PTFB:

"C:\Program Files (x86)\Technology Lighthouse\PTFB Pro\PTFBPro.exe" /WAIT 1AB0 83CB 2FF0

In the above example, the command will only return when the final macro (ID 2FF0) has finished executing. If you omit the “/WAIT” directive, the command will return almost immediately, likely before any of the macros have run to completion.

Parameters

Some of PTFB Pro’s macro actions now take optional named parameters, and these parameters are supplied via the command line:
"C:\Program Files (x86)\Technology Lighthouse\PTFB Pro\PTFBPro.exe" 1AB0 -param10 "3" -param2 "My Text" 83CB 2FF0

In the above example, the macro with ID 1AB0 will be executed and the values 3 and My text will be provided as parameter#10 and parameter#2 respectively to any actions in the macro that use those named parameters. The macros with IDs 83CB and 2FF0 will then be executed, but they will run without any parameter values.

So, which actions can take parameters? Currently the list includes: Run Item, Run Executable, Enable Item Temporarily, Repeat Loop, Switch To Prog and Set Clipboard. That last action – Set Clipboard – is also new to PTFB Pro version 5; it allows you to load the Windows clipboard with one of the following:

  • literal text
  • the contents of a nominated text file
  • one or more file paths (file objects)

If you’re a bit of a Powershell script addict, I’m sure you’re already realising just how useful the new parameterized control of PTFB is going to be. Even if you’re not much of a scripter now, be aware that the facilities are there for if you should need them in the future, and they’re due to be extended further in subsequent updates to v5!

PTFB’s Visual Trigger Up Close

It’s time to take a closer look at one of the major new features in PTFB Pro version 5 : Visual Triggers.

Simply put, they allow PTFB to react to a change on screen that is visible to the eye, but is otherwise not detectable. Examples include a change in color, in wording, or in a graphic.  Visual change triggers are available for single clicks / presses and for all of PTFB’s macro types, including”ProgMons” which are used to handle launching, suppression and automatic restarting of other programs on your Windows PC.

To use the new trigger type, you need to open up your macro for editing (just double-click it on PTFB Pro’s main screen) then switch to the Triggers tab. The option you’re looking for is the checkbox labelled “Visual Change” in the top left of the “Other Triggers” section:

Visual Change - Triggers Page

Tick this new trigger type or press the “Change Settings…” button next to it to open up a new screen where you can set the specifics: what part of the screen you want to monitor, and what kind of changes will be enough to cause your macro to run. Let’s take a look at that settings dialog now:

Trigger on Visual Change - Settings

The first section of this dialog defines which part of the screen should be monitored for changes; you do this by press the button marked “Choose Area”. Your mouse cursor will change to a little grey-bordered box; simply move that box over the target area and click the left mouse button to select it (or click the right mouse button / press the “Esc” key to abort). For performance reasons the largest area you can monitor is a 32 x 32 pixel square; you can narrow this to a smaller area (16 x 16 or 8 x 8) at any point if you wish. PTFB Pro will indicate whether the area you’ve chosen is a part of the screen as a whole, or a part of your target window if you’re editing a single-press item or window-based macro. At the instant you click to set the area, PTFB Pro takes a snapshot of the region as it is right now. You get to choose if and how this snapshot will be used in the section titled “Conditions For Trigger”.

The first choice in the Conditions section is whether to react to a difference or a match; the “Match” case is useful when the monitored area changes routinely but you only want the press or macro to run when it’s a reasonable match to the snapshot you just recorded.

Next – if you’ve chosen to trigger on “Difference” – you can choose whether comparisons will be made against the fixed snapshot you made earlier, or against a so-called “Dynamic” snapshot. If you want PTFB Pro to react each and every time the monitored area changes then you should choose “Dynamic”, otherwise just go for the “Fixed snapshot” option.

Finally there’s a slider that lets you fine-tune the sensitivity of the visual trigger. The effect of this depends on whether you previously chose to trigger on a “Difference” or a “Match”. When looking for a difference, the left hand side of the slider represents maximum sensitivity; PTFB Pro will run the macro in response to any detectable change. As you move the slider to the right, PTFB Pro requires a more substantial change before the macro runs. The slider effect for “Match” works the other way around; the left hand side requires an almost exact match with the snapshot, but as you move it to the right, an increasingly less perfect match will be enough to trigger your macro.

I should take a moment here to note the link between the effect of the slider control and the area size that you choose. A small change in the largest (32 x 32 pixel) area size might only rack up a difference value of say 8%. However, if you drop that to the smallest area size (8 x 8) then that same small change becomes more significant. Remember that phrase “small fish in a big pond” : the same principal applies here.

To make it easy to tune all these settings and ensure that you’ll get the effect you want, the Visual Change Settings screen has a button marked “Test Now”. Press it, and PTFB Pro will tell you exactly how much of a change it sees, and whether it would be enough to trigger your macro.


So that’s the lowdown on the new Visual Change trigger-type in PTFB Pro; the next post will focus on some of the other new features in version 5. Don’t forget you can try PTFB Pro right now by downloading the free 30-day trial.

 

PTFB Pro Version 5 Adds Visual Triggers and Command Line Control

PTFB Pro has just received a major update and its brought a lot of new features that our customers have been asking for, including:

1) Visual Triggers

Your macros can now fire automatically when a change is seen in a portion of the target window or the screen. It’s a huge new addition for PTFB, allowing it to react to things that we as humans can readily see (such as changes to text, graphics and color) but which previously it was unable to detect. This new trigger can be fine-tuned in a number of ways, so you can have your macros fire exactly when you need them to.

2) Greatly improved command line control for better integration with Powershell and other script shells

Ever since version 3 it’s been possible to trigger macros via the command line, but version 5 has expanded on this considerably. From the command line you can now:

  • Enable/Disable PTFB Pro as a whole, enable/disable a list of macros
  • Trigger any number of macros AND pass named parameters through to be used by v5’s newly extended macro actions
  • Properly synchronise command line actions thanks to the new /WAIT command line directive

3) Control the clipboard

A new “Set Clipboard” macro action has been added which lets you load literal text, the contents of text files, and even files themselves into the Windows clipboard, for use in subsequent paste operations. This action can take a command line parameter, so you can pass in clipboard content from a script or command shell such as Powershell.

4) Track when a macro was last used, and easily archive little-used macros

I’m not afraid to admit that I have mild hoarding tendencies; when I create a macro or single press for a specific job I rarely delete it. The result is that over time my copies of PTFB Pro have filled up with lots of items that were used heavily for a short time, but have layed dormant ever since. PTFB Pro dutifully loads them into memory and checks them multiple times each second to see if they’re ready to fire automatically; remove them, and PTFB Pro becomes just a little leaner and faster to respond. Version 5 now tracks the most recent usage date/time, and can use this information to disable unused items and/or move them to a specific tab.

5) Instantly test your settings on the “Identifying the Target” page

There can be a learning curve for people who are tailoring a single-press or window-based macro so that it keeps firing even when the target window changes. Version 5 takes the guesswork out of this process by adding a “View Matches” button to the target identification page; press that button, and PTFB Pro will show you exactly which windows match your settings.


I’ll take a closer look at these new features in later posts, but you can try them out yourself right now by getting your copy of v5 from our download page: http://www.ptfbpro.com/download.shtml

Note that because this is a major upgrade it’s only free to people who bought v4 on or after June 1st 2016 (about 90 days prior to the release of v5). Anyone who bought before this date can purchase an upgrade license at a 50% discount. Please visit our upgrades page for more details or just send an email to support@ptfbpro.com and we’ll send you a free license / discount purchase link  – whichever is appropriate.

Bypassing the Windows 10 lock screen to press buttons automatically

For some time now PTFB Pro has had a special setting in Options -> Configure called “Unlock computer to press targets”. When enabled, its purpose is to briefly bypass the locked workstation screen on Windows to deal with any buttons that have to be pressed (or macros that have to be run) on the desktop. As soon as any necessary work is done, the workstation is automatically re-locked, and under normal circumstances this happens much faster than a human could react.  For those who needed it, this option worked beautifully on all versions of Windows.. until Windows 10 came along, with its new lock screen.

lockscreen

Well, after finally taking the plunge and installing Windows 10 TH2 on my main development system, I’m happy to report that I’ve found a way to get the “Unlock computer to press targets” option to work even on the new OS. All you have to do is make a small registry edit to disable the new Windows 10 lock screen, as described below. To be honest, if you’re like me then you’ll probably want to do this anyway just because the lock screen places an extra mouse press between you and logging back in to your desktop.

Here’s what to do, but before you go ahead, here’s a warning: don’t do this unless you’re experienced at registry editing! The Windows registry is critical to the operation of your computer and if you make a mess in there, you’ll likely have to restore or reinstall your operating system to fix it. Still want to go ahead? OK, here’s the step-by-step:

  • Open regedit
  • Navigate to: HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows
  • Look for a subkey entitled “Personalization”. If it’s there, enter it, otherwise create it. And then enter it.
  • Add a new DWORD (32-bit) value called “NoLockScreen” and set its value to 1

That’s it, you can close Regedit now because you’re done. This change takes immediate effect; you can test it straight away by tapping Windows key + L. If you go direct to the login screen, you’ve done it right. After this, PTFB’s “Unlock computer to press targets” will work just fine (so long as you’ve enabled it and also chose the option to include the PTFB Pro workstation service when you last installed PTFB).

If you need a more involved step-by-step procedure than the above for turning off the new Windows 10 lock screen,  then you probably shouldn’t be messing around with Regedit in the first place (just kidding, well, maybe). Nevertheless you’ll find a really excellent walk through here, complete with screenshots:
http://www.laptopmag.com/articles/disable-lock-screen-windows-10