AHK sends unwanted keystrokes on Windows login screen

Get help with using AutoHotkey and its commands and hotkeys
AniRayn
Posts: 1
Joined: 30 Sep 2017, 06:00

AHK sends unwanted keystrokes on Windows login screen

Post by AniRayn » 30 Sep 2017, 06:24

I have the code below in my compiled script which is set to run at Windows startup.
Problem is that every time I wake my PC from sleep I have the magnifier already launched. I'm guessing AHK just automatically triggers itself and sends the keystrokes.
I noticed the problem usually happens when I leave my PC to sleep for more than 4 hours. If I just set it to sleep then wake up right away, there is no magnifier. Also I don't have this problem if I disable the hotkey in my script.
My Windows and Autohotkey are both 64-bit.

Would really appreciate any suggestions on how to work around this :)

Code: Select all

SendMode Input 

SetWorkingDir %A_ScriptDir% 

DetectHiddenWindows, on

^!+M::StartClose("magnify.exe") ;Ctrl+Shift+Alt+M

StartClose(exe)
{
    Process, Exist, %exe% ; check to see if program is running
    If (ErrorLevel = 0) ; If program is not running -> Run
    {
		Run, %exe%
    }
    Else ; If program is running, ErrorLevel = process id for the target program -> Close
    {
		Process, Close, %ErrorLevel%
    }
}
lexikos
Posts: 6175
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AHK sends unwanted keystrokes on Windows login screen

Post by lexikos » 26 Nov 2017, 01:00

It is very unlikely that AutoHotkey is causing this. The script you posted does not send any keystrokes, and will only launch magnify.exe when the system notifies AutoHotkey that the Ctrl+Alt+Shift+M hotkey was pressed. Magnifier is most likely being launched by the OS due to some system setting and/or the mere fact that you had been using it previously.

You can verify that the magnifier is being launched by something other than AutoHotkey:
  • Using ListLines after the magnifier appears will show whether Run was called.
  • Add MsgBox or FileAppend to a log file. If magnifier launches and there is no MsgBox or change to the log file, magnifier was started by something else.
  • Sysinternals Process Explorer shows each process nested (indented) under its parent process. If magnify.exe was started by the script, it will be nested under your script.exe (or AutoHotkey.exe).
I suggest you check the "Start Magnifier automatically" system setting, both before and after the issue occurs.
Post Reply

Return to “Ask For Help”