I would like replace the UCASE letter F by the Lcase letter g
And also the opposite : Replace the LCASE letter d by the Ucase letter H
And impossible, for the moment if the first letter is UCASE, the letter who replace it, is also UCASE, and the opposite have the same behavior

If someone know how do this exploit

Code: Select all
#WH_KEYBOARD_LL = 13
#INPUT_KEYBOARD = 1
#KEYEVENTF_SCANCODE = $8
Global myKeyHook, SearchCharacter.s, ReplaceCharacter.s
Global Dim Key.s(256)
Structure INPUT_DATA
type.l
StructureUnion
mi.MOUSEINPUT
ki.KEYBDINPUT
hi.HARDWAREINPUT
EndStructureUnion
EndStructure
Procedure.l KeyProc(nCode.l,wParam.l,lParam.l)
Protected *keyInput.KBDLLHOOKSTRUCT
Protected InputData.INPUT_DATA
If nCode = #HC_ACTION
*keyInput = lParam
GetKeyboardState_(@Key())
ToAscii_(*keyInput\vkCode, *keyInput\scanCode, @Key(), @RealCharacter_Ascii.w, 0)
; Key pressed
RealCharacter_VkCode = *keyInput\vkCode
RealCharacter_State = 0 ; I don't know how obtain the STATE of the HOOK :-(
RealCharacter_ScanCode = *keyInput\scanCode
RealCharacter.s = Chr(RealCharacter_Ascii)
; Character to replace
SearchCharacter_VkCode = VkKeyScan_(Asc(SearchCharacter)) & $FF
SearchCharacter_State = VkKeyScan_(Asc(SearchCharacter)) >> 8
SearchCharacter_ScanCode = OemKeyScan_(Asc(SearchCharacter))
SearchCharacter_Ascii = OemKeyScan_(Asc(SearchCharacter))
; Replacer character
ReplaceCharacter_VkCode = VkKeyScan_(Asc(ReplaceCharacter)) & $FF
ReplaceCharacter_State = VkKeyScan_(Asc(ReplaceCharacter)) >> 8
ReplaceCharacter_ScanCode = OemKeyScan_(Asc(ReplaceCharacter))
If RealCharacter_VkCode = SearchCharacter_VkCode
Inputdata\type = #INPUT_KEYBOARD
inputdata\ki\wVk = ReplaceCharacter_VkCode
inputdata\ki\wScan = ReplaceCharacter_ScanCode
If inputdata\ki\wVk <> 0
inputdata\ki\time = *keyInput\time
InputData\ki\dwExtraInfo = *keyInput\dwExtraInfo
If wParam = #WM_KEYUP
InputData\ki\dwFlags = #KEYEVENTF_SCANCODE|#KEYEVENTF_KEYUP
EndIf
SendInput_(1, InputData, SizeOf(INPUT_DATA))
Result = #True
; Clear the buffers
RtlZeroMemory_(InputData,SizeOf(INPUT_DATA))
RtlZeroMemory_(*keyInput,SizeOf(KBDLLHOOKSTRUCT))
Else
Result = CallNextHookEx_(myKeyhook, nCode, wParam, lParam)
EndIf
Else
Result = CallNextHookEx_(myKeyhook, nCode, wParam, lParam)
EndIf
Else
Result = CallNextHookEx_(myKeyhook, nCode, wParam, lParam)
EndIf
ProcedureReturn Result
EndProcedure
; First try
SearchCharacter = "F"
ReplaceCharacter = "g"
; ; Second try
; SearchCharacter = "d"
; ReplaceCharacter = "H"
hInstance = GetModuleHandle_(0)
If hInstance
myKeyhook = SetWindowsHookEx_(#WH_KEYBOARD_LL, @KeyProc(),hInstance,0)
Else
MessageRequester("hook", "can't get module handle")
EndIf
OpenWindow(0, 0, 0, 350, 100, "")
Repeat : WaitWindowEvent(100) :Until GetAsyncKeyState_(#VK_ESCAPE)