What're the key codes for "Alt+Q Alt+Q"? - scripting

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.

Related

Maya crashes when duplicate special

I try to make instance copies of my character using Duplicate Special. But unfortunately it crashes every time I try.
For this I select my character's group "rig_group", then go to Edit → Duplicate Special ⊡
And I want to use these settings:
And it crashes Maya when I hit "Apply" or "Duplicate Special".
Note that it works on this character on a fresh file.
Test file - M01_WalkNeutral.0080.mb
Remember that duplicate special doesn't work properly on rig's. You can use duplicate special for polygons, curves or etc.
Ps. If you wanted to duplicate special a high-poly mesh I would say that to reduce the vertex then run that but about rig_group I'm not sure.
I hope to help that to you.

VIM equivalent of IntelliJ's expand/shrink selection?

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)

Autohotkey - AltGr hotkey behaves differently from LAlt hotkey

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

Shortkey or Script that can select block of code

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.

Extracting information from a file variable in d3 pick basic

I have a file variable in d3 pick basic and I am trying to figure out what file it corresponds to.
I tried the obvious thing which was to say:
print f *suppose the file variable's name is f in this case
but that didn't work, because:
SELECTION: 58[B34] in program "FILEPRINTER", Line 7: File variable used
where string expression expected.
I also tried things like:
list f *didn't compile
execute list dict f *same error
execute list f *same error
but those also did not work.
In case any one is wondering, the reason I am trying to do this in the first place is that there is a global variable that is passed up and down in the code base I am working with, but I can't find where the global variable gets its value from.
That file pointer variable is called a "file descriptor". You can't get any information from it.
You can use the file-of-files to log Write events, and after a Write is performed by the code, check to see what file was updated. The details for doing this would be a bit cumbersome. You really should rely on the Value-Add Reseller or contract with competent assistance for this.
If this is not a live end-user system, you can also modify an item getting written with some very unique text like "WHAT!FILE!IS!THIS?". Then you can do a Search-System command to search the entire account (or system) to find that text. See docs for proper use of that command.
This is probably the best option... Inject the following:
IF #USER = "CRISZ" THEN ; * substitute your user ID
READU FOO FROM F,"BLAH" ELSE
DEBUG
RELEASE F,"BLAH"
END
END
That code will stop only for one person - for everyone else it will flow as normal. When it does stop, use the LIST-LOCKS command to see which file has a read lock for item "BLAH". That's your file! Don't forget to remove and recompile the code. Note that recompiling code while users are actively using it results in aborts. It's best to do this kind of thing after hours or on a test system.
If you can't modify the code like that, diagnostics like this can be difficult. If the above suggestions don't help, I think this challenge might be beyond your personal level of experience yet and recommend you get some help.
If suggestion here Does help, please flag this as the answer. :)