Kerl

Check if workstation is locked on Windows 10

9 posts in this topic

Hi, this used to work on Windows 7 64, but doesn't on Windows 10 64:

Func _isWorkstationLocked()
    $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", 0x100)
    $ret = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0])
    DllCall("User32.dll", "int", "CloseDesktop", "int", $ret[0])
    If $ret[0] Then
        Return SetError(0, 0, 0)
    Else
        Return SetError(0, 0, 1)
    EndIf
EndFunc

Please, has anybody an idea how to make this work on Windows 10 64?

Share this post


Link to post
Share on other sites



This one works on Windows 10 x64

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

I am trying to write a script that will keep a software logged in. It has a login window that pops up centered on the active application every 30 minutes, sometimes it pops over and sometimes it pops under. There is an option to keep the connection alive by clicking "Stay Logged In". Unfortunately when the window pops under the active application, I don't see it and it isn't easy to notice in the Task Bar that it's about to log out. The script activates the window, bringing it the focus, and then clicks the "Stay Logged In" button. It works fine when at the desktop and working in other applications. It will not work when the system is at the lock screen. Yes, I know about the limitations of the SEND() command; this is why it won't work

I have tested the script shown above by Kerl and I've also tested the script shown above by jguinch. Both scripts tell me when I'm at the login screen. Neither script tells me if I'm at the lock screen in Win10. When you are on a domain and press Ctrl+Alt+Del and the click "Lock" (or press Win+L) and the computer is on a domain, you are shown the lock screen. I have tried numerous other scripts on the AutoIt Forums as well as the AutoIt Wiki, and all seem to replicate the same behavior.

    Both scripts do not distinguish between the lock screen and the desktop.
    Both scripts show that the system is locked at the login screen (after Ctrl+Alt+Del and before logging in) and at the log off screen (after Ctrl+Alt+Del and before clicking "Lock").
    Both scripts show that the system is NOT locked while on the lock screen.
    Both scripts show that the system is NOT locked while on the desktop.

I need a script that will determine if the system truly is locked and not simply at the security screen (which is what these two scripts above do).


Who lied and told you life would EVER be fair?

Share this post


Link to post
Share on other sites

#5 ·  Posted

Bump


Who lied and told you life would EVER be fair?

Share this post


Link to post
Share on other sites

#6 ·  Posted

@benched42 not the solution you are looking for, but have you tried ControlSend?

Share this post


Link to post
Share on other sites

#7 ·  Posted

On 5/11/2017 at 0:26 AM, Floops said:

@benched42 not the solution you are looking for, but have you tried ControlSend?

Yes I have. It doesn't seem to work. I have the utility writing to a log file to see when it fires. ControlSend() requires the controlID as a parameter, and the controlID changes with each instance of the popup.


Who lied and told you life would EVER be fair?

Share this post


Link to post
Share on other sites

#8 ·  Posted

ControlSend() does not have to use the controlID. There are several other properties of the control you can use to identify it, Check the help file, Specifically this section Autoit->Using AutoIt->Controls


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

#9 ·  Posted

Thank you @Bowmore! I tested without a controlID and the ControlSend() function works properly.


Who lied and told you life would EVER be fair?

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