Toggle the Doc Switcher in Notepad++

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Odylg
Posts: 17
Joined: 14 Jan 2016, 23:31

Toggle the Doc Switcher in Notepad++

23 Feb 2018, 01:00

I'd like to set a hotkey to show/hide the Doc Switcher in Notepad++ and i'm having some trouble. This is what i have so far

Code: Select all

F3::
Send, {Alt}
Sleep, 5
Send, t
Sleep, 5
Send, p
Sleep, 5
ControlGet, IsChecked, Checked , , Button9, ahk_class #32770
if IsChecked = 1
{
	Control, Uncheck, , Button9, ahk_class #32770
	WinClose, ahk_class #32770	
}
else
{
	Control, Check, , Button9, ahk_class #32770
	WinClose, ahk_class #32770
}
Return
It works unless Notepad++ has just been opened because there's a delay the first time you open Preferences (or probably any menu thing) on a new session.

Mainly I'd like a better way to open Preferences, though if there's a better way to do the other part i'd like that too.

Code: Select all

WinShow, ahk_class #32770
would actually work but only if Preferences was the last menu thing opened in n++.

Any help i can get will be greatly appreciated.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Toggle the Doc Switcher in Notepad++

23 Feb 2018, 01:55

Here's a way. You may like to look at the documentation for WinWaitActive, in case you want to add a timeout. I used the fact that, almost always, each menu item has a fixed menu item ID.

Code: Select all

q:: ;Notepad++ - hide/show Doc Switcher
PostMessage, 0x111, 48011,,, A ;WM_COMMAND := 0x111 ;Preferences...
WinWaitActive, ahk_class #32770 ahk_exe notepad++.exe
hWnd := WinExist() ;retrieves hWnd of window found via WinWaitActive (Last Found Window)
ControlGet, IsChecked, Checked,, Button9, % "ahk_id " hWnd
Control, % IsChecked ? "Uncheck" : "Check",, Button9, % "ahk_id " hWnd
WinClose, % "ahk_id " hWnd
return
Link:
Get Info from Context Menu (x64/x32 compatible) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=31971
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Odylg
Posts: 17
Joined: 14 Jan 2016, 23:31

Re: Toggle the Doc Switcher in Notepad++

23 Feb 2018, 02:22

awesome, thanks for your help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 332 guests