5 posts in this topic
If I am using a RunWait command to launch a batch file from within an AutoIt script, how can I pass a variable to said batch file so that the batch file can utilize said variable like in a %var% format? Thank you in advance.
I'm trying to create a program where the user can input a material number into a GUI and the script will search out and find the respected material folder. I've been able to piece together the file mapping part so that the correct folder is stored within a variable. However I can not seem to get the Run function to work as the directory contains commas. Could I please get assistance with this?
Here is some test code I've experimented with
$filepath = "C:\Users\annoymousx\Documents\" ; Variable Works ;$filepath = "C:\Users\annoymousx\Documents\Test with Spaces\"; Works with folder spacing $filepath = $filepath & "Test with Spaces\"; Works with using a prior directory history $filepath = $filepath & "Folder with ()"; Works if brackets are used ;$filepath = $filepath & "\Folder with ," ;Does not Work if comma is used in file directory $filepath = $filepath & "\Folder with " & ""","""; Works if triple brackets are used Run("explorer.exe " & $filepath)
So I've learnt if you put triple quotations around a comma it will work correctly. The challenge is, in the actual script i'm not manually entering in text.
$filepath = $filepath & $Materialclass[$classnum] & "\"
Which is put into a loop, then at the end of the script I have the correct file path saved to the variable but it may contain many commas.
How would I take this variable with the correct file path and open windows explore to it?
Say if the variable contained the value: C:\Users\anonymousx\Documents\This folder has a ,\comma, (comma, comma,)\And more , here
Thanks for any suggestions,
I am trying to rebuild an old single signon script that has been giving us a bit of trouble lately. I didn't write it and it was written in another script language. If the target program is already open it will have the current user's last name as part of the window text, which I am trying to compare against the user name to see if I should just WinActivate or Process Close and start the program over. I will be provided the username like "jones", or "smith" and the title check works fine for last names (with no spaces), but if the last name DOES contains spaces, say "Nom De Plume", then all I will be given as a username is "nomdeplume". Is there any way (via a regex maybe) that I can still check the text on the screen and somehow ? I have been reading about the Advanced (4) mode of WinTitleMatchMode, but it is over my head. Any help is appreciated. Here is a small reproducer script:
Opt("WinTitleMatchMode", -1) Run("Notepad") WinWait("[CLASS:Notepad]", "", 10) Send ("Smith" & @CRLF & "Jones" & @CRLF & "Nom De Plume" & @CRLF) If WinExists("[CLASS:Notepad]", "jones") Then MsgBox(0,"FOUND","Found Jones") EndIf If WinExists("[CLASS:Notepad]", "nomdeplume") Then MsgBox(0,"FOUND","Found Nom De Plume") EndIf
Can anyone help me explain this?
$szFile = "test.htm" $szText = FileRead($szFile) $szText = StringReplace($szText, "hello", "ö") FileDelete($szFile) FileWrite($szFile,$szText) If the file "test.htm" has it's text changed into something containing non US characters, in this example "ö", the output is " Ã¶ " when shown in a browser.
If i manually change the text in the "test.htm" file to "ö" - the output in the browser is "ö" !
In both cases, if the htm file is opened in notepad, the content is just "ö" - but the one changed from the script, still opens as " Ã¶ " in a browser. How weird is this?
I am aware that I can replace the text to " ö" , which is the HTML code for "ö" - then the output is correct in the browser, but this is just dumb when there are a lot of characters to be changed
Does anyone know why this happens, and how to solve it in a more simple way?
I need to write a code in which I am reading a text file which is of .vbs format and in that a line contains function signature like below
Function CreateEnvironmentVariable($sType, $sName, $sValue, $bOverwrite)
If the string is in above format, then I need to check number of arguments in it.
For in above case it should return 4.
Can anyone help me on this.