Sankesh Posted March 6, 2019 Author Share Posted March 6, 2019 Awesome !!!! Francesco. I have fixed the errors in the above code. My script is running with exit code 0 but there is no output. I tried printing it through Msgbox stil no Output. I want the username and password to be stored in different variable (Var1 and Var2 where i can pass this in the GUI). Can i have the above code altered as per this please.. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 6, 2019 Share Posted March 6, 2019 @Sankesh Post the entire script Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Sankesh Posted March 6, 2019 Author Share Posted March 6, 2019 #include <StringConstants.au3> Global $strXMLFileName = "C:\sam1.xml" Global $strFileContent = FileRead($strXMLFileName) $arrResult = StringRegExp($strFileContent, '<entry key="(DBDefault(?:UserName|Password))">([^<]*)</entry>', $STR_REGEXPARRAYGLOBALMATCH) If UBound($arrResult) = 4 Then For $i = 0 To UBound($arrResult) - 1 Step 2 If $i < UBound($arrResult) - 1 Then ConsoleWrite($arrResult[$i] & " = " & $arrResult[$i + 1] & @CRLF) Next EndIf In the above code i want the username to be stored in $var1 and password in $var2. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 6, 2019 Share Posted March 6, 2019 @Sankesh Now you can work with a lot of samples #include <MsgBoxConstants.au3> #include <StringConstants.au3> Global $strFileContent = '<?xml version="1.0" encoding="UTF-8"?>"' & @CRLF & _ '<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">' & @CRLF & _ '<properties>' & @CRLF & _ '' & @CRLF & _ '<entry key="DBDefaultUserName">PIQ72</entry>' & @CRLF & _ '<entry key="DBDefaultPassword">PIQ72yut</entry>"', _ $strUsername = "", _ $strPassword = "" ; Getting the Username $arrResult = StringRegExp($strFileContent, '<entry key="DBDefaultUserName">([^<]*)</entry>', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then $strUsername = $arrResult[0] ; Getting the Password $arrResult = StringRegExp($strFileContent, '<entry key="DBDefaultPassword">([^<]*)</entry>', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then $strPassword = $arrResult[0] MsgBox($MB_ICONINFORMATION, "", "Username: " & $strUsername & @CRLF & _ "Password: " & $strPassword) Fr33b0w 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Sankesh Posted March 6, 2019 Author Share Posted March 6, 2019 Thank you so much Francesco. Working perfectly Automation 1 with AutoIT scuccess. There comes my second automation where i have to pick third variable value from the same xml where entry key="JSqlAccessJdbcUrl">jdbc:oracle:thin:@//CLRCSWPIQIN0041:1521/PIQ72</entry> In the above entry i have to pick only CLRCSWPIQIN0041 (i.e only the VM name it should pick). ;Getting the VM name $arrResult = StringRegExp($strFileContent, '<entry key="JSqlAccessjdbcUrl">([^<]*)</entry>', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then $strPassword = $arrResult[0]. its picking the whole data inside JSqlAccessjdbcUrl where i need only vm name. Link to comment Share on other sites More sharing options...
Sankesh Posted March 6, 2019 Author Share Posted March 6, 2019 So i understood there is something need to be done here ([^<]*). So if there are four datas inside the entry and i have to pick the 3 rd data alone how to change that ([^<]*) value? eg:entry key="JSqlAccessJdbcUrl">jdbc:oracle:thin:@//CLRCSWPIQIN0041:1521/PIQ72</entry> in the above code how to pick "PIQ72" alone also "CLRCSWPIQIN0041" alone. <entry key="JSqlAccessjdbcUrl">([^<]*)</entry> Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 6, 2019 Share Posted March 6, 2019 (edited) @Sankesh It depends from how your string are going to be formatted. If the format they would always have is this (as it seems) : 1 hour ago, Sankesh said: <entry key="JSqlAccessJdbcUrl">jdbc:oracle:thin:@//CLRCSWPIQIN0041:1521/PIQ72</entry> Then you can use something like this: #include <Array.au3> #include <StringConstants.au3> Global $strFileContent = '<entry key="JSqlAccessJdbcUrl">jdbc:oracle:thin:@//CLRCSWPIQIN0041:1521/PIQ72</entry>' $arrResult = StringRegExp($strFileContent, '<entry key="JSqlAccessJdbcUrl">jdbc:oracle:thin:@[\/]{1,}([^:]+):\d+\/([^<]+)<\/entry>', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then _ArrayDisplay($arrResult) ; $arrResult[0] = CLRCSWPIQIN0041 ; $arrResult[1] = PIQ72 Edited March 6, 2019 by FrancescoDiMuro Fr33b0w 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Sankesh Posted March 7, 2019 Author Share Posted March 7, 2019 Hi Francesco..Thank You so much ..Done with Automation ..when my manager executes the script ..the script shows wierd behaviour..when he executes the 2 nd time its working perfectly. I used ControlSend() instead of send(),Controlclick() instead of Mouseclick(). Used if to check window is active then to proceed..Still i am not able to control the wierd behaviour..if i run my script 10 times it fails atleast 4 times.Used Win and Control commands only in my code but still no control ...the inputs which i am passing are getting feeded either early or very late ..Any luck? Link to comment Share on other sites More sharing options...
Sankesh Posted March 7, 2019 Author Share Posted March 7, 2019 If you want to have a look at my final code i can attach it.. Link to comment Share on other sites More sharing options...
Sankesh Posted March 7, 2019 Author Share Posted March 7, 2019 PFA code for reference. TDT_Server Code.txt Link to comment Share on other sites More sharing options...
Fr33b0w Posted March 7, 2019 Share Posted March 7, 2019 Can you put control checkpoints and visual or sound confirmations along your code so you can have a clue where it stuck? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 7, 2019 Share Posted March 7, 2019 1 hour ago, Sankesh said: If you want to have a look at my final code i can attach it.. Sure, because in the code you attached there are ONLY Send() and MouseClick() functions. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Sankesh Posted March 7, 2019 Author Share Posted March 7, 2019 Hi PFA the code where i have used Control click and Controlsend().. In the below part if i uncomment the msgbox, the behaviour of script is wierd. all data which i am passing through variables got printed on the sametab whereever ControLID's are same. If i comment it the behaviour is fine. On two places only Mouseclick is working, if i Controlclick(), its not pointing it.Please review the code and highlight wherever changes can be done for better performance. If WinActive("Reena Desktop Server") Then ;MsgBox(0, "", "Reena Desktop Server is active") Else ;MsgBox(0, "", "Reena Desktop Server is not active") EndIf Link to comment Share on other sites More sharing options...
Sankesh Posted March 7, 2019 Author Share Posted March 7, 2019 updated TDT_server code.txt Link to comment Share on other sites More sharing options...
Sankesh Posted March 7, 2019 Author Share Posted March 7, 2019 2 hours ago, Fr33b0w said: Can you put control checkpoints and visual or sound confirmations along your code so you can have a clue where it stuck? @Fr can you show some sample example where visual or sound confirmations used which will help me to improve my code Also i have a query..i have to install this software in many VM'S. To install how should i do 1.Compile the script to .exe 2.Placing the .exe file in the folder where setup file is placed. Will this alone be enough to install it or i should install AutoIT in every VM for this script to support? Link to comment Share on other sites More sharing options...
Fr33b0w Posted March 7, 2019 Share Posted March 7, 2019 Ah, now you are making a joke Sure Beep(698.46,200) Beep(739.99,200) Beep(783.99,200) Hope this helps, no need for likes please. It was my duty to return my debts to a mankind. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 7, 2019 Share Posted March 7, 2019 @Sankesh You can compile your executable as you wish, which you can then copy wherever you want. You don't need to have AutoIt installed on every VM; you just need it on your development one Fr33b0w 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Sankesh Posted March 8, 2019 Author Share Posted March 8, 2019 9 hours ago, FrancescoDiMuro said: @Sankesh You can compile your executable as you wish, which you can then copy wherever you want. You don't need to have AutoIt installed on every VM; you just need it on your development one Sure Francesco. 1.There's a requirement from my manager where the path of xml should not be hardcoded and the path should be feeded through text file as input Since the path of xml is different in different VM's. i tried the below Global $sFile ="D:\Path.txt" $strFileContent=FileRead($sFile) MsgBox($MB_ICONINFORMATION, "", "XML DATA: " & $sFile) Where in the above code Path.txt has the path of xml file. when i print through msgbox the output is D:\Path.txt which is wrong 2. There's a wizard where it has 4 radio buttons. which button need to be clicked should also be included in the txt file..is it possible ? For ex: 1.Apple 2.Blueberry 3.Dell 4.Hp if user wants Dell he wil add that Dell in txt file. My script should pick dell and it should check where dell is in the wizard and it should click the 3 rd radio button. NOTE: Both xml path and input for radio button ..everything i want to include in a single text file.Is it possible with AutoIT script? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 8, 2019 Share Posted March 8, 2019 @Sankesh You could use an INI file, in which you store the XML file path, and the radio button to check on each VM. So, when your script starts, it obtains those configurations from the INI, so you can use your script on different VMs, with different configurations. Take a look at INI* functions in the Help file Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Sankesh Posted March 8, 2019 Author Share Posted March 8, 2019 Ini file helped me greatly . I am passing DB value in ini file and storing it in variable $DBname its getting accepted and working. For eg if my $DBname=Oracle it should click the radio button of oracle which i wrote in the below code but radio button is not getting clicked,whereas MsgBox is printing the correct data. Controlclick not working inside if(). Whats the mistake in the below code ? If $DBname="Oracle" Then $hWnd = WinGetHandle("Trader Desktop Server") ControlClick ($hwnd, "", "[CLASS:Button; INSTANCE:4; TEXT:Oracle]","left", 1, 0, 0) MsgBox($MB_ICONINFORMATION, "", "The Database server is: " & $DBname) ElseIf $DBname="SQL Server" Then MsgBox($MB_ICONINFORMATION, "", "The Database server is: " & $DBname) ControlClick ($hwnd, "", "[CLASS:Button; INSTANCE:6; TEXT:SQL Server]","left", 1, 0, 0) ElseIf $DBname="Oracle Instant Client" Then ;MsgBox($MB_ICONINFORMATION, "", "The Database server is: " & $DBname) ControlClick ($hwnd, "", "[CLASS:Button; INSTANCE:5; TEXT:Oracle Instant Client]","left", 1, 0, 0) elseIf $DBname="DB2" Then ControlClick ($hwnd, "", "[CLASS:Button; INSTANCE:3; Text:DB2]","left", 1, 0, 0) MsgBox($MB_ICONINFORMATION, "", "The Database server is: " & $DBname) Else MsgBox($MB_ICONINFORMATION, "","Database Doesn't exist") endif Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now