How to "click" on a FileControl element?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
JackK
Posts: 16
Joined: Thu Apr 04, 2013 12:11 pm

How to "click" on a FileControl element?

Post by JackK »

Hi,
I have a dialog that need a file from disk for correct work. At the moment I have a FileControl item on the dialog which user must click to select the needed file. How may I open the dialog for file selecting automaticaly without the need of user action?

Thanks in advance.
OpenOffice 3 / Windows 7
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: How to "click" on a FileControl element?

Post by hanya »

So, you are using file control!
Try accessibility API to push the button inside the file control:

Code: Select all

Sub Snippet(Optional oInitialTarget As Object)
  Dim oControls As Variant
  Dim oXControl As Variant
  Dim oAccessibleContext As Variant
  Dim oAccessibleChild As Variant
  Dim oAccessibleContext2 As Variant
  Dim nAccessibleRole As Integer
  Dim oObj1 As Boolean

  oControls = oInitialTarget.getControls()
  oXControl = oControls(0)
  oAccessibleContext = oXControl.getAccessibleContext()
  
  oAccessibleChild = oAccessibleContext.getAccessibleChild(1)
  oAccessibleContext2 = oAccessibleChild.getAccessibleContext()
  nAccessibleRole = oAccessibleContext2.getAccessibleRole() ' should be PUSH_BUTTON
  
  oObj1 = oAccessibleContext2.doAccessibleAction(0)
End Sub
This code is recorded by MRI extension, oInitialTarget is the dialog object. The accessible role of the button that you have to find in the list of accessible child is css.accessibility.AccessibleRole.PUSH_BUTTON (44).
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Post Reply