Jump to content

Recommended Posts

Posted (edited)

Hi , i getting some output for wingethandle which is attached.

 $hWnd = WinGetHandle("Reena Desktop Server")
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the window handle of server.")
        Exit
     else
     MsgBox($MB_SYSTEMMODAL, "", $hWnd)

    EndIf
    
$DBname="Oracle"
If $DBname="Oracle" Then
       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")

Winclose("Reena Desktop server")
endif
 

 

why the value of winGethandle changes everytime i run whereas in autoit Info too i can see the value under window handle to be 0X000112058E. Msgbox printing the correct data whereas controlclick() not working :(

My requirement is to switch between radio buttons based on the input through inifile. Is there a better way to write code for this since the above is not working. :)

 

 

Capture.PNG

 

Edited by Sankesh
Posted

Yeah radio buttons are clicked through Control command.

Now i am getting Path of setup.exe input file from a shared location.  When i get through shared path ,my script behaviour is different where its not clicking the radio button and skips to the nxt wizard where total script collapses .

At some time the special characters get appended to the path file where its stopping the script to execute as attached in the image(Infront of C:\Users\dnataraj\).How to avoid this special character getting appended.

 

 

Capture.PNG

Posted
[xml]

path=C:\JSqlAccessProperties.xml

[ServerSetup]

Filepath=\\socrates.global.ad\pune\dev\TCM\Cisco-Full\Production\BuildArchives\ReenaDesktop\TDT_4.x\Cisco_Reena_Desktop_4.0.0.0_GA\erver\s64\destop installer.msi

[Database]
Name=Oracle

In the above ini file , sometimes the special characters get added either to path or Filepath. If i change the location back special characters get disappeared .Not sure what's the logic behind this..

 

Thanks a lot Francesco..without you definitely my automation was not possible :)

 

Posted

Got one hint ..that if file is placed in C:\ i can see that special characters maximum..but if it is placed in documents..probability is less. But msi files need to be placed in C:\ only so i want it to wrk in C:\ only

 

Posted

I am retrieving info through iniread() and storing the value in a variable.

$Strfilepath=IniRead("C:\Users\dnataraj\Documents\TDTServer3958_installer\Server-64bit\server.ini","xml","path","") ;Fetching xml
$Strserverfilepath=IniRead("C:\Users\dnataraj\Documents\TDTServer3958_installer\Server-64bit\server.ini","ServerSetup","Filepath","") ;Fetchig msi file
$DBname=IniRead("C:\Users\dnataraj\Documents\TDTServer3958_installer\Server-64bit\server.ini","Database","Name","") ;Database selection from user

 

Posted (edited)

@Sankesh
Tried with this script:

#include <Array.au3>
#include <MsgBoxConstants.au3>

Global $strFileName = @ScriptDir & "\SampleText.ini", _
       $arrINISections


$arrSections = IniReadSectionNames($strFileName)
If @error Then
    ConsoleWrite("!IniReadSectionNames ERR: " & @error & @CRLF)
Else
    For $i = 1 To $arrSections[0] Step 1
        _ArrayDisplay(IniReadSection($strFileName, $arrSections[$i]))
    Next
EndIf

;~ MsgBox(0, "", IniRead($strFileName, "xml", "path", ""))
;~ MsgBox(0, "", IniRead($strFileName, "ServerSetup", "Filepath", ""))
;~ MsgBox(0, "", IniRead($strFileName, "Database", "Name", ""))

and with this file content (encoded in UTF-8):

Spoiler

path=C:\JSqlAccessProperties.xml

[ServerSetup]

Filepath=\\socrates.global.ad\pune\dev\TCM\Cisco-Full\Production\BuildArchives\ReenaDesktop\TDT_4.x\Cisco_Reena_Desktop_4.0.0.0_GA\erver\s64\destop installer.msi

[Database]
Name=Oracle

and seems to work fine.

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted
#include <Array.au3>
#include <MsgBoxConstants.au3>

Global  $arrINISections

Global $strFileName = @ScriptDir & "\C:\TDT-Automation-Installers\TDT3957 installer\Server\Server-64 bit\server_3957.ini"
Msgbox(0,"",$strFileName)
$arrINISections = IniReadSectionNames($strFileName)
Msgbox(0,"",$arrINISections)
If @error Then
    ConsoleWrite("!IniReadSectionNames ERR: " & @error & @CRLF)
Else
    For $i = 1 To $arrINISections[0] Step 1
        _ArrayDisplay(IniReadSection($strFileName, $arrINISections[$i]))
    Next
EndIf
 MsgBox(0, "", IniRead($strFileName, "xml", "path", ""))
 MsgBox(0, "", IniRead($strFileName, "ServerSetup", "Filepath", ""))
 MsgBox(0, "", IniRead($strFileName, "Database", "Name", ""))

Hi Francesco,

First of all thank you so much. i have executed the above code and i couldn't see the output i.e section path name and all..One more you hav edeclared arrINISections variable and haven't used inside the code. I am getting output as '1' for the 2 nd msgbox and the code stops over there.

 

Can you help me on what's wrong with the above code..

Posted
58 minutes ago, Sankesh said:

Msgbox(0,"",$arrINISections)

$areINISections is an array, and checking the value of the @error code after calling a MsgBox is useless, since that function doesn't set any @error code.

1 hour ago, Sankesh said:

One more you hav edeclared arrINISections variable and haven't used inside the code.

$arrINISections is used everywhere in the code (lines 6, 10, and 12).

1 hour ago, Sankesh said:

I am getting output as '1' for the 2 nd msgbox and the code stops over there

As said above, $arrSections is an array, so you can't access to a whole array with a MsgBox.

Remove that MsgBox and see if the code runs again :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted
#include <Array.au3>
#include <MsgBoxConstants.au3>

Global  $arrINISections,$arrSections

Global $strFileName = @ScriptDir & "C:\TDT-Automation-Installers\TDT3958_installer\Server\Server 64 bit\Server_3958_64bit.ini"



$arrSections = IniReadSectionNames($strFilename)
If @error Then
    ConsoleWrite("!IniReadSectionNames ERR: " & @error & @CRLF)
Else
    For $i = 1 To $arrSections[0] Step 1
        _ArrayDisplay(IniReadSection($strFileName, $arrSections[$i]))
    Next
EndIf

;~ MsgBox(0, "", IniRead($strFileName, "xml", "path", ""))
;~ MsgBox(0, "", IniRead($strFileName, "ServerSetup", "Filepath", ""))
;~ MsgBox(0, "", IniRead($strFileName, "Database", "Name", ""))

On executing the above i got error..not sure where is wrong. Basically what i understood in the above code is its reading the section name of the ini file. My code also reading the value in the key..but while reading the value special character gets added. Is there any way to amend that? :(

 

Posted

Tried this code 

$ini = IniReadSectionNames("C:\Users\dnataraj\Desktop\xml.ini")
_ArrayDisplay($ini)

$de=IniReadSection ( "C:\Users\dnataraj\Desktop\xml.ini", "Ls2app" )
_ArrayDisplay($de)

i got the output as attached where special characters are coming here also.Don't know how to resolve this. From the below image i can confirm the ini file is getting read but the path specified inside ini file is where the issue is.

 

ini file:

[Ls2app]

lpath=‪C:\ls2app.ini

 

Is there any other way to specify "‪C:\ls2app.ini" in lpath to make special character disappear. Thanks France!!!

Capture2.PNG

Posted

Good Morning Francesco,

File encoding issue resolved.

Currently creating a folder inside a specified path using the below code .But "Logs" folder is not getting generated. Is there any good way to create it? :)

My requirement is inside socrates i have to create a folder "Logs".

Global $a
Global $dir = "C:\Program Files\Socrates"
   If $dir = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Specified Directory doesn't exist")
        Exit
     Else
        $a=Dircreate("C:\Program Files\Socrates\Logs")
    EndIf

 

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
  • Recently Browsing   0 members

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