---- START NEW MESSAGE --- Received: from cherry.ease.lsoft.com [209.119.0.109] by dpmail10.doteasy.com with ESMTP (SMTPD32-8.05) id A0FC271D003C; Thu, 29 Jan 2004 09:21:00 -0800 Received: from PEAR.EASE.LSOFT.COM (209.119.0.19) by cherry.ease.lsoft.com (LSMTP for Digital Unix v1.1b) with SMTP id <14.00CC2DC6@cherry.ease.lsoft.com>; Thu, 29 Jan 2004 12:20:46 -0500 Received: from MITVMA.MIT.EDU by MITVMA.MIT.EDU (LISTSERV-TCP/IP release 1.8e) with spool id 7105 for PICLIST@MITVMA.MIT.EDU; Thu, 29 Jan 2004 12:20:36 -0500 Received: from MITVMA (NJE origin SMTP@MITVMA) by MITVMA.MIT.EDU (LMail V1.2d/1.8d) with BSMTP id 5630; Thu, 29 Jan 2004 12:18:56 -0500 Received: from *unknown [212.247.55.211] by mitvma.mit.edu (IBM VM SMTP Level 430) via TCP with ESMTP ; Thu, 29 Jan 2004 12:18:55 EST X-Warning: mitvma.mit.edu: Host *unknown claimed to be dns.flintab.se x-fsavag4mse-ts: d9626306de279954 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Re:[EE:] Spreadsheet w/serial input? thread-index: AcPmjA2oksSNKr2bR1Wg7nZsIB4ggQ== Message-ID: <8A2A45D3D18D574484CFD980CDB73A31024C4C@flmail.dns.flintab.se> Date: Thu, 29 Jan 2004 18:19:07 +0100 Reply-To: pic microcontroller discussion list Sender: pic microcontroller discussion list From: =?iso-8859-1?Q?Tony_K=FCbek?= Subject: Re: [EE:] Spreadsheet w/serial input? To: PICLIST@MITVMA.MIT.EDU Precedence: list X-RCPT-TO: Status: U X-UIDL: 371856291 Hi, John Pearson wrote: >Is there a spreadsheet that offers direct real-time input from a serial = =3D >port? Well I've seen some modules that does that, but normally they are tied = to an specific data format (or brand of device), so I did it myself. Coding in c I have used the SendInput() function from the win32 api, = with sucess. It will work as an general keyboard wedge (s/w) and one has to write all = the nessesary code for communicating with 'your' device. Then at an hotkey (global) = you just put any data you want into the keyboard que. You can also add as much bell = and whistles you want to this scheme. My program has options for only sending to specific = apps (such as Excel) I had timers which would insert the data at specific intervals, I added = some macro functionality so the user could format the data in the way he wanted, adding tabs, = date, free text, enter etc.. In operation my app was down at the notify area, I hooked an global = hotkey, when pressed it would insert the data according to an macro wherever the cursor was (normally = in Excel).=20 The actual sending of data was trivial, however handling all the = 'oddities' with windows and keyboard focus (well any focus) etc took quite some time to get to grips with. Here's a snippet(hacked): .. .. PINPUT pKeyInputArray; // pointer to input array .. .. some code to handle current shift/alt/ctrl/caps states = (GetAsynchKeyState..) SHORT ShiftStat =3D GetAsyncKeyState(VK_SHIFT); // get current = state of shift key SHORT CtrlStat =3D GetAsyncKeyState(VK_CONTROL); // get current = state of control key .. =20 .. .. for(int i =3D 1; i <=3D KeyText.Length();i++) { // get next key Key =3D KeyText[i]; // if capital then we need to also send shift key up/down events if(isupper(Key))PressShift =3D true; // make key capital=20 Key =3D (char)toupper(KeyText[i]); // if key was capital then we need to add Shift key to = the input que // and release it after we have put the (real) key into the que if(PressShift) { 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; } // add the key to the input que, both down and up actions // take note of the order and the variable CurrArrayPos = increments / as we fill two input structures in one swoop here 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;=20 pKeyInputArray[CurrArrayPos+1].ki.wScan =3D sk; pKeyInputArray[CurrArrayPos].ki.dwFlags =3D 0; // key = down code pKeyInputArray[CurrArrayPos+1].ki.dwFlags =3D = KEYEVENTF_KEYUP; // key up code 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; .. .. .. restore the shift/ctrl/alt/caps states .. .. after all done // finally send all kb events unsigned int Result =3D = SendInput(CurrArrayPos+1,pKeyInputArray,sizeof(INPUT)); .. .. /Tony -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. .