Jump to content

Using a $variable with Send()


JerryH
 Share

Recommended Posts

In order to make it more versatile, I've added parameters to an AU3 script that accesses a web site. Where I once used string constants for the agency name, user name, and password on the login page, I'd like to use variables now. In other words, something like this:

Send($agency + "{TAB}")

Send($user + "{TAB}")

Send($password + "{ENTER}")

However, I can find no syntax or other function that will allow it. I could even live with sending characters individually from a loop, if I had to, but I can't find a way to convert the variant string that's passed as a command-line argument into an array of characters.

Am I totally out of luck, or am I just missing something in the documentation?

Thanks!

Link to comment
Share on other sites

$password = 'secret'
Send($password & "{ENTER}")
Thanks for the quick response. I noticed that you used single quotes when assigning the $password variable. In my case, I need to assign it $CmdLine[6].

I think that may be why changing the + signs to & wasn't enough to get this to work for me. The script doesn't put anything into the text boxes on the login page, and it just waits for the next page, which never appears.

Using hard-coded strings with Send() works fine, but I haven't been able to get it to do anything with variables.

Link to comment
Share on other sites

Then there has to be another error somewhere, maybe the input field doesn't have the focus? " and ' are interchangeable, it doesn't matter which one you use, as long as you stick to the same within one function :)...

Link to comment
Share on other sites

IDK if i get you correct, but wouldn't it work to do like this?

WinWaitActive("AutoIt Forums")

$USR = Inputbox("My Username", "Type Username")

$PW = Inputbox("My Password", "Type Password")

;or instead of that type $USR = "Username" and $PW = "Password"

Sleep(1000)

Send($USR)

Sleep(100)

Send("{TAB}")

Sleep(100)

Send($PW)

Sleep(100)

Send("{ENTER}")

Sleep(1000)

MSgBox(0,"Logged in?", "Now you should be logged in huh?")

Link to comment
Share on other sites

Then there has to be another error somewhere, maybe the input field doesn't have the focus? " and ' are interchangeable, it doesn't matter which one you use, as long as you stick to the same within one function :)...

Indeed there was. A totally unrelated, accidental error, in another location, at exactly the right time to cast doubt on the Send() statements. (Data wasn't appearing in the fields that were supposed to be plugged.)

I had just changed the script to use variables for those fields instead of hard-coded string literals. When I checked the help, to assure myself that the syntax was right, I couldn't find a single instance where Send() was shown using a variable. That's why I thought perhaps it worked with literals only.

Thanks for letting me know that it should work, which got me looking elsewhere. Eventually I found the root of the problem in the PowerShell script that launches the AU3 script.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...