2Tricky 0 Posted July 30, 2011 Hello. I'm wondering whether there is an easy answer to why the following only partly works. expandcollapse popup$MsComm = ObjCreate("MSCOMMLib.MsComm.1") $MsComm.CommPort = 1 $MsComm.Settings = "9600,N,8,1" $MsComm.Handshaking = 0 $MsComm.InBufferSize = 1024 $MsComm.InputLen = 1 $MsComm.PortOpen = 1 While 1 MsgBox(0,"Testing",_MsgIn()) Sleep(2000) WEnd Func _MsgOut($str) $MsComm.OutBufferCount = 0 $MsComm.InBufferCount = 0 If $MsComm.PortOpen = True Then $MsComm.Output = $str EndIf $MsComm.InputLen = 0 EndFunc Func _MsgIn() $TIMEOUT = 1000 ;1000 $nTimeCtr = 0 $sBuffer = "" Do $nTimeCtr += 1 If $MsComm.InBufferCount > 0 Then $sBuffer = $sBuffer & $MsComm.Input EndIf Sleep(500) Until StringInStr($sBuffer,@CR) OR $nTimeCtr > $TIMEOUT If $nTimeCtr < $TIMEOUT Then $nI = StringInStr($sBuffer,@CR) Return StringLeft($sBuffer,$nI) Else Return "Error" EndIf EndFunc SORRY, THIS WILL BE IN CAPS AS IPHONE HAS THROWN A WOBBLY TOO! FROM A WIN 7 PC, THIS LARGELY 'BORROWED' CODE (THANKS BY THE WAY) DOESN'T QUITE WORK. HAVING GOT AROUND MANY OBSTACLES, I CAN RUN THIS BUT IT FALLS OVER AT THE POINT WHERE THE INBUFFERCOUNT IS TESTED FOR > 0. IT NEVER BECOMES GREATER. I SAW MENTION OF USING A NULL CABLE BUT THIS WAS WRITTEN WITH 2 COM PORTS AVAILABLE WHICH I DON'T HAVE. I HAVE TRIED THE ALTERNATIVE NETCOMM... WRAPPED ACTIVEX BUT HAD THE SAME OUTCOME. THE AUTHOR (OF NETCOMM) SPECIFICALLY STATED THAT IN WIN 7 IT NEEDED ADMIN RIGHTS - THOUGH HE DIDN'T KNOW OF AUTOIT. I HAVE TO SAY THAT IN WIN 7, MY USUAL APPROACH IS TO RUN WITH ADMIN RIGHTS (AND FAST!). IF ANYONE HAS A CLUE I'D BE V GRATEFUL. MANY THANKS. NB MY 'REAL' AIM IS TO FEED ASCII COMING INTO COM 1 FROM A DEVICE TO MY OWN AUTOIT WINDOW AND EVENTUALLY EXCEL 2000. Share this post Link to post Share on other sites
water 2,387 Posted July 30, 2011 Seems you borrowed the code from this So maybe the might be useful and help you with your problem. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
2Tricky 0 Posted July 31, 2011 Seems you borrowed the code from this So maybe the might be useful and help you with your problem.Water I chose to start a new thread because the 'doner' thread seemed to have become diluted and I needed to clear the blackboard. Thanks for the alternative UDF idea but I have a problem here too again and that thread is unfortunately quite old to add to.If you have experience in this subject in relation to Win 7 I'd be grateful for your input. Specifically (with your UDF idea) I get a vilolation of the array boundary after completing "stage 2" as written to the console in the latest example included in the thread. Actually I think this is simply that the array isn't an array i.e. the instantiation did not occur properly at all because of some earlier issue. My difficulty is that I don't know much about Com ports (though I wrote my own code in C years ago - long forgotten and probably doesn't travel well to here). My quest goes on but I feel that in order for me to progress I have to have some success to build on and I don't feel I've reached that point.I'm all ears for any ideas - thanks a lot. Share this post Link to post Share on other sites
water 2,387 Posted July 31, 2011 Hi 2Tricky, unfortunately I can't help you with this subject. When I read your post I just remembered that there was an UDF for this kind of task. But I think the UDF thread is quite active because the author (martin) just answered a few days ago. Maybe you can post the questions you have regarding the UDF there and I'm quite sure you'll get some answers. Good luck! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites