PDA

View Full Version : Convert NSString to KeyCode.




DeDMakar
Apr 12, 2008, 12:02 PM
I use function CGPostKeyboardEvent for Keyboard Event. I need to convert NSString in KeyCode. What offers?



kainjow
Apr 12, 2008, 12:17 PM
Are you trying to convert it to a CGKeyCode? CGKeyCode is just an unsigned short essentially, so NSString's intValue may work (typecasted of course), but it depends what the NSString value is. Can you give an example?

DeDMakar
Apr 13, 2008, 09:50 AM
I have a variable of type NSString *sStr = "password". Each letter I enter by means of CGPostKeyboardEvent. The letter "p" and following must to convert in CGKeyCode.

kainjow
Apr 13, 2008, 10:15 AM
Check out the keyCodeForKeyString() function here:
http://ritter.ist.psu.edu/projects/RUI/macosx/rui.c

DeDMakar
Apr 13, 2008, 01:39 PM
If there are no other variants, it is necessary to use this simple function keyCodeForKeyString.:rolleyes: Thank!!!

DeDMakar
Aug 11, 2008, 07:14 AM
HI!!!
What CGKeyCode do the capital letters have?