• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can I create an action or script that toggles the "Align art to pixel grid on creation" button?

Contributor ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

I'm talking about this option:

ILSnap.png
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?

TOPICS
Draw and design , Feature request , How-to , Scripting , Tools , Type

Views

620

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Contributor , Jul 01, 2023 Jul 01, 2023

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

...

Votes

Translate

Translate
Enthusiast , Jul 02, 2023 Jul 02, 2023

I don't see why AHK is needed here when you can assign a hotkey by default: Snap to Pixel.

align-pixel.jpg

Votes

Translate

Translate
Enthusiast , Jul 03, 2023 Jul 03, 2023

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. 

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 27, 2023 Jun 27, 2023

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.

Screen Shot 2023-06-27 at 7.08.37 PM.jpg

 

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

quote

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2023 Jun 27, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2023 Jun 29, 2023

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.

  • You have to reopen the document for it to be applied
  • It can be enabled but not disabled

 

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 01, 2023 Jul 01, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2023 Jul 01, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 02, 2023 Jul 02, 2023

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.

align-pixel.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2023 Jul 02, 2023

Copy link to clipboard

Copied

"Snap to Pixel" was that it. I did not know that. Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 02, 2023 Jul 02, 2023

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.

Illustrator_9GXkpAeniz.png
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 03, 2023 Jul 03, 2023

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 03, 2023 Jul 03, 2023

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. 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 03, 2023 Jul 03, 2023

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 03, 2023 Jul 03, 2023

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines