Jump to content

eohalloran

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by eohalloran

  1. Never mind. I managed to find Partypooper's _ChangeScreenRes function which works great
  2. I managed to download a UDF called "Screen Resolution.au3" that someone wrote a while back that worked great but can't seem to locate it. I don't have access to the computer that I used that script on anymore, but if someone knows where that is located would it be possible to point me to it?? Thanks
  3. And there in probably lies my problem. I told you I was a Novice. Let me correct that and see how I get on. I knew you'd probably be able spot it without trying Thanks for looking eo
  4. I might have been a little premature saying that it was all up and running OK. I can setup the ports fine and I have tested it right up to port 50, so the _CommSwitch and the _CommSetPort seem to work great. However when I try _CommGetline or _CommSendString then my script barfs with a return code of rc:250477278 I've attached my script for the 8 connection GUI. You will note that only the very top set of ports will call _CommGetline or _CommSendString in a function called Connect1(), until I can figure what the problem is. It may well be my mess up in the way I'm calling the function, but if you get the chance would you take a look to see if I have messed up?? Much appreciated eo com_port_redirector_8_connections.au3
  5. Cheers Martin, Great work on the dll. The new comMGaa.dll seems to be functioning just great. I have now modified my GUI to allow 8 connections (16 com ports in total) and so far absolutely no problems. I am still tinkering with the GUI and as soon as I've finished with it I'll load it on here. It's turned out to be pretty useful so far. I could see a further use to allow a connection between one port to many, but don't know how much work that would involve in your dll or if it is even possible. I get an error if I try to reuse a port, but I expected that!!! Rgds eo
  6. OK, so it turns out I made a typo and a few small errors. I now have this working where I can take input on one Com port and output it on a second Com port and vice versa (i.e. it is now bidirectional). There are 2 things I want to do now. Firstly get the Disconnect button working; this is key because my goal is to be able to connect and disconnect at will. I have a disconnect function but I can't call it from an appropriate place for it to do something. I've tried placing it within the various loops, the obvious one was where I am sending data out, but that didn't work so for now it is in my Events function until I can figure that out. Then ultimately I want to have multiple connection/disconnections. Here's what I have so far" #include <GUIConstants.au3> #include <CommMG.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> $Main = GUICreate("Com Port Redirector - Com Port Configuration", 400, 150) GUISetFont(10, 400, "Times New Roman") $cmboPortsAvailable1 = GUICtrlCreateCombo("", 110, 75, 75, 25) $lblPort1 = GUICtrlCreateLabel("Connect Port", 30, 78, 80, 25) $cmboPortsAvailable2 = GUICtrlCreateCombo("", 280, 75, 75, 25) $lblPort2 = GUICtrlCreateLabel("To Port", 230, 78, 50, 25) $lblBaud = GUICtrlCreateLabel("Baud Rate for both Ports", 124, 10, 160, 25) $CmBoBaud = GUICtrlCreateCombo("", 160, 30, 70, 25) GUICtrlSetData(-1, "50|75|110|150|600|1200|1800|2000|2400|3600|4800|7200|9600|10400|14400|15625|19200|28800|38400|56 000|57600|115200|", "4800") $btnConnect = GUICtrlCreateButton("Connect Com Ports", 130, 120, 140, 25) GUISetState(@SW_SHOW, $Main) GUISetOnEvent($GUI_EVENT_CLOSE, "Bye") $Main1 = GUICreate("Com Port Redirector - Monitor Window", 600, 200) $lblBaud1 = GUICtrlCreateLabel("", 50, 10, 150, 25) $lblPort3 = GUICtrlCreateLabel(GUICtrlRead($cmboPortsAvailable1), 10, 10, 35, 25) $monitor1 = GUICtrlCreateEdit("", 10, 30, 550, 40, BitOR($WS_EX_WINDOWEDGE, $ES_READONLY, $ES_AUTOVSCROLL, $ES_MULTILINE, $WS_VSCROLL)) $lblPort4 = GUICtrlCreateLabel(GUICtrlRead($cmboPortsAvailable2), 10, 90, 35, 25) $lblBaud2 = GUICtrlCreateLabel("", 50, 90, 150, 25) $monitor2 = GUICtrlCreateEdit("", 10, 110, 550, 40, BitOR($WS_EX_WINDOWEDGE, $ES_READONLY, $ES_AUTOVSCROLL, $ES_MULTILINE, $WS_VSCROLL)) $btnDisconnect = GUICtrlCreateButton("Disconnect Com Ports", 230, 160, 140, 25) GetPorts() SetupComPorts() GUISetState(@SW_HIDE, $Main) GUISetState(@SW_SHOW, $Main1) Events() _CommClearOutputBuffer() _CommClearInputBuffer() While 1 _CommSwitch(1) $instr = _CommGetline(@CR, 1000, 200) GUICtrlSetData($monitor1, $instr) _CommSwitch(2) _CommSendString($instr) $instr = _CommGetline(@CR, 1000, 200) GUICtrlSetData($monitor2, $instr) _CommSwitch(1) _CommSendString($instr) WEnd Func Events() $msg = GUIGetMsg() If $msg = $btnDisconnect Then Disconnect() EndIf Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Bye") EndFunc;==>Events Func Bye() _Commcloseport() Exit EndFunc;==>Bye Func GetPorts();Find all com ports $portlist = _CommListPorts(0);find the available COM ports and write them into the ports combo If @error = 1 Then MsgBox(0, 'trouble getting portlist', 'Program will terminate!') Exit EndIf If IsArray($portlist) then For $pl = 1 To $portlist[0] GUICtrlSetData($cmboPortsAvailable1, $portlist[$pl]);_CommListPorts()) GUICtrlSetData($cmboPortsAvailable2, $portlist[$pl]);_CommListPorts()) Next Else MsgBox(262144,"ERROR", "No COM ports found on this PC.") EndIf EndFunc;==>GetPorts Func SetupComPorts();Open com port Local $sportSetError $baud = GUICtrlRead($CmBoBaud) GUICtrlSetData($lblBaud1, $baud & " bps - Monitor 1") GUICtrlSetData($lblBaud2, $baud & " bps - Monitor 2") While 1 Sleep(50) $msg = GUIGetMsg() If $msg = -3 Then; Exit button on GUI Exit EndIf If $msg = $btnConnect Then Sleep(50) _CommSwitch(1) $setport1 = StringReplace(GUICtrlRead($cmboPortsAvailable1), 'COM', '') _CommSetPort($setport1, $sportSetError, $baud, 8, 0, 1, 0) GUICtrlSetData($lblPort3, GUICtrlRead($cmboPortsAvailable1)) _CommSwitch(2) $setport2 = StringReplace(GUICtrlRead($cmboPortsAvailable2), 'COM', '') _CommSetPort($setport2, $sportSetError, $baud, 8, 0, 1, 0) GUICtrlSetData($lblPort4, GUICtrlRead($cmboPortsAvailable2)) If @error Then MsgBox(0, 'Setport error = ', $sportSetError) ExitLoop EndIf WEnd EndFunc;==>SetupComPorts Func Disconnect() _CommSwitch(1) _CommClosePort() _CommSwitch(2) _CommClosePort() EndFunc;==>Disconnect Rgds eo
  7. Martin, Yes I intend to take data in on one Com port and send it out on another. My purpose is that I want to be able to take 4 GPS signals in on 4 seperate Com ports and then send them to some devices on 4 other Com ports. I then want to be able to make and break the connections between the Com ports to simulate GPS information being lost, so my devices automatically switch over to SNTP. So ultimately I will have a second radio button to disconnect the connectios as well. I'm a complete Novice at this Autoit stuff, but I am keen to learn and I have dug around on previous postings to get bits and pieces of code. In fact it's your UDF that started me on this path. As requested the link to the UDF is http://www.autoitscript.com/forum/index.php?showtopic=45842 Best Rgds eo
  8. I had the exact same error and it was easily resolved by adding the commg.dll file to c:\Windows\System32. It can be downloaded with the UDF on page 1 of this posting Rgds eo Edit - I also ran the program on a machine that didn't have Com ports and got the same error, so Martin has pretty much given you another area to check I used the example Martin gave as follows in my code and on a Windows Vista machine that does not have Com ports, I now get a message box saying so Func GetPorts();Find all com ports $portlist = _CommListPorts(0);find the available COM ports and write them into the ports combo If @error = 1 Then MsgBox(0, 'trouble getting portlist', 'Program will terminate!') Exit EndIf If IsArray($portlist) then For $pl = 1 To $portlist[0] GUICtrlSetData($cmboPortsAvailable1, $portlist[$pl]);_CommListPorts()) GUICtrlSetData($cmboPortsAvailable2, $portlist[$pl]);_CommListPorts()) Next Else MsgBox(262144,"ERROR", "No COM ports found on this PC.") EndIf EndFunc;==>GetPorts
  9. Thanks for the responses. The problem I am having now is having more than one Com Port open at the time. Looking in the Commg UDF, there is a _CommSwitch function that allows switching between com ports, but when I use this, it takes focus away from the original com port, so cosequently, when I set one port up and switch to the next, I am left with only one configured port. I've uploaded what I have so far. I've icluded the commMG.au3 and the commg.dll needed EDIT - As requested files removed and link to original UDF is: http://www.autoitscript.com/forum/index.php?showtopic=45842 I'm interested in trying the ini approach that Uwe suggests, but I would need to edit it to contain 18 com ports. I'm also going to try to persevere with this script and if I get it to work, I'll add the 18 com port connections and maybe some method of removing used com ports eo Edit --- If you try to run this on a machine with only one com port, it'll throw an exception (something else I'll need to add!!!) BTW, I put the second window in to monitor that I was getting input , so consequently as it stands now, if I send something in on the second com port it'll appear in the bottom window. If I comment out the _CommSwitch(2) stuff, I can see the input on the first com port, so I know data is getting to the application Oh, and Martin you were perfectly correct, the com ports behave as though they are physically attached to the PC com_port_redirector.au3
  10. Hmmm, having analyzed this a little further it may not be as simple as you describe. Coms 3 through 18 are on a Terminal server that communicate with the target PC via IP. So I would have to do the turn around at the transport layer perhaps, (TCP???). The ports appear to function as physical ports, in that if I pass the GPS data in on Port 1 through 16 of the Port Server (Com 3 through 18), I see it in Hyperterminal/Procomm. I noted that someone already has Server/Client code out there (can't remember who it was but will post their link when I find it), that takes data in from a serial port on one machine and then passes it via TCP/IP to another machine. I'm thinking that this approach may work, but compile the server client as a single entity and run on the same machine. Then work out how to turn the TCP layer back around to the physical on the new Com port. Thoughts???
  11. Has anyone come across autoit code to take the input from a physical com port and redirect it out of a second physical com port. I have a terminal server that I want to take GPS data in on one port and then distribute it out of 8 additional serial ports. I need to be able to remotely connect and disconnect the GPS data for some tests I want to run. I have a purchased piece of software that claims to be able to do this. I can input on Com 3 and redirect to Com 11 and see both sets of data on Hyperterminal, but nothing physically comes out Com 11, so the data is being passed to the application layer and not down to the physical layer. I also have a second piece of purchased software that allows redirection to virtual Com ports which is absolutely no use to me. I saw a Serial Port UDF and was contemplating playing around with it, but if someone has something already, that would be a fantastic start
  12. Is this a conspiracy??? I extend a common courtesy and I get pounced on for it???? If you walked down the street and saw someone you knew but hadn't seen them for a year, would you walk past them or say Hi? If you found a great quote from a long dead author, would you claim it as your own, or give the author credit? When your mom sends you a birthday present and you haven't seen her for a while, do you just ignore her? Come on, all I said was Thanks. Since when was being polite bounded by time???
  13. Thanks Zedna. The first tool was pretty handy. I ran it on my scripts and got rid of some locally declared variables, but I think my original question was perhaps not as clear as it could have been. A typical script I have switches off CAPS Lock, NUM Lock and SCROLL lock, before continuing to run because I found that CAPS Lock actually stopped the ENTER command from functioning correctly. I searched this forum and found a solution for that and it told me to add #include<Constants.au3> and #include<Misc.au3>. When I looked in both of these there were no constants VK_SCROLL, VK_NUMLOCK or VK_CAPITAL. I did a search on all the other au3 files and none of these contained these constants, so I manually added them to Constants.au3. The script I ended up using by the way came courtesy of MrCreator and works extremely well. My question therefore was that I have the latest and greatest AutoIt, but looking at examples, it would appear that there must be a more up to date Include folder that has additional constants in it. The reason I ask this was because it took me a little time to work out the values to assign to the constants, not too long, but as I get into further scripting, it would be nice to take existing stuff and utilize it. Best Regards
  14. Yes I did, but as the two posters are current members (last seen today and 7th October) and I used their solution, I thought it only fit to say Thank you. I wasn't aware that saying thanks was a problem???
  15. Guys, Thanks. I was after something to completely terminate my script, as it is controlling a GUI with a lot of selections and if something went wrong (I'm still writing it), it was extremely hard to take back control of the mouse. Works great
  16. MrCreatoR, you're the bees knees mate!!!! Works perfectly Best Regards
  17. I noted that when I tried some of the example files and solutions posted in this forum that certain variables are declared and the includes have such things as Constants.au3, GUIConstants.au3, Misc.au3 etc....... When I try to run the files, I get errors stating the the variables have not been declared and indeed when I look in the include folder at the collection of files, I check those being included and the variables are not declared. Is there a more up to date Include folder somewhere. I have the one that came with version 3 Rgds
  18. Hi, New to this forum. I have a problem in that if Caps Lock is on, when I send commands to a particular GUI, the {ENTER} commands are being ignored, meaning my script fails. If I manually switch the Caps lock off, the script works great. I have used the following: #include <Constants2.au3> #include <Misc.au3> If _GetScrollLock() = 1 Then Send("{SCROLLLOCK Toggle}"); 0 = Off / 1 = On Func _GetScrollLock(); Checks to see if Scroll Lock is on Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_SCROLL) Return $ret[0] EndFunc If _GetNumLock() = 1 Then Send("{NUMLOCK Toggle}"); 0 = Off / 1 = On Func _GetNumLock(); Checks to see if Scroll Lock is on Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK) Return $ret[0] EndFunc If _GetCapsLock() = 1 Then Send("{CAPSLOCK Toggle}"); 0 = Off / 1 = On Func _GetCapsLock(); Checks to see if Scroll Lock is on Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_CAPITAL) Return $ret[0] EndFunc I looked in the Include folder for the VK declarations and none existed for VK_SCROLL, VK_CAPITAL or VK_NUMLOCK, so I created the following in Constants2.au3 (wouldn't let me create them in Constants.au3) Global Const $VK_SCROLL = 0x91 Global Const $VK_NUMLOCK = 0x90 Global Const $VK_CAPITAL = 0x14 When I run the script, the Number lock and Scroll lock work perfectly, but Caps lock does not switch off. I ran a code scanner to interrogate the Caps lock key and know that it is definitely 0X14, so my script is correct. Has anyone else managed to resolve this problem????
×
×
  • Create New...