Jump to content

Help with code


Recommended Posts

Im new but I learned some of the help of this awesome forum :o!

Well I just made this code and I wanted to add something but I can't here is the code:

$answer = InputBox("Login", "What is your username?")
    Run("Notepad")
    WinWait("Untitled - Notepad")
    WinWaitActive("Untitled - Notepad")
    Send("Welcome {$answer}!")
EndIf

What I want it to do is when they type their name the notepad opens and it says Welcome {the name they typed}! :D please help

Edited by urmommie
Link to comment
Share on other sites

Im new but I learned some of the help of this awesome forum :D!

Well I just made this code and I wanted to add something but I can't here is the code:

$answer = InputBox("Login", "What is your username?")
    Run("Notepad")
    WinWait("Untitled - Notepad")
    WinWaitActive("Untitled - Notepad")
    Send("Welcome {$answer}!")
EndIf

What I want it to do is when they type their name the notepad opens and it says Welcome {the name they typed}! :o please help

Where did you get the idea that curly braces allow you to insert a variable into a string? Some other language, no doubt. This is AutoIt, use the AutoIt help file and run the simple tutorials in it to learn how AutoIt uses strings.

In this case you have to assemble the part before the variable, the variable contents, and the part after the variable with the append (ampersand) operator:

Send("Welcome " & $answer & "!")

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Just another solution with embedded variable ;-)

Opt("ExpandVarStrings", 1)
$answer = InputBox("Login", "What is your username?")
Run("Notepad")
WinWaitActive("[Class:Notepad]") ; to accept other languages title.
Send("Welcome $answer$!",1) ;   "1" to send it raw

App: Au3toCmd              UDF: _SingleScript()                             

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