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 

two diferents amounts of clik for a single key

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
DrAzTiK



Joined: 18 Jun 2009
Posts: 2

PostPosted: Thu Jun 18, 2009 4:24 pm    Post subject: two diferents amounts of clik for a single key Reply with quote

Hi all

I have discover Autohotkey since some days. Very cool sofware but not so easy for my poor skill....so I need a little help Very Happy

I would like to use 2 sorts of clik ( more precisely : distinct amount of clic) somewhere on my screen (MouseClick, left, 743, 741) for a single key :

Only one clic when key is pressed normaly.
Four click when key is pressed 2 second.

It it possible ??

ps: this key is Mbutton and I want to perform one or 4 left mouse clik. Futhermore, I would prefer activate clic when the key is pressed. ( not when the key is relaxed).



ty Wink Very Happy
Back to top
View user's profile Send private message
Z_Gecko
Guest





PostPosted: Thu Jun 18, 2009 4:41 pm    Post subject: Reply with quote

Quote:
Futhermore, I would prefer activate clic when the key is pressed. ( not when the key is relaxed)
This is of course not possible, no computer can look in the future.
There is NO way to know on keypress, how long the user will hold down the key, only afterwards.
You can of course alway send one click on keypress
and if the key is still down after 2 seconds send three more.
Back to top
DrAzTiK



Joined: 18 Jun 2009
Posts: 2

PostPosted: Thu Jun 18, 2009 11:06 pm    Post subject: Reply with quote

ok thank you very much Cool
Back to top
View user's profile Send private message
jethrow



Joined: 24 May 2009
Posts: 1907
Location: Iowa, USA

PostPosted: Thu Jun 18, 2009 11:15 pm    Post subject: Reply with quote

What about checking to see if the key is still pressed after 1 sec? Then after 2 sec?
If not pressed after 1 sec, click normal.
Else, check after 2 sec. If not pressed, 4 clicks.

Just a thought
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
lbrtdy



Joined: 13 Apr 2009
Posts: 101

PostPosted: Fri Jun 19, 2009 3:49 am    Post subject: Reply with quote

I'm guessing it should be something like this:

Code:
#Persistent
MButton::
Loop
{
   execute := "1"
   GetKeyState, buttonstate, Mbutton, P
   if buttonstate = D
      press := A_Sec
   Else
      release := A_Sec
      Break
}
Return

while execute = 1
{
   Time := release - press

   if (time = 1)
      MouseClick, left, 743, 741
      execute := "0"
   if (time = 2)
      Loop, 4
      {
         MouseClick, left, 743, 741
      }
      execute := "0"
}
Return


of course this code may not work, it didn't work for me haha. But that should be the basic structure of how you want it.
Back to top
View user's profile Send private message
jethrow



Joined: 24 May 2009
Posts: 1907
Location: Iowa, USA

PostPosted: Sat Jun 20, 2009 8:12 am    Post subject: Reply with quote

I'm with Z_Gecko - don't see how it would be possible to execute a action when the key is pressed if the action is dependent on how long the key is held. However, you could do it very quickly afterward:
Code:
MButton::
CoordMode mouse, screen
sleep 200
GetKeyState pressed, MButton, P
if pressed = U
{   click 743, 741
   return
}
else
   sleep 1800
GetKeyState pressed, MButton, P
if pressed = D
loop 4
   click 743,741   
return
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Sat Jun 20, 2009 10:07 am    Post subject: Reply with quote

RapidHotkey
Code:
MButton::RapidHotkey("{LButton}""{LButton 4}",1,0.15)

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Display posts from previous:   
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