AutoHotkey Community

It is currently May 26th, 2012, 6:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: June 18th, 2009, 5:24 pm 
Offline

Joined: June 18th, 2009, 5:10 pm
Posts: 2
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 :D

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: :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2009, 5:41 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2009, 12:06 am 
Offline

Joined: June 18th, 2009, 5:10 pm
Posts: 2
ok thank you very much 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2009, 12:15 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2009, 4:49 am 
Offline

Joined: April 13th, 2009, 3:15 am
Posts: 101
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 9:12 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 11:07 am 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
RapidHotkey
Code:
MButton::RapidHotkey("{LButton}""{LButton 4}",1,0.15)

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: dra, rbrtryn and 65 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