Coloring Pixels

Coloring Pixels

评价数不足
How to Create a Painting Tool that will Paint more than one Pixel?
由 acibi 制作
This guide will use AutoHotkey script to create a mouse movement simulator on a horizontal line so that you can rest those weary wrists a little bit. (For Windows Users)
   
奖励
收藏
已收藏
取消收藏
Introduction
Hello and welcome. I will try to guide you through setting up a mouse movement simulation script where the mouse oscillates from left to right while clicking to aid you in your coloring endeavors.

I think of this script as an accessibility tool. I've looked far and wide for an option to increase the brush size or have some variance in the way we color things. One thing I was able to find is the ClickLock ( for Windows people). What this does is, basically, after you keep clicking for some time, even if you remove your hand from the left mouse button, it holds the click. Very helpful with the coloring.

Now, as this was helpful, as it took the strain of clicking from the hand, it was not enough because I still needed to go over a huge area where I needed to constantly oscillate my hand for painting. Even if you zoom out, although it minimalizes the oscillation amount, it doesn't allow you to see the numbers and takes away from the fun.

At first, I tried to check for increased brush size in the discussion forums, but from some of the dev replies I've seen there, it looks like they don't have any plans to add such tools to the game. Then I checked if it was possible to mod the game, but I also couldn't find any modding options. The last resort was to find a way to simulate whatever I am doing with my hand using mouse movement tools or autoclickers.

Although some of the auto clickers have record&play option, the speed of the mouse is not adjustable, and mouse movement is very jittery, so it is not a viable option.

Lastly, I was able to discover the AutoHotkey(AHK) scripting tool. After some consultations with an AI, I was able to come up with the code in this guide. But before checking the code, let's talk about what it does and see an example of it.

DISCLAIMER: AHK use can be problematic if you don't know what you are doing. Even though I explained the code line by line, a change of the variables might lead to unexpected results. So use it at your own risk. Don't use the tools you don't understand. I am just sharing a way to do things better, but in no way responsible for all the unexpected outcomes that may arise from the use of this tool.

Also, you can take this tool and make it better. You should have foundational information on how to set up AHK scripts after you finish this guide.
What the Tool Does?
The script we will use utilizes AHK scripting commands and moves the mouse back and forth in a speed the user desires. Coupled with the different zooming options, the script helps you paint vast areas with minimal effort and less strain on the wrists.

The system works this way: We connect a hotkey to a bunch of movements, and whenever we click on that hotkey, our script starts doing the commands we added.

Example for speed level 1:


In this example, I am using Q and E to change the color. In the middle of the gif, I am stopping the mouse to show that we can start and stop the process at any time.

Example for speed level 2:


Example for speed level 10:


Contrary to what we would normally think, in AHK, the speed decreases as the number increases. 2 is the default speed; 0 is the fastest instant movement, and 100 is the slowest. The system only accepts integers, so 1.5 is out of the question.

As you can see from the examples above, slower speeds, i.e higher numbers, better fits to zoomed-out scenarios, while faster speeds fit better to zoomed-in scenarios.

Another thing to consider is our ability to move the mouse vertically. When the speed is 1, the input delay is almost non-existent; that's why we are able to move the mouse freely. But if it's higher than that, moving the mouse becomes a bit more problematic. (If there's a way to fix this issue please comment so I can add it here.)
AutoHotkey Setup
Follow the tutorial in this page[www.autohotkey.com]. We only need to do 1-a and 1-b.

When you go to the homepage, download the v2.

After you finish creating your first script, test it as it's shown in the tutorial. If it's successful, then copy the code below and replace everything in the .ahk file.

; Initialize the toggle state and speed +Esc::ExitApp SendMode "Event" #SingleInstance Force toggle := false speed := 1 move_distance := 300 ; ` key toggles the mouse movement `:: ; Tilde key { global toggle toggle := !toggle if (toggle) { ; Start moving the mouse SetTimer(MoveMouse, 100) } else { ; Stop moving the mouse SetTimer(MoveMouse, 0) } } ; Hotkey to increase speed (e.g., F10) F10:: { global speed speed := Min(100, speed + 1) ToolTip "Speed: " speed ; Show current speed Sleep 1000 ; Display for 1 second ToolTip ; Hide the tooltip } ; Hotkey to decrease speed (e.g., F9) F9:: { global speed speed := Max(1, speed - 1) ToolTip "Speed: " speed ; Show current speed Sleep 1000 ; Display for 1 second ToolTip ; Hide the tooltip } MoveMouse() { global speed global move_distance ; Move the mouse to the right MouseClickDrag("Left", , , move_distance, 0, speed, "R") ; Move the mouse back to the left MouseClickDrag("Left", , , -move_distance, 0, speed, "R") }

Then, save the file and run it. Right now, if you check your system tray, you would see a green H icon that shows your script is running. Until we click on the required hotkeys, though, it does nothing.
What's Going on in the Code?
You don't need to read this chapter if you are not interested in how each line works. But doing so should equip you with the knowledge to edit the code to your liking.

Let's go over the code line by line.
; Initialize the toggle state and speed
; denotes comments. Makes the code more readable.

+Esc::ExitApp
Clicking Shift+Esc will close the script. Very useful if you mess up the numbers below.

SendMode "Event"
The default SendMode moves the mouse instantaneously, so we need to set it up here to be "Event". More info in the docs[www.autohotkey.com] and also in the docs of the main function we will use later.

#SingleInstance Force
This is to not get prompt every time we change something in the code and run the ahk file again. More info in the docs[www.autohotkey.com].

toggle := false
Main toggle. It's set to false, so when we first run the script, it doesn't start drawing wherever the mouse is.

speed := 1
Default speed. You can change this to your liking. 0 won't work though.

move_distance := 300
Default mouse movement distance. You can change this to your liking. I chose 300 because it was close to what I generally work with. Also, it might be a good idea to keep it less than your display width.

`:: ; Tilde key
This is the key above the TAB button. Its our main hotkey. The toggle changes status based on our click of this hotkey, thus starting/stopping the painting process. It's close to WASD for movement and QE for number change. You can change this to another button. More on your options in the docs[www.autohotkey.com].

global toggle
The global tag denotes that the inner function uses the global variable.

toggle := !toggle
Whenever the hotkey is pressed, the toggle situation changes.

if (toggle) { ; Start moving the mouse SetTimer(MoveMouse, 100) }
SetTimer calls a function in the given intervals. In this example it calls the function every 100 milliseconds. You can change the interval as you like. More on this function in the docs[www.autohotkey.com].

else { ; Stop moving the mouse SetTimer(MoveMouse, 0) }
And the function is not being called when the toggle is false.

F10:: { global speed speed := Min(100, speed + 1) .... }
F10 to increase the speed variable, thus decreasing the mouse movement speed. You can change this hotkey to something else. Min function here makes sure the speed is always within the boundaries.

ToolTip "Speed: " speed ; Show current speed Sleep 1000 ; Display for 1 second ToolTip ; Hide the tooltip
This part is just to show the current speed. You can delete it if you don't want to see this information.

F9:: { global speed speed := Max(1, speed - 1) ... }
F9 to make the mouse move faster by decreasing the speed variable. Max is there to ensure the speed is always within the boundaries. If you want, you can make the 1 into 0 to reach the instantaneous movement. Don't know how it would help with the painting, though.

MoveMouse() { ... }
Our main moving function

MouseClickDrag("Left", , , move_distance, 0, speed, "R")
This function does many things in one go. So, it click to "Left" mouse button wherever the position of it, then moves it to the right based on the move_distance, at the speed of "speed" variable.

"R" is to denote Relative, so it doesn't go and click on the absolute coordinate positions. Instead, it starts from the immediate pixel the mouse is at.

More info about this specific function is at the docs[www.autohotkey.com]. You can also find information about SendEvent mode here.

MouseClickDrag("Left", , , -move_distance, 0, speed, "R")
Does the same thing as the one above but in the other direction.
Coloring Pixels Setup
This is the setup that works for me, but it's possible that there are other/better ways. Here is what I have:

In the Coloring Pixel settings:
In Game Settings:
Lock: Completed Pixels
Remove Completed Colors from Palette: Selected ( Can work without it, too)
Keyboard Pan Speed x1.9 (Can be lowered, but felt ok. Especially important for zoomed-out slower mouse speed use cases.)

I would say only the Completed Pixel Lock is necessary, the rest can be adjusted according to your own play style.
Known Issues/Limitations
1- Antivirus Programs
Although everything in this program is written by me with the help of AI, my Norton 360 still tried to make me quarantine it. You can create an exclusion for this file.

2- Speed can only be an integer, like 1 or 2.

3- If used on the second display, it becomes very wonky.

4- AutoHotkey is for Windows. Don't know about other OSs, but surely there should be ways of doing the same there. If you have tools do the same in other mainstream OSs and want them to be in this guide, I can add them here.

5- On slower speeds, after 2-3 basically, it becomes harder to move the mouse vertically. It's possible there is a solution for this, but I am no AHK wizard myself, so I don't know it now. If you know, do share, though.
Closing Remarks
Thanks for reading the guide, and I hope it was helpful to you. If you have any questions or suggestions, please leave a comment.
Credits
AHK website for the download, tutorials, and the documentation:
https://www.autohotkey.com/

Poe's Assistant for providing the code, because I am not going to learn a whole new language for a side project when we have tools to write codes on a whim (maybe I would've done it 5 years ago):
https://poe.com/

Girlfiend's guide that taught me about Click-lock, initial tool that later on evolved into the tool above:
https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2810068097

LICEcap for those nice looking GIFs:
https://www.cockos.com/licecap/