Jump to content

[Solved] Want to press a control in Windows. Got simplespy code but don't know what to do.


careca
 Share

Recommended Posts

Hey there, i have the code from simplespy but have no idea about what to use, got the UIA_V0_64 files.

Spoiler

https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/?do=findComment&comment=1156373
At least we have an element title: [More apps] class: [TouchHyperLink]

Having the following values for all properties:
Title is: <More apps>    Class   := <TouchHyperLink>    controltype:= <UIA_HyperlinkControlTypeId>    ,<50005>    , (0000C355)    1081;673;390;50
*** Parent Information top down ***
6: Title is: <How do you want to open .mp3 files from now on?>    Class   := <Shell_Flyout>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    1080;270;392;522
"Title:=How do you want to open .mp3 files from now on?;controltype:=UIA_WindowControlTypeId;class:=Shell_Flyout""    
5: Title is: <Flyout window>    Class   := <FlyoutElement>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    1080;270;392;522
"Title:=Flyout window;controltype:=UIA_PaneControlTypeId;class:=FlyoutElement""    
4: Title is: <>    Class   := <Element>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    1081;271;390;520
"Title:=;controltype:=UIA_PaneControlTypeId;class:=Element""    
3: Title is: <Immersive Openwith Flyout>    Class   := <Element>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    1081;271;390;520
"Title:=Immersive Openwith Flyout;controltype:=UIA_PaneControlTypeId;class:=Element""    
2: Title is: <>    Class   := <TouchScrollViewer>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    1081;358;390;365
"Title:=;controltype:=UIA_PaneControlTypeId;class:=TouchScrollViewer""    
1: Title is: <>    Class   := <AppItemListContainer>    controltype:= <UIA_ListControlTypeId>    ,<50008>    , (0000C358)    1081;299;390;424
"Title:=;controltype:=UIA_ListControlTypeId;class:=AppItemListContainer""    
0: Title is: <>    Class   := <AppItemList>    controltype:= <UIA_ListControlTypeId>    ,<50008>    , (0000C358)    1081;423;390;300
"Title:=;controltype:=UIA_ListControlTypeId;class:=AppItemList""    


;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=How do you want to open .mp3 files from now on?;controltype:=UIA_WindowControlTypeId;class:=Shell_Flyout")    ;How do you want to open .mp3 files from now on?
_UIA_setVar("oP2","Title:=Flyout window;controltype:=UIA_PaneControlTypeId;class:=FlyoutElement")    ;Flyout window
_UIA_setVar("oP3","Title:=;controltype:=UIA_PaneControlTypeId;class:=Element")    ;
_UIA_setVar("oP4","Title:=Immersive Openwith Flyout;controltype:=UIA_PaneControlTypeId;class:=Element")    ;Immersive Openwith Flyout
_UIA_setVar("oP5","Title:=;controltype:=UIA_PaneControlTypeId;class:=TouchScrollViewer")    ;
_UIA_setVar("oP6","Title:=;controltype:=UIA_ListControlTypeId;class:=AppItemListContainer")    ;
_UIA_setVar("oP7","Title:=;controltype:=UIA_ListControlTypeId;class:=AppItemList")    ;

;~ $oUIElement=_UIA_getObjectByFindAll("Moreapps.mainwindow", "title:=More apps;ControlType:=UIA_HyperlinkControlTypeId", $treescope_subtree)
_UIA_setVar("oUIElement","Title:=More apps;controltype:=UIA_HyperlinkControlTypeId;class:=TouchHyperLink") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=TouchHyperLink")

;~ Actions split away from logical/technical definition above can come from configfiles

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")
;~_UIA_Action("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")
;~_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")
;~_UIA_Action("oP7","highlight")
_UIA_Action("oP7","setfocus")

_UIA_action("oUIElement","highlight")
;~_UIA_action("oUIElement","click")


;~ *** Standard code Flexible***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP6=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=How do you want to open .mp3 files from now on?;controltype:=UIA_WindowControlTypeId;class:=Shell_Flyout", $treescope_children)    
_UIA_Action($oP6,"setfocus")
Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=Flyout window;controltype:=UIA_PaneControlTypeId;class:=FlyoutElement", $treescope_children)    
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Element", $treescope_children)    
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=Immersive Openwith Flyout;controltype:=UIA_PaneControlTypeId;class:=Element", $treescope_children)    
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=TouchScrollViewer", $treescope_children)    
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_ListControlTypeId;class:=AppItemListContainer", $treescope_children)    
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_ListControlTypeId;class:=AppItemList", $treescope_children)    
;~ First find the object in the parent before you can do something
;~$oUIElement=_UIA_getObjectByFindAll("Moreapps.mainwindow", "title:=More apps;ControlType:=UIA_HyperlinkControlTypeId", $treescope_subtree)
Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=More apps;ControlType:=UIA_HyperlinkControlTypeId", $treescope_subtree)
;~_UIA_action($oUIElement,"highlight")
_UIA_action($oUIElement,"click")


*** Detailed properties of the highlighted element ***
UIA_title:= <More apps>
UIA_text:= <More apps>
UIA_regexptitle:= <More apps>
UIA_class:= <TouchHyperLink>
UIA_regexpclass:= <TouchHyperLink>
UIA_iaccessiblechildId:= <0>
UIA_id:= <OptionsButton>
UIA_handle:= <0>
UIA_RuntimeId:= <7740;955018816;396>
UIA_BoundingRectangle:= <1081;673;390;50>
UIA_ProcessId:= <7740>
UIA_ControlType:= <50005>
UIA_LocalizedControlType:= <link>
UIA_Name:= <More apps>
UIA_HasKeyboardFocus:= <False>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <OptionsButton>
UIA_ClassName:= <TouchHyperLink>
UIA_ClickablePoint:= <1276;698>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <0>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <DirectUI>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <True>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <True>
UIA_IsSelectionItemPatternAvailable:= <True>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <True>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleName:= <More apps>
UIA_LegacyIAccessibleRole:= <30>
UIA_LegacyIAccessibleState:= <7340096>
UIA_LegacyIAccessibleDefaultAction:= <Jump>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:7740,providerId:0x0 Main(parent link):Unidentified Provider (unmanaged:DUI70.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

 

I look at the examples but i get lost, i ask for guideance in this matter.

Best regards.

screenshot - 08122017-1624.jpg

 

To get to this window simply run:

control.exe /name Microsoft.DefaultPrograms /page pageFileAssoc

select a filetype and click "change program"

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

There is a registry setting you can add to set the default application for an extension type...that would be much easier.

 

https://social.technet.microsoft.com/Forums/ie/en-US/06d35f90-56cb-4dec-b326-bd471d06acee/change-default-program-for-file-command-line-or-registry?forum=w7itprogeneral

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Oh been there, done that, but win 10 is so much trickier.. im done with trying registry.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

 

Figured it out, just dont know why it takes so long, like 10 secs or so per action. Any way to speed up?

#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)
Local $sText1, $Vis
ShellExecute(@WindowsDir & '\system32\control.exe', '/name Microsoft.DefaultPrograms /page pageFileAssoc')
            WinWaitActive("Set Associations", 'Set Associations', 10)
            Local $hWnd = WinGetHandle("[CLASS:CabinetWClass]", "Set Associations")
            If $hWnd <> 0 Or @error <> 0 Then
                Do
                    $Vis = ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:1]", 'IsVisible')
                Until $Vis = 1
                Sleep(100)
                Local $iCount = ControlListView($hWnd, "", "SysListView321", "GetItemCount")
                For $k = 0 To $iCount - 1
                    $sText1 = ControlListView($hWnd, "", "SysListView321", "GetText", $k, 0)
                    If $sText1 = '.mp3' Then
                        ControlListView($hWnd, "", "SysListView321", "Select", $k, $k)
                        ConsoleWrite('=============================================================================' & @CRLF)
                        ConsoleWrite('Line - ' & $k & ' - ' & $sText1 & @CRLF)
                        ConsoleWrite('=============================================================================' & @CRLF)
                        ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:1]")
                        Elem()
                        ExitLoop
                    EndIf
                Next
            EndIf
Func Elem()
_UIA_setVar("oUIElement","Title:=Line down;controltype:=UIA_ButtonControlTypeId;class:=TouchRepeatButton")
_UIA_action("oUIElement","click")
MouseWheel ( "down", 100)
_UIA_setVar("oUIElement","Title:=More apps;controltype:=UIA_HyperlinkControlTypeId;class:=TouchHyperLink")
_UIA_action("oUIElement","click")
_UIA_setVar("oUIElement","Title:=Line down;controltype:=UIA_ButtonControlTypeId;class:=TouchRepeatButton")
_UIA_action("oUIElement","click")
MouseWheel ( "down", 100)
_UIA_setVar("oUIElement","Title:=Look for another app on this PC;controltype:=UIA_HyperlinkControlTypeId;class:=TouchHyperLink")
_UIA_action("oUIElement","click")
EndFunc

 

UIAWrappers.au3

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
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
 Share

×
×
  • Create New...