Post by Roger Cabo on Jan 16, 2023 22:51:38 GMT 1
Hi everyone,
I never know that inside of the _KeyPress(Ascii&) it's possible to grab CTRL+A,+V,+C, etc.. // Select All, Copy, Paste etc... has predefined ASCII values. It's 1, 2, 23, 26 and there are a lot more.
I always garbed CTRL+A,+V,+C by _KeyDown(), or _KeyUp().
A small test. Here I suppress keys from the keyboard can be used to insert invisible control code into a text box.
But "select all, copy, paste, undo" now works well.
I always garbed CTRL+A,+V,+C by _KeyDown(), or _KeyUp().
A small test. Here I suppress keys from the keyboard can be used to insert invisible control code into a text box.
But "select all, copy, paste, undo" now works well.
$Library "gfawinx"
$Library "UpdateRT"
UpdateRuntime ' Patches GfaWin23.Ocx
OpenW # 1
Win_1.FontName = "Segoe UI"
Win_1.FontSize = 11
// Perso1(0) Creates an Array of OCXs and the Elements of the array will be return in Index%. Sub Perso1_KeyPress(Index%, Ascii&)
// Perso1 Creates a single OCX and is used without (Index%). Sub Perso1_KeyPress(Ascii&)
OcxOcx Win_1 TextBox Perso1(0) = , 30, 30, 600, 300 // Perso1(0) Creates an Array of OCXs.
Perso1(0).FontSize = 12
Perso1(0).BorderStyle = 1
Perso1(0).Appearance = 4
Perso1(0).MultiLine = True
Perso1(0).ScrollBars = 2
Perso1(0) = "Try to use CTRL + A "#13#10"Any textAny textAny textAny textAny textAny textAny textAny textAny textAny text"#13#10"aklsdma dlamdapos dkam"
OcxOcx Win_1 Label lbl1 = "", 630, 30, 30, 60
Do
Sleep
Loop Until Me Is Nothing
Sub Perso1_KeyPress(Index%, Ascii&)
lbl1 = Ascii // Display the incoming ASCII value
Ascii& = TextInputAllow_All(Ascii&) // Filter any keystrokes.
EndSub
Function TextInputAllow_All(k&) As Int Naked
If (k => Asc("0") && k <= Asc("9")) || (k => Asc("A") && k <= Asc("Z")) || (k => Asc("a") && k <= Asc("z")) || _
k = Asc("(") || k = Asc(")") || k = Asc("+") || k = Asc("-") || k = Asc("%") || _
k = Asc("Ä") || k = Asc("Ö") || k = Asc("Ü") || k = Asc("ä") || k = Asc("ö") || _
k = Asc("ü") || k = Asc("/") || k = 8 || k = Asc("%") || k = Asc("!") || _
k = Asc(".") || k = Asc(",") || k = Asc(":") || k = Asc(";") || k = Asc("=") || _
k = Asc(" ") || k = 13 || k = Asc("*") || k = Asc("?") || k = Asc("ß") || k = 9 /*TAB*/ || k = Asc(">") || k = Asc("<") || k = Asc("§") || _
k = 1 || k = 3 || k = 23 || k = 26 // <--------Remove to prevent system keyboard commands: select all, copy, paste, undo. Only mouse text copy is possible then.
Else
k = 0
EndIf
Return k&
EndFunc