Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[assumed impossible] How to ControlSend arrow keys (held down for a period)


  • Please log in to reply
21 replies to this topic
girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
I'm not sure this is appropriate for what you need but from the help file for the Send command you find this...

When a key is held down via the method above, it does not begin auto-repeating like it would if you were physically holding it down (this is because auto-repeat is a driver/hardware feature). However, a Loop can be used to simulate auto-repeat. The following example sends 20 tab keystrokes:

Loop 20
{
    Send {Tab down}  [color=#408000]; Auto-repeat consists of consecutive down-events (with no up-events).[/color]
    Sleep 30  [color=#408000]; The number of milliseconds between keystrokes (or use SetKeyDelay).[/color]
}
Send {Tab up}  [color=#408000]; Release the key.[/color]


I don't often use ControlSend but perhaps something like this might work?
[color=#408000]   ; Send {Up down} ; move character off rope to recast skills and reset limit
   ; sleep 1500 ; estimated 3 seconds to move off rope
   ; Send {Up up} ; to stop holding down and prepare for recast[/color]
[color=#BF0000]   WinTitle := "MapleStory"[/color]

[color=#BF0000]   fnHoldDown("Up","1500")[/color]
   ControlSend, , {Up Up}, %WinTitle%
   sleep 500
   ControlSend,,{pgup}, MapleStory [color=#408000]; hotkey for skill to recast and reset limit[/color]
[color=#408000]   sleep 2000 ; wait for cast animation to finish
   ; Send {down down} ; press up key and hold to climb back up rope
   ; sleep 1700 ; estimated time to get back to original position
   ; Send {down up} ; release up key[/color]
[color=#BF0000]   fnHoldDown("Down","1700")[/color]
   ControlSend,,{Down Up}, %WinTitle%
Return


[color=#BF0000]fnHoldDown(key,duration)
{   Global WinTitle
   End := (A_Tickcount + duration)
   While (A_Tickcount < end)
   {   ControlSend, ,{%key% down}, %WinTitle%
       Sleep 10
   }
}[/color]

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


MapleBish
  • Members
  • 64 posts
  • Last active: Mar 30 2015 12:47 AM
  • Joined: 05 Jun 2012
O.o I couldn't find fnHoldDown. I'm guessing that you made it yourself. Correct me if I'm wrong. The function will keep sending a key down in a loop until a certain duration passes. However, doesn't A_Tickcount record time from when the computer last rebooted? Or in this case is it measuring time since loop commences? For the duration value, should I put half the intended duration value because A_TickCount should cover half the duration and added onto 'duration' should be the full intended duration value?

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
1) fnHoldDown is the function at the bottom of the script I posted. It is a custom function.
2) A_Tickcount is the number of ms since the computer last rebooted however if you check it now and add some time to it that will become the value it will check for in the whlle loop. Since there is no sleep following the call to the function you may have to adjust the duration value you send to the function so it gets the proper length of time to wait while it's holding the key down. This is all theoretical so you will need to test it in the game. Otherwise you will have to change the value of WinTitle to whatever other app you want to test the function with.

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


MapleBish
  • Members
  • 64 posts
  • Last active: Mar 30 2015 12:47 AM
  • Joined: 05 Jun 2012
Wouldnt the value of A_Tickcount change as my computer runs, thus changing the value of end as every second goes by? Or would this number remain constant?

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
That's the whole point, lets say you start into the routine at time tickcount = 1
end then becomes 1+15000 or 150001
the we enter the loop

while(tickcount (which is now 10 for example) < 150001 so we enter the block
and controlsend to the %wintitle% window the key down thing.
and sleep 10ms to let the key register with the game
then back to the top of the loop where the tickcount is now, lets say, 30.. that's still less than 15001
so we're back again to send the key down and the sleep 10 then back up top again to check
the tickcount.
we keep doing that until the tickcount reaches whatever it was when we entered + 15000 and the loop bails out. See it now?

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


MapleBish
  • Members
  • 64 posts
  • Last active: Mar 30 2015 12:47 AM
  • Joined: 05 Jun 2012
o.O i do. Sorry for the late reply. Just finished my last diploma today :D Gonna try making this tonight.

CoreTwo
  • Members
  • 33 posts
  • Last active: Dec 29 2014 03:06 PM
  • Joined: 16 Oct 2007

I was able to get keys to stay down in Torchlight II using ControlSend

http://www.autohotke...blotitan-quest/