Inside of emacs, I use 'C-c c' to make an org-capture.
I would like to bind the same key (or some function key) to perform the same function even if emacs is not the currently open window.
Is there a way to tell OS X when pressing 'C-c c' (or f10, say) to change the window to Emacs, and then perform a org-mode capture?
There a post on thinknix.net [http://www.thinknix.net/2015/02/19/cross-platform-system-wide-org-capture/] which will do what you want using Keyboard Maestro or for Automator if you don't have KM.
I include parts of the post here for completeness:
There are two ways I’ve accomplished this. The first is to use Keyboard Maestro if you already have it. Create a new macro called
Org-Capture that triggers on F9. Have it Activate Emacs, simulate
keystroke Control-C, and simulate keystroke C.
If you don’t have Keyboard Maestro, you can use the following
Applescript in Automator:
on run {input, parameters}
tell application "Emacs"
activate
tell application "System Events"
keystroke "c" using {control down}
keystroke "c"
end tell
end tell
return input
end run
Save it as a service, and then in the Keyboard Shortcuts panel assign
the service to F9.
Related
67-year-old grannie here. My 12-year-old programmable keyboard died and I will try to use AutoHotkey in its stead to do simple keyboard macros. Here's the first one I need to create. When I press F12, I want it to send these keystrokes to Audacity (but it could be any program; the keystrokes are simply shortcut keys to do specific functions):
Alt+G
S
Enter
Enter
How would I program that in AutoHotkey?
Fairly straightforward:
F12:: ;When F12 is pressed
Send !g ;Press Alt+g
Send s ;Press s
Send {Enter 2} ;Press Enter Twice
return ;End this hotkey
(Note: Anything after a semicolon is a comment)
When tested in Audacity, it properly generates a default length clip of silence, then deselects the created audio segment.
Bonus:
Add #IfWinActive ahk_exe audacity.exe to the top of the script to make the hotkey only activate if Audacity is the active window.
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.
I have a very simple AutoHotkey.ahk file, where I remap Capslock to Esc and Esc to Capslock (swapping the keys):
Capslock::Esc
Esc::Capslock
However, this doesn't work in games like Battlefield 4 or League of Legends. It simply does not do anything.
However, I can press Reload This Script in AutoHotkey, and the remapping will start working in those games. It does however work in other games without the need to reload the script first.
I hope you can help me. I would really like this to just work, instead of manually reloading the script.
Try using the #IfWinActive directive so that those hotkeys only work in the programs you want - then you don't need to ever reload.
Check in the documentation for "Context-sensitive hotkeys" (under "hotkey" in the index). Here is an example from the documentation:
#IfWinActive, ahk_class Notepad ^a::MsgBox You pressed Ctrl-A while Notepad is active. Pressing Ctrl-A in any other window will pass the
Ctrl-A keystroke to that window.
#c::MsgBox You pressed Win-C while Notepad is active.
But I think I know why it begins to "not work". It may be that certain programs set those keys as hotkeys. Whenever you start those programs they set their own hotkeys and it overrides your script. You see, the hotkey combination belongs to whatever program sets it last. When you reload the script, it resets your script as having the authourity.
So if you want the script to never be overridden, and you don't want to manually reload it, find out what programs the combinations don't work in, and use ifwinactive to reload your script using autohotkey's reload command.
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!
Several times now while programming in Emacs my keyboard has started to write Greek letters into the buffer. I assumed that I'd pressed some key combination but after searching I've yet to figure out what it is and my only solution right now is to restart Emacs. So what am I doing and how do I fix it?
Try to analyse what you've pressed.
M-x list-command-history shows command history
C-h l runs the command view-lossage which displays last 300 input keystrokes
I'm going out on a limb.
You're working on a windows computer that has multiple input languages configured (including greek). It also has the default keyboard shortcut to switch between them enabled (left alt+shift is the default, and if you have multiple inputs set up, it is on by default).
Some emacs shortcuts require an alt-shift combo, and depending on the order you press them, you get or don't get windows intercepting it for the IME switch.
Possible solutions include:
remove the greek IME
disable the windows shortcut to switch IMEs
change said shortcut
I typically want multiple IMEs on my systems, like that I can switch IMEs quickly, and don't want to mess with default shortcuts, so I ended up getting used to always pressing shift then alt when doing alt-shift combos in emacs.