How to use the greater-than character as a shortcut trigger in AutoHotkey? - special-characters

The question is quite straight forward, I want pressing the > character to send Tab. Something like
>::Send, {Tab}
but that doesn't seem to work, probably because the '>' is used to denote right-(ctrl|alt|shift). How do I escape it? Tried {>} with no luck.

Your code does work:
Code before or after your hotkey might be affecting how it works.
Try putting your code at the top of the script.
If that doesn't work, RIGHT CLICK the autohotkey icon on your taskbar, then click "Edit This Script". Save and replace the script with just:
>::Send, {Tab}
RIGHT CLICK the autohotkey icon on your taskbar again, then click "Reload This Script". Now test > again.

Related

Can I configure VS Code to disable Breakpoint by middle click?

I am switching from PyCharm to VS Codium. I want to be able to disable breakpoints by middle mouse click, like in pycharm.
Currently, I can disable a breakpoint by right click at breakpoint and select Disable Breakpoint:
Another way is to disable it in list in Breakpoints view.
But I want to be able to quickly enable/disable it by just clicking with mouse wheel (middle button). Is it possible to configure VS Code this way? Currently, when I middle click on breakpoint, this is ignored, and instead a text from selection clipboard is pasted (it is the default behavior in linux). Visual Studio Code version is 1.66.1.
There is no way at the moment to customize mouse click events. There are a few hardcoded options you can change in the settings, but it is extremely limited like pressing ctrl and the mouse wheel for zoom. As far as I am aware, disabling breakpoints is not among those options.
Check out: https://github.com/microsoft/vscode/issues/3130
I currently use the following workaround.
Remap the middle click to some button.
For wayland several utilities can be used for that. Let's take kbct.
Add such config (edit for your needs)
/etc/kbct/config.yml:
- keyboards: [ "Logitech MX Master" ]
keymap:
btn_middle: f15
Then start kbct.service.
Create the ruler script
Make the file choose_press.sh:
#!/bin/bash
class=$(xdotool getactivewindow getwindowclassname)
if [ "x$class" == "xVSCodium" ]; then
ydotool click 0xC1 # right click
sleep 0.2
ydotool key 107:1 107:0 28:1 28:0 # End, Enter
else
ydotool click 0xC2 # middle click
fi
Do not forget to add executable permissions.
Bind shortcut to the script
To assign a command to shortcut in KDE, go to System Settings -> Shortcuts -> Custom Shortcuts, right click, choose New -> Global Shortcut -> Command/URL. Go to Action tab and fill in the command. In this case it will be the path to choose_press.sh. Note: do not use ~ there.
And in Trigger tab assign the shortcut. In this case we use f15 (use some way to simulate it, if it is not presented on the keyboard).
Start VS Codium
Use vs codium in X11 mode. This is because I currently do not know how to get active window class in wayland.
Result
Now if you middle click in vscodium window, it will receive the sequence of input that leads to enabling/disabling breakpoint. In any other window, the middle click will behave as normal.
There is debug.enableOrDisableBreakpoint in codium, but toggling that with shortcut only works when the cursor is on the line with breakpoint. I did not found a way to move cursor to the line where you pressed (method to get the mouse over line?). So I made that complex thing with ydotool choose_press.sh.
I also tried to start stop kbct by window activation, but that is unfortunately broken in kde wayland currently.

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.

Save with "Retry as Sudo" using keyboard commands

Anytime I try to save a file (using Ctrl+S) that requires elevated permissions, I get the popup with the button to "Retry as Sudo". This is fine, but there does not seem to be any way to select "Retry as Sudo" using the keyboard. I have to use the mouse to actually click the "Retry as Sudo" button. I have tried tabbing, but cannot seem to select this button without using the mouse. Does anyone know if there is anyway to save a file as sudo without using the mouse?
From https://github.com/microsoft/vscode/issues/90661#issuecomment-586422989:
Create keyboard shortcut for command notifications.focusToasts
When the Retry as Sudo toaster appears you can now:
Press the assigned shortcut
Press Tab
Press Enter
I wanted to include an example to complement the other answers.
To add a keybinding open the command pallet:
ctl+shift+p Windows
cmd+shift+p MacOS
Search for >Open Keyboard Shortcuts (JSON) and press enter.
https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization
Below is an example that you can copy and paste as is into the json document. If there are no existing custom bindings just place it in between the [ ] brackets. If there are existing bindings (denoted by { } brackets) make sure you use a comma to separate them.
{
"key": "ctrl+shift+l",
"command": "notifications.focusToasts",
}
To be clear you will need to first save to bring up the "save as sudo" notification. Then you press the hotkey combination (which focuses the notification), then press TAB to highlight the "save as sudo" button, then press Enter to save.
It's not ideal, but it works.

Basic AutoHotKey Use For Multiple Key Presses

How can I use AutoHotKey to simulate pressing control quote, then the menu bar button, then the down arrow when I press control p?
As a beginner, I have just been fiddling around with it, but I did not manage to make it work.
>^p::
Send ^{'}
Send {AppsKey}
Send {Down}
Right now, to me at least, it seems as though the only line of the code that is executing is "Send ^{'}" without anything under it executing.

AutoHotKey script fails after first use

I am working with a Help file as a Word 2007 document. I need to update the screenshots as I go through, so I'm trying to get AHK to select the 'Change Picture' option from the right click drop down menu when I press my key combination. I've got the code, and it works perfectly... the first time I use it. After that, I only see the right click menu flash and disappear. I suspect that the script from Send {Down 4} on is not executing because I can just barely see the 'Cut' option highlighted, but the selected image is not cut from the document, indicating that the Send {Enter} is also not being executed.
I cannot find anyone else who seems to be having this problem. If I manually reload my script, it works fine again, but only the once. Then it's back to flashing the drop down and nothing else. Any help would be greatly appreciated. I'm trying to get this process down to as few clicks as possible, but it's getting to the point where I'm wasting more time trying to solve my macro problems than I would just doing it the slow awkward way.
My script as it is now:
^!z::
Send +{F10}
Send {Down 4}
Send {Enter}
return
For clarification's sake:
When I remove everything following Send +{F10} and then use my hotkey, I get the right click menu displayed and not flashed, but again, only the first time I use it. After that, the menu goes back to flashing on the screen once. To compare, actually pressing Shift and {F10} displays the right click menu, and it does not disappear on lift.
If I move all three Send commands into one line to get Send +{F10} {Down 4} {Enter} The script executes the 'Cut' option from the right click menu, then moves the cursor down 4 lines and then sends the {Enter} keystroke. This set of actions works after the first use of the script, unlike previous instances.
In my copy of Word, the control key causes a secondary 'Layout Options' menu to pop up if there is an image selected. While I'm not sure why it's working for you the first time but not subsequently, when I test this at my end it works if I change two things:
Use mouseclick, right instead of Send +{F10}
Change the shortcut modifier from shift-ctrl to Win, i.e. set it to #z
You can try sending the keyboard shortcut instead of down command
SetBatchLines, 1
SetKeyDelay , 100 ; in miliseconds, keep increasing until your pc can hadle it
!x:: ; your hotkey in my case alt + x which is similar to ctrl + x for cutting text
Send +{F10}
Send {t} ; use the cut keyboard shortcut, for word should be 't'. if for some weird reason isn't change it
Send {Enter}
return