Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Hotkey Send Sequence for PC Game

  • Please log in to reply
No replies to this topic
  • New members
  • 1 posts
  • Last active: Oct 17 2015 05:40 AM
  • Joined: 15 Oct 2015
First post!  I have a quick question about my script, it works properly, but not 100% of the time.  I think I am missing something fundamental here, and I am hoping any of you with more experience may spot the issue right away.  I know a little bit about autohotkey coding, as I have used it off and on for a couple years.  Being both disabled and a fairly serious gamer, I mostly use autohotkey to make necessary adaptations to properly play my PC games.  Recently, I have started playing Fable III on the PC.
I just finished playing Fable Anniversary, and it had great native control customization.  I especially liked having hotkeys for individual magic spells.  Basically, while controlling your sword/bow with the mouse, you could set spells to the various number keyboard keys 1-0.  This worked great!
Unfortunately, Fable III seems to be designed for use with a gamepad (it being an XBOX port), and so it has a not very disability-friendly control scheme.  To put it simply, you must use the mouse left and right click to control both swords and magic (and bow).  To switch between them, you have to press 1, or 2 (or 3) respectively.  So first I need to create an autohotkey script that makes magic a purely keyboard function (and I will work on the other functions later after getting this right).  I want every time I press INSERT to first press 2 to switch to magic, then LEFT CLICK the mouse fire the spell, and then press 1 to switch back to swords so I can still use LEFT CLICK normally to swing my sword.  The only game specific nuance is that the script needs to hold down LEFT CLICK while I am holding down INSERT (the game has a hold-to-charge-function).  I thought this would be a relatively easy code, and here is what I got so far:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Event
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Process, priority, , High 
BlockInput On
Send 2
Sleep 15
Send {LButton Down}
BlockInput Off
Space Up::
BlockInput On
Send {LButton Up}
Sleep 10
Send 1
BlockInput Off
This script seems to work about 90% of the time, including when I hold the INSERT key down & when I am mashing the keyboard as fast as possible.  However, for some unknown reason, after 5-10 presses it suddenly will stop casting the spell and instead swing my sword.  It continues to do so for several seconds after I stopped hitting any buttons, which in gaming terms is a game over.  I believe the two hotkey codes are improperly interfering with each other or operating of sync.  Does anybody have any thoughts on how to improve my reliability using this code?
In anticipation of questions, I had to include the sleep commands because, without them, the game had difficulty parsing the command correctly, and would keep me in swords, never switching to magic.  It seems to be a problem with the game engine itself, as it is fully possible switch to magic by pressing 2, and if you left click quick enough afterwards, still swing your sword despite the GUI showing clearly you are in magic mode.  A delay of 15 ms seems to be enough to get the commands the process correctly.  Any shorter and it fails to process, any longer and the out of sync problem is exacerbated.
Finally, I used the BlockInput On/Off to eliminate the possibility of me accidentally clicking left click in the middle of a spell attack sequence being a source my problem.  However, I really do not think I am doing so, as I have still had a happen with my hand off the mouse.  I would prefer to eliminate these lines altogether, but including them did seem to improve reliability a little.
I could really use some help cleaning this script up.  I have tried numerous things, including SendInput Play (which did not work at all).  It is just really frustrating to have this so close yet be still unable to have a work.  Any help at all is appreciated!