Sign in to follow this  
Followers 0
Ivan808

Variable within Send()

8 posts in this topic

#1 ·  Posted (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 by Ivan808

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

this is what I have for a test script:

#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?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

this is what I have for a test script:

#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 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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0