Page 1 of 1
Change the ASCII of a given character
Posted: Tue Sep 08, 2009 2:46 am
by donSHAYA
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!
Posted: Tue Sep 08, 2009 3:05 am
by Rook Zimbabwe
get the inkey... add 1 to whatever is pushed and output...
There is a malicious virus that does this... My sister managed to get a hold of it... terrible!
Posted: Tue Sep 08, 2009 9:11 am
by Kaeru Gaman
this has nothing to do with ASCII and Charakter, but with Key and Scancode.
wich Key is associated to wich Char is determined by the Scancode, these are located in the CodePage.
Search these terms on MSDN.
...
Posted: Tue Sep 08, 2009 4:53 pm
by donSHAYA
Can some of you give me an example code? Don't understand the inkey-thing. I tried to search on MSDN and I got BumpBar.SetKeyTranslation(), but can't find it in PB. An example code will be cool.
Posted: Tue Sep 08, 2009 6:02 pm
by Henrik
Why not Search for Scancode on this forum ?
Posted: Tue Sep 08, 2009 7:04 pm
by eJan
You can find great PB codes at
PureBasic CodeArchiv:
http://www.purearea.net/pb/CodeArchiv/English.html
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
When you release key 'A' - it simulates pressing key 'B'.
Re: Change the ASCII of a given character
Posted: Thu Sep 24, 2009 2:19 am
by Blue
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
