mercadantelaura Posted January 13, 2014 Posted January 13, 2014 I need for my different purposes to get how many items there are in window folder active right ponel and how many items are selected in that active window list and change the default details view to EXTRA LARGE ICONS for Windows Seven or Large Icons under XP. If @OSVersion = "WIN_7" Then $sControl = "DirectUIHWND3" Else $sControl = "SysListView321" Endif $ItemNumber = ControlListView("[Active]", "", $sControl,"GetItemCount") $SelectNumber = ControlListView("[Active]", "", $sControl, "GetSelectedCount") If $SelectNumber < $ItemNumber Then ControlListView("[Active]", "", $sControl, "SelectAll") ControlListView("[Active]", "", $sControl, "ViewChange", "largeicons") Endif Unfortunately my script runs only under Windows XP 32 bits but NOT under Windows7 64 Bits AutoIT Guide reports: << Some commands may fail when using a 32-bit AutoIt process to read from a 64-bit process. << Likewise commands may fail when using a 64-bit AutoIt process to read from a 32-bit process. ...therefore i have launched my script in both method using AutoIT 32Bit and 64 bit without effect. "GetItemCount" and "GetSelectedCount" return always ZERO value and "Large icons" is not setted. (I would want "EXTRA Large Icons" but i don't know how set EXTRA Large) Using this function: $sControl = ControlGetFocus(WinGetTitle("[Active]")) - Under Windows XP: "SysListView321" is the "Right Panel Control" obtained - Under Windows Seven Sp1 64 Bit the control used is: "DirectUIHWND3" and i have inserted this value in my script. Where i'm wronging ?? Can you help me with some suggestion ? Thank you
JohnOne Posted January 13, 2014 Posted January 13, 2014 Can you show how you "launched my script in both method using AutoIT 32Bit and 64 bit" AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
mercadantelaura Posted January 14, 2014 Author Posted January 14, 2014 (edited) In AutoIT folder there is: AutoIt3.exe and AutoIt3_x64.exe i have proved using 1st and second exe to run my Au3 file but under Win7 x64 my script don't run, under XP run correctly Under Win7 script is launched and finished without errors, but script don't make that i want. Script do nothing under Win7. Edited January 14, 2014 by mercadantelaura
JohnOne Posted January 14, 2014 Posted January 14, 2014 Have you tried using autoit wrapper directives? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
mercadantelaura Posted January 14, 2014 Author Posted January 14, 2014 I have also proved to compile au3 using wrapper but don't run "directives" ....I don't kow how is. If you have Win7 x64 test my script under your system if you can in order to know if it run's to you.
JohnOne Posted January 14, 2014 Posted January 14, 2014 #AutoIt3Wrapper_UseX64=y AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
mercadantelaura Posted January 14, 2014 Author Posted January 14, 2014 Thank you for reply JohnOne, but NOTHING TO DO, don't run on my system. I have readed directives and i have inserted into my script your suggestion and compile ir using Wrapper. I have added Msgbox that shows me value of variable "$ItemNumber" and "$SelectNumber " and when i select some files and i run script the answr is: $ItemNumber = 0 $SelectNumber = 0 Always zero ?? I have 20 files and 3 folders into right panel and i have selected 10 files !! How can i write a script that run under win7 x64 and do that i want ??
LarsJ Posted January 14, 2014 Posted January 14, 2014 Counting the number of items (files/folders) and especially selected items in Windows Explorer on Win 7 is not easy to do with built-in commands. The real challenge is that the listview on Win 7 is a virtual listview.This means that the listview contains only the items that you can see. The rest of the items are stored in a table probably in the form of PIDLs. When you scroll up/down the virtual items get realized and shown in the listview. The items that scrolls out of sight will be stored in the tabel as virtual items. You can find more info here.A solution to that problem is to use the UI Automation framework which is a COM based framework.If you are not used to COM programming this can also be a challenge. I'll try to figure out how to get these numbers and if I succeed I'll add the code to this thread. But I need a few days and may be also the weekend. If I don't succeed I'll let you know. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
mercadantelaura Posted January 15, 2014 Author Posted January 15, 2014 Thank you very much LarsJ i will wait your reply in next week. My 1st purpose into my script was: Count items selected in explorer session list and if is not selected all files then select all files and change view into "EXTRA LARGE ICONS" if possible (large icons is too small for my purpose) Only when i press: ("+{ESC}") using HotKeySet, script come back to "DETAILS" and deselect all files I hope that there is solution under my Win7 x64
LarsJ Posted January 15, 2014 Posted January 15, 2014 Try this for a start. You need the CUIAutomation2.au3 UDF in the bottom of first post here. expandcollapse popup#include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() ; Get window handle ; Be sure to use the right class if you are on Vista or Windows 8 Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]", "" ) ; Windows Explorer, Windows 7 ;Local $hWindow = WinGetHandle( "[CLASS:ExploreWClass]", "" ) ; Windows Explorer, Windows XP If Not $hWindow Then Return ; Create UI Automation object Local $oUIAutomation $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; 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 ; Condition to find listview Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition ) If Not $pCondition Then Return ; Find listview Local $pUIList, $oUIList $oWindow.FindFirst( $TreeScope_Descendants, $pCondition, $pUIList ) $oUIList = ObjCreateInterface( $pUIList, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oUIList ) Then Return ; Get number of items and selected items Local $sStatus $oUIList.GetCurrentPropertyValue( $UIA_ItemStatusPropertyId, $sStatus ) MsgBox( 0, "", $sStatus ) EndFuncReturns empty string on XP. OK on Win 7. Not tested on Vista or Win 8.If you are running a 64 bit windows you must run the script as a 64 bit program.Wasn't that just easy? Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
LarsJ Posted January 16, 2014 Posted January 16, 2014 This is code to set the view type (details, extra large icons, ...) of the listview. expandcollapse popup#include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() ; Get window handle for Windows Explorer Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]", "" ) ; Vista, 7, 8 ;Local $hWindow = WinGetHandle( "[CLASS:ExploreWClass]", "" ) ; Windows XP If Not $hWindow Then Return ; Create UI Automation object Local $oUIAutomation $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; 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 ; Condition to find listview Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition ) If Not $pCondition Then Return ; Find listview Local $pUIList, $oUIList $oWindow.FindFirst( $TreeScope_Descendants, $pCondition, $pUIList ) $oUIList = ObjCreateInterface( $pUIList, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oUIList ) Then Return ; Create multiple view pattern object Local $pView, $oView $oUIList.GetCurrentPattern( $UIA_MultipleViewPatternId, $pView ) $oView = ObjCreateInterface( $pView, $sIID_IUIAutomationMultipleViewPattern, $dtagIUIAutomationMultipleViewPattern ) If Not IsObj( $oView ) Then Return ; Set view Local $sView $oView.SetCurrentView( 0 ) ; Values 0 - 7 on Win 7: 0 = Extra Large Icons, 5 = Details, 7 = Content $oView.GetViewName( 0, $sView ) MsgBox( 0, "", $sView ) EndFuncDoesn't work on XP. If you are running a 64 bit windows you must run the script as a 64 bit program. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
mercadantelaura Posted January 17, 2014 Author Posted January 17, 2014 (edited) I'm searching into download section the file "CUIAutomation2.au3" to include into your script but i don't find it. When it is allocated into AutoIT site ? Whithout success I have saw into: - libraries - misc Thanks Edited January 17, 2014 by mercadantelaura
mercadantelaura Posted January 17, 2014 Author Posted January 17, 2014 Oh sorry i'm stupid, i don't see your link for necessary script to include. I have download it and next time when i come back to home i test it on my computer. Thank you very much for now
mercadantelaura Posted January 17, 2014 Author Posted January 17, 2014 (edited) Thank you very much LarsJ for your time . I have proved on my Win7 x64 your "EXTRA LARGE ICON" function and it runs very well. :-) I'm very satisfied, thanks again. In the script i also added this mouse shortcuts in order to maximize effect of my design. Send("!vb") ; --> Status Bar ON / OFF ( MenuBar -> View ) Send("!d+{TAB 4}{ENTER}LN") ; --> Navigation pane ON / OFF ( Organize -> Layout ) Send("{F11}") ; Maximize Windows to all screen dimension available There is possibility to disable "status bar" and "Navigation pane" without use mouse shortcut that for few moment using this method, shows on screen opened pop menu ? When i have finished my design i will press +ESC and all files SELECTED i need that will be unselected and StatusBar and Navigation Pane will be showed again. Do you think that is realizable this ? Edited January 17, 2014 by mercadantelaura
mercadantelaura Posted January 17, 2014 Author Posted January 17, 2014 Also your function to know number of selected files on active folder runs very well. Thanks for help and congratualtions for good job. Sorry, but unfortunately i'm beginner and Msgbox shows [ selected / number files value ] but i don't know how test the variable. ; Get number of items and selected items Local $sStatus $oUIList.GetCurrentPropertyValue( $UIA_ItemStatusPropertyId, $sStatus ) MsgBox( 0, "", $sStatus ) .....I need to do test: If $SelectNumber < $ItemNumber Then Send("^a") ; only way that i know to "SELECT ALL" Else Send("{F5}") ; only way that i know to "DESELECT ALL" Refreshing Window Endif ...but how can i get < $SelectNumber > and < $ItemNumber > value from < $sStatus > variable ? It is not an array [0] .. [1] Can you explain me please.
mercadantelaura Posted January 18, 2014 Author Posted January 18, 2014 (edited) To have two separate varibles with my little know-how of AutoIT i have done in this mode: Local $FileNumber = StringSplit ( $sStatus, " " ) Local $FileSelect = StringSplit ( StringRight($sStatus, StringLen ($sStatus) - (StringInStr ($sStatus, ",") + 1)), " " ) If $FileNumber[1] = $FileSelect[1] Then Send("{F5}") Else Send("^a") Endif If in future somebody can modify my script replacing mouse shortcuts to disable StatusBar and NavigationPane with script that do same thing without open pop menu is the perfection and maximum that i need for my purpose. Thanks again to LarsJ for scripts Edited January 18, 2014 by mercadantelaura
LarsJ Posted January 18, 2014 Posted January 18, 2014 I have seen your posts. I'm still coding (and reading documentation). I'll be back. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
mercadantelaura Posted January 18, 2014 Author Posted January 18, 2014 (edited) :-)) Thank a lot LarsJ . You are very gentile and disponible. Your help is very precious for me. Thanks again. Edited January 18, 2014 by mercadantelaura
LarsJ Posted January 21, 2014 Posted January 21, 2014 This is code to select all items in the listview. expandcollapse popup#include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Global $oUIAutomation MainFunc() Func MainFunc() ; Get window handle for Windows Explorer Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]", "" ) ; Vista, 7, 8 If Not $hWindow Then Return ; Create UI Automation object $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; 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 ; Condition to find listview Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition ) If Not $pCondition Then Return ; Find listview Local $pList, $oList $oWindow.FindFirst( $TreeScope_Descendants, $pCondition, $pList ) $oList = ObjCreateInterface( $pList, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oList ) Then Return ; Select or deselect all items SelectAllItems( $oList, True ) EndFunc Func SelectAllItems( $oList, $bSelect ) ; ItemContainer object ; A virtual listview must support the ItemContainer object Local $pItemContainer, $oItemContainer $oList.GetCurrentPattern( $UIA_ItemContainerPatternId, $pItemContainer ) $oItemContainer = ObjCreateInterface( $pItemContainer, $sIID_IUIAutomationItemContainerPattern, $dtagIUIAutomationItemContainerPattern ) If Not IsObj( $oItemContainer ) Then Return ; Find first item Local $pItem, $oItem ; The following command works for both real and virtual items $oItemContainer.FindItemByProperty( 0, $UIA_NamePropertyId, 0, $pItem ) $oItem = ObjCreateInterface( $pItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oItem ) Then Return ; Empty folder ; Is first item a virtual item? Local $pVirtualItem, $oVirtualItem $oItem.GetCurrentPattern( $UIA_VirtualizedItemPatternId, $pVirtualItem ) If $pVirtualItem Then ; First item is a virtual item, realize it $oVirtualItem = ObjCreateInterface( $pVirtualItem, $sIID_IUIAutomationVirtualizedItemPattern, $dtagIUIAutomationVirtualizedItemPattern ) $oVirtualItem.Realize() ; $oItem is now a real item EndIf Local $pSelection, $oSelection While $pItem ; Add to or remove from selection $oItem.GetCurrentPattern( $UIA_SelectionItemPatternId, $pSelection ) $oSelection = ObjCreateInterface( $pSelection, $sIID_IUIAutomationSelectionItemPattern, $dtagIUIAutomationSelectionItemPattern ) If $bSelect Then $oSelection.AddToSelection() Else $oSelection.RemoveFromSelection() EndIf ; Find next item $oItemContainer.FindItemByProperty( $pItem, $UIA_NamePropertyId, 0, $pItem ) $oItem = ObjCreateInterface( $pItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oItem ) Then ExitLoop ; No more items ; Virtual item? $oItem.GetCurrentPattern( $UIA_VirtualizedItemPatternId, $pVirtualItem ) If $pVirtualItem Then ; The item is a virtual item, realize it $oVirtualItem = ObjCreateInterface( $pVirtualItem, $sIID_IUIAutomationVirtualizedItemPattern, $dtagIUIAutomationVirtualizedItemPattern ) $oVirtualItem.Realize() ; $oItem is now a real item EndIf WEnd EndFuncDoesn't work on XP. If you are running a 64 bit windows you must run the script as a 64 bit program.For questions about menus and toolbars see those sections in the help file. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
mercadantelaura Posted January 21, 2014 Author Posted January 21, 2014 Thank you very, very much for all scripts that you posts for me. For disable/re-Enable Windows Left Tree Navpane and Status Bar do you think that is possible, code without using mouse shortcut as now i'm using ?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now