AutoHotkey Community

It is currently May 27th, 2012, 10:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Mouse double click
PostPosted: December 27th, 2006, 11:41 am 
Offline

Joined: December 20th, 2006, 10:40 am
Posts: 11
Hi
The answer for this question is probably straight forward but I have searched the forum for quite some time now without any good hints so I post this message.

What I want is a funtion that closes a window by holding ALT and clicking anywhere in the window.

I allready have a funtion that uses
Code:
!LButton::
but is there a similar one I can capture for double click. E.g
Code:
!DoubleClick::


The code I will use to close is the following that I found in another post:

Code:
MouseGetPos,,,KDE_id
WinClose,ahk_id %KDE_id%


Please advise :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2006, 3:50 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Here is what I have come up with for my use.....There are a few ways to accomplish this, this is just mine.

Code:
Time = 400 ; This is the max time between hotkey presses to be considered sequential

!LButton::
If ( A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < Time ) ;check for sequential presses
   Count++ ;Sequential presses....Count them
Else
   Count = 1 ;first press...reset
;I use a timer here to allow for duplicate presses of the hotkey
SetTimer, Handler, %Time%
return

;Exit application on escape
Esc::ExitApp

Handler:
SetTimer, Handler, Off
 ; What to do for the respective presses of the hotkey.....The values can be changed to whatever you want. 10 clicks, 100 clicks, 2 clicks
 
IfEqual, Count, 1 ; 1 Press
   {
   ;.....
   ; Do Whatever for 1 fire of the hotkey (put the !Lbutton:: code you already have here)
   ;.....
   }Else IfEqual, Count, 2 ;2 Presses
      {
      ;.....
      MouseGetPos,,,KDE_id
      WinClose,ahk_id %KDE_id%
      ;.....
      }Else IfEqual, Count, 3 ; 3 Presses
         {
         ;.....
         ;If you want 3 clicks put whatever here
         ;.....
         }
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2006, 4:34 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
jes123 wrote:
What I want is a funtion that closes a window by holding ALT and clicking anywhere in the window.

Either use MouseGetPos to get the window under the mouse cursor or:
Code:
!LButton::WinClose, A

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2006, 5:18 pm 
Offline

Joined: November 29th, 2006, 7:54 pm
Posts: 54
Nice script, ahklerner!
The script i wrote for the same purpose was twice as big as yours... ^^'

btw, why are you using Else in:
Code:
Else IfEqual, Count, 2

Code:
IfEqual, Count, 2

would do the same job...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2006, 5:32 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Quote:
btw, why are you using

Take this scenario.

Code:
x = 1

if x = 1
   {
   MsgBox, x=1
   }Else if x = 2 ; this is not evaulated if x=1
      {
      MsgBox, x=2
      }
ListLines
Pause
return



Code:
x = 1
If x = 1
   {
   MsgBox, x = 1
   }
If x = 2 ; this is evaluated even if x = 1
   {
   MsgBox, x = 2
   }
ListLines
Pause
return




There is less to evaluate....More evaluations= more time....In a large script or one that processes a lot of info in loops it can make a dramatic difference.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2006, 5:48 pm 
Offline

Joined: November 29th, 2006, 7:54 pm
Posts: 54
i knew that the next "If lines" get evaluated,
but i didnt knew that such small evaluations could make any difference in a script...
Now i know it better, thanks for info.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, HotkeyStick and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group