Sign in to follow this  
Followers 0
Erik.

Lock When Not Press Ctrl And Close

6 posts in this topic

Hi

I want to make something that when you do not press LCTRl and you press close at a program the pc. will lock

i made this:

#include <file.au3>
WHile 1
If MouseClick("left",1011,10) Then
    Run("rundll32.exe user32.dll, LockWorkStation")
Else
EndIf
WEnd

it does not wokr but the lock works

how to let the program look when the mouse cursos it at position 1011,10?

i can not found that

and how to doo if the LCTRL is pressed down?


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites



look up _IsKeyPressed() and also MouseGetPos() in helpfile and on forums

these two should get you where you need to be


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi

Whit mousegetpos you get the position of the mouse

i want that when the mouse is into the position 1011,10 that it will lock when you did not press the LCRTL key

is there no key to look if the mouse is at that pos.?

Edited by Erik.

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

#include <Misc.au3>

While 1
    If _IsPressed("A2") Then
    ; do something here
    EndIf
    If $pos = MouseGetPos()
        If $pos[0] = 1101 And $pos[1] = 10 Then
            Run("rundll32.exe user32.dll, LockWorkStation")
        EndIf
    EndIf
    Sleep ( 50 )
WEnd


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$pos = MouseGetPos()
While 1
If ($pos)= "1011,10"  Then
    Run("rundll32.exe user32.dll, LockWorkStation")
Else
Endif
wend

this will not work:P

what is the option of the red close button of a program in autoit?

does it has a command ore something?

so i do not need a position of the mouse?

EDIT:

i was close:P

it won't work but i try to fix it thanks

2)

When i do this:

$pos = MouseGetPos()
While 1
If $pos[0] = 1011 & $pos[1] = 10 Then
            Run("rundll32.exe user32.dll, LockWorkStation")
        endif
        sleep(0)
WEnd

it won't work

Edited by Erik.

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

Try this..

While 1
$pos = MouseGetPos()
    If $pos[0] = 1011 & $pos[1] = 10 Then
        Run("rundll32.exe user32.dll, LockWorkStation")
    endif
sleep(100)
WEnd

You were only collecting the mouse coords out with your loop. So for it to have work you would have to had the mouse at the coords 1011x10 for the start of the program. Also rember that this is pixel perfect.. so you need to be at the coords exactly. (you could add a little + or - 5 pixels..)

L8r :)


Welcome to the internet :) where men are men! Women are men! and 16 year old women are FBI agents!

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  
Followers 0