AutoHotkey Community

It is currently May 26th, 2012, 10:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: October 13th, 2008, 1:28 pm 
Offline

Joined: October 1st, 2008, 11:17 pm
Posts: 11
based on my previous posts i figured out that both the constructions SetTimer and KeyWait for performing different actions when pressing 1 button once (maintain original function, typing the letter r) or twice (call function x) brings a significant delay. (when typing words involving r the effect is that the letter after the r comes for the r: wolrd). the solution for the problem is to assign different actions to different keys. but that makes things just more complicated, so actually it's not a solution for me.

i thought a solution might be to record the time one key is pressed down. that would fix the delay problem when typing words.

Code:
GetKeyState, state, r
if state = D > 200 (ms)
    action 1
else
    send, r

Maybe some can reflect on my point of view and help me if possible, thanks
Code:
Current situation (which always gives the Delay (in ms) when typing):
if keyPressed, KeyPressedAgain < Delay
   action 1
else
   send, r


Last edited by deandoe on October 15th, 2008, 11:12 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2008, 11:16 pm 
Offline

Joined: October 1st, 2008, 11:17 pm
Posts: 11
i'm not giving up and still try to make things work. since my programming experience is not that great i hope someone could tell me if it's even possible to perform an action like this. or that i'm trying to do the impossible. thanks anyway.

Code:
GetKeyState, state, r        ;define the button which will be watched
if state = D > 200 (ms)      ;if the button gets pressed longer then 200 ms
    action 1                 ;execute action 1 (e.g. run notepad)
else                         ;else...
    send, r                  ;...keep the original function (enter gives an enter, r gives an r)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2008, 2:36 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
Code:
$n::
Sleep 250
If GetKeyState("n", "p")
   Run Notepad.exe
Else Send {Blind}n
return

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2008, 10:38 am 
Offline

Joined: October 1st, 2008, 11:17 pm
Posts: 11
thnx, so may i conclude that the answer to the topic question is no? every function (setTime, KeyWait, GetKeyState) created has it's delay at the beginning of the script; there will be always a, no matter how short, a delay? when typing all functions fail, no becomes on..

so the proposed function is not possible?
Code:
as soon as the key gets pressed
timer starts
if the key is pressed longer then 500ms
fuction a will execte
else keep original function

in the case above, typing is no problem since one keystroke will always be shorter then 500 ms only when i hold the key down long enough the function will execute..

thanks anyway for the help and suggestion you did.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2008, 11:10 pm 
Offline

Joined: October 1st, 2008, 11:17 pm
Posts: 11
the solution is the usage of: A_TimeSinceThisHotkey thanks to laz0r in the irc channel #ahk =)

Code:
$r::
  KeyWait r
  If A_TimeSinceThisHotkey > 200
     Send a
Else
     Send r
Return


this function will always type an r (as rapid as writing other characters) when typing in a word processor but will execute a function when holding down the key for more then 200 ms. thanks anyway for all the support!


Last edited by deandoe on November 25th, 2008, 7:03 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2008, 2:51 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
Thanks. found this very usefull.

One thing i noticed was that it won't be send until you actually release R. So if you hold R for 2mins, nothing happens. Any way to do it so it triggers as soon as you hit the 200ms ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2008, 6:13 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Use the timeout option:

Code:
$r::
  KeyWait r, T0.2
  If A_TimeSinceThisHotkey > 200
     Send {a}
Else
     Send {r}
Return

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2008, 9:29 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
Ahh great idea, had thought of another way of doing it, but was abit more complex.

I've tried adding hotkeys like this to alot of the keyboard buttons, but it seems like its still causing a very very small delay (which i'm think is inevitable?). The odd thing is that even i have hotkeys on all the letters i'm trying to use, it the still come out in a different order.

For example, lets say i have hotkeys on p, o, w, e and r. And if i type power fast, i'lll end up with opewr, poewr etc. Seems odd to me that i'm getting different delay on the same code?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2008, 11:42 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
I noticed this delay too.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2008, 2:55 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
Good to hear. What really got me wondering is how two hotkeys with the exact same code, can take different time to execute.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, iBob35555VR, just me, Tilter_of_Windmills, tomoe_uehara and 71 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