Sign in to follow this  
Followers 0
mf3

How to find tab by text and click it?

6 posts in this topic

#1 ·  Posted

Hello.

The question is: How to find tab by text and click it?

I tried to use this code:

$hTab = ControlGetHandle($hWnd, "", "[TEXT:E9077]")
ControlClick($hWnd, "", "[TEXT:9077]")

and this

$hTab = ControlGetHandle($hWnd, "", "[TEXT:E9077]")
_GUICtrlTab_SetCurFocus($hTab, 1)

 

But nothing is going on.

Help me, please.

tabs.png

Share this post


Link to post
Share on other sites



#2 ·  Posted

First suggestion would be to do some error handling. Check the @error flag after the call to ControlGetHandle.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Try this

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

Global $tabMainTab = GUICtrlCreateTab(10, 10, 200, 100)

GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
GUICtrlCreateButton("OK0", 20, 50, 50, 20)
GUICtrlCreateInput("default", 80, 50, 70, 20)

GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
GUICtrlCreateCombo("", 20, 50, 60, 120)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo|guinness", "Jon") ; default Jon
GUICtrlCreateButton("OK1", 80, 50, 50, 20)

GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
GUICtrlCreateButton("OK2", 140, 50, 50)

GUICtrlCreateTabItem("") ; end tabitem definition

Global $btnClick = GUICtrlCreateButton("Select tab 2", 10, 130, 100, 20)

GUISetState(@SW_SHOW)

Local $idMsg
; Loop until the user exits.
While 1
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case $btnClick
            _GUICtrlTab_ActivateTabEx($tabMainTab, "tab0")
    EndSwitch
WEnd

Func _GUICtrlTab_ActivateTabEx($hWnd, $sText)
    Local $hTab = IsHWnd($hWnd) ? $hWnd : GUICtrlGetHandle($hWnd)
    For $i = 0 To _GUICtrlTab_GetItemCount($hTab)
        If (_GUICtrlTab_GetItemText($hTab, $i) = $sText) Then
            _GUICtrlTab_ActivateTab($hTab, $i)
            ExitLoop
        EndIf
    Next
EndFunc   ;==>_GUICtrlTab_ActivateTabEx

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

9 minutes ago, Danp2 said:

First suggestion would be to do some error handling. Check the @error flag after the call to ControlGetHandle.

I checked. No error occurs after ControlGetHandle.

And this

ControlCommand ( $hTab, "", "", "TabRight")

is working with this handle, but I can't get text of current tab.

And ControlClick is still not working...

Share this post


Link to post
Share on other sites

#5 ·  Posted

3 minutes ago, InunoTaishou said:

Try this

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

Global $tabMainTab = GUICtrlCreateTab(10, 10, 200, 100)

GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
GUICtrlCreateButton("OK0", 20, 50, 50, 20)
GUICtrlCreateInput("default", 80, 50, 70, 20)

GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
GUICtrlCreateCombo("", 20, 50, 60, 120)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo|guinness", "Jon") ; default Jon
GUICtrlCreateButton("OK1", 80, 50, 50, 20)

GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
GUICtrlCreateButton("OK2", 140, 50, 50)

GUICtrlCreateTabItem("") ; end tabitem definition

Global $btnClick = GUICtrlCreateButton("Select tab 2", 10, 130, 100, 20)

GUISetState(@SW_SHOW)

Local $idMsg
; Loop until the user exits.
While 1
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case $btnClick
            _GUICtrlTab_ActivateTabEx($tabMainTab, "tab0")
    EndSwitch
WEnd

Func _GUICtrlTab_ActivateTabEx($hWnd, $sText)
    Local $hTab = IsHWnd($hWnd) ? $hWnd : GUICtrlGetHandle($hWnd)
    For $i = 0 To _GUICtrlTab_GetItemCount($hTab)
        If (_GUICtrlTab_GetItemText($hTab, $i) = $sText) Then
            _GUICtrlTab_ActivateTab($hTab, $i)
            ExitLoop
        EndIf
    Next
EndFunc   ;==>_GUICtrlTab_ActivateTabEx

 

Thank You for reply.

But window and controls are not created with AutoIt. GUI created by unknown developer with Delphi and .NET as I see

Share this post


Link to post
Share on other sites

#6 ·  Posted

Does the Autoit info tool show SysTabControl32 as the Class of the tab control? If not you could try using this

I've never used it so you're on your on to try and see if it'll work with your program you're trying to automate.

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