Inspired by a question from user Gizmo199 in the Discord channel, I’ve been experimenting and found a workaround that lets you draw while your animation “is playing” in Aseprite, much like the feature in GameMaker.
Demonstration Videos:
How it works in GameMaker:
How it works in Aseprite:
Here’s a step-by-step guide to help you achieve this.
Prerequisites:
Aseprite software installed (Note: This process also works seamlessly with LibreSprite).
Autohotkey: You can download it from here https://www.autohotkey.com/ . (I used v1.1, which is now deprecated, but you can have both versions installed if needed).
Basic knowledge of modifying shortcuts in Aseprite (or LibreSprite).
Steps:
Install Autohotkey:
Download from the provided link above and install.
Modify Aseprite Shortcut:
Change the shortcut for “Go to next frame” in Aseprite to the “s” key.
It’s just plain text, so feel free to open it with any text editor like Notepad++ to inspect its content.
Double-click on the script to run it.
Enter the millisecond delay you want for each frame.
Now, you can open Aseprite and start drawing while the animation “plays”!
Note: This method has a few issues. Sometimes, it might not detect when you release the mouse button. But it’s a fun workaround until we get an official feature (or script).
I’d love to hear your feeback, so please share your experiences and suggestions to refine this method further!
“Until we get an official feature (or script)” I’m on it! XD Messed with this idea today and it was super fun to play with, though there were some tricky issues when dealing with mouse input and basically faking the painting XD Also leads to a lot of undo actions because of this hahaha BUT made great progress on it today I think!
That’s great! I’d love to see this implemented in one of your scripts!
By the way, I loved “The Tween Machine”, it’s very useful! (I worked on a similar script long ago, but I didn’t then have much time to learn enough Aseprite scripting, so mine only does very basic tweening and it’s long forgotten somewhere on my hard disks XD)
Absolutely! I’m excited to keep working though the little querks Ive got currently with this. Love this technique. It was so much fun to mess around with even at this state.
Oh thats amazing to hear! Would love to see what youve been tweening! Im glad you were able to check out the tween machine Once you figure out how it work it too is super fun to play with.
; MIT License
; Copyright (c) 2024 JJHaggar
; Auto-Update Frame Script for Aseprite
; This script simulates sending the 's' keypress periodically to advance frames in Aseprite,
; taking into account whether the user is drawing with the mouse or not.
#Persistent ; This ensures that the script continues running after initial startup
#NoEnv ; Recommends not using environment variables for better performance
SetKeyDelay, 10 ; Sets a small delay between key down and key up events to ensure proper detection
; Initial state of the toggle (whether the script sends the 's' keypress periodically)
Toggle := False
; Prompt the user for the time interval the first time the script is executed
InputBox, UserDelay, Time Interval for advancing frames, WARNING: Change the shortcut in Aseprite for "Go to Next Frame" to "A"`nPress S (or A) to start/stop the script.`nHow many milliseconds do you want for each frame? (Recommended = 100)
if (ErrorLevel) ; If the user closes the dialog box without entering a value
{
ExitApp ; Exit the script
}
; Ensure the inputted value is numeric
if (!IsNumber(UserDelay))
{
MsgBox, You must enter a valid number.
ExitApp ; Exit the script if the input is not a valid number
}
; The 's' key will not be "absorbed" by the script, and will be used as a toggle to control the script
~s::ToggleFunc()
; Function to toggle the keypress state
ToggleFunc() {
global Toggle, UserDelay ; Declare global variables
Toggle := !Toggle ; Switch the state of the Toggle variable
if (Toggle)
{
; Set a timer to execute SendKey function periodically with the user-defined delay
SetTimer, SendKey, %UserDelay%
}
else
{
; Disable the timer if Toggle is set to false
SetTimer, SendKey, Off
}
}
; Function to send the 's' keypress
SendKey:
; Check if Aseprite window is active
if (WinActive("ahk_exe aseprite.exe"))
{
; Remember the state of the mouse buttons upon entering the function
wasLButtonPressed := GetKeyState("LButton", "P")
wasRButtonPressed := GetKeyState("RButton", "P")
; If the left mouse button was pressed
if wasLButtonPressed
{
; Wait to allow drawing in Aseprite for 60% of the delay duration
Sleep, %UserDelay%*6/10
; Simulate the release of the left mouse button
Click, Up
; Pause briefly to ensure the event is recognized
Sleep, %UserDelay%*2/10
; Send the 's' keypress
Send, s
Sleep, %UserDelay%*1/10
; Simulate pressing the left mouse button again
Click, Down
}
; If the right mouse button was pressed
else if wasRButtonPressed
{
; (Similar code for the right mouse button, with adjusted delays)
}
else
{
; Wait for the duration of the delay if no mouse button was pressed
Sleep, %UserDelay%*9/10
; Send the 's' keypress
Send, s
Sleep, %UserDelay%*1/10
}
}
return
; Function to check if a value is a number
IsNumber(value)
{
; Return True if the value is a number, otherwise False
return value is number
}