[jawsscripts] Re: Using the SetWindowVisualState Method

  • From: Bob _ <temp@xxxxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Sun, 5 Feb 2017 14:20:55 +0000

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

Other related posts: