[jawsscripts] Re: Using the SetWindowVisualState Method

  • From: Marcus <marcus.canaday@xxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Sun, 5 Feb 2017 09:47:58 -0500

Thanks Bob! I'll try setting it to restored first,but if that doesn't 
work, I'll just keep pecking away at it!



On 2/5/2017 9:44 AM, Bob wrote:

You could try setting it to restored first and see if that works but 
essentially you have run into one of the joys of scripting. Especially with 
UIA!
Somethings just don’t work as they should, especially when dealing with other 
peoples applications.

I recently had an application with two list views. One UIA reported as only 
allowing a single selection but it was possible to select multiple items and 
the other that reported it could accept multiple but would only allow one.
The second of these that only allowed a single selected item when I used UIA 
to query what was selected the application crashed every time.

So perhaps an alternative method:
I cant remember all the function names so you may need to check a lot of this!

hWnd = GetAppMainWindow(GetCurrentWindow())

hWnd = GetFirstWindow(hWnd)

iNumWindows = GetWindowHeirarchyX(GetLastWindow(hWnd))

While iNumWindows > 0

      SendMessage(hWnd, 274, 61488, 0)
      
      hWnd = GetNextWindow(hWnd)

      iNumWindows = iNumWindows - 1

EndWhile


I have no idea what each of the send message parameters mean but it’s a line 
that I have noted down and have used many times before.
You will obvs need to add your checking for the correct window.

Bob


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx 
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Marcus
Sent: 05 February 2017 14:27
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Using the SetWindowVisualState Method

Thanks Bob,


The function works perfectly until I run into a window that is minimized. The 
only issue I'm having and can't get to work is the SetWindowVisualState to 
maximize a minimized window when focus changes.

On 2/5/2017 9:20 AM, Bob _ wrote:
The root element is usually the desktop and doesn't have any siblings.
Move to the first child before iterating across the siblings.
You can use
While Walker.GoToNextSibling()
As this returns false when there is nothing to move to rather than limiting 
your loop to an arbitrary number.

I think the FSUIA object also has a GetRootElement() option so you don't 
need to get the walker to move there. Small difference but slightly more 
efficient.

SetFocus and GetWindowPattern might need the brackets afterwards but it 
wouldn't surprise me if it works without.

Bob


On 5 Feb 2017, at 14:02, Marcus <marcus.canaday@xxxxxxxxx> wrote:


I'm still struggling with the SetWindowVisualState mmethod. I use
scripts using the following function to quickly move from one program
to another. Occasionally, the program I'm moving to is  and I can't
interact with it. I haven't been able to set the visual state to
"maximized" when the focus moves to a minimized window. Again, any
help would be appreciated. Here's the function:


String Function MoveToProgram (string ByRef ProgramName)

var
Object MyObject = CreateObjectEx("FreedomSci.UIA", false,
"UIAScriptAPI.x.manifest"), Object MyTreeWalker =
MyObject.ControlViewWalker (), Object Pattern =
MyTreeWalker.CurrentElement.GetWindowPattern,
Int Safety = 1

MyTreeWalker.CurrentElement =
MyObject.GetElementFromHandle(GetAppMainWindow(GetCurrentWindow()))
MyTreeWalker.GoToRootElement

While Safety <=10
MyTreeWalker.GoToNextSibling
If StringContains (MyTreeWalker.CurrentElement.name, ProgramName)
SayString ("Moving to " + ProgramName)
myTreeWalker.CurrentElement.SetFocus
Pattern.SetWindowvisualState(WindowVisualState_Maximized)
Return
EndIf
Safety = Safety+1
EndWhile

EndFunction



On 2/4/2017 12:39 PM, Bob wrote:

I cant remember the line to declare the the UIA object so some lazy code 
below:

hWnd = GetAppMainWindow(GetCurrentWindow())

Element = UIA.GetElementFromHandle(hWnd)

Two options:

PatternObject = Element.GetWindowPattern()

PatternObject.SetWindowVisualState(WindowVisualState_Maximized)

Or single line:

Element.
GetWindowPattern().SetWindowVisualState(WindowVisualState_Maximized)

Hope this helps

Bob


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Marcus
Sent: 04 February 2017 17:08
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Using the SetWindowVisualState Method
Importance: High

Good afternoon,


I'm hoping someone can give me an example of how to use the 
SetWindowVisualState method to maximize a window. Thanks much.



__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts



__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts

__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts

__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts

__________

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts



__________�

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts


__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: