Jump to content

How to select "view" from Windows Explorer


 Share

Recommended Posts

Howdy all!

This is my first post here, as I am new to AutoIt.

I want to write a script that will select "view" from the Windows Explorer menu bar, then select, "folder view". But I have the alt key command turned off on my computer, so I can't use the sendkeys function. How do I do this?

;THIS GETS THE WINDOW TITLE

$title = WinGetTitle("[ACTIVE]", "")

;NONE OF THESE COMMANDS WORK

;$this = WinMenuSelectItem($title, "View", "Explorer Bar")

;$this = WinMenuSelectItem($title, "View", "[Explorer Bar]")

;$this = WinMenuSelectItem($title, "View", "[View]")

;WHEN I DO USE ONE OF THE ABOVE COMMANDS, zero IS RETURNED

MsgBox (1, "found:", $this)

Thanks for reading my little note!

- Brother Gabriel-Marie

Link to comment
Share on other sites

Howdy all!

This is my first post here, as I am new to AutoIt.

I want to write a script that will select "view" from the Windows Explorer menu bar, then select, "folder view". But I have the alt key command turned off on my computer, so I can't use the sendkeys function. How do I do this?

;THIS GETS THE WINDOW TITLE

$title = WinGetTitle("[ACTIVE]", "")

;NONE OF THESE COMMANDS WORK

;$this = WinMenuSelectItem($title, "View", "Explorer Bar")

;$this = WinMenuSelectItem($title, "View", "[Explorer Bar]")

;$this = WinMenuSelectItem($title, "View", "[View]")

;WHEN I DO USE ONE OF THE ABOVE COMMANDS, zero IS RETURNED

MsgBox (1, "found:", $this)

Thanks for reading my little note!

The first "Text" parameter is visible text to identify the window, not menu text. So this would be more correct:
$this = WinMenuSelectItem($title, "", "View", "Explorer Bar")
But that still doesn't work.

The problem is that it's a ToolBar, not a Menu:

#include <GuiToolbar.au3>

$hWin = WinGetHandle("[CLASS:CabinetWClass]")
ConsoleWrite("Debug: $hWin = " & $hWin & @LF)

$hTB = _GUICtrlToolbar_FindToolbar($hWin, "&View")
ConsoleWrite("Debug: $hTB = " & $hTB & @LF)

$sClass = _WinAPI_GetClassName($hTB)
ConsoleWrite("Debug: $sClass = " & $sClass & @LF)

$iBCnt = _GUICtrlToolbar_ButtonCount($hTB)
ConsoleWrite("Debug: $iBCnt = " & $iBCnt & @LF)

ConsoleWrite(@TAB & "index: CommandID - Text" & @LF)
For $i = 0 To $iBCnt - 1
    ConsoleWrite(@TAB & $i & ": " & _
        _GUICtrlToolbar_IndexToCommand($hTB, $i) & " - " & _
        _GUICtrlToolbar_GetButtonText($hTB, _GUICtrlToolbar_IndexToCommand($hTB, $i)) & @LF)
Next

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Wow! Hey, thanks. Well, now I know all the ID's. I apologize for being so newbish, but I can't locate the commands by which to select those IDs. I understand "WinMenuSelectItem", but where would I find something of the equivalency of "ToolbarSelectItem" ?

- Brother Gabriel-Marie

Link to comment
Share on other sites

Wow! Hey, thanks. Well, now I know all the ID's. I apologize for being so newbish, but I can't locate the commands by which to select those IDs. I understand "WinMenuSelectItem", but where would I find something of the equivalency of "ToolbarSelectItem" ?

It's _GuiCtrlToolbar_ClickItem(). This clicks on View and toggles the Folders pane:
#include <GuiToolbar.au3>

$hWin = WinGetHandle("[CLASS:CabinetWClass]")
ConsoleWrite("Debug: $hWin = " & $hWin & @LF)

$hTB = _GUICtrlToolbar_FindToolbar($hWin, "&View")
ConsoleWrite("Debug: $hTB = " & $hTB & @LF)

$sClass = _WinAPI_GetClassName($hTB)
ConsoleWrite("Debug: $sClass = " & $sClass & @LF)

$iBCnt = _GUICtrlToolbar_ButtonCount($hTB)
ConsoleWrite("Debug: $iBCnt = " & $iBCnt & @LF)

ConsoleWrite(@TAB & "index: CommandID - Text" & @LF)
For $i = 0 To $iBCnt - 1
    ConsoleWrite(@TAB & $i & ": " & _
        _GUICtrlToolbar_IndexToCommand($hTB, $i) & " - " & _
        _GUICtrlToolbar_GetButtonText($hTB, _GUICtrlToolbar_IndexToCommand($hTB, $i)) & @LF)
Next

WinActivate($hWin)
WinWaitActive($hWin)
_GUICtrlToolbar_ClickIndex($hTB, 2, "Left", True); 2 = index for '&View'
Sleep(500)
Send("e"); Explorer Bar
Sleep(500)
Send("f"); Folders

This is still kind of lame, because when you click on View, it opens another Class #32778 window with no controls visible to AutoIt. The popup menu window has a different handle than the parent, so this just uses Send() vice ControSend().

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Mr. PSalty,

My autoit3 doesn't recognize this function: _GUICtrlToolbar_ClickIndex and I can't find it in the list. Is it part of autoit beta?

I found a _GUICtrl_PressButton, however.

When I use it in the code it will change the color of "view" in the Explorer menu bar, but nothing else happens. And alls I get with the sendkeys is a system beep to tell me I can't do that. Surely it isn't that difficult of a thing to script a code to change the view in explorer?

- Brother Gabriel-Marie

Link to comment
Share on other sites

Mr. PSalty,

My autoit3 doesn't recognize this function: _GUICtrlToolbar_ClickIndex and I can't find it in the list. Is it part of autoit beta?

It's a UDF in one of the extra include files that comes with AutoIt. Just add "#Include <GuiToolBar.au3>" to the top of your script.

I found a _GUICtrl_PressButton, however.

When I use it in the code it will change the color of "view" in the Explorer menu bar, but nothing else happens. And alls I get with the sendkeys is a system beep to tell me I can't do that. Surely it isn't that difficult of a thing to script a code to change the view in explorer?

There is probably a Reg hack somewhere for it, I don't recall. But as you found, automation of the GUI window for it is not trivial given the restriction YOU came up with, to whit: "But I have the alt key command turned off on my computer, so I can't use the sendkeys function."

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Why not just do this:

#include <GuiListView.au3>
$Hwnd = ControlGetHandle("", "", 1)
_GUICtrlListView_SetView($hWnd, 2);2=listview

You have to make the Title/text parameters if you don't plan on using the active window.

I don't get it. How does that control the Folders pane? I don't think that is the "view" being discussed here.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't get it. How does that control the Folders pane? I don't think that is the "view" being discussed here.

:)

Oh my bad. :P

thought he was talking about listview of a folders o something. I dunno i misread.

Link to comment
Share on other sites

Okay, I was figuring things and found that the underline for the alt command was only "hidden", that is, it isn't displayed, but the keys still work. And I HAVE included the #Include <GuiToolBar.au3> command. (sorry for being burdensome...)

- Brother Gabriel-Marie

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...