Menu Item in AHK - autohotkey

I'm switching from keyboard maestro and mac, to AHK and Windows.
I'd like to choose a menu item in Thunderbird, say,
"Message>Move to>me#email.com>Archive".
Or I'd like to choose bookmark "2checkvist" in Chrome.
How do I create hotkeys to menu items? And how do I keep them to only that program, so that alt+t in chrome can do one thing, while alt+t in thunderbird does another thing?

As Jan Dvorak says, look at ifWinActive in the docs (I should get a point for posting the link to docs, you know).
Then you can use send with the alt key, something like this (you have to expiriment).
ifwinexist thunderbird
{
winactivate thunderbird
send !m ;message menu
send m ;move to (if you have more m-commands, then you have to send this more than once till you get to it)
send something ;here put keys until you get to your account
send a ;archive
}
Basically, you want ahk to use the alt menu keys. Everyone's interface differs a little depending on your addons and version. In your main interface, hold down the alt key and look at your menu bar. You will see that little underlines appear under certain letters. This is your "alt" key command. Now, figure out the sequence. You only need to push alt once to open the "alt thread" - now navigate manually through the menus using your keyboard. Now translate that sequence into autohotkey send commands.
You might also have to use activateWindow to assure your alt key will take correctly.

Related

Using the §-key instead of the TAB key in ALT+TAB with Autohotkey

I have a need to use something else than the TAB key to achieve ALT+TAB functionality in Windows 10. (long story short - I'm using Parallells and remote desktop on a Mac, and need to keep the Remote Desktop setting "Apply Windows Key Combinations" set to "On this computer", so I can't just forward everything to the remote computer).
Using Autohotkey on the remote computer, I thought I could simply do something like
§::Send {Tab}
to be able to press ALT+§ instead of ALT+TAB, and have Parallells ignore it and just forward it as any other key (for example SHIFT+A to type an "A"). But it doesn't seem to work that way, nothing happens when holding down ALT and pressing § except a "pling" sound. Just pressing § alone prints a TAB character if I'm in a text editor.
I tried
^!§::Send ^!{Tab}
as well, same result.
For now I settled on using the following script instead, which lets me press § to bring up the ALT+TAB window, where I can either use arrow keys or the § key to select an application, and then Enter to switch to it:
§::Send ^!{Tab}
This is not bad, but it's annoying to have to use the Enter key to activate the window. So, is there any way to simply replace ALT+TAB with ALT+§ and get the normal functionality of the ALT+TAB window-switcher?
Use the hotkey <!§::AltTab.
<! means left alt and you can read more about AltTab here.
Also, AltTabMenuDismiss might be worth looking into related to the problem you outlined in the comments.

Apple Mail "Show Related Messages" Script for Hotkey

I'm usually a Gmail user but on my most recent gig have to use an Exchange account and so decided to give Apple Mail another try (after looking at a bunch of other options) but I digress.
I prefer the classic layout but don't like to group messages by conversation.
I'm looking for a way/script to use the "Show Related Messages" button, which you can add to the toolbar, so that I can bind it to a shortcut so I can quickly catch up on emails using no mouse clicks.
Is this possible or am I hoping for something not doable?
I'm running El Capitan in case that's an issue.
Thanks for your time!
If I'm understanding you correctly, you essentially want a keyboard shortcut to access the menu item Show Related Messages in the Mail application. You mention adding something to the toolbar, but then also say you don't wish to use any mouse clicks, so I'm going to assume that it doesn't really matter whether or not there's a shortcut on the toolbar—that your priority is using the keyboard to turn on/off the Show Related Messages option.
I'm using MacOS High Sierra, so my screenshots may look a little bit different to what you see on your system, but the process for El Capitan is the same or very similar.
Open up System Preferences and selected the Keyboard pane. In the left-hand list, select App Shortcuts:
Then click the + button to the right in order to create a new shortcut:
Choose the Mail application from the dropdown list, and enter the menu item for which you want the shortcut to apply; in this case, Show Related Messages. Note: It must be typed in exactly, including any capital letters that feature, and without any extra spaces that aren't appropriate. For example, "Show related messages" will not work.
Finally, highlight the Keyboard Shortcut box and press the key combo that you'd like to use as your shortcut. You can even use one that's already assigned in Mail to something else; the pre-existing shortcut will automatically get reassigned where possible.
Click the Add button.
From then on, you'll be able to use your shortcut to toggle the Show Related Messages option on/off.

Close Quick Panel (window.show_quick_panel) on key release in Sublime Text

I am new to sublime text plugin development, I am developing a plugin that involves opening a quick panel on pressing certain key binding. I want the panel to be open only as long as the keys are pressed and once the keys are released I want it (Quick panel) to close. I've figured out I can fire the 'hide_pannel' command to close my Quick panel but I want it to fire on release of the key combination.
For example lets say, I want the quick panel on pressing Ctrl+p and I want it to close after I release ctrl.
So I was thinking if I fire 'hide_pannel' command after release ctrl should do the trick, but I couldn't find how I can fire a certain command on key release instead of key press. If there is any other solution or workaround other than what I was thinking please do let me know.
Although you can detect when a key is pressed in Sublime, you can't directly detect when it has been released. Similarly, the modifier keys (Ctrl, Alt, etc) can not be mapped to anything on their own and always require a non-modifier as well. For example, Ctrl+P is allowed, but Ctrl alone is not.
That said, theoretically it's possible to interface with the underlying operating system using a python library that uses native code in your plugin to observe the state of the keyboard.
I'm not aware of any Sublime specific examples of doing such a thing, however. Note also that in doing this you would also have to provide such a library for all of the platforms that Sublime supports (Windows, MacOS, Linux, and 32 or 64 bit versions on Windows/Linux), presuming that you want your plugin to work on multiple platforms.

In notepad++ change tab size instantly

I'm using notepad++ (v6.5.3) and I constantly have to change the size of the tab for viewing some results. Not that it's taking me a lot of time to do it manually everytime, but it would be great if I could optimize that.
Is there a way to do so? Would a macro be the solution, or are they just for typing stuff?
Thanks a lot!
Ok, there's an easy way how you can achieve this - I have tested it right now:
Install AutoHotKey (or start portable version which runs without installation)
In Windows 7 and above, ensure you launched AutoHotKey as Administrator (otherwise you get inconsistencies in its behavior) - if not sure, exit it and restart it as administrator
Right click Autohotkey tray icon and select Edit This Script
Import the macro below this list at the end of the AutoHotKey script file and save the file
Right click Autohotkey tray icon and select Reload This Script.
–– This was end of general steps, now let's go with your macro: ––
In N++, display Preferences window and press its Close button1 at the bottom (NOT at the top-right corner)
Now you can use shortcuts Win+F2 and Win+F3 to switch different tab sizes instantly
SendMode Input
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
;--------------------------------- Hotkeys for Notepad++ only
#IfWinActive ahk_class Notepad\+\+
#F2::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}16{Enter}{Tab 3}{Space}
#F3::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}4{Enter}{Tab 3}{Space}
#IfWinActive
1) Important: N++ user experience provided in dialog boxes is absolutely terrible. There are no anchors where you can fix focus when using keyboard. Thus you always need to perform step 4 manually when leaving Preferences dialog box otherwise the macros would send keys into incorect window page OR at correct page but incorrect control. Preferences dialog window remembers selected page and control. Macros I created for you therefore assume that correct page is already listed and button Close was recently focused.
Good news is Notepad++ windows with this weird behavior are rare exception from general user experience. In other places in N++ (or in other apps) where user interface components (menus, dialogs etc.) always start from the same point you do not need any special precautions like the one in step 4.
Adjust the macros as you like:
you can create more of them
you can adjust the numbers "16" and "4" typed into tab size input box
you can change shortcut keys to something else
you can replace sending keys with sending mouse clicks at desired screen/window positions
you can achieve many other useful shortcuts in N++ and in all other apps – check AHK deeper!

Autohotkey - capture extra mouse buttons

Can autohotkey capture nonstandard mouse buttons? I use a five-button mouse (Microsoft Wireless Laser Mouse 6000).
XButton1 and XButton2 according to the documentation on autohotkey.com.
The following URLs show how to have autohotkey log all keyboard and mouse events, and how to look at the log autohotkey generates of those events.
http://www.autohotkey.com/docs/commands/_InstallMouseHook.htm
http://www.autohotkey.com/docs/KeyList.htm#SpecialKeys (special keys section)
Based on this, you can find out about all mouse and keyboard events by creating an autohotkey script as such:
#InstallKeybdHook
#InstallMouseHook
Once you run the script, you can double click on the tray icon for that script, then go to View > Key History and Script Info (Ctrl K)
Based on this information, I figured out that my mouse driver is already redefining the extra mouse buttons to other keys. However, I can re-map those keys by going to Control Panel > Mouse, selecting the desired button, and using the "Macro..." option in the mouse configuration (this is a special configuration only for the Microsoft Wireless Laser Mouse 6000 v2). In the macro dialog, I can define keystrokes for those mouse buttons to send (only one per mouse button). Next, I can use AutoHotkey to watch for whatever keystrokes I have defined, and perform specific actions based on those keystrokes.
You need to capture the scancode of the key and then use that. You can find a script in 5th post of this thread, written by Skan, which will allow you to do this. Just run that and click on the GUI with the mouse button you wish to determine the scancode. Then use the scancode in place of the normal key when you create the hotkey.
There is also a built in method of retrieving keys which is documented at the bottom of this page under the heading "Special Keys". Essentially, AHK logs your key presses and automatically records the scancodes for you.
To use the scancode as a hotkey, you just do the following:
SC###:: ;Your code here
Where ### is replaced with the code of your key (or mouse button).