Simple aplication typing?

Thread Solved
Reply

Join Date: Apr 2008
Posts: 177
Reputation: Black Magic is an unknown quantity at this point 
Solved Threads: 4
Black Magic's Avatar
Black Magic Black Magic is offline Offline
Junior Poster

Simple aplication typing?

 
0
  #1
May 8th, 2008
Hey, I was just wondering what was the simplest way to "real" world type, like open wordpad and you could watch it actually typing, thanks in advance. (Hopefully the answer is not writing to file etc)
C Plus Plus Coder.
Fourteen Years Of Age
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 1,839
Reputation: twomers has a spectacular aura about twomers has a spectacular aura about twomers has a spectacular aura about 
Solved Threads: 49
twomers's Avatar
twomers twomers is offline Offline
Posting Virtuoso

Re: Simple aplication typing?

 
0
  #2
May 8th, 2008
Wha'?
I blag!?
"Mr Kitty, you have to live in the attic now. Here, write a diary."
I am the Walrus!
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 177
Reputation: Black Magic is an unknown quantity at this point 
Solved Threads: 4
Black Magic's Avatar
Black Magic Black Magic is offline Offline
Junior Poster

Re: Simple aplication typing?

 
0
  #3
May 8th, 2008
Never mind..
C Plus Plus Coder.
Fourteen Years Of Age
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,383
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 112
Sponsor
William Hemsworth William Hemsworth is offline Offline
Nearly a Posting Virtuoso

Re: Simple aplication typing?

 
0
  #4
May 11th, 2008
Do you meen actually emulating keypresses ?
Here is an example of how to do that:

  1. #include<iostream>
  2. #include<windows.h>
  3. using namespace std;
  4.  
  5. void SendKeysWait(char *text, int interval);
  6.  
  7. int main() {
  8. system("start C:\\Windows\\notepad.exe");
  9. Sleep(1000);
  10. SendKeysWait("Hello world!", 30);
  11. cin.ignore();
  12. return 0;
  13. }
  14.  
  15. void SendKeysWait(char *text, int interval) {
  16. int ch;
  17. int ch2 = -1;
  18. bool SHIFTDOWN = 0;
  19. for (int i = 0; text[i]; i++) {
  20. SHIFTDOWN= 0;
  21. switch (text[i]) {
  22. case '\"':{ch = VkKeyScan('\"');ch2= VK_SHIFT; SHIFTDOWN = 1;} break;
  23. case '£': {ch = VkKeyScan('£');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  24. case '$': {ch = VkKeyScan('$');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  25. case '%': {ch = VkKeyScan('%');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  26. case '^': {ch = VkKeyScan('^');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  27. case '&': {ch = VkKeyScan('&');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  28. case '*': {ch = VkKeyScan('*');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  29. case '_': {ch = VkKeyScan('_');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  30. case '+': {ch = VkKeyScan('+');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  31. case '{': {ch = VkKeyScan('{');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  32. case '}': {ch = VkKeyScan('}');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  33. case '@': {ch = VkKeyScan('@');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  34. case '~': {ch = VkKeyScan('~');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  35. case '?': {ch = VkKeyScan('?');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  36. case '<': {ch = VkKeyScan('<');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  37. case '>': {ch = VkKeyScan('>');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  38. case '|': {ch = VkKeyScan('|');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  39. case ':': {ch = VkKeyScan(':');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  40. case '!': {ch = VkKeyScan('!');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  41. case '(': {ch = VkKeyScan('(');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  42. case ')': {ch = VkKeyScan(')');ch2 = VK_SHIFT; SHIFTDOWN = 1;} break;
  43. default:
  44. {
  45. if (text[i] >= 'A' && text[i] <= 'Z') {
  46. ch = VkKeyScan( text[i]);
  47. ch2 = VK_SHIFT;
  48. SHIFTDOWN = 1;
  49. } else ch = VkKeyScan( text[i]);
  50. }
  51. }
  52. if (SHIFTDOWN) keybd_event(ch2, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
  53. keybd_event(ch, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
  54. keybd_event(ch, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
  55. if (SHIFTDOWN) keybd_event(ch2, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
  56. Sleep(interval);
  57. }
  58. }

I just made this work with my computer, dont know about others
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC