AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Double Middle Mouse Button Click Locks Computer

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
DoubleDave
Guest





PostPosted: Tue May 13, 2008 5:10 pm    Post subject: Double Middle Mouse Button Click Locks Computer Reply with quote

Hello

I'm trying to create a script which will send the window key and L when the middle mouse button is double clicked, thus locking the computer.

This is what I've got so far:

Code:

~MButton::
    KeyWait, MButton
    KeyWait, MButton, D T0.2
    if ErrorLevel 
        return
    else
send #L
return


But this just sends 'L's to the active window. I've tried putting a comma after the send, but it didn't make any difference.

Please help me!
Back to top
sinkfaze



Joined: 19 Mar 2008
Posts: 138

PostPosted: Tue May 13, 2008 7:30 pm    Post subject: Reply with quote

Check out Example #3 under SetTimer for some guidance on how to accomplish this.
_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
stewie7griffin
Guest





PostPosted: Tue May 13, 2008 7:41 pm    Post subject: asdf Reply with quote

send::{control}{l}

maybe idk im at school so i cant test it out try it though im not sure if control is for control but replace control for whichever word it is for the control key heh
Back to top
stewie7griffin
Guest





PostPosted: Tue May 13, 2008 7:43 pm    Post subject: asdf Reply with quote

ahh nvm i got confused wasnt paying attention fvck wut i said O.o
Back to top
DoubleDave
Guest





PostPosted: Tue May 13, 2008 8:59 pm    Post subject: Reply with quote

Thanks sinkfave. However having implemented that example I still have the same problem; the script still inputs 'L's. One of my attempts made the script press and hold the win key, and input one L, but I still had to press L on the keyboard in order to lock the computer.

My most recent attempt is below, with three different attempts (all commented out) in the key pressed twice bit, with an explanation of the effect they had.

Code:

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; Example #3: Detection of single, double, and triple-presses of a hotkey. This
; allows a hotkey to perform a different operation depending on how many times
; you press it:

;3rd attempt
~MButton::
if mbutton_presses > 0 ; SetTimer already started, so we log the keypress instead.
{
    mbutton_presses += 1
    return
}
; Otherwise, this is the first press of a new series. Set count to 1 and start
; the timer:
mbutton_presses = 1
SetTimer, MButtonT, 400 ; Wait for more presses within a 400 millisecond window.
return

MButtonT:
SetTimer, MButtonT, off
if mbutton_presses = 1 ; The key was pressed once.
{
;    Run, m:\  ; Open a folder.
}
else if mbutton_presses = 2 ; The key was pressed twice. ;THIS IS THE IMPORTANT BIT
{
   ; Run, m:\multimedia  ; Open a different folder.
;   Send {LWin Down} {L}  ;effect: in first instance types 'L', user must press L on keyboard to initiate lock.  Win key stays down until user presses Win key
;   Send {LWin} {L} ;effect: an L is typed every time, with a space in between each one
;   Send #L ;effect: an L is typed every time with no spaces
}
;else if mbutton_presses > 2
;{
;    MsgBox, Three or more clicks detected.
;}
; Regardless of which action above was triggered, reset the count to
; prepare for the next series of presses:
mbutton_presses = 0
return


The problem probably has something to do with making the script send the windows key AND the L key, as the detection of the double middle mouse button click seems to work fine.

So I guess the question is how to do this?
Back to top
Vinthian



Joined: 11 May 2008
Posts: 15
Location: USA

PostPosted: Tue May 13, 2008 10:15 pm    Post subject: Reply with quote

try

Code:

Send {LWin Down}
Send {L Down}
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
DoubleDave
Guest





PostPosted: Tue May 13, 2008 10:47 pm    Post subject: Reply with quote

Unfortunately that had the same result - the windows key was pressed down but a single 'L' was typed in the text editor and then only pressing L on the keyboard locked the computer.
Back to top
sinkfaze



Joined: 19 Mar 2008
Posts: 138

PostPosted: Wed May 14, 2008 12:39 am    Post subject: Reply with quote

Don't Send something to lock the computer, Run something:

Code:
else if mbutton_presses = 2
{
 Run rundll32.exe user32.dll, LockWorkStation
}

_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group