ControlClick auf unbekanntes control

  • Ich will ein ControlClick in einem Fenster machen, von dem ich nur den Prozess und einen Teil der Buttonschrift kenne.

    Also z.b.: "Mein Programm.exe" und der Button: "Start!" oder "Start" oder "Starten"

    ne Idee wie ich das machen kann?

    • Offizieller Beitrag

    Hallo

    Probier das mal, die ID des button musst du aber trozdem wissen...
    Die ID findest du raus in dem du C:\Programme\AutoIt3\AU3Info.exe startest...Bei der neuen Beta( 3.2.3.x ) klickst du dann auf den Tab "Control"..Wenn du die Stable (3.2.2.0) hast dann solltest du sie unter Control ID finden...

    $ProcessName und $IdDesButton musst du noch richtig ausfüllen

    Spoiler anzeigen
    [autoit]

    $ProcessName = "MeinProgramm.exe"
    $IdDesButton = "Start"
    ;Die ID findest du raus in dem du C:\Programme\AutoIt3\AU3Info.exe startest...
    ;Bei der neuen Beta( 3.2.3.x ) klickst du dann auf den Tab "Control"..
    ;Wenn du die Stable hast dann solltest du sie unter Control ID finden...

    [/autoit] [autoit][/autoit] [autoit]

    $win = _WinGetInfoByPID(ProcessExists($ProcessName))
    If Not IsArray($win) Then Exit MsgBox(16,"","Error: Der Process exisistiert nicht...")
    $win = $win[1][2]
    ConsoleWrite("win: "&$win & @CRLF)
    ControlClick($win,"",$IdDesButton)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _WinGetInfoByPID($sPID)
    Local $aPList = ProcessList(), $iPID
    If Not $sPID Then Return 0
    For $iiCount = 1 To $aPList[0][0]
    If $aPList[$iiCount][1] = $sPID Then
    If $sPID = 0 Then Return 0
    $iPID &= $aPList[$iiCount][1] & Chr(01)
    EndIf
    Next
    $iPID = StringSplit($iPID, Chr(01))
    If $iPID = 0 Then Return SetError(1, 0, 0)
    Local $aStoreHwndAndText[2][9], $nCount = 1
    $OptWSC = Opt('WinSearchChildren', 1)
    $OptWDHT = Opt('WinDetectHiddenText', 1)
    Local $aWinList = WinList()
    For $iCount = 1 To $aWinList[0][0]
    For $xCount = 1 To $iPID[0]
    If WinGetProcess($aWinList[$iCount][1]) = $iPID[$xCount] And _
    $aWinList[$iCount][0] <> '' Then
    Local $aWinPos = WinGetPos($aWinList[$iCount][1])
    Local $aWinClient = WinGetClientSize($aWinList[$iCount][1])
    $nCount += 1
    ReDim $aStoreHwndAndText[$nCount][9]
    $aStoreHwndAndText[$nCount - 1][1] = $aWinList[$iCount][0]
    $aStoreHwndAndText[$nCount - 1][2] = $aWinList[$iCount][1]
    $aStoreHwndAndText[$nCount - 1][3] = WinGetText($aWinList[$iCount][1])
    $aStoreHwndAndText[$nCount - 1][4] = $aWinPos[0]
    $aStoreHwndAndText[$nCount - 1][5] = $aWinPos[1]
    $aStoreHwndAndText[$nCount - 1][6] = $aWinClient[0]
    $aStoreHwndAndText[$nCount - 1][7] = $aWinClient[1]
    $aStoreHwndAndText[$nCount - 1][8] = WinGetClassList($aWinList[$iCount][1])
    EndIf
    Next
    Next
    Opt('WinSearchChildren', $OptWSC)
    Opt('WinDetectHiddenText', $OptWDHT)
    If $nCount = 1 Then Return SetError(2, 0, 0)
    Return $aStoreHwndAndText
    EndFunc ;==>_WinGetInfoByPID

    [/autoit]

    Mfg Spider

  • hey thx gta...das ding geht...ich werds nur noch n bissl kürzen

    edit: hier, wers noch braucht:

    Spoiler anzeigen
    [autoit]


    $ProcessName = "MeinProgramm.exe"
    $IdDesButton = "Start";
    $win = _WinGetInfoByPID(ProcessExists($ProcessName))
    If $win=0 Then Exit MsgBox(16,"","Error: Der Process exisistiert nicht...")
    ConsoleWrite("win: "&$win & @CRLF)
    ControlClick($win,"",$IdDesButton)


    Func _WinGetInfoByPID($sPID)
    If Not $sPID Then Return 0
    Local $aWinList = WinList()
    Local $iCount
    For $iCount = 1 To $aWinList[0][0]
    If WinGetProcess($aWinList[$iCount][1]) = $sPID Then
    Return $aWinList[$iCount][1]
    ExitLoop
    EndIf
    Next
    Return 0
    EndFunc ;==>_WinGetInfoByPID

    [/autoit]

    Einmal editiert, zuletzt von Flamefire (1. April 2007 um 18:52)