Bob Ammerman wrote: >My MSDN documentation says: > > >mouse_event >The mouse_event function synthesizes mouse motion and button clicks. > >Windows NT/2000/XP: This function has been superseded. Use SendInput >instead. > >Send input is documented as: > >SendInput >The SendInput function synthesizes keystrokes, mouse motions, and = button Sendinput is way to do this thing (on XP/NT). I programmed an keyboard wedge type of app a while ago, recived data in = an serial input, formatted it an then when an hotkey was pressed I inserted = some text into the keyboard que of the current topmost app (focused). Be vary about some pitfalls in regards to these functions though. If you have hopes of inserting the mouse event into an arbitrary = application you will find that input focus and OS latency will come into affect.=20 For example in my case I programmed an hotkey, when pressed, the text = was supposed to be inserted into any arbitrary app that currently had focus. The problem was that = the hotkey event shifted the focus to my application, I had to write some tricky = code to find out the previous focused app and force focus manually, then you have no = garantues how long it will take the os to switch focus (windows is not RT), eventually I = had to insert an approriate delay ( sleep(xx) ) to allow the os time to switch. Then in = regards to the keyboard I had to manually keep track of the states of ctrl,alt, shift etc as = they could intervene with my insertion (getasynckeystate).=20 Here's an small snippet of my insert action (cutNpasted from an Builder = application): //********** only when input size is changed (and startup) PINPUT pKeyInputArray; // pointer to array // get the input locale LocaleIdent=3DGetKeyboardLayout(0);=09 // .. some code omitted for caculating input size requirments // allocate room for input=20 pKeyInputArray =3D new INPUT[InputLength+40]; // pointer to array InputArraySize =3D InputLength; //************ =09 // ******* do input action // release timeslice to OS // will return kb focus to (previous)topmost app Sleep(100);=20 // get start time in millisecs ( time running ) InputStartTime =3D GetTickCount()+100; KeymsecDelay =3D 100; // delay beetween keys, needed else some = input will be 'lost' // re-set current input array structure counter CurrArrayPos =3D 0; // handling of shift beeing pressed when we are to insert key into the = keyboard que. SHORT ShiftStat =3D GetAsyncKeyState(VK_SHIFT); // get current = state of shift key bool doShift =3D false; // code omitted for caps, alt, ctrl etc. if((ShiftStat & 0x8000)) // test if down when we are about to insert = input { // yes then release it, remeber to rest to original = state at exit ! doShift =3D true; pKeyInputArray[CurrArrayPos].type =3D INPUT_KEYBOARD; pKeyInputArray[CurrArrayPos].ki.wVk =3D VK_SHIFT; sk =3D MapVirtualKey(VK_SHIFT,0); pKeyInputArray[CurrArrayPos].ki.wScan =3D sk; pKeyInputArray[CurrArrayPos].ki.dwFlags =3D = KEYEVENTF_KEYUP; pKeyInputArray[CurrArrayPos].ki.time =3D InputStartTime = + CurrArrayPos*KeymsecDelay; pKeyInputArray[CurrArrayPos++].ki.dwExtraInfo =3D(sk << = 8) + 1; } // adding a particular key=3D'Key' (always capital here) // press key pKeyInputArray[CurrArrayPos].type =3D INPUT_KEYBOARD; vk =3D VkKeyScanEx(Key,LocaleIdent); pKeyInputArray[CurrArrayPos].ki.wVk =3D vk; pKeyInputArray[CurrArrayPos+1].ki.wVk =3D vk; sk =3D MapVirtualKey(vk,0); pKeyInputArray[CurrArrayPos].ki.wScan =3D sk; pKeyInputArray[CurrArrayPos+1].ki.wScan =3D sk; pKeyInputArray[CurrArrayPos].ki.dwFlags =3D 0; // release key pKeyInputArray[CurrArrayPos+1].ki.dwFlags =3D KEYEVENTF_KEYUP; pKeyInputArray[CurrArrayPos].ki.time =3D InputStartTime + = CurrArrayPos*KeymsecDelay; pKeyInputArray[CurrArrayPos+1].ki.time =3D InputStartTime + = (CurrArrayPos+1)*KeymsecDelay; pKeyInputArray[CurrArrayPos++].ki.dwExtraInfo =3D(sk << 8) + 1; pKeyInputArray[CurrArrayPos].type =3D INPUT_KEYBOARD; pKeyInputArray[CurrArrayPos++].ki.dwExtraInfo =3D(sk << 8) + 1; // reset original shift state if( doShift)//(ShiftStat & 0x8000) && doShift) // test if we = released it and still down { // yes then press it again pKeyInputArray[CurrArrayPos].type =3D INPUT_KEYBOARD; pKeyInputArray[CurrArrayPos].ki.wVk =3D VK_SHIFT; sk =3D MapVirtualKey(VK_SHIFT,0); pKeyInputArray[CurrArrayPos].ki.wScan =3D sk; pKeyInputArray[CurrArrayPos].ki.dwFlags =3D 0; pKeyInputArray[CurrArrayPos].ki.time =3D InputStartTime = + CurrArrayPos*KeymsecDelay; pKeyInputArray[CurrArrayPos++].ki.dwExtraInfo =3D(sk << = 8) + 1; } // code omitted for resetting caps, alt, ctrl etc. // then finally commit to send the input unsigned int Result =3D = SendInput(CurrArrayPos+1,pKeyInputArray,sizeof(INPUT)); if(Result =3D=3D 0) { Result =3D GetLastError(); String Mess =3D "Unable to send input data !\nError code: = "+IntToStr(Result); Application->MessageBox(Mess.c_str(),"SendInput()failed!", MB_OK + MB_ICONWARNING); } Something like that should get you started :) /Tony -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics