BGM Posted June 18, 2008 Share Posted June 18, 2008 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 More sharing options...
PsaltyDS Posted June 18, 2008 Share Posted June 18, 2008 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 More sharing options...
BGM Posted June 19, 2008 Author Share Posted June 19, 2008 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 More sharing options...
PsaltyDS Posted June 19, 2008 Share Posted June 19, 2008 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 More sharing options...
BGM Posted June 21, 2008 Author Share Posted June 21, 2008 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 More sharing options...
PsaltyDS Posted June 22, 2008 Share Posted June 22, 2008 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 More sharing options...
Paulie Posted June 22, 2008 Share Posted June 22, 2008 (edited) 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. Edited June 22, 2008 by Paulie Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 22, 2008 Share Posted June 22, 2008 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 More sharing options...
Paulie Posted June 23, 2008 Share Posted June 23, 2008 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. thought he was talking about listview of a folders o something. I dunno i misread. Link to comment Share on other sites More sharing options...
BGM Posted June 23, 2008 Author Share Posted June 23, 2008 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 More sharing options...
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