How do I change the ASCII code of a given character? Example: When I press on button A on my keyboard, B shall be pushed.
Thank You!
Change the ASCII of a given character
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
You can find great PB codes at PureBasic CodeArchiv: http://www.purearea.net/pb/CodeArchiv/English.html
This is modified from CodeArchiv 'KeyboardCatcher.pb':
When you release key 'A' - it simulates pressing key 'B'.
This is modified from CodeArchiv 'KeyboardCatcher.pb':
Code: Select all
; http://www.purearea.net/pb/CodeArchiv/Input+Output/Keyboard/KeyboardCatcher.pb
Main = OpenWindow(0, 0, 0, 320, 200, "My Form", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
Repeat
Event = WindowEvent()
If Event = #WM_KEYUP
key = EventwParam()
Debug Str(key) + " = " + Chr(key)
If key = 65 ; when released key 'A' simulate pressing key 'B'
keybd_event_(#VK_B, 0, 0, 0) : keybd_event_(#VK_B, 0, #KEYEVENTF_KEYUP, 0)
EndIf
EndIf
Delay(1) ; don't take all CPU power
Until Event = #PB_Event_CloseWindow

Re: Change the ASCII of a given character
Nice and so simple.
Any idea on how to catch scancodes in a similarly simple manner ? In theory you should be able to read scancodes using bits 16-23 of the same Windows message, but all i ever get is 0
Any idea on how to catch scancodes in a similarly simple manner ? In theory you should be able to read scancodes using bits 16-23 of the same Windows message, but all i ever get is 0

PB Forums : Proof positive that 2 heads (or more...) are better than one 
