AutoHotkey Community

It is currently May 26th, 2012, 12:59 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: January 1st, 2009, 5:17 am 
Offline

Joined: January 1st, 2009, 5:12 am
Posts: 1
Location: Brazil
made the following code for a friend. It works like a turbo for some hotkeys. Although there are some hotkeys that just won't work depending on the order i put them on the .ahk file:

Code:
#MaxHotkeysPerInterval 1000

~Enter::Suspend

*2::
loop
{     
   GetKeyState, state, 2, P
   if (state = "U"){
      break
   } else {
      send 2
      sleep, 30
   }
}


*3::
loop
{     
   GetKeyState, state, 3, P
   if (state = "U"){
      break
   } else {
      send 3
      sleep, 30
   }
}

4::
Loop
{
GetKeyState, state, 4
    if state = U
        break
    Send yui
      sleep, 30
}
return

*5::
loop
{     
   GetKeyState, state, 5, P
   if (state = "U"){
      break
   } else {
      send 5
      sleep, 30
   }
}
return

*6::
loop
{     
   GetKeyState, state, 6, P
   if (state = "U"){
      break
   } else {
      send 6
      sleep, 30
   }
}
return

*+4::
loop
{     
   GetKeyState, state, 4, P
   if (state = "U"){
      break
   } else {
      send +4
      sleep, 30
   }
}
return

*+2::
loop
{     
   GetKeyState, state, 2, P
   if (state = "U"){
      break
   } else {
      send +2
      sleep, 30
   }
}
return

*+3::
loop
{     
   GetKeyState, state, 3, P
   if (state = "U"){
      break
   } else {
      send +3
      sleep, 30
   }
}
return

*+5::
loop
{     
   GetKeyState, state, 5, P
   if (state = "U"){
      break
   } else {
      send +5
      sleep, 30
   }
}
return

*+6::
loop
{     
   GetKeyState, state, 6, P
   if (state = "U"){
      break
   } else {
      send +6
      sleep, 30
   }
}
return

*q::
loop
{     
   GetKeyState, state, q, P
   if (state = "U"){
      break
   } else {
      send q
      sleep, 30
   }
}
return

*e::
loop
{     
   GetKeyState, state, e, P
   if (state = "U"){
      break
   } else {
      send e
      sleep, 30
   }
}
return

*r::
loop
{     
   GetKeyState, state, r, P
   if (state = "U"){
      break
   } else {
      send r
      sleep, 30
   }
}
return

*t::
loop
{     
   GetKeyState, state, t, P
   if (state = "U"){
      break
   } else {
      send t
      sleep, 30
   }
}
return

*f::
loop
{     
   GetKeyState, state, f, P
   if (state = "U"){
      break
   } else {
      send f
      sleep, 30
   }
}
return

*x::
loop
{     
   GetKeyState, state, x, P
   if (state = "U"){
      break
   } else {
      send x
      sleep, 30
   }
}
return

*c::
loop
{     
   GetKeyState, state, c, P
   if (state = "U"){
      break
   } else {
      send c
      sleep, 30
   }
}
return

*+q::
loop
{     
   GetKeyState, state, q, P
   if (state = "U"){
      break
   } else {
      send +q
      sleep, 30
   }
}
return

*+e::
loop
{     
   GetKeyState, state, e, P
   if (state = "U"){
      break
   } else {
      send +e
      sleep, 30
   }
}
return

*+r::
loop
{     
   GetKeyState, state, r, P
   if (state = "U"){
      break
   } else {
      send +r
      sleep, 30
   }
}
return

*+t::
loop
{     
   GetKeyState, state, t, P
   if (state = "U"){
      break
   } else {
      send +t
      sleep, 30
   }
}
return

*+f::
loop
{     
   GetKeyState, state, f, P
   if (state = "U"){
      break
   } else {
      send fffuuucccck
      sleep, 30
   }
}
return

*+x::
loop
{     
   GetKeyState, state, x, P
   if (state = "U"){
      break
   } else {
      send +x
      sleep, 30
   }
}
return

*+c::
loop
{     
   GetKeyState, state, c, P
   if (state = "U"){
      break
   } else {
      send +c
      sleep, 30
   }
}
return


!WheelUp:: Send {vk4Bsc025}

!WheelDown:: Send {vk4Csc026}


so if he presses shift+q for a while he will have : QQQQQQQQ
but if he presses shift+r for a while he will have : rrrrrrrr (instead of RRRRR)

first post here, so sorry if I did anything wrong.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2009, 5:32 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3329
Location: Simi Valley, CA
You should probably use #UseHook at the top of your script. Additionally, you should look into the different SendModes.

_________________
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: January 1st, 2009, 7:13 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
#UseHook may help, but only for the hotkeys which do not have "*". IIRC, the keyboard hook is required for wildcard hotkeys.
Quote:
so if he presses shift+q for a while he will have : QQQQQQQQ
"Send q" should always result in "q", never "Q"... {Blind} prevents the send from automatically releasing modifier keys, so *q -> {Blind}q is equivalent to q -> q, +q -> Q, ^q -> ^q, etc.

To support multiple keys simultaneously and also reduce redundancy, you could use timers and A_ThisLabel. For instance:
Code:
; Support any combination of modifiers:
*2::SetTimer, Repeat_{Blind}2, 30
*2 Up::SetTimer, Repeat_{Blind}2, Off
*3::SetTimer, Repeat_{Blind}3, 30
*3 Up::SetTimer, Repeat_{Blind}3, Off
; Example of longer key name, without modifier support:
Space::SetTimer, Repeat_{Space}, 30
Space Up::SetTimer, Repeat_{Space}, Off
; Example of sending arbitrary text:
4::SetTimer, Repeat_yui, 30
4 Up::SetTimer, Repeat_yui, Off ; It's that simple!

; Must have a label for each one:
Repeat_{Blind}2:
Repeat_{Blind}3:
Repeat_{Space}:
Repeat_yui:
    Send % SubStr(A_ThisLabel,8)
return


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Exabot [Bot], Google [Bot], Maestr0, poserpro and 15 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