Jump to content

Recommended Posts

Hi,

I am just wondering if there is any way to controle TDBGRID ? get the selected text, go to specifique index and read columens  !!

this is my window ? theTDBgrid is read only !

this is my code 

I tested also ControlGetText ControlListView 

#include <MsgBoxConstants.au3>

ControlSend("FChifa","","TEdit10","{BS 10}DOLIPRANE")


;$a= ControlListView("FChifa","","TDBGrid2","GetItemCount")
ControlSend("FChifa", "", "TDBGrid2", "{DOWN 10}")
$a = ControlCommand ("FChifa", "", "TDBGrid2","GetLineCount", "")

MsgBox($MB_SYSTEMMODAL, "", "Le texte : " & $a); ==>0 ??

TDBGRID.PNG.c98c7c4c8860077bcc364080c8083c15.PNGAW.PNG.86a9fcf909850c605f60ffda018a8c7b.PNG

Link to post
Share on other sites

Usually the answer here is to get into UI Automation. There's quite a few topics on it here, I personally suggest using LarJ's UDFs and tutorials to get started. (See LarJ's signature to see the UI Automation code)

Try inspecting it with his UIA Spy

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Link to post
Share on other sites

There is no need to shout at us because you failed to make it work.  A little bit of effort searching the forum and google would have given you some answers.  Here one recent discussion about UIAutomation and grid.

Salutations cordiales.

Link to post
Share on other sites

Appreciated for your information. I need time to study those  articles.This why am asking for one part of code if it's possible ,I have already did the most of work, and am stuck on this .  Thank you again 

 
Link to post
Share on other sites

Can help us help you by showing what 'most of the work' you did? There's only so much we can do with 'I am stuck'. 😕

Code + SciTE output is very helpful

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Link to post
Share on other sites

I was speaking about my entier project 😓 :'(

 

this is my code :

there is other filling function which works fine 

#include "CUIAutomation2.au3"
#include <MsgBoxConstants.au3>
AutoItSetOption("WinTitleMatchMode", 2)



ControlSend("FChifa","", '[CLASS:TEdit; ID:5643910]',"{END}+{HOME}{BS}DOLIPRANE")


MainFunc()

Func MainFunc()

  Local $App_Title = 'FChifa'
  If Not WinExists($App_Title) Then Exit

  $hWindow = WinGetHandle($App_Title)
  If Not $hWindow Then Return ConsoleWrite( "Window handle ERR" & @CRLF )
  ConsoleWrite( "Window handle OK" & @CRLF )

  ; Create UI Automation object
  Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation )
  If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "UI Automation object ERR" & @CRLF )
  ConsoleWrite( "UI Automation object OK" & @CRLF )

  ; Get UI Automation element from window handle
  Local $pWindow, $oWindow
  $oUIAutomation.ElementFromHandle( $hWindow, $pWindow )
  $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )
  If Not IsObj( $oWindow ) Then Return ConsoleWrite( "Automation element from window ERR" & @CRLF )
  ConsoleWrite( "Automation element from window OK" & @CRLF )

  ; Condition to find Edit elements
  Local $pCondition
  $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_PaneControlTypeId, $pCondition )
  If Not $pCondition Then Return ConsoleWrite( "Property condition ERR" & @CRLF )
  ConsoleWrite( "Property condition OK" & @CRLF )

  ConsoleWrite( "--- Find window/control ---" & @CRLF )

  Local $pCondition0
  $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "2301570", $pCondition0 )
  If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF )
  ConsoleWrite( "$pCondition0 OK" & @CRLF )


  Local $pTable1, $oTable1
  $oWindow.FindFirst( $TreeScope_Descendants, $pCondition0, $pTable1 )
  $oTable1 = ObjCreateInterface( $pTable1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )
  If Not IsObj( $oTable1 ) Then Return ConsoleWrite( "$oTable1 ERR" & @CRLF )
  ConsoleWrite( "$oTable1 OK" & @CRLF )

EndFunc
Quote

Window handle OK
UI Automation object OK
Automation element from window OK
Property condition OK
--- Find window/control ---
$pCondition0 OK
$oTable1 OK

 

Link to post
Share on other sites

Like it was suggested, in the link I gave you, there is specific examples that you have to study to answer your questions.  Since we cannot run your script (not having your particular application), we cannot provide an undefeated script for you.

Link to post
Share on other sites

lounisDz, If you right-click a non-blank line in the listview in UIASpy and select "Copy all items", you can paste all info about the TDBGRID control directly into a code box. Will you please do so. Significant information about the TDBGRID control is missing in the image above.

Link to post
Share on other sites
Treeview Element                                    Pane: TDBGrid
                                                    
Element Properties (identification)                 
$UIA_AutomationIdPropertyId                         13045632
$UIA_ClassNamePropertyId                            TDBGrid
$UIA_ControlTypePropertyId                          $UIA_PaneControlTypeId
                                                    
Element Properties (session unique)                 
$UIA_NativeWindowHandlePropertyId                   0x0000000000C70F80
$UIA_ProcessIdPropertyId                            7520
$UIA_RuntimeIdPropertyId                            42,13045632
                                                    
Element Properties (information)                    
$UIA_BoundingRectanglePropertyId                    l=27,t=338,w=459,h=129
$UIA_FrameworkIdPropertyId                          Win32
$UIA_LocalizedControlTypePropertyId                 volet
$UIA_ProviderDescriptionPropertyId                  [pid:1524,providerId:0xC70F80 Main:Nested [pid:7520,providerId:0xC70F80 Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]
                                                    
Element Properties (has/is info)                    
$UIA_HasKeyboardFocusPropertyId                     False
$UIA_IsContentElementPropertyId                     True
$UIA_IsControlElementPropertyId                     True
$UIA_IsDataValidForFormPropertyId                   False
$UIA_IsEnabledPropertyId                            True
$UIA_IsKeyboardFocusablePropertyId                  True
$UIA_IsOffscreenPropertyId                          False
$UIA_IsPasswordPropertyId                           False
$UIA_IsRequiredForFormPropertyId                    False
                                                    
Control Patterns (element actions)                  
$UIA_IsLegacyIAccessiblePatternAvailablePropertyId  True (LegacyIAccessiblePattern)
$UIA_IsScrollPatternAvailablePropertyId             True (ScrollPattern)
                                                    
Control Pattern Properties                          
$UIA_LegacyIAccessibleChildIdPropertyId             0
$UIA_LegacyIAccessibleDefaultActionPropertyId       
$UIA_LegacyIAccessibleDescriptionPropertyId         
$UIA_LegacyIAccessibleHelpPropertyId                
$UIA_LegacyIAccessibleKeyboardShortcutPropertyId    
$UIA_LegacyIAccessibleNamePropertyId                
$UIA_LegacyIAccessibleRolePropertyId                10 = $ROLE_SYSTEM_CLIENT
$UIA_LegacyIAccessibleStatePropertyId               1048576 = $STATE_SYSTEM_FOCUSABLE
$UIA_LegacyIAccessibleValuePropertyId               
$UIA_ScrollHorizontallyScrollablePropertyId         False
$UIA_ScrollHorizontalScrollPercentPropertyId        0
$UIA_ScrollHorizontalViewSizePropertyId             100
$UIA_ScrollVerticallyScrollablePropertyId           False
$UIA_ScrollVerticalScrollPercentPropertyId          0
$UIA_ScrollVerticalViewSizePropertyId               100
                                                    
Control Pattern Methods                             
LegacyIAccessible Pattern Methods                   
                                                    DoDefaultAction()
                                                    Select(long)
                                                    SetValue(wstr)
                                                    GetIAccessible(idispatch*)
                                                    CurrentChildId(int*)
                                                    CurrentDefaultAction(bstr*)
                                                    CurrentDescription(bstr*)
                                                    CurrentHelp(bstr*)
                                                    CurrentKeyboardShortcut(bstr*)
                                                    CurrentName(bstr*)
                                                    CurrentRole(uint*)
                                                    CurrentState(uint*)
                                                    CurrentValue(bstr*)
                                                    GetCurrentSelection(ptr*)
Scroll Pattern Methods                              
                                                    Scroll($iScrollAmountHorz,$iScrollAmountVert)
                                                    SetScrollPercent($fPercentHorz,$fPercentVert)
                                                    CurrentHorizontalScrollPercent($fPercent*)
                                                    CurrentVerticalScrollPercent($fPercent*)
                                                    CurrentHorizontalViewSize($fViewSize*)
                                                    CurrentVerticalViewSize($fViewSize*)
                                                    CurrentHorizontallyScrollable($bScrollable*)
                                                    CurrentVerticallyScrollable($bScrollable*)
                                                    
Parents from Desktop                                Pane: Bureau 1
                                                    Pane: FChifa
                                                    Pane: TPanel
                                                    Pane: TPanel
                                                    
Parent to child index                               7

Hi, thank you for being interested

Link to post
Share on other sites

It seems that the grid control actually supports UIA code. Open UIASpy, place the mouse cursor over a grid cell and press F1. You should see a red rectangle around the cell. Print all cell info in a code box.

Link to post
Share on other sites
Treeview Element                                    Pane: TDBGrid
                                                    
Element Properties (identification)                 
$UIA_AutomationIdPropertyId                         70910
$UIA_ClassNamePropertyId                            TDBGrid
$UIA_ControlTypePropertyId                          $UIA_PaneControlTypeId
                                                    
Element Properties (session unique)                 
$UIA_NativeWindowHandlePropertyId                   0x00000000000114FE
$UIA_ProcessIdPropertyId                            16664
$UIA_RuntimeIdPropertyId                            42,70910
                                                    
Element Properties (information)                    
$UIA_BoundingRectanglePropertyId                    l=27,t=338,w=459,h=129
$UIA_FrameworkIdPropertyId                          Win32
$UIA_LocalizedControlTypePropertyId                 volet
$UIA_ProviderDescriptionPropertyId                  [pid:18924,providerId:0x114FE Main:Nested [pid:16664,providerId:0x114FE Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]
                                                    
Element Properties (has/is info)                    
$UIA_HasKeyboardFocusPropertyId                     False
$UIA_IsContentElementPropertyId                     True
$UIA_IsControlElementPropertyId                     True
$UIA_IsDataValidForFormPropertyId                   False
$UIA_IsEnabledPropertyId                            True
$UIA_IsKeyboardFocusablePropertyId                  True
$UIA_IsOffscreenPropertyId                          False
$UIA_IsPasswordPropertyId                           False
$UIA_IsRequiredForFormPropertyId                    False
                                                    
Control Patterns (element actions)                  
$UIA_IsLegacyIAccessiblePatternAvailablePropertyId  True (LegacyIAccessiblePattern)
$UIA_IsScrollPatternAvailablePropertyId             True (ScrollPattern)
                                                    
Control Pattern Properties                          
$UIA_LegacyIAccessibleChildIdPropertyId             0
$UIA_LegacyIAccessibleDefaultActionPropertyId       
$UIA_LegacyIAccessibleDescriptionPropertyId         
$UIA_LegacyIAccessibleHelpPropertyId                
$UIA_LegacyIAccessibleKeyboardShortcutPropertyId    
$UIA_LegacyIAccessibleNamePropertyId                
$UIA_LegacyIAccessibleRolePropertyId                10 = $ROLE_SYSTEM_CLIENT
$UIA_LegacyIAccessibleStatePropertyId               1048576 = $STATE_SYSTEM_FOCUSABLE
$UIA_LegacyIAccessibleValuePropertyId               
$UIA_ScrollHorizontallyScrollablePropertyId         False
$UIA_ScrollHorizontalScrollPercentPropertyId        0
$UIA_ScrollHorizontalViewSizePropertyId             100
$UIA_ScrollVerticallyScrollablePropertyId           False
$UIA_ScrollVerticalScrollPercentPropertyId          0
$UIA_ScrollVerticalViewSizePropertyId               100
                                                    
Control Pattern Methods                             
LegacyIAccessible Pattern Methods                   
                                                    DoDefaultAction()
                                                    Select(long)
                                                    SetValue(wstr)
                                                    GetIAccessible(idispatch*)
                                                    CurrentChildId(int*)
                                                    CurrentDefaultAction(bstr*)
                                                    CurrentDescription(bstr*)
                                                    CurrentHelp(bstr*)
                                                    CurrentKeyboardShortcut(bstr*)
                                                    CurrentName(bstr*)
                                                    CurrentRole(uint*)
                                                    CurrentState(uint*)
                                                    CurrentValue(bstr*)
                                                    GetCurrentSelection(ptr*)
Scroll Pattern Methods                              
                                                    Scroll($iScrollAmountHorz,$iScrollAmountVert)
                                                    SetScrollPercent($fPercentHorz,$fPercentVert)
                                                    CurrentHorizontalScrollPercent($fPercent*)
                                                    CurrentVerticalScrollPercent($fPercent*)
                                                    CurrentHorizontalViewSize($fViewSize*)
                                                    CurrentVerticalViewSize($fViewSize*)
                                                    CurrentHorizontallyScrollable($bScrollable*)
                                                    CurrentVerticallyScrollable($bScrollable*)
                                                    
Parents from Desktop                                Pane: Bureau 1
                                                    Pane: FChifa
                                                    Pane: TPanel
                                                    Pane: TPanel
                                                    
Parent to child index

This is what i got ! 

Link to post
Share on other sites

If you cannot find any info about the grid cells with UIASpy, then it's probably because the internal implementation of the grid control doesn't support UIA code but possibly only MSAA code. Try examining the grid control with Inspect.exe contained in the SDK.

If it turns out that the internal controls in the grid only support MSAA code, then you can find an example in the DataGridView & UI Automation framework and you can find other examples by googling MSAccessibility.au3.

Link to post
Share on other sites
How found:  Mouse move (290,392)
    hwnd=0x001202E6 32bit class="TFChifa" style=0x96000000 ex=0x10000
ChildId:    0
Interfaces: IEnumVARIANT IOleWindow IAccIdentity
Impl:   Local oleacc proxy
AnnotationID:   010000800E090400FCFFFFFF00000000
Name:   [null]
Value:  [null]
Role:   client (0xA)
State:  pouvant être actif (0x100000)
Location:   {l:29, t:340, w:438, h:108}
Selection:  
Description:    [null]
Kbshortcut: [null]
DefAction:  [null]
Help:   [null]
HelpTopic:  ""
ChildCount: 0
Window: 0x4090E
FirstChild: [null]
LastChild:  [null]
Next:   "Vertical" : barre de défilement : normal
Previous:   [null]
Left:   [null]
Up: [null]
Right:  "Vertical" : barre de défilement : normal
Down:   "Horizontal" : barre de défilement : normal
Other Props:    Object has no additional properties
Children:   Container has no children
Ancestors:  none : fenêtre : pouvant être actif
    none : client : Non disponible,pouvant être actif
    none : fenêtre : Non disponible,pouvant être actif
    none : client : Non disponible,pouvant être actif
    none : fenêtre : Non disponible,pouvant être actif
    "FChifa" : client : pouvant être actif
    "FChifa" : fenêtre : pouvant être actif
    "Bureau 1" : client : pouvant être actif
    "Bureau 1" : fenêtre : pouvant être actif
    [ No Parent ]

This is MSSA 

 

How found:  Mouse move (285,396)
    hwnd=0x001202E6 32bit class="TFChifa" style=0x96000000 ex=0x10000
RuntimeId:  "[42.264462]"
BoundingRectangle:  {l:27 t:338 r:486 b:467}
ProcessId:  14956
ControlType:    UIA_PaneControlTypeId (0xC371)
LocalizedControlType:   "volet"
Name:   ""
AccessKey:  ""
HasKeyboardFocus:   false
IsKeyboardFocusable:    true
IsEnabled:  true
AutomationId:   "264462"
ClassName:  "TDBGrid"
HelpText:   ""
IsPassword: false
NativeWindowHandle: 0x4090E
IsOffscreen:    false
FrameworkId:    "Win32"
ProviderDescription:    "[pid:13840,providerId:0x4090E Main:Nested [pid:14956,providerId:0x4090E Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
Scroll.HorizontalScrollPercent: 0.000000
Scroll.HorizontalViewSize:  100.000000
Scroll.VerticalScrollPercent:   0.000000
Scroll.VerticalViewSize:    100.000000
Scroll.HorizontallyScrollable:  false
Scroll.VerticallyScrollable:    false
IsDockPatternAvailable: false
IsExpandCollapsePatternAvailable:   false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable:   false
IsMultipleViewPatternAvailable: false
IsRangeValuePatternAvailable:   false
IsScrollPatternAvailable:   true
IsScrollItemPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsTablePatternAvailable:    false
IsTableItemPatternAvailable:    false
IsTextPatternAvailable: false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    false
IsValuePatternAvailable:    false
IsWindowPatternAvailable:   false
IsItemContainerPatternAvailable:    false
IsVirtualizedItemPatternAvailable:  false
FirstChild: "Vertical" barre de défilement
LastChild:  (null) thumb
Next:   "" Modifier
Previous:   "Enregistrer " Bouton
Other Props:    Object has no additional properties
Children:   "Vertical" barre de défilement
    "Horizontal" barre de défilement
    (null) thumb
Ancestors:  "" volet
    "" volet
    "FChifa" volet
    "Bureau 1" volet
    [ No Parent ]

This is UI automation 

I don't think it's controllable with MSAA code also ?

 

 

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

    No registered users viewing this page.

×
×
  • Create New...