AutoHotkey Community

It is currently May 26th, 2012, 7:20 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Loop question
PostPosted: May 23rd, 2008, 2:04 am 
Hi guys,

Wonder if anyone is able too give me a hand.

I have a script where when XButton2 is held it completes an action and is looped until I let go of the key.

Is there a way too add a timer onto that so, lets say after 10 seconds of holding XButton2 the script will no longer function, and for me too use that hotkey again I just have too let go and re-hold it?

Thanks
- bk1d


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2008, 5:53 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
Code:
~XButton1::
If GetKeyState("XButton1")
{
   SetTimer, %A_ThisLabel%, -10
   If (!XB1downtime)
      XB1downtime := A_TickCount
   Tooltip % "You have held the XButton1 for " (A_TickCount - XB1downtime) "ms"
}
else
{
   tooltip
   XB1downtime = 0
}
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: May 23rd, 2008, 6:32 am 
Thanks for the help [VxE].
I'll give this a shot when I get home from work.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2008, 9:19 am 
Okay I've got it working but not doing what I want...so essentially I dont :P

I'd like too set it so that after 2 seconds the action will be none functional. How do I go about doing this?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2008, 8:58 am 
Posted below is the actual script I'm using so you can see what it does. What I'm trying too get too work is, after holding down LButton for 2 seconds the script goes inactive UNTIL I press LButton again.

If thats possible, could someone give me a hand? :)

Code:
#NoEnv
#SingleInstance Force
Process Priority,,High
SetKeyDelay -1

*LButton::
   Loop
   {
      GetKeyState, szButtonState, LButton, P
      if szButtonState = U
         break
      MouseClick, left,,, 1, 0, D
      Sleep, 10
      MouseClick, left,,, 1, 0, U
      DllCall("mouse_event", uint, 1, int, 0, int, 2, uint,0, int,0 )
   }
return


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, kkkddd1, tomL and 67 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