Jump to content

Send text, variable, then text again?


Recommended Posts

Hi,

How can I combine a text string, a variable and then a text string again?

I thought I could do it like this:

$UserPath = "C:\Users\" & $UserClean[2] & "\GSS"
Send($UserPath)

But that only returns "C:\Users\<username>". The "\GSS" part is left out.

I've also tried to do it like this:

$UserPath = "C:\Users\" & $UserClean[2]
Send($UserPath & "\GSS")

That also only returns "C:\Users\<username>"

Help please :unsure:

Edited by scanie
Link to comment
Share on other sites

Well it's probably got something to do with GSS. This code,

Local $UserClean[3] = ["ausername", "busername", "cusername"]
$UserPath1 = "C:\Users\" & $UserClean[2] & "\GSS"
$UserPath2 = "C:\Users\" & $UserClean[2] & "\ABC"
;ConsoleWrite($UserPath1 & @LF)
Send($UserPath1)
Send("{ENTER}")
Send($UserPath2)

'sends' this,

C:\Users\cusername\GSS

C:\Users\cusername\ABC

to SciTE. The GSS is colored red in SciTE, due to the syntax highlighting. I have no idea why though.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

I found the problem :unsure:

I had @CRLF in this section:

If IsObj($colItems) then
   For $objItem In $colItems
       $UserName = $objItem.UserName & @CRLF
   Next

This is the entire script and it's now working as intended. It resolves logged on user and then inserts correct installation path for a software installation.

#region ---Au3Recorder generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
                                          
If IsObj($colItems) Then
   For $objItem In $colItems
       $UserName = $objItem.UserName
   Next
$UserClean = StringSplit($UserName, "\")
; $UserClean[2] ; Username variable  
$UserPath = "C:\Users\" & $UserClean[2]
;$UserPath = $UserPath & "\GSS"
EndIf
_WinWaitActivate("Welcome","")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActivate("Choose Destination Location","Setup will install G")
Send("{ALTDOWN}r{ALTUP}")
_WinWaitActivate("Select Destination Directory","")
Send($UserPath & "\GSS")
Send("{ENTER}")
;_WinWaitActivate("Install","The directory C:\Use", 2)
;Send("{ENTER}")
_WinWaitActivate("Choose Destination Location","Setup will install G")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActivate("Select Program Manager Group","")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActivate("Start Installation","")
Send("{ALTDOWN}n{ALTUP}")
#region --- Internal functions Au3Recorder Start ---
Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
#endregion --- Internal functions Au3Recorder End ---

#endregion --- Au3Recorder generated code End ---
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...