Skip to content

Instantly share code, notes, and snippets.

@lelandbatey
Created December 21, 2021 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lelandbatey/ed10fa2ea471b2460f62ac3cd6edc914 to your computer and use it in GitHub Desktop.
Save lelandbatey/ed10fa2ea471b2460f62ac3cd6edc914 to your computer and use it in GitHub Desktop.
An autohotkey script for animation-canceling while playing Stardew valley.
; Stardew Valley animation cancel script
; Original from this post:
; https://forums.stardewvalley.net/threads/a-better-animation-canceling-autohotkey-script.7391/
; This version has been modified to be slightly more explicit about things like
; making sure that the Keyboard Hooks are in use.
; WARNING: make sure that the "Check/Do Action" control within the options of
; Stardew Valley is bound to a *DIFFERENT* key than the key that this script uses
; to trigger the animation canceling. If you have this script bound to the same
; key as the "Check/Do Action" key in-game, you'll face issues where holding down
; the key for this script causes your mouse to keep clicking over and over and
; over even after you've released the key for this script, which is very
; inconvenient in-game.
;
; By default this script is bound to the Spacebar key (labeled "Space" in the
; code below), and the "Check/Do Action" key of Stardew Valley is bound to the
; "x" key of the keyboard, so you may not ever encounter this problem. However,
; if you've been manually remapping things, you may have set "Check/Do Action" to
; be bound to the Spacebar within Stardew Valley. To fix the repeat-clicking
; issue, you should re-bind the "Check/Do Action" to a different key, e.g. back
; to "x". You can do this by opening Stardew Valley, pausing the game, going to
; the "Options" section (with the icon of a game controller) in the top bar, then
; scrolling about 80% of the way to the bottom, to a section labeled "Controls".
; In the "Controls" section, roughly the fourth option down should by "Check/Do
; Action". Click that to rebind it to a different key of your choice.
#Warn
#InstallKeybdHook
#SingleInstance, Force
#IfWinActive, Stardew Valley
SleepForFrames(x)
{
Sleep, x * 16.666
}
Space::
While GetKeyState("Space", "P")
{
SendEvent, {LButton Down}
SleepForFrames(1)
SendEvent, {LButton Up}
SleepForFrames(5) ; This value depends heavily on the actual FPS you're getting
SendEvent, {r Down}{Delete Down}{RShift Down}
SleepForFrames(1)
SendEvent, {r Up}{Delete Up}{RShift Up}
}
SleepForFrames(1)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment