Jump to content

Noob trouble with CtrlClick


Recommended Posts

Use moving through the thread and though the following code I posted in another thread may help. One of the ways list should be able to get you what you need.

If not ... I can find some of the functions SmOke_N has created to address this. Also post the output of the summary section of the autoit tool into a code box.

You will need to change the values with your own

Opt("WinTextMatchMode", 1) ; you may want to try this set to 2 as well. This is the default
Opt("WinTitleMatchMode", 2) ; help file explains this, look up opt or AutoItSetOption
AutoItSetOption("MustDeclareVars", 1)
AutoItSetOption("MouseCoordMode", 1)

#include <WinAPI.au3>
#include <Array.au3>
#include <WindowsConstants.au3>


Func whichMsgBox()
    Local $appHandle = ""
    Local $controlHandle = ""

    ; get the window handle

    If $appHandle = "" Then
        $appHandle = WinGetHandle("[ACTIVE")
    ElseIf $appHandle = "" Then
        $appHandle = WinGetHandle("classname=Afx:00400000:8:00010003:00000000:067C070D", "")
    ElseIf $appHandle = "" Then
        MouseMove(356, 14, 0) ; releates to the mouse output in your post.
        Local $h_wfp = DllCall("user32.dll", "hwnd", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1))
        $appHandle = _WinAPI_GetAncestor($appHandle, $GA_ROOT)
    ElseIf $appHandle = "" Then
        Local $aWinList = WinList("AxCent", "")
        If $aWinList[0][0] > 0 Then ; it found something
            _ArrayDisplay($aWinList) ; see how may there are. If this does not work remove the "AxCent" param from WinList
            $appHandle = $aWinList[1][1] ; need to something like this to get the window handle.
        EndIf
    ElseIf $appHandle = "" Then
        ConsoleWrite("Error: could not get the window handle" & @CR & @extended)
        Exit
    EndIf

    ; get the control handle

    If $controlHandle = "" Then
        $controlHandle = ControlGetHandle($appHandle, "", "[ID:65535]")
    ElseIf $controlHandle = "" Then
        $controlHandle = ControlGetHandle($appHandle, "", "[CLASS:Static; INSTANCE:2]")
    ElseIf $controlHandle = "" Then
        $controlHandle = ControlGetHandle($appHandle, "", "[X:65 Y:26]")
    ElseIf $controlHandle = "" Then
        Local $nInstance, $sLastClass, $sComposite
        Local $sList = WinGetClassList($appHandle) ; list of every class in the Window
        Local $aList = StringSplit(StringTrimRight($sList, 1), @LF, 2)
        _ArraySort($aList) ; improves speed
        _ArrayDisplay($aList) ; static class should be in there. If its not the $appHandle may not correct
        ConsoleWrite("Error: could not get the control handle" & @CR & @extended)
        Exit
    EndIf

    ; when you get the control you can get the text from it.

    Local $string = ControlGetText($controlHandle, "", "") ; add your code here but using ControlClick

   
EndFunc   ;==>whichMsgBox
Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

You are correct. It is just some different ways to get the handle. Once you have the handle you can use any other control function with ease.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Hi just noticed this topic had a second page.

bo8ster your post has confused me a little, i'm still not past 'noob' stage as far as autoit is concerned. I will however try out your idea and see if it will work =) i do hope it works Lol!

Link to comment
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
 Share

  • Recently Browsing   0 members

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