Sign in to follow this  
Followers 0
joeloyzaga

running QCConnection.InitConnectionEx "http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/"

6 posts in this topic

how would I run this via autoit?

Share this post


Link to post
Share on other sites



how would I run this via autoit?

; AutoIt 3.1.1 beta version
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Opt("WinWaitDelay", 0)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Global $oMyError = ObjEvent("AutoIt.Error", "_ErrFunc")


Global $hOLEACC = DllOpen("oleacc.dll")

; Make a GUI
Global $hGui = GUICreate("ActiveX", 800, 500)

; Create object
Global $oIEObject = ObjCreate("Shell.Explorer.2")

; Check if it's created
If Not IsObj($oIEObject) Then
    MsgBox(262144 + 48, "Error!", "Could not create object. That's bad!")
    Exit
EndIf

; Create ActiveY control
Global $hActiveX = GUICtrlCreateObj($oIEObject, 0, 0, 800, 400)
; Hide it for now
GUICtrlSetState($hActiveX, $GUI_HIDE)

; Some page
Global $sURL = "http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/"

; Navigate to that page
$oIEObject.navigate($sURL)

; Exit function
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

; Wait cursor
GUISetCursor(15)

; Show GUI
GUISetState()

; Get that handle
Global $hObjWinHandle = _GetObjectWinHandle($oIEObject)
; Write it
ConsoleWrite("! $oIEObject win handle: " & $hObjWinHandle & @CRLF)

; New function
Global $oAccessibleObject = _AccessibleObjectFromWindow($hObjWinHandle)

; Gained:
If IsObj($oAccessibleObject) Then

    ; ConsoleWrite("accChild: " & $oAccessibleObject.accChild($Param) & @CRLF) ;<-
    ConsoleWrite("accChildCount: " & $oAccessibleObject.accChildCount & @CRLF)
    ConsoleWrite("accDefaultAction: " & $oAccessibleObject.accDefaultAction & @CRLF)
    ConsoleWrite("accDescription: " & $oAccessibleObject.accDescription & @CRLF)
    ConsoleWrite("accFocus: " & $oAccessibleObject.accFocus & @CRLF)
    ConsoleWrite("accHelp: " & $oAccessibleObject.accHelp & @CRLF)
    ; ConsoleWrite("accHelpTopic: " & $oAccessibleObject.accHelpTopic($Param) & @CRLF) ;<-
    ConsoleWrite("accKeyboardShortcut: " & $oAccessibleObject.accKeyboardShortcut & @CRLF)
    ConsoleWrite("accName: " & $oAccessibleObject.accName & @CRLF)
    ConsoleWrite("accParent: " & $oAccessibleObject.accParent & @CRLF)
    ConsoleWrite("accRole: " & $oAccessibleObject.accRole & @CRLF)
    ConsoleWrite("accSelection: " & $oAccessibleObject.accSelection & @CRLF)
    ConsoleWrite("accState: " & $oAccessibleObject.accState & @CRLF)
    ConsoleWrite("accValue: " & $oAccessibleObject.accValue & @CRLF)

EndIf

ConsoleWrite(@CRLF)

#cs
; Change style (got to do something with the handle now that I have it)
Global Const $GWL_STYLE = -16
_WinAPI_SetWindowLong($hObjWinHandle, $GWL_STYLE, BitOR($WS_OVERLAPPEDWINDOW, $WS_CHILD))
#ce

; Change title
WinSetTitle($hObjWinHandle, 0, "My embedded browser")

; Show it
GUICtrlSetState($hActiveX, $GUI_SHOW)

; Needed to check state
Global $iNotLoaded = 1

; Will get another handle, declare variable for it
Global $hObjDocWinHandle ; for other handle

; New objects
Global $oIEObjectDocument
Global $oAccessibleObjectDoc

; For moving (nothing smart)
Global $iX
Global $iUp

; Loop till end
While 1

    If $iNotLoaded Then

        $oIEObjectDocument = $oIEObject.document

        If IsObj($oIEObjectDocument) Then

            ;Wait till fully loaded
            While 1
                If $oIEObjectdocument.readyState = "complete" Or $oIEObjectdocument.readyState = 4 Then ExitLoop
                Sleep(100)
            WEnd

            $hObjDocWinHandle = _GetObjectWinHandle($oIEObjectDocument)

            ConsoleWrite("! $oIEObject.document win handle: " & $hObjDocWinHandle & @CRLF) ; this is what you normally get with AutoIt Window Info tool

            $oAccessibleObjectDoc = _AccessibleObjectFromWindow($hObjDocWinHandle)

            If IsObj($oAccessibleObjectDoc) Then

                ; ConsoleWrite("accChild: " & $oAccessibleObject.accChild($Param) & @CRLF) ;<- limitation
                ConsoleWrite("accChildCount: " & $oAccessibleObjectDoc.accChildCount & @CRLF)
                ConsoleWrite("accDefaultAction: " & $oAccessibleObjectDoc.accDefaultAction & @CRLF)
                ConsoleWrite("accDescription: " & $oAccessibleObjectDoc.accDescription & @CRLF)
                ConsoleWrite("accFocus: " & $oAccessibleObjectDoc.accFocus & @CRLF)
                ConsoleWrite("accHelp: " & $oAccessibleObjectDoc.accHelp & @CRLF)
                ; ConsoleWrite("accHelpTopic: " & $oAccessibleObjectDoc.accHelpTopic($Param) & @CRLF) ;<- limitation
                ConsoleWrite("accKeyboardShortcut: " & $oAccessibleObjectDoc.accKeyboardShortcut & @CRLF)
                ConsoleWrite("accName: " & $oAccessibleObjectDoc.accName & @CRLF)
                ConsoleWrite("accParent: " & $oAccessibleObjectDoc.accParent & @CRLF)
                ConsoleWrite("accRole: " & $oAccessibleObjectDoc.accRole & @CRLF)
                ConsoleWrite("accSelection: " & $oAccessibleObjectDoc.accSelection & @CRLF)
                ConsoleWrite("accState: " & $oAccessibleObjectDoc.accState & @CRLF)
                ConsoleWrite("accValue: " & $oAccessibleObjectDoc.accValue & @CRLF)

            EndIf

            ; Restore cursot
            GUISetCursor(-1)
            $iNotLoaded = 0

        EndIf

    Else

        WinMove($hObjWinHandle, 0, $iX, 0)

        If $iX > 100 Then
            $iUp = -1
        ElseIf $iX <= 0 Then
            $iUp = 1
        EndIf

        $iX += $iUp

    EndIf

    Sleep(30)

WEnd


; FUNCTIONS:

Func _GetObjectWinHandle($oObject)

    Local $aCall = DllCall("oleacc.dll", "int", "WindowFromAccessibleObject", _
            "idispatch", $oObject, _
            "hwnd*", 0)

    If @error Or $aCall[0] Then
        Return SetError(1, 0, 0)
    EndIf

    Return $aCall[2]

EndFunc   ;==>_GetObjectWinHandle


Func _AccessibleObjectFromWindow($hWnd)

    Local $sIID_IAccessible = "{618736E0-3C3D-11CF-810C-00AA00389B71}"
    Local $tGUID = _WinAPI_GUIDFromString($sIID_IAccessible)
    Local $pGUID = DllStructGetPtr($tGUID)

    Local $aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromWindow", _
            "hwnd", $hWnd, _
            "dword", 0, _ ; OBJID_WINDOW
            "ptr", $pGUID, _
            "idispatch*", 0)

    If @error Or $aCall[0] Then
        Return SetError(1, 0, 0)
    EndIf

    Return $aCall[4]

EndFunc   ;==>_AccessibleObjectFromWindow


Func _ErrFunc()

    ConsoleWrite("--- COM Error, number = " & Ptr($oMyError.number) & ", description: " & $oMyError.windescription)

EndFunc   ;==>_ErrFunc


Func _Quit()

    Exit

EndFunc   ;==>_Quit
;

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Dim $tdc, $qcServer,$qcHostName, $qcPort ,$qcProject
Dim $qcDomain,$qcUser,$qcPassword
$qcHostName = "http://qualitycenter.test.det.nsw.edu.au"
$qcPort = "8080"

$qcServer = "http://" & $qcHostName & ":" & $qcPort & "/qcbin"
$qcUser = "user_name"
$qcPassword = "password"
ConsoleWrite($qcServer)

$qcDomain = "domaine"
$qcProject = "projet"

Global $tdc =  ObjCreate("TDApiOle80.TDConnection")
$tdc.InitConnectionEx($qcServer)
consoleWrite($tdc.ServerName)
$tdc.Login($qcUser, $qcPassword)
$tdc.Connect($qcDomain, $qcProject)
$tdc = 0
exit

is it right ?

Edited by anib

Me frappe pas !! je débute dans le monde du code :)Un novice avertit en vaut dix sans ennuie ;)AuToiT-FR

Share this post


Link to post
Share on other sites

Dim $tdc, $qcServer,$qcHostName, $qcPort ,$qcProject
Dim $qcDomain,$qcUser,$qcPassword
$qcHostName = "http://qualitycenter.test.det.nsw.edu.au"
$qcPort = "8080"

$qcServer = "http://" & $qcHostName & ":" & $qcPort & "/qcbin"
$qcUser = "user_name"
$qcPassword = "password"
ConsoleWrite($qcServer)

$qcDomain = "domaine"
$qcProject = "projet"

Global $tdc =  ObjCreate("TDApiOle80.TDConnection")
$tdc.InitConnectionEx($qcServer)
consoleWrite($tdc.ServerName)
$tdc.Login($qcUser, $qcPassword)
$tdc.Connect($qcDomain, $qcProject)
$tdc = 0
exit

is it right ?

this code logs in and connects correctly but doesn't return the domains and projects I am entitled to useso I'm, trying to figure out the code and then I'll ask how to do it via autoit - later

Dim $tdc, $qcServer,$qcHostName, $qcPort ,$qcProject
Dim $qcDomain,$qcUser,$qcPassword
$qcHostName = "qualitycenter.test.det.nsw.edu.au"
$qcPort = "8080"

$qcServer = "http://" & $qcHostName & ":" & $qcPort & "/qcbin"
$qcUser = "joseph.loyzaga"
$qcPassword = "password1"
ConsoleWrite($qcServer)

$qcDomain = "DEFAULT"
$qcProject = "AUTOMATION"

Global $tdc =  ObjCreate("TDApiOle80.TDConnection")
$tdc.InitConnectionEx($qcServer)
consoleWrite($tdc.ServerName)
$tdc.Login($qcUser, $qcPassword)
$tdc.Connect($qcDomain, $qcProject)
$tdc = 0
exit

Share this post


Link to post
Share on other sites

baeutiful gui and logs in and accepts all I need - the gui keeps moving left to right all the time and how do I get the values returned to me - e.g form the screen shot attached - for :Domain and Project? Otherwise ABSOLUTELY BRILLIANT

; AutoIt 3.1.1 beta version
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Opt("WinWaitDelay", 0)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Global $oMyError = ObjEvent("AutoIt.Error", "_ErrFunc")


Global $hOLEACC = DllOpen("oleacc.dll")

; Make a GUI
Global $hGui = GUICreate("ActiveX", 800, 500)

; Create object
Global $oIEObject = ObjCreate("Shell.Explorer.2")

; Check if it's created
If Not IsObj($oIEObject) Then
    MsgBox(262144 + 48, "Error!", "Could not create object. That's bad!")
    Exit
EndIf

; Create ActiveY control
Global $hActiveX = GUICtrlCreateObj($oIEObject, 0, 0, 800, 400)
; Hide it for now
GUICtrlSetState($hActiveX, $GUI_HIDE)

; Some page
Global $sURL = "http://qualitycenter.test.det.nsw.edu.au:8080/qcbin/"

; Navigate to that page
$oIEObject.navigate($sURL)

; Exit function
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

; Wait cursor
GUISetCursor(15)

; Show GUI
GUISetState()

; Get that handle
Global $hObjWinHandle = _GetObjectWinHandle($oIEObject)
; Write it
ConsoleWrite("! $oIEObject win handle: " & $hObjWinHandle & @CRLF)

; New function
Global $oAccessibleObject = _AccessibleObjectFromWindow($hObjWinHandle)

; Gained:
If IsObj($oAccessibleObject) Then

    ; ConsoleWrite("accChild: " & $oAccessibleObject.accChild($Param) & @CRLF) ;<-
    ConsoleWrite("accChildCount: " & $oAccessibleObject.accChildCount & @CRLF)
    ConsoleWrite("accDefaultAction: " & $oAccessibleObject.accDefaultAction & @CRLF)
    ConsoleWrite("accDescription: " & $oAccessibleObject.accDescription & @CRLF)
    ConsoleWrite("accFocus: " & $oAccessibleObject.accFocus & @CRLF)
    ConsoleWrite("accHelp: " & $oAccessibleObject.accHelp & @CRLF)
    ; ConsoleWrite("accHelpTopic: " & $oAccessibleObject.accHelpTopic($Param) & @CRLF) ;<-
    ConsoleWrite("accKeyboardShortcut: " & $oAccessibleObject.accKeyboardShortcut & @CRLF)
    ConsoleWrite("accName: " & $oAccessibleObject.accName & @CRLF)
    ConsoleWrite("accParent: " & $oAccessibleObject.accParent & @CRLF)
    ConsoleWrite("accRole: " & $oAccessibleObject.accRole & @CRLF)
    ConsoleWrite("accSelection: " & $oAccessibleObject.accSelection & @CRLF)
    ConsoleWrite("accState: " & $oAccessibleObject.accState & @CRLF)
    ConsoleWrite("accValue: " & $oAccessibleObject.accValue & @CRLF)

EndIf

ConsoleWrite(@CRLF)

#cs
; Change style (got to do something with the handle now that I have it)
Global Const $GWL_STYLE = -16
_WinAPI_SetWindowLong($hObjWinHandle, $GWL_STYLE, BitOR($WS_OVERLAPPEDWINDOW, $WS_CHILD))
#ce

; Change title
WinSetTitle($hObjWinHandle, 0, "My embedded browser")

; Show it
GUICtrlSetState($hActiveX, $GUI_SHOW)

; Needed to check state
Global $iNotLoaded = 1

; Will get another handle, declare variable for it
Global $hObjDocWinHandle ; for other handle

; New objects
Global $oIEObjectDocument
Global $oAccessibleObjectDoc

; For moving (nothing smart)
Global $iX
Global $iUp

; Loop till end
While 1

    If $iNotLoaded Then

        $oIEObjectDocument = $oIEObject.document

        If IsObj($oIEObjectDocument) Then

            ;Wait till fully loaded
            While 1
                If $oIEObjectdocument.readyState = "complete" Or $oIEObjectdocument.readyState = 4 Then ExitLoop
                Sleep(100)
            WEnd

            $hObjDocWinHandle = _GetObjectWinHandle($oIEObjectDocument)

            ConsoleWrite("! $oIEObject.document win handle: " & $hObjDocWinHandle & @CRLF) ; this is what you normally get with AutoIt Window Info tool

            $oAccessibleObjectDoc = _AccessibleObjectFromWindow($hObjDocWinHandle)

            If IsObj($oAccessibleObjectDoc) Then

                ; ConsoleWrite("accChild: " & $oAccessibleObject.accChild($Param) & @CRLF) ;<- limitation
                ConsoleWrite("accChildCount: " & $oAccessibleObjectDoc.accChildCount & @CRLF)
                ConsoleWrite("accDefaultAction: " & $oAccessibleObjectDoc.accDefaultAction & @CRLF)
                ConsoleWrite("accDescription: " & $oAccessibleObjectDoc.accDescription & @CRLF)
                ConsoleWrite("accFocus: " & $oAccessibleObjectDoc.accFocus & @CRLF)
                ConsoleWrite("accHelp: " & $oAccessibleObjectDoc.accHelp & @CRLF)
                ; ConsoleWrite("accHelpTopic: " & $oAccessibleObjectDoc.accHelpTopic($Param) & @CRLF) ;<- limitation
                ConsoleWrite("accKeyboardShortcut: " & $oAccessibleObjectDoc.accKeyboardShortcut & @CRLF)
                ConsoleWrite("accName: " & $oAccessibleObjectDoc.accName & @CRLF)
                ConsoleWrite("accParent: " & $oAccessibleObjectDoc.accParent & @CRLF)
                ConsoleWrite("accRole: " & $oAccessibleObjectDoc.accRole & @CRLF)
                ConsoleWrite("accSelection: " & $oAccessibleObjectDoc.accSelection & @CRLF)
                ConsoleWrite("accState: " & $oAccessibleObjectDoc.accState & @CRLF)
                ConsoleWrite("accValue: " & $oAccessibleObjectDoc.accValue & @CRLF)

            EndIf

            ; Restore cursot
            GUISetCursor(-1)
            $iNotLoaded = 0

        EndIf

    Else

        WinMove($hObjWinHandle, 0, $iX, 0)

        If $iX > 100 Then
            $iUp = -1
        ElseIf $iX <= 0 Then
            $iUp = 1
        EndIf

        $iX += $iUp

    EndIf

    Sleep(30)

WEnd


; FUNCTIONS:

Func _GetObjectWinHandle($oObject)

    Local $aCall = DllCall("oleacc.dll", "int", "WindowFromAccessibleObject", _
            "idispatch", $oObject, _
            "hwnd*", 0)

    If @error Or $aCall[0] Then
        Return SetError(1, 0, 0)
    EndIf

    Return $aCall[2]

EndFunc   ;==>_GetObjectWinHandle


Func _AccessibleObjectFromWindow($hWnd)

    Local $sIID_IAccessible = "{618736E0-3C3D-11CF-810C-00AA00389B71}"
    Local $tGUID = _WinAPI_GUIDFromString($sIID_IAccessible)
    Local $pGUID = DllStructGetPtr($tGUID)

    Local $aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromWindow", _
            "hwnd", $hWnd, _
            "dword", 0, _ ; OBJID_WINDOW
            "ptr", $pGUID, _
            "idispatch*", 0)

    If @error Or $aCall[0] Then
        Return SetError(1, 0, 0)
    EndIf

    Return $aCall[4]

EndFunc   ;==>_AccessibleObjectFromWindow


Func _ErrFunc()

    ConsoleWrite("--- COM Error, number = " & Ptr($oMyError.number) & ", description: " & $oMyError.windescription)

EndFunc   ;==>_ErrFunc


Func _Quit()

    Exit

EndFunc   ;==>_Quit
;

Share this post


Link to post
Share on other sites

I am not sure what is your requirement but you can use OTA client API and SA Client API to automate Site admin and QC tasks using Autoit.

Check the below blog, In that I have mentioned the OTA connection using autoit. I have automated few tasks and soon I will post the code which i have automated using Autoit.

http://qualitycenterautoit.blogspot.com/2011/05/connecting-to-qc-using-ota-api-through.html

Share this post


Link to post
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
Sign in to follow this  
Followers 0