Unlock computer

Some triggers (scheduler, file, event log, process) may start the macro while QM is not running in the currently active user session/desktop. For example, the computer may be locked (directly or by a secure screen saver), the user is not logged on, the user is switched off, a custom desktop is active. Then the macro runs in the background, and cannot use keyboard, mouse, and some other functions.

 

To ensure that the macro will run only in normal conditions, check Properties -> Macro properties -> "Don't run in background". This also will close nonsecure screensaver.

 

If you also check "If computer locked, unlock", QM unlocks computer if it is locked when the macro starts. Also closes screensaver. When the macro ends, QM can lock computer again. This feature is unavailable in portable QM.

 

Before using this feature first time, configuration is necessary. To show the configuration dialog, click the 'How to unlock computer...' button. Enter the Windows user account password. If need, change keys and other options. Whenever in the future you change Windows user account password, need to change it here too.

 

To unlock, QM uses keys specified in the dialog. The format is the same as with key. For example, T is Tab, Y is Enter, Au is Alt+U, (1.0) is 1 second delay, "Text" is Text typed as simple text, etc. Some key features not supported, for example VK_ and (#n). Use (USERNAME) and (PASSWORD) to type username/password specified in the "Unlock Computer - Options" dialog. Examples:

 

1. Windows XP, when shows dialog with user name and password fields:

Au (USERNAME) Ap (PASSWORD) Y

 

2. Windows XP, welcome screen, when initially shows password field:

(PASSWORD) Y

 

3. Windows XP, welcome screen, when initially does not show password field. Examples for user 1, 2 and 3:

TT (PASSWORD) Y

TTD (PASSWORD) Y

TTDD (PASSWORD) Y

 

4. Windows Vista/7. Examples for user 1, 2 and 3:

V (1.0) B (PASSWORD) Y

R V (1.0) B (PASSWORD) Y

RR V (1.0) B (PASSWORD) Y

 

5. Windows Vista/7, when initially shows password field:

(PASSWORD) Y

 

6. Windows 8/8.1:

Z (0.5) Z (1.5) (PASSWORD) Y

 

7. Windows 10:

Z (1.5) (PASSWORD) Y

 

8. Windows 11:

Z (PASSWORD)

 

QM 2.3.5. Alternatively you can use a program that unlocks computer. You can create it from a macro. It can do anything - evaluate conditions, send keys, click, wait, use window and accessible object functions, etc. It should return a nonzero value if failed. Example.

Acc a.Find(win "TEXT" "" "class=Edit" 0x1005) ;;find password field
err
	key Y
	2
	a.Find(win "TEXT" "" "class=Edit" 0x1005)
	err
		LogFile "no password field" 0 "qmtul.log"
		ret 1 ;;error
act child(a) ;;set focus
key "password" Y

 note: out will not work. Use LogFile.

 

Notes

  1. The options in the configuration dialog are common to all macros.
  2. This feature has minimal impact on security. The password is saved encrypted. While temporarily unlocked, keyboard and mouse are disabled, and there is no way to access the computer. Pressing Ctrl+Alt+Delete will immediately lock the computer.
  3. QM attempts to unlock computer only if it is locked (manually or by a secure screen saver). The macro will not run if not logged on, or another user is active, or another desktop is active.
  4. While computer is temporarily unlocked, macros that have "don't run in background" checked are not allowed to run. They wait until computer is locked and unlocked again (if "if locked, temporarily unlock" is checked) or don't run.
  5. The log file can be used to find problems. It does not have a size limit.
  6. You also can use function EnsureLoggedOn.
  7. Does not support Unicode. User name, password, keys and file names must be ANSI.
  8. On Windows XP fails to unlock in these conditions: a) After switching to other user and then logging off. b) When locked by Remote Desktop.
  9. On Windows Vista and later fails to send Ctrl+Alt+Delete if security settings modified. To fix it, run gpedit.msc, open Computer Config/Admin Templ/Win Comp/Win Logon Opt/Disable Enable SAS, and enable Ease Access Apps.
  10. Tested on Windows XP, Vista, 7, 8, 8.1, 10, 11. May not work on newer Windows versions.

Use this macro to test unlocking:

shutdown 6 ;;lock
wait 10
int unlocked=EnsureLoggedOn(1)
out "unlocked=%i" unlocked ;;should be 2
if(!unlocked and FileExists("$qm$\qmtul.log")) run "$system$\notepad.exe" "$qm$\qmtul.log"