I wrote a AutoHotKey script to remap LWin to LAlt
LWin::LAlt
LWin & Tab::AltTab
LWin+Tab works OK. But I found, for example in my emacs, LWin+b can not work as Alt+b. And if I disable this statment
LWin & Tab::AltTab
LWin+b works. But I know LWin+Tab will not works very good without this remapping statement as mentioned in AutoHotKey Remapping.
I'm not entirely sure why, but it seems the first key mapped can only be declared once. I have found a solution (although not perfect) of writing the second command as so: Tab & LWin::AltTab. This means that you have to hold Tab down first though.
Related
I want to create a script that triggers when pressing Q twice while holding Alt, but couldn't figure out what're the correct key codes for that, could someone please shed some light?
P.S. I want to bind this shortcut to Ctrl+F12, which I assigned Sogou IME to turn on the Chinese input mode.
I didn't test this and there's probably a more concise way to do it, but I think something like this should work.
!Q::
If(keyPressed = 1){
...Do a thing...
}
keyPressed := 1
SetTimer, altQTimer, 50
return
altQTimer:
keyPressed := 0
return
TL;DR
In conclusion, even if I do all kinds of hacks and get the script working as intended, it's likely to break in the future, which is really not worth the trouble.
After hours of experimenting, the current conclusion is Sogou IME which uses Ctrl+F12 won't trigger the bound action i.e. switching to the Chinese input mode if it was sent by Alt+[Any Other Key], it can be triggered if it was sent by other shortcuts such as Ctrl+C, which is really unfortunate.
And the weirdest thing is the following code works:
^c::Send !q
!q::Send ^{F12}
And to rule out the potential extra simulated keystrokes (Ctrl by default) effect, the following code also works:
^!q::Send ^{F12}
But the following doesn't (tested on several machines):
!q::Send ^{F12}
Update
After much effort, I did get Alt+Q to turn on the Chinese input mode with the following code, not sure why:
!q::Send ^{F6}
^F6::Send ^{F7}
^F7::Send ^{F12}
But because I also need to trigger a VSCode command using Alt+Q at the same time, I had to modify the above code to the following:
~!q::Send ^{F6} ; with ~ prefixed
^F6::Send ^{F7}
^F7::Send ^{F12}
Now Alt+Q does trigger the VSCode command, but it won't turn on the Chinese input mode...
At last, if I take a step back and bind the VSCode command to Ctrl+C (which could turn on the Chinese input mode with just ^c::Send ^{F12}), I still have to prefix ^c with ~, otherwise it won't trigger the VSCode command, now I'm repeating the cycle all over again...
After all of these attempts, I have to say Sogou IME's logic for determining whether to enable the Chinese input mode is quite indeterminate, making the script for enabling the Chinese input mode very unreliable.
In conclusion, even if I do all kinds of hacks and get the script working as intended, it's likely to break in the future, which is really not worth the trouble.
How would one achieve the same result. I believe the keybinding for macOS Intellij is op+up/down and on windows it is alt+w/d.
Essentially the function highlights the current word, then, with successive presses, expands out to the full string/line/area in-between parenthesis/further out to the next set of parenthesis. Very useful for developing in LISP.
The closest I've gotten is this: https://vi.stackexchange.com/a/19028
Try this plug in: https://github.com/terryma/vim-expand-region
It expands selections based on Vim’s text objects.
Well this may seem comfortable but does not correspondent with the internal logic of vim itself.
See, in vim everything you enter is like a sentence. va{ for example: there is a verb v -> visually select and an object (or movement) { -> paragraph. In this case there is also a modifier a around. You can exchange stuff in this sentence and it will still work vaw, dil, cB and so on. The power of vim is greatly based on that concept.
Of course you can write a function that does vaw first, then S-v and lastly va{ but that will only work with visual selection. It will not work with c or d or anything. So I will recommend to get used to use different keys for different actions.
The visual selection is mostly not needed anyway. Change a paragraph? directly use ca} and so on.
I have found that VI/VA + WOBO (as many times as you need to expand) works similarly. Not as fast but its the same concept and you can even expand/shrink asymmetrically based on your WO's and BO's (Or OW's and OB's depending on how you look at it)
I know how to bind a key to a sub in VBA for Mac (Word 2016 etc.). But I can't find a way to do so with German umlauts. I already created some code to bind all 255 variations of wdKey to code, but that didn't get me a solution either. The keys ä, ö, ü on my keyboard never fire any event.
I'd be happy for any advice.
I do not think it is possible.
Some notes:
It looks as if you asked a similar question here in 2012, and the suggestion in there that the problem is that these keys cannot be assigned in Word, only in Mac OS, seems still to be correct. However, that seems to mean that you can only assign a key combination that Mac OS allows you to assign, to an existing Word menu item. So you can use that mechanism to assign ctrl-ö to "Advanced Symbol..." but you cannot use that mechanism to assign ctrl-ö to a Word internal command name and I do not think you can assign ö, on its own, to anything.
In Windows Word, I was able to assign alt-ö, alt-ä and alt-ü to "InsertSymbol" in Word, but the keystrokes Word actually assigned this comand to were the Alt-shifted wdKeyBackSingleQuote, wdKeySingleQuote, and wdKeySemiColon.
Attempting to use the same key assignments in Mac VBA did not work.
On my (UK) keyboard, the actual keys used for ö, ä and ü are SemiColon, Comma, and LeftSquareBracket. Even on the US English keyboard, I think they are SemiColon, SingleQuote, and LeftSquareBracket, so it is not obvious why Word assigns those particular codes. I think you would probably have to understand how DOS and Widnows and Word deal with keyboard scan codes to make sense of it, and on Mac it will of course be different.
For anyone wishing to explore further, you can use VBA to reassign a key without using BuildKeyCode, like this:
Dim i As Integer
i = 1022
KeyBindings.Add KeyCode:=i, _
KeyCategory:=wdKeyCategoryCommand, _
Command:="InsertSymbol"
Some values of i cause an "Invalid Parameter" command, and others a 5346 "Word cannot change the function of the specified key". Most of these values of i probably just represent a "base keystroke" such as "A", eithe ron its own or combined with one or more shifts such as Shift, Alt, etc., but without exploring every single possibile value of i that does not raise an error it is difficult to be certain that there are no other possibilities.
I'm trying to map LAlt+Space to Delete and AltGr+Space to Backspace, so i made this script :
<!Space::Delete
<^>!Space::Backspace
LAlt+Space gets mapped correctly to Delete, but AltGr+Space doesn't work properly : it removes words like Ctrl+Backspace would do instead of removing one character at a time.
I switched 'Delete' and 'Backspace' and got the same issue : LAlt+Space works properly but AltGr+Space removes words like Ctrl+Delete instead of characters.
I'm guessing this might have to do with the fact that AltGr is actually Ctrl+RAlt, so the Ctrl might be composed with Backspace or Delete at some point ?
Does anybody know what the cause of this could be, and a solution ?
While #user3419297's answer is essentially correct, it's advisable in modern versions of AHK to use SendInput over Send.
<!Space::
SendInput, {Delete}
return
<^>!Space::
SendInput, {Backspace}
return
I am using SQL Server Management Studio and there are 5-10 lines of queries that I edit and execute a lot. I'm wondering whether there is a way that can quickly select a block of code? The code could start and end with some key words. For example:
--Start
line1
line2
--end
I searched the shortcut key webpage for Sql management studio and didn't find a quick solution.
The solution could either be a keyboard shortcut or some automatic script like autohotkey. A generic solution works with general text/code editor would be the best, since I also works with R/MATLAB and wondering whether there is a generic solution for selecting code.
Thanks in advance for your help!
Jason
Simple, general, autohotkey solution, working with notepad, bound to ctrl+b for testing purposes, do edit accordingly.
^b::
selectBlock(){
clipbackup:=clipboard
clipboard:=
Send ^a^c
ClipWait
Loop, parse, clipboard, `n, `r
{
if (SubStr(A_LoopField,1,7)="--Start")
s:=A_Index
if (s and SubStr(A_LoopField,1,5)="--end"){
e:=A_Index-1
break
}
}
if (s and e)
Send % "^{Home}{Down " s "}{Shift Down}{Down " e-s "}{Shift Up}"
else
Send {Left}
clipboard:=clipbackup
}
return
Side note, I'm not familiar with your software but I find it hard to imagine there are no better ways of doing it. For example using built in search tool that might even support regex as most "text editors" aimed at "coding" have. Or adopting above code to work with "go to X line" function of your program.