Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing: AHK script so that single Escape key closes palettes #1621

Open
cspotcode opened this issue Oct 19, 2024 · 1 comment
Open

Sharing: AHK script so that single Escape key closes palettes #1621

cspotcode opened this issue Oct 19, 2024 · 1 comment
Labels
discussion Open discussion

Comments

@cspotcode
Copy link

I wanted to share a small AutoHotKey script I wrote so that Command Palettes can be closed by pressing the escape key only once instead of twice. By default, OneMore opens the dropdown list by default, and pressing escape once closes the dropdown, twice closes the palette.

This Autohotkey script intercepts Escape key when a palette is open and closes the palette directly.

I hope it's helpful to anyone else who wants to tweak their OneMore setup.

#Persistent
#SingleInstance, Force

#If WinActive("OneMore Command Palette") || WinActive("Quick Palette")
Escape::
    WinClose, A
return
#If
@cspotcode
Copy link
Author

I have also tried to teach it to auto-close the palette if I alt-tab or click away from it. Ideally, I wish the command palette didn't appear in the alt-tab list so that when I alt-tabbed, it switched to a next non-OneNote window. But I'm guessing that would be really tricky or impossible to implement.

The next best thing is auto-closing the palette when it loses focus. So if I open the palette, then change my mind and alt-tab, it will switch focus to OneNote and the palette will close.

I realize it might seem silly for me to be opening the palette and changing my mind, but I guess that's just the way it goes when I use computers. Things get a bit frantic.

Unfortunately, stress testing this feature occasionally caused OneMore to lock up. So I don't recommend it, but I'm sharing the syntax in case anyone wants to tinker.

#Persistent
#SingleInstance, Force

SetTimer, CheckPaletteLostFocus, 100
return

#If WinActive("OneMore Command Palette") || WinActive("Quick Palette")
Escape::
    WinClose, A
return
#If

CheckPaletteLostFocus:
    If !WinActive("OneMore Command Palette") && !WinActive("Quick Palette")
    {
        If WinExist("OneMore Command Palette") || WinExist("Quick Palette")
        {
            WinClose, OneMore Command Palette
            WinClose, Quick Palette
        }
    }
return

@stevencohn stevencohn added the discussion Open discussion label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Open discussion
Projects
None yet
Development

No branches or pull requests

2 participants