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:
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:
6. Windows 8/8.1:
Z (0.5) Z (1.5) (PASSWORD) Y
7. Windows 10:
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.
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 "notepad.exe" "$qm$\qmtul.log"