I'm really sorry, my english is not very good. I will try to write better.
So I'm stopped to use Notepad as my code editor, download a VsCode with debugger, and things go a little better.
So now this is my version of code, that works but have few bugs, that I can't fix.
Code: Select all
#InstallKeybdHook
ih := InputHook(), ih.KeyOpt("{All}", "E")
modifier := "LCtr|Shift|LAlt|LWin"
layer = 1 ; Auto-execute section
#If (layer = 2)
SC01E:: LAlt
SC01F:: LWin
SC020:: Shift
SC021:: LCtrl
#If !prefix && layer != 1
SC01E::
Send {Alt Down}
If (A_PriorKey ~= NULL) {
prefix := "{Alt down}"
suffix := "{Alt up}"
Loop {
ih.Start(), ih.Wait()
If match := ih.EndKey ~= modifier {
prefix .= "{" ih.EndKey " down}"
suffix .= "{" ih.EndKey " up}"
}
} Until !match
Key := % prefix "{" ih.EndKey "}" suffix
Send % prefix "{" ih.EndKey "}" suffix
prefix := ""
}
Return
SC01F::
Send {Lwin Down}
If (A_PriorKey ~= NULL) {
prefix := "{LWin down}"
suffix := "{LWin up}"
Loop {
ih.Start(), ih.Wait()
If match := ih.EndKey ~= modifier {
prefix .= "{" ih.EndKey " down}"
suffix .= "{" ih.EndKey " up}"
}
} Until !match
Key := % prefix "{" ih.EndKey "}" suffix
Send % prefix "{" ih.EndKey "}" suffix
prefix := ""
}
Return
SC020::
Send {Shift Down}
If (A_PriorKey ~= NULL) {
prefix := "{Shift down}"
suffix := "{Shift up}"
Loop {
ih.Start(), ih.Wait()
If match := ih.EndKey ~= modifier {
prefix .= "{" ih.EndKey " down}"
suffix .= "{" ih.EndKey " up}"
}
} Until !match
Key := % prefix "{" ih.EndKey "}" suffix
Send % prefix "{" ih.EndKey "}" suffix
prefix := ""
}
Return
SC021::
Send {Control Down}
If (A_PriorKey ~= NULL) {
prefix := "{Control down}"
suffix := "{Control up}"
Loop {
ih.Start(), ih.Wait()
If match := ih.EndKey ~= modifier {
prefix .= "{" ih.EndKey " down}"
suffix .= "{" ih.EndKey " up}"
}
} Until !match
Key := % prefix "{" ih.EndKey "}" suffix
Send % prefix "{" ih.EndKey "}" suffix
prefix := ""
}
Return
#If
So code is bad designed, and it actually repeats almost the same block of code 4 times and i think If (A_PriorKey ~= NULL) is not necessary here. I tried make a function like below, but it didn't work.
And I didn't figure out how to implement Switch block to this so i did it this way. Now it work with remapped modifiers like i need.
Script works with any two keys hotkeys almost well. When i press any Modifier once and then press any non modifier key, for example: If i press Ctrl and release and then press 'a' it produce Ctrl-a . So bugs are:
1) It not work with 3 keys hotkeys at all. For example if press Alt+CTRL+DEL at one time like usual, it doesnt work. More interesting when i press those buttons in order, It not work too, but for debug purposes I create that variable "Key" at the end of each code block, to see what output is generated, and when i press Alt Ctrl Del in order, the value of this variable Key : "{Control down}{LAlt down}{Delete}{Control up}{LAlt up}" So it looks like it should work, but it doesn't.
2) If I press and hold for example CTRL and then press many times for example "v" it produce Ctrl+V only after first "v" press, and then it just produce letter "v" many times.
This is a function that i tried to do
Code: Select all
SC021::
Send {Control Down}
Sticky("{Control down}" , "{Control up}")
Sticky(prefix , suffix)
{
global modifier
If (A_PriorKey ~= NULL) {
Loop {
ih.Start(), ih.Wait()
If match := ih.EndKey ~= modifier {
prefix .= "{" ih.EndKey " down}"
suffix .= "{" ih.EndKey " up}"
}
} Until !match
Key := Send prefix "{" ih.EndKey "}" suffix
prefix := ""
}
Return Key
}