Adding Keyboard Shortcuts in PRAAT - praat

I'm hoping to create a shortcut that allows the user to replay the last 10ms as well as a short cut that allows the user to play the subsequent 10ms of an audio file.
Do folks know any methods for incorporating shortcuts like this into PRAAT or any existing plugins?
Tips on good PRAAT message boards or listservs are also appreciated.

Praat has very bad support for shortcuts. As far as I know, the only platform-independent way in which you can specify what some keyboard shortcuts do is by using the logging scripts, and these only really work in the Sound and TextGrid editors.
In a nutshell, you can write up to two scripts and link them to Alt + F12 or Ctrl + F12, and pressing those keys in the editors will execute the specified scripts (in editor mode!). The mechanic is designed for logging scripts, but since the shortcuts simply execute a script, and you can specify the contents, you can do anything you want with them.
To link them, open an editor and go to Query -> Log settings...
Write the path of your scripts in the "Log script 3" (which uses Alt + F12) and "Log script 4" (which uses Ctrl + F12).
Of course, one of the limitations of using this approach is that you cannot specify the shortcuts (which is also a problem because there are sometimes conflicts that need to be resolved; in KDE, for example, Ctrl + F12 is used to show the desktop).
As for Praat message boards, there are only two I know of: the Praat user's mailing list (which is for general use), and the issue tracker for the repository on Github (which is for ... bug tracking).

Related

ctrl+f2 keyboard shortcut does not work in VSCode on macOs

I have ctrl+f2 mapped to toggle bookmark in my vscode keyboard shortcuts.
{ "key": "ctrl+f2", "command": "bookmarks.toggle", "when": "editorTextFocus" },
It work correctly on Linux and Windows, but not on macOs.
I have enabled the setting to switch function keys (f1, f2, etc) to behave as standard function keys.
I have then unmapped ctrl+f2 in macOs keyboard shortcut settings.
But still ctrl+f2 keyboard shortcut is not registering with vscode.
Troubleshooting VS-Code Keybinding Issues
The best way to troubleshoot an issue with Keybindings in V.S. Code is to use the tool that was created for solving keybinding issues
The tool is simply named: "Keyboard Shortcut Troubleshooting Tool"
The tool comes with V.S. Code "out of the box", as a result; no downloading, or installation is needed. To use the tool you just activate it from the Quick Input Menu that drops open by pressing the F1-Key. If you cannot find it your self I posted instructions below, and an image. If you can find it yourself, then skip the "Activating the Troubleshooting Tool" Section, and go ahead and read, "Effectively Troubleshooting Issues with the Troubleshoot Keyboard-Shortcut Tool"
Activate V.S. Code's Troubleshooting Tool
Hit the F1-Key
When the quick input drops open type the following into the text input:
"Toggle Keyboard Shortcuts Troubleshooting"
Select the option: Developer: Toggle Keyboard Shortcuts Troubleshooting
It should automatically open the OUTPUT panel, which is located in the same panel that your terminal is. Make sure that the OUTPUT is set to LOG(Window) in the drop down. (I took a picture and posted it below if you can't find the Keyboard Shortcut Troubleshooter).
The image might have funny declensions because I am on a dual monitor setup with 1 1080x1920 curved screen and one 1080x720 screen.... I cropped it to a STD HD 1920 width.
HELPFUL SIDE NOTE:
"This tool may be the most verbose program ever written, as far as I can tell, it logs data to the OUTPUT Console each & every time you activate a keyboard event. Truth be told, I find this tool to be extremely distracting, and very annoying. Because of this, it is important to note, that even if you switch out of your OUTPUT console to your terminal or something. The Troubleshooter is still actively logging to the OUTPUT Console. Make sure when you are finished to turn it off."
Turning off the Keyboard Troubleshooter, requires the same process as turning it on.
Using V.S. Code's Troubleshooter
STEP-1: Close VS Code
This is not to be confused with reload V.S. Code. The only mechanism that VS-Code has for reloading its-self, doesn't provide the same functionality as closing, and reopening V.S. Code. The two are similar, but they are not equal (discussion for another time).
actually stop its process from running by hitting the X in the upper right corner of the title-bar, or hit
**[Alt + F4].
Step-2: Reopen V.S. Code W/O Any Extensions
Don't worry, you won't have to uninstall anything. You will start V.S. Code from the command-line though. Open up your bash terminal, or Powershell, and enter the following command:
$ code --disable-extensions
V.S. Code should start almost immediately
If the V.S. Code CLI doesn't open your editor, or this doesn't disable your extensions, you should refer to this link
Step-3: Start the Keyboard Shortcut Troubleshooter
I already explained this step above, so their is no reason to go over it again. Do make sure you have your panel open, and the OUTPUT tab is selected. You should see a bunch of logging being output, in the VS-Code output (that is redundant sounding), logging when you use any keybinding. The drop-down should have Log(Window) showing, as the current log selected.
Step-4: Test Your Keybinding
At this point you can use your keybinding, and get results. They might not be the results that you were hoping for, but the troubleshooter should give you details as to what is happening when you use your keyboard shortcut (aka bound-key, aka key-binding).
Step-5:
Fix the issue by opening the Keyboards Shortcuts configuration file by opening the quick input, (like I described above for the troubleshooter), and type Keyboard Shortcuts. Their will be two options, one is the default Keybindings that cannot be written too, the other is a configuration file, where you are allowed to overwrite all of the default keybindings if you choose. Look in the default keybinding.json file and make sure the keybinding that you feel is assigned to a certain task, really is assigned to it. Look in the regular keybindings.json file, and make sure if anything is written in it, that those keybindings are not affecting the keybinding that is not working for you. Use the information from the troubleshooter to help guide you through the process.
These links below further elaborate on V.S. Code keybindings:
V.S. Code Community Docs (Community Contributed)
V.S. Code Official Docs (Keybindings)

I need to make a standalone service for detecting and executing custom Windows hotkeys

I am attempting to make a macro keyboard that will automatically open some webpages and programs for me. In order to accomplish this, I have made a custom keyboard that is able to input keystrokes for me.
I would like to use a key combination like ctrl + a + b + c to activate my macros so that it does not interfere with the macros I already have on my keyboard. I have attempted to use Auto Hotkey for this purpose, but it does not accept multiple keys like I want.
I, therefore, believe that I will be forced to code my own hotkey manager. Here are the features That I want to be included in my hotkey manager:
Multiple key activation. example: ctrl + a + b + c
Ability to open webpages.
Ability to run programs.
preferably a single program, so that it can be used on multiple computers easily.
Is a project like this possible for an intermediate programmer?
I am currently experimenting with C# and Windows services, but I am unable to figure out how to listen for keystrokes. I am not married to C#. I can change languages as needed.
Any advice you would give is greatly appreciated.
You can try using hotstrings instead of a multi-key hotkey.
A hotstring is a sequence of keystrokes.
You can define hotstrings like this
::btw::by the way
Typing "btw" and then a Space or Enter or any word terminator, will expand "btw" to "by the way"
AutoHotKey can also be used to open webpages, run programs etc.

Remap keys in OS X

Specifically I'm attempting to map my MacBook's fn key to left mouse click.
Back in the old days when I was using Windows, I came across a wonderful little utility that let me map anything to anything: http://www.autohotkey.com/
You create a little text file, e.g.
^!s:: ; CTRL + ALT + s
Send Sincerely,{enter}John Smith ; sends keystrokes to active window
return
Creating a simple text file was infinitely better than any GUI based remapper.
I can look through it and see everything that is going on at a glance
I can customise every last detail
I can save / retrieve / post / share my scripts
Really, it's the one thing I really miss about Windows.
So my question is: How do I go about doing this in OS X? Every Google search leads to https://pqrs.org/macosx/keyremap4macbook/ and I dislike this package: it has an insanely cluttered GUI.
I would be very happy if I could do it in a shell script, or even compile code.
HotKeys on OS X
Even though AHK is seemingly absent on Mac, the functionality that AHK provides on Windows can likely be achieved in OS X. It could be a matter of coding your own solution, modifying something that's open-source, or using a combination of applications that will work together. I haven't tried all of the following, but might as well mention them as they might be worth checking out:
Open Source
IronAHK - .NET rewrite of AHK ported to OS X
AHK Forum Thread
Github Project
*the original project might be dead
CliClick - command-line application that will emulate mouse clicks
Github Project
Commercial
TextExpander - scriptable text completion / hotkey / macro app (supports AppleScript, Shell scripts)
Typinator - similar to TextExpander, although some features vary.
KeyMo - mostly for mapping keys exclusively to your mouse.
FastScripts - maps hotkeys/user-definable keyboard shortcuts to AppleScripts
*I use Text Expander and FastScripts together and can't live without them.
Rolling Your Own
It's fairly easy to create something with an AppleScript, or a shell script for just about anything imaginable in OS X. For example, I've seen CliClick used along with a custom AppleScript to achieve a certain functionality that it might not provide otherwise. To find an AHK replacement on Mac it'll probably be through trial and error, patience, and ultimately what ends up working best for you.
It is possible with a program called ControllerMate, instructions here. It is, however, a commercial software. I'm also interested in finding a free alternative.
Sikuli project looks promising. Not sure about your particular problem (e.g. Fn key remapping), but it's definitely a crossplatform alternative to AHK.
Another Open Source solution to this problem not mentioned in l'L'l's answer is Karabiner; I have been looking for a way to remap the key to the left of 1 to Esc for a while, and this worked perfectly. It even resolved an issue I was having where swapping Cmd and Alt using the built in OSX key remapping was breaking terminal Alt shortcuts! Highly recommend it.

Can you remap keys of a specific keyboard?

I've got two keyboards attached to my computer. A normal full-size keyboard and a numeric keypad. I want to "remap" the keys on the numeric keypad, but leave the full keyboard alone. So, when the user presses "5" on the keypad it would get remapped to the "Media Play" key, but if the same "5" was pressed on the keypad of the full keyboard, I'd get a "5". In essence, I want to turn that seperate numeric keypad into a media control device.
Unfortunately I'm not sure how to make this work. There is a "Raw Input" feature of Windows which allows to distinguish between keyboards, but that only allows to read the keys - not remap them. There are keyboard hooks (low level and high level) which can remap the keystrokes, but they don't distinguish between keyboards.
Can I make a combination of the two methods work? For that I'd have to be sure that the raw input message is processed before the keyboard hook kicks in. Is that so?
Also, I've read that Windows for some reason does not allow to use Raw Input and Keyboard Hooks in the same process. I could work around that by making 2 different processes, but that becomes more fragile because of communication latency (keyboard hooks have very limited time in which they must complete their work).
Is this doable at all?
In the end it turned out I needed a custom keyboard driver to accomplish this. Fortunately I found one ready for taking - Interception. The app is ready and works perfectly. :)
I wanted to expand on the answer by Vilx as I've revisited this post several times, and I've only just managed to remap my second keyboard so the keys act uniquely. This is done using Interception and Intercept together, and it's the only working solution that I've managed to get working so far.
I'm also looking into using a raspberry pi to remap a second keyboard. Although early days, I think it it's achievable: Plug keyboard into Pi, plug Pi into PC and write script to turn input keycodes into customized output commands / keycodes. Will update when I have tested.
My working Intercept solution is completely based on a Github tutorial by TaranVH which details the process the best so far. I've copied his solution below with some amends of my own.
DOWNLOADING INTERCEPTION:
Navigate to this page: https://github.com/oblitum/Interception
Click on "download the latest release."
Click on Interception.zip to download it.
Unzip the file to a folder on your computer - I recommend using a folder location that won't ever move. I put my Interception folder into C:\Program Files\ and I'll be using this location in my examples.
INSTALLING INTERCEPTION:
Open a terminal as administrator and type cd "C:\Program Files\Interception\command line installer"
Hit Enter
Now, type in the following line of text exactly as shown:
install-interception.exe /install
Hit Enter
Once the program installs sucessfully, you still must restart your computer in order to complete the installation.
(If you ever want to UNinstall interception, watch this): https://www.youtube.com/watch?v=Hn18vv--sFY
INSTALLING INTERCEPT - (This is different from intercepTION!)
Download Kamaz's intercept.exe zip from one of these locations:
http://octopup.org/img/code/interception/intercept.zip
https://github.com/TaranVH/2nd-keyboard/blob/master/Intercept/intercept.exe
Unzip it if it's a .zip file and locate intercept.exe
To keep these files all in one place, I moved intercept.exe into C:\Program Files\Interception\
Reboot your system.
SETTING UP INTERCEPT
Plug in your second keyboard and ensure that it is working normally.
Go to where you saved intercept.exe and double click to open.
Intercept will open as a terminal, and from there you should have basic instructions to start remapping your keyboard.
Type a to add a key.
On the SECONDARY keyboard, press the Q key once. (this is the key that you are remapping)
You will be prompted with Enter combo for this trigger, end with ESC.
Carefully execute the following keystrokes (it doesn't matter which keyboard): Win + E (That is: hold down the windows key while pressing the letter E. I've found you need to do this quickly and accurately, if you hold down too long, extra keypresses are added)
When I did it, this was shown in the terminal: [Left Windows]↓ [E]↓ [E]↑ [Left Windows]↑
Press Esc and you will be prompted to label the script
I labelled mine Q->WinE so I knew what it was doing.
Press Enter to accept the label
Press S to save the filter, or C to cancel if you made a mistake.
Add more filters or close the terminal.
USING INTERCEPT
Now you've set up a custom key command, you need to apply the filter to use it.
Open up intercept.exe
Press Y to apply the filters, you will get confirmation that the filters have been activated.
Now, when you press Q on your second keyboard, Intercept will change the command to Win+E which will open File Explorer.
Caveat:
Please read TaranVH githubs page on this https://github.com/TaranVH/2nd-keyboard/tree/master/Intercept as it provides some further details and troubleshooting.
Please take care to follow the instructions very exactly as there's very little error handling in this process
In this article http://vlaurie.com/computers2/Articles/remap-keyboard.htm is explained how to remap keys of a keyboard. Hope that helps.

Safe keyboard shortcut for activating code completion style functionality in Mac OS X browsers

I'm building some code completion style text expansion functionality for text areas and inputs in a web application. I'm trying to work out a safe keyboard shortcut for invoking the completion proposals for browsers running on Mac OS X.
I've eliminated some potential candidates:
Command + Space - activates the Spotlight search field
Control + Space - activates the context menu in Firefox
Esc - cancels any background XMLHttpRequests in Firefox
That leaves Option + Space. I'm aware that may conflict with tools like Ubiquity, but that's something we don't expect our audience to be using.
Are there any conflicts I may have missed with Option+Space? Or do you have a better idea for a keyboard shortcut, and why?
A lot of Mac OS X apps use Option + Esc to do code completion or code hints.
Some kind of tab shortcut sounds like the best and most intuitive approach - users should be used to the 'type-tab-type-tab' workflow - maybe combine it with a modifier if it only wants to be optional.
As I recall, Visual Studio and TextMate both use tab to code-complete. In Visual Studio an intellisense menu pops up as you start typing and tab acts as the selection confirmation.
In TextMate, you start typing part of a command then hit tab to activate said command's associated "bundle". The associated bundle typically generates a code snippet and fills in any dynamic parts of the snippet as you type.
Come to think of it, most command lines work this way as well, auto-completing file names and paths when tab is pressed after typing a few characters.
EDIT: You say tabs are needed for field switching in a web interface, but you may want to try intercepting the keyboard event in the textfield, and check if they're started typing a macro. If they have, auto-complete and swallow the key by returning false; if not, simply let the command bubble through.
I discussed these ideas with our design team. One of them suggested using Control + Enter, which is what we decided to go with. This causes forms that only contain a single input field to automatically submit in Firefox, but we deal with that by preventing the default action caused by the event.
I re-assigned the Spotlight command to Command + Shift + Space. This is easily done via Prefrences.App

Resources