winapi - Run program when window user switches active window -
i prevent user switching window (similarly kiosk applications). turn behaviour od (and off) anytime keyboard shortcut application.
the best thing achieved autohotkey script waits activating keyboard shortcut , detects changes of active window , when active window changed runs program (clearlock in case) locking computer fine me.
i use when on computer , when want leave temporarily , not lock computer completely. friends, girlfriend or coworkers understand me not trusting them.
here autohotkey script have:
gui +lastfound hwnd := winexist() dllcall( "registershellhookwindow", uint,hwnd ) msgnum := dllcall( "registerwindowmessage", str,"shellhook" ) onmessage( msgnum, "shellmessage" ) return shellmessage( wparam,lparam ) { wingettitle, title, ahk_id %lparam% if (wparam=4) { ;hshell_windowactivated global kiosk if (kiosk) { global kiosk kiosk := 0 run "%portable_apps%\utility\clearlock\clearlock.exe" } } } kiosk := 0 ^!k:: global kiosk global kiosk if (kiosk) { kiosk := 0 tooltip "unlocked`n%kiosk%" } else { kiosk := 1 tooltip "the screen locked if necessary`n%kiosk%" } sleep 1000 tooltip return
the script works flawlessly on windows 7. doesn't on windows 10.
what cause problem? how solve it? either correct script. or other solution how invisibly lock computer or swich aplication application kios mode or prevent switching applications.
however don't need super secure. because wan't people want prevent doing nasty friends.
if utmost security isn't focus, simplest solution this:
f3:: loop { winactivate, untitled - notepad sleep, 50 if getkeystate("esc", "p") { break } } return
Comments
Post a Comment