| View previous topic :: View next topic |
| Author |
Message |
DrAzTiK
Joined: 18 Jun 2009 Posts: 2
|
Posted: Thu Jun 18, 2009 4:24 pm Post subject: two diferents amounts of clik for a single key |
|
|
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
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  |
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Thu Jun 18, 2009 4:41 pm Post subject: |
|
|
| 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
|
Posted: Thu Jun 18, 2009 11:06 pm Post subject: |
|
|
ok thank you very much  |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Thu Jun 18, 2009 11:15 pm Post subject: |
|
|
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 |
|
 |
lbrtdy
Joined: 13 Apr 2009 Posts: 101
|
Posted: Fri Jun 19, 2009 3:49 am Post subject: |
|
|
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 |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Sat Jun 20, 2009 8:12 am Post subject: |
|
|
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 |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
|
| Back to top |
|
 |
|