Copy link to clipboard
Copied
I'm talking about this option:
Ideally I want to create either an action or script that toggles this so I can assign it to a hotkey. I switch back and forth between this option all the time and having a keyboard shortcut would be a HUGE quality of life boost when working.
Anyone know how to do this?
Got it working in AutoHotKey. Here's the script:
#Requires AutoHotkey v2.0
; Illustrator SHIFT + 3 Toggle Pixel Snapping
#HotIf WinActive("ahk_class illustrator")
+3::
{
WinGetClientPos &X, &Y, &ilW, &ILH, "ahk_class illustrator"
ilC := "x" (ilW - 72) " y50"
SetControlDelay -1
ControlClick ilC, "ahk_class illustrator",,,, "NA"
}
This script binds SHIFT + 3 to toggle snapping. You can change the hotkey to your tastes. If you are using a HDPI screen, or the UI is modified in an
I don't see why AHK is needed here when you can assign a hotkey by default: Snap to Pixel.
Custom hotkey in Keyboard Shortcuts > Menu Commands > Snap To Pixel toggles the top right button. Tested on Windows 10 AI CC 27.1.1, 27.6.1, Mac OS.
Copy link to clipboard
Copied
Quite often you can use the actions flyout menu to add a menu item, that do not record. In this case unfortunately there is no menu item so sincerely doubt you can record or add that.
I am finding that once you turn that setting on, it stays on if you are creating a new document using a web preset. Once you create a print preset it takes the setting off. As you switch often, thought i would explain, as I often forget to check, so did some exploration into this.
Copy link to clipboard
Copied
Quite often you can use the actions flyout menu to add a menu item, that do not record. In this case unfortunately there is no menu item so sincerely doubt you can record or add that.
By @Mike_Gondek
Yup, tried that. I wonder if there is a way in ExtendScript.
Copy link to clipboard
Copied
You may have been able to do this in an older version when align to pixel grid was under the align flyout. This guy that looks alot like me posted screenshot what that used to look like.
Copy link to clipboard
Copied
This is supposed to be handled by the "snapToPixelOnUserAction" preference.
// turn on
app.preferences.setBooleanPreference('snapToPixelOnUserAction', true) ;
However, it is difficult to use in practice for the following reasons.
It would be more realistic to use applications such as Keyboard Maestro or Power Automate Desktop to automatically detect the icon image of "Align art to pixel grid on creation" from the screen and click on it.
Copy link to clipboard
Copied
Got it working in AutoHotKey. Here's the script:
#Requires AutoHotkey v2.0
; Illustrator SHIFT + 3 Toggle Pixel Snapping
#HotIf WinActive("ahk_class illustrator")
+3::
{
WinGetClientPos &X, &Y, &ilW, &ILH, "ahk_class illustrator"
ilC := "x" (ilW - 72) " y50"
SetControlDelay -1
ControlClick ilC, "ahk_class illustrator",,,, "NA"
}
This script binds SHIFT + 3 to toggle snapping. You can change the hotkey to your tastes. If you are using a HDPI screen, or the UI is modified in any way that affects the position of the snap toggle button, you might need to adjust the script.
This will not work on Mac.
Copy link to clipboard
Copied
You solved on your own. Congratulations!
AutoHotkey does not work on macOS, but clicking on specific coordinates is possible with Keyboard Maestro, AppleScriptObjC, JXA+ObjC, etc.
Copy link to clipboard
Copied
I don't see why AHK is needed here when you can assign a hotkey by default: Snap to Pixel.
Copy link to clipboard
Copied
"Snap to Pixel" was that it. I did not know that. Thanks.
Copy link to clipboard
Copied
That hotkey isn't working for me. And the snap toggle button on the top right does more than just snapping to pixel.
You can obviously customize this to your liking. Snap to pixel only toggles the menu item. And for some reason even that is failing after assigning a custom shortcut. I'm happy with the AHK script. Appreciate the information though about that option being exposed by keyboard shortcuts.
Copy link to clipboard
Copied
Custom hotkey in Keyboard Shortcuts > Menu Commands > Snap To Pixel toggles the top right button. Tested on Windows 10 AI CC 27.1.1, 27.6.1, Mac OS.
Copy link to clipboard
Copied
Wow, I have no idea why the keyboard shortcut didn't work before. I changed the shortcut to something else and now it's working great! I had no idea that snap to pixel toggles that button. I thought the button encapsulated a few other settings too.
Thank you for pointing this out. I guess my AHK script is kind of useless now. 😞
Copy link to clipboard
Copied
Glad you got it solved, but it should just worked with an assigned hotkey directly in Illustrator.
Also the command is availbleat the bottom of the View menu, just 'Snap to Pixel' (surely without sub-options).
Can you please check if it gets toggled through the menu?
If either of both does not, I encourage you to log a bug at illustrator.uservoice.com and shre full details on your OS and the build used — even though it is solved for you with an AHK script... perhaps somebody else has this problem as well, and instead or reporting it and force the team to fix it, everyone hacks. No wonder we got broken Ai at our hands...
Copy link to clipboard
Copied
It was my fault. The keyboard shortcut I entered for some reason was the problem. When I changed the shortcut it started working perfectly. Sergey was spot on with this one. I am glad this works now, even if it renders my AHK script useless.