Jump to content
Sign in to follow this  
sc4ry

catch WIN+L to do something before locking the PC

Recommended Posts

sc4ry

Hey, is it possible, to catch the combo of WIN + L (which locks directly the PC)?

It want to do a function before the PC really is locked ... after this i can call another function which locks the pc after that.

have anyone an idea?

i found a reg-hack, but im not able to write this into the registry, so that wont work.

thank you for your help.

Share this post


Link to post
Share on other sites
Jos

Hey, is it possible, to catch the combo of WIN + L (which locks directly the PC)?

It want to do a function before the PC really is locked ... after this i can call another function which locks the pc after that.

have anyone an idea?

i found a reg-hack, but im not able to write this into the registry, so that wont work.

thank you for your help.

..and why do you need this type of function?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
sc4ry

nothing illegal =)

ok, here we go.

we got a tel-client on work. there we have the posibility to say we are active or in pause. we should do pause when we are not at our desk.

because i forgot every time to change in pause-mode, i want to write a tool, which automate this.

i always lock my pc, when im not at my desk. but the client does not change automativcly to pause-mode when pc is locked ... so i have to catch the combo of WIN + L, set client in pause-mode and the lock my pc.

Share this post


Link to post
Share on other sites
Yashied

nothing illegal =)

ok, here we go.

we got a tel-client on work. there we have the posibility to say we are active or in pause. we should do pause when we are not at our desk.

because i forgot every time to change in pause-mode, i want to write a tool, which automate this.

i always lock my pc, when im not at my desk. but the client does not change automativcly to pause-mode when pc is locked ... so i have to catch the combo of WIN + L, set client in pause-mode and the lock my pc.

#Include <HotKey.au3>

Global Const $VK_ESCAPE = 0x1B
Global Const $VK_L = 0x4C

_HotKeyAssign(BitOR($CK_WIN, $VK_L), 'MyFunc')
_HotKeyAssign(BitOR($CK_CONTROL, $VK_ESCAPE), 'Quit')

While 1
    Sleep(100)
WEnd

Func MyFunc()
    MsgBox(0, '', 'WIN-L has been pressed!')
    DllCall('user32.dll', 'int', 'LockWorkStation')
EndFunc   ;==>MyFunc

Func Quit()
    Exit
EndFunc   ;==>Quit

HotKey.au3

Share this post


Link to post
Share on other sites
Jos

Not sure you can avoid it from locking the PC, but you should be able to capture the keys pressed with _IsPressed() and maybe you can still use Ctrl???() functions to update the telnet screen even though its locked.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
KaFu
sc4ry

thank your very much yashied ... thats what i need =)

i wrote this function before with an own hotkey, but its better for me, when WIN + L (also) switch the client in pause mode.

very nice, big thx

Share this post


Link to post
Share on other sites
sc4ry

hi, im again with another question.

its something nice to have, but not a must ...

what is, when a user lock the pc via CTRL+ALT+DEL and LOCK PC?

i dont think i can use this hotkey-funktion, because CTRL+ALT+DELETE ist not the hotkey, my script should work with ... only if in this screen the LOCK PC button was clicked.

can i here also do a function before the pc is really locked?

Share this post


Link to post
Share on other sites
Yashied

hi, im again with another question.

its something nice to have, but not a must ...

what is, when a user lock the pc via CTRL+ALT+DEL and LOCK PC?

i dont think i can use this hotkey-funktion, because CTRL+ALT+DELETE ist not the hotkey, my script should work with ... only if in this screen the LOCK PC button was clicked.

can i here also do a function before the pc is really locked?

You can NOT lock CTRL-ALT-DEL in Windows XP and above.

Share this post


Link to post
Share on other sites
sc4ry

i dont want to lock this kombo, i only want to do my function (set tel-client in pause) when a user lock the pc via ctrl+alt+del.

Share this post


Link to post
Share on other sites
Yashied

i dont want to lock this kombo, i only want to do my function (set tel-client in pause) when a user lock the pc via ctrl+alt+del.

You can define CTRL-ALT-DEL as a hot key, but stop the Windows Task Manager does not turn out. I'm sorry.

_HotKeyAssign(BitOR($CK_CONTROL, $CK_ALT, $VK_DELETE), 'MyFunc')

Share this post


Link to post
Share on other sites
sc4ry

ok, i can do my function when ctrl+alt+del is pressed and set it back, if the user do not want to lock the pc ... but when i catch ctrl+alt+del, how can i return to the normal screen, which appears? (lock pc, change user, task manager, logoff, change pw, ...)

Share this post


Link to post
Share on other sites
Yashied

ok, i can do my function when ctrl+alt+del is pressed and set it back, if the user do not want to lock the pc ... but when i catch ctrl+alt+del, how can i return to the normal screen, which appears? (lock pc, change user, task manager, logoff, change pw, ...)

Well, if you need to track the closing session, it can be done much easier.

Global Const $WM_QUERYENDSESSION = 0x0011

GUICreate('')
GUIRegisterMsg($WM_QUERYENDSESSION, 'WM_QUERYENDSESSION')

While 1
    Sleep(1000)
WEnd

Func WM_QUERYENDSESSION($hWnd, $iMsg, $wParam, $lParam)
    ; Do something
    SoundPlay(@WindowsDir & '\media\tada.wav', 1)
    Return 'GUI_RUNDEFMSG'
EndFunc   ;==>WM_QUERYENDSESSION

EDIT:

Add here the previous example for lock the computer (Win-L) and get what you need.

Edited by Yashied

Share this post


Link to post
Share on other sites
Yashied

Here is another useful function.

Global Const $DESKTOP_SWITCHDESKTOP = 0x0100

Func _IsWorkstationLocked()

    Local $Result = False

    $hDesktop = DllCall('user32.dll', 'hwnd', 'OpenDesktop', 'str', 'Default', 'int', 0, 'int', 0, 'int', $DESKTOP_SWITCHDESKTOP)
    If Not @error Then
        $Result = DllCall('user32.dll', 'int', 'SwitchDesktop', 'hwnd', $hDesktop[0])
        $Result = Not $Result[0]
        DllCall('user32.dll', 'int', 'CloseDesktop', 'hwnd', $hDesktop[0])
    EndIf
    Return $Result
EndFunc   ;==>_IsWorkstationLocked

Share this post


Link to post
Share on other sites
sc4ry

hey,

i dont get, what these function do =)

but to explain, when i use ctrl+alt+del, not the taskmanager appears, but a windows which name is "window security".

however ... when i catch ctrl+alt+del and set my tel-client to pause, how can i get the "window security" screen?

windows disalow to send ctrl+alt+del by any program. is there a dll call, which can open the window security screen?

Share this post


Link to post
Share on other sites
Yashied
_IsWorkstationLocked() returns True, if the workstation is locked (Win-L), False - otherwise. You can call this function in a loop, and if it returns True, then user pressed the Win-L or has other means, such as CTRL-ALT-DEL - Shut Down - Switch User.

Share this post


Link to post
Share on other sites
sc4ry

ok, thank you, but my problem is, when pc is locked (and i get it via these function), i cannot do the mouseclicks and controlsend to pause the tel-client ;-)

so that seems no option for me?!

but do you know, how i can call the "windows-security" screen, which appears on network-devices, when you push ctrl+alt+del?

Share this post


Link to post
Share on other sites
sc4ry

i read, that windows does not allow to simulate ctrl+alt+del ... but i think that must not needed, because only a dllcall could be used to get the windows-security-screen.

i also use Real VNC and there is the possibility, to send ctrl+alt+del to the host system. so it must be possible =)

please help =)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×