Ivan808 Posted November 29, 2009 Share Posted November 29, 2009 (edited) How is this not possible? Is there any work around this? I am trying to find out how I could make a variable go into a Send(). IE. Send ($Variablehere) I have checked the help file and found that this: $x = Chr(65) Send("{" & $x & " 4}") does not help me. I am trying to send numbers... ie: $n = 12345 Send($n) Case $test_button $DB2 = FileOpen("Db2.db",1) $read5_1 = 987654321 $read5_2 = 123456789 Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("DB2 - Notepad","") If Not WinActive("DB2 - Notepad","") Then WinActivate("DB2 - Notepad","") WinWaitActive("DB2 - Notepad","") MouseMove(32,152) MouseDown("left") MouseMove(12,151) MouseUp("left") Send($read5_1) MouseMove(98,150) MouseDown("left") MouseMove(77,155) MouseUp("left") Send($read5_2) FileClose($DB2) Edited November 29, 2009 by Ivan808 Link to comment Share on other sites More sharing options...
martin Posted November 29, 2009 Share Posted November 29, 2009 How is this not possible? Is there any work around this? I am trying to find out how I could make a variable go into a Send(). IE. Send ($Variablehere) I have checked the help file and found that this: $x = Chr(65) Send("{" & $x & " 4}") does not help me. I am trying to send numbers... ie: $n = 12345 Send($n) Case $test_button $DB2 = FileOpen("Db2.db",1) $read5_1 = 987654321 $read5_2 = 123456789 Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("DB2 - Notepad","") If Not WinActive("DB2 - Notepad","") Then WinActivate("DB2 - Notepad","") WinWaitActive("DB2 - Notepad","") MouseMove(32,152) MouseDown("left") MouseMove(12,151) MouseUp("left") Send($read5_1) MouseMove(98,150) MouseDown("left") MouseMove(77,155) MouseUp("left") Send($read5_2) FileClose($DB2) If I remove the first two lines and the last line then what you posted works. Also $n = 12345 Send($n) is fine. I don't know what this $x = Chr(65) Send("{" & $x & " 4}") was for , but if you want to send the letter A then $x = Chr(65) Send("{ASC " & 65 & "}") would do it. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Ivan808 Posted November 29, 2009 Author Share Posted November 29, 2009 hmmm. I just tried it again, and i dont know what i did differently. It works! Thanks for your help If I remove the first two lines and the last line then what you posted works. Also $n = 12345 Send($n) is fine. I don't know what this $x = Chr(65) Send("{" & $x & " 4}") was for , but if you want to send the letter A then $x = Chr(65) Send("{ASC " & 65 & "}") would do it. Link to comment Share on other sites More sharing options...
Ivan808 Posted November 30, 2009 Author Share Posted November 30, 2009 ok... so $n = 987654321 works but what about $n = FileReadLine($file, 2) Send($n) The above does not work.... I can't figure out why. I have tried multiple scenarios with no luck. Thanks. Link to comment Share on other sites More sharing options...
mikjay Posted November 30, 2009 Share Posted November 30, 2009 To do your error checking, I suggest sending your variable to the console as well as to the keyboard. Do this for both assigning the variable and the send command. For instance: $n = FileReadLine($file, 2) ConsoleWrite($n & @CRLF) ;Write $n to console (read in bottom of SCITE) Send($n) ConsoleWrite(@error & @CRLF) ;Write error level to console In this case, if $n returns a string, then you need to check your file. If it returns 1, your FileReadLine wasn't set up correctly. Make sure you are using the handle from a previous FileOpen command. If the error turns up in Send, you'll have a whole different issue. The problem likely lies in FileReadLine, as the file has to be open first. Link to comment Share on other sites More sharing options...
Ivan808 Posted December 2, 2009 Author Share Posted December 2, 2009 this is what I have for a test script: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 517, 170) $Button1 = GUICtrlCreateButton("Button1", 144, 96, 65, 65, $WS_GROUP) $file = FileOpen("city_cord.db", 0) $test = FileReadLine($file, 1) $Label1 = GUICtrlCreateLabel($test, 160, 216, 73, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;$file = FileOpen("city_cord.db", 0) ;$test = FileReadLine($file, 2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit Case $Button1 ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $test = FileReadLine($file, 1) MsgBox(0, "d", $test = FileReadLine($file, 1)) ;MsgBox(0, "Test", $test) ; Read in lines of text until the EOF (End of File) is reached ;While 1 ; $line = FileReadLine($file) ;If @error = -1 Then ExitLoop ;MsgBox(0, "Line read:", $line) ;Wend ;FileClose($file) EndSwitch WEnd this returns a msg box that comes up and says "True". but I dont want it to come up true or false, i want it to come back with a string that i want to display. is this possible? i figure if this works with the msgbox, it should work with the Send($test). what do you all think? Link to comment Share on other sites More sharing options...
martin Posted December 2, 2009 Share Posted December 2, 2009 (edited) this is what I have for a test script: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 517, 170) $Button1 = GUICtrlCreateButton("Button1", 144, 96, 65, 65, $WS_GROUP) $file = FileOpen("city_cord.db", 0) $test = FileReadLine($file, 1) $Label1 = GUICtrlCreateLabel($test, 160, 216, 73, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;$file = FileOpen("city_cord.db", 0) ;$test = FileReadLine($file, 2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit Case $Button1 ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $test = FileReadLine($file, 1) MsgBox(0, "d", $test = FileReadLine($file, 1)) ;MsgBox(0, "Test", $test) ; Read in lines of text until the EOF (End of File) is reached ;While 1 ; $line = FileReadLine($file) ;If @error = -1 Then ExitLoop ;MsgBox(0, "Line read:", $line) ;Wend ;FileClose($file) EndSwitch WEnd this returns a msg box that comes up and says "True". but I dont want it to come up true or false, i want it to come back with a string that i want to display. is this possible? i figure if this works with the msgbox, it should work with the Send($test). what do you all think? Your MsgBox parameters are not what I think you think they are Instead of MsgBox(0, "d", $test = FileReadLine($file, 1)) you should have MsgBox(0, "d", "$test = " & $test);which you have already tried, or similar. EDIT:Oops wrong code posted at first. Edited December 2, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Ivan808 Posted December 2, 2009 Author Share Posted December 2, 2009 Your MsgBox parameters are not what I think you think they are Instead of MsgBox(0, "d", $test = FileReadLine($file, 1)) you should have MsgBox(0, "d", "$test = " & $test);which you have already tried, or similar. EDIT:Oops wrong code posted at first. it works! I swear i tried that... i dont know what was wrong with it. after some troubleshooting i got it to work... now im not touching it... thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now