AutoHotkey Community

It is currently May 26th, 2012, 2:40 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: June 13th, 2005, 8:58 am 
Hi, I'm Korean
So forgive my English..

At below code the key Numpad0 is the hotkey.
Now I want to modify the script to display a tooltip when the Numpad0 key is pressed for 3 seconds. Otherwise send {Numpad0}
But I don't know how to do...


$Numpad0::Send, {Numpad0}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2005, 10:00 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Hi Ifwind,
I'm not very good at hotkeys, but I hope I can direct you into the right direction.
Please have a look at the manual. Look for SetTimer, GetKeyState, EnvSub

MY first guess was:
Code:
$Numpad0:: DownTime = %A_Now%

$Numpad0 UP::
  EnvSub, DownTime, %A_Now% , S
  MsgBox, DownTime = %DownTime%
return
But that didn't work,

So I tried this
Code:
$Numpad0::
  DownTime = %A_Now%
  SetTimer, WatchKey, 100
return

WatchKey:
  Down := GetKeyState(Numpad0)
  If not Down
    {
      UpTime = %A_Now%
      EnvSub, DownTime, %UpTime% , S
      MsgBox, DownTime = %DownTime%
      SetTimer, WatchKey, Off
    }
return
And that didn't work either.

I'm sorry I didn't found a solution for you, but maybe some other user stroles by and points out the mistakes I've made.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2005, 10:59 am 
Offline

Joined: December 15th, 2004, 10:24 pm
Posts: 303
Location: United States
ifwind, please describe more specifically the result you prefer.
The following are all possibilities:

1) Numpad0 behaves normally in all ways, and tooltip appears after 3 seconds if Numpad0 is still held down.
2) Numpad0 sends Numpad0 once upon release before 3 seconds, but a tooltip appears if Numpad0 is still held down after 3 seconds.
3) Numpad0 sends Numpad0 once upon being pressed, and tooltip appears after 3 seconds if Numpad0 is still held down.
4) Numpad0 auto-repeats while held down until 3 seconds is finished, and then the tooltip appears.

_________________
1) The Open Source Definition http://www.opensource.org/docs/definition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <<AutoHotkey>>


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 13th, 2005, 11:09 am 
Offline

Joined: April 5th, 2005, 10:50 pm
Posts: 133
ifwind wrote:
I want to modify the script to display a tooltip when the Numpad0 key is pressed for 3 seconds. Otherwise send {Numpad0}
But I don't know how to do...
$Numpad0::Send, {Numpad0}


I'm not sure if that what you want or not.
anyway it's an idea you can work on it.
Code:
Numpad1::
tt=0 ; set time to 0
loop,100 ; check every 30 ms
{
      GetKeyState, s , Numpad1, p 
   if s=U
   {
      break   
   }
; you can delete the next line it's just to show time running   
Tooltip, %tt% ; show time counter
   tt+=30
   sleep 30
}
if tt<3000  ; if key pressed less than 3 secs
{
      send 1
}
else
{
   Tooltip ,time is more than 3 secs!
   sleep 1000   
}
Tooltip
return


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 13th, 2005, 12:33 pm 
I just want to know how to do belows

1) Numpad0 behaves normally in all ways, and tooltip appears after 3 seconds if Numpad0 is still held down.
--> Not exactly, but i'm interested in how to do

2) Numpad0 sends Numpad0 once upon release before 3 seconds, but a tooltip appears if Numpad0 is still held down after 3 seconds.
--> This is what i want. Please teach me about it.


Report this post
Top
  
Reply with quote  
 Post subject: Thanks
PostPosted: June 13th, 2005, 12:45 pm 
Thank you, MYYM
It runs very well..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 29th, 2005, 7:33 pm 
Offline

Joined: December 15th, 2004, 10:24 pm
Posts: 303
Location: United States
ifwind wrote:
1) Numpad0 behaves normally in all ways, and tooltip appears after 3 seconds if Numpad0 is still held down.
--> Not exactly, but i'm interested in how to do


Code:
~Numpad1::
tt=0 ; set time to 0
loop,100 ; check every 30 ms
{
      GetKeyState, s , Numpad1, p 
   if s=U
       Break   
 ; you can delete the next line it's just to show time running   
Tooltip, %tt% ; show time counter
   tt+=30
   sleep 30
}
if tt>3000  ; if key pressed more than 3 secs
{
   Tooltip, time is more than 3 secs!
   sleep 2000
}
Tooltip
return

_________________
1) The Open Source Definition http://www.opensource.org/docs/definition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <<AutoHotkey>>


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Delay inbetween commands
PostPosted: June 2nd, 2007, 7:33 pm 
Hey i'm trying to create a command so that after a command is played there is a delay (few seconds) before the second command is played
etc : send keyA delay 3s send keyB

Thanks for help from pros :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 2nd, 2007, 8:48 pm 
Offline

Joined: June 2nd, 2007, 1:33 pm
Posts: 9
read the help, is very well done!

the command you need is

Sleep


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: G. Sperotto, patgenn123, poserpro, Yahoo [Bot] and 17 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