如何获取和设置 Windows 资源管理器视图设置
How to get and set Windows Explorer view settings
我正在尝试在 Windows 资源管理器中制作脚本循环视图(Windows 7 个库不允许记住每个文件夹的视图设置)。
我发现 postMessage
带有 WM_COMMAND
消息(代码 0x111
),但似乎无法使用它来影响资源管理器视图。我发送时没有任何反应:
PostMessage,0x111,0x702c,0,,ahk_id %parent%
其中 %parent%
是 window 的句柄。论坛上的示例适用于 Windows XP,它的工作方式似乎有所不同。如何获取和设置视图设置?
您可以尝试以下方法。它启动一个持久性脚本,该脚本运行一个计时器子例程寻找另存为类型 windows,当它遇到一个时,它会发送找到的 window 某些击键。请注意,发送的键肯定取决于您使用的 Win 版本——我在使用标准 Win 7 快捷方式时遇到了麻烦,因此使用了一个笨拙的解决方法。从代码中的注释中应该可以清楚地看到我在做什么,这应该可以让您按自己的方式去做您需要做的事情。
#Persistent
SetTitleMatchMode, 2 ; Matches all titles with the designated words in it (picks the top most)
SetTimer, MaxAll, 150 ; time in ms
return
MaxAll:
IfWinActive, Save MoviePlus File As ; runs only on "Save MoviePlus File As"
DoIt("Movie")
IfWinActive, Save ; runs on "Save" "Save As" "Save File" etc.
DoIt("Save")
IfWinExist, Open ; runs on "Open" "Open File" "File Open" etc.
DoIt("Open")
IfWinExist, Import ; runs on "Import" "File Import" "Import Commands" etc.
DoIt("Import")
return
DoIt(Type)
{
SetTimer, MaxAll, Off ; turn of timer
sleep, 250
WinMaximize ; maximize the window (or comment out)
sleep, 250
Send, !n ; start at the Filename textbox
sleep, 250
Send, +{tab} ; SHIFT+TAB to move to files pane
sleep, 250
; Send, ^+5 ; CTRL+SHIFT+5: Win8.1 to go to "List View"
; Send, ^!5 ; CTRL+ALT+5: Win8 to go to "List View"
; Send, {LAlt}vl ; LEFTALT+V+L: Win7 to go to "List View" - but doesn't work consistently
SendEvent, {F3}{tab}{right 2}{down}{end}{up 3}{enter} ; Navigate to "View" drop-down-list starting from from search bar
sleep, 250
IfEqual, Type, Open ; If the dialog was a File Open
{
Send, !p ; ALT+P: Toggles preview pane
sleep, 250
}
IfEqual, Type, Movie ; If the dialog was for MoviePlus
{
Send, ^!p ; Ctrl+ALT+P: Toggles preview pane? Google the keyboard shortcuts (I didn't check)
sleep, 250
}
Send, !n ; back to Filename textbox
WinWaitClose ; wait to close the dialog
SetTimer, MaxAll, On ; turn timer back on
return
}
+esc::ExitApp ; Shift+Esc ends script
HTH,
找到适合我的 AutoIt UDF。它被称为automating windows explorer。下面的代码是我根据论坛示例编写的,它显示了一个获取视图并通过递增现有状态来更改它的工作示例。
因为它适用于 Windows 7 我跳过了缩略图和拇指条视图——我认为它们适用于 Vista。 Vista 也不支持内容视图。
我用谷歌搜索了 Windows 常量名称和值。我根据自己的结果 experimenting/looking 找到了正确的视图大小。
#include "Includes\AutomatingWindowsExplorer.au3"
;Icon sizes are standard: 16, 48, 96, 196
;Details & list: 16
;Tiles: 48
;Content: 32 (!)
;~ FVM_ICON = 1, (48, 96, 196)
;~ FVM_SMALLICON = 2, (16)
;~ FVM_LIST = 3,
;~ FVM_DETAILS = 4,
;~ FVM_THUMBNAIL = 5, (seems to be same as ICON in win7)
;~ FVM_TILE = 6,
;~ FVM_THUMBSTRIP = 7, (seems to be same as ICON in win7)
;~ FVM_CONTENT = 8,
Opt( "MustDeclareVars", 1 )
Example()
Func Example()
; Windows Explorer on Vista, 7, 8
Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" )
If Not $hExplorer Then
MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." )
Return
EndIf
; Get an IShellBrowser interface
GetIShellBrowser( $hExplorer )
If Not IsObj( $oIShellBrowser ) Then
MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." )
Return
EndIf
; Get other interfaces
GetShellInterfaces()
; Get current icon view
Local $view = GetIconView() ;returns array [view,size]
; Determine the new view
Local $iView, $iSize, $iNewView, $iNewSize
$iView = $view[0] ; Icon view
$iSize = $view[1] ; Icon size
If $iView = 8 Then
$iNewView = 1
$iNewSize = 48
Else
$iNewView = $iView + 1
If $iNewView = 5 Or 7 Then
$iNewView += 1 ;skip from 5 to 6, or from 7 to 8
EndIf
EndIf
Switch $iNewView
Case 2 To 4
$iNewSize = 16
Case 6
$iNewSize = 48
Case 8
$iNewSize = 32
EndSwitch
;MsgBox( 0, "NewView", $iNewView )
SetIconView( $iNewView, $iNewSize ) ; Set details view
Sleep( 1000 ) ; Wait
SetIconView( $iView, $iSize ) ; Restore old view
EndFunc
我正在尝试在 Windows 资源管理器中制作脚本循环视图(Windows 7 个库不允许记住每个文件夹的视图设置)。
我发现 postMessage
带有 WM_COMMAND
消息(代码 0x111
),但似乎无法使用它来影响资源管理器视图。我发送时没有任何反应:
PostMessage,0x111,0x702c,0,,ahk_id %parent%
其中 %parent%
是 window 的句柄。论坛上的示例适用于 Windows XP,它的工作方式似乎有所不同。如何获取和设置视图设置?
您可以尝试以下方法。它启动一个持久性脚本,该脚本运行一个计时器子例程寻找另存为类型 windows,当它遇到一个时,它会发送找到的 window 某些击键。请注意,发送的键肯定取决于您使用的 Win 版本——我在使用标准 Win 7 快捷方式时遇到了麻烦,因此使用了一个笨拙的解决方法。从代码中的注释中应该可以清楚地看到我在做什么,这应该可以让您按自己的方式去做您需要做的事情。
#Persistent
SetTitleMatchMode, 2 ; Matches all titles with the designated words in it (picks the top most)
SetTimer, MaxAll, 150 ; time in ms
return
MaxAll:
IfWinActive, Save MoviePlus File As ; runs only on "Save MoviePlus File As"
DoIt("Movie")
IfWinActive, Save ; runs on "Save" "Save As" "Save File" etc.
DoIt("Save")
IfWinExist, Open ; runs on "Open" "Open File" "File Open" etc.
DoIt("Open")
IfWinExist, Import ; runs on "Import" "File Import" "Import Commands" etc.
DoIt("Import")
return
DoIt(Type)
{
SetTimer, MaxAll, Off ; turn of timer
sleep, 250
WinMaximize ; maximize the window (or comment out)
sleep, 250
Send, !n ; start at the Filename textbox
sleep, 250
Send, +{tab} ; SHIFT+TAB to move to files pane
sleep, 250
; Send, ^+5 ; CTRL+SHIFT+5: Win8.1 to go to "List View"
; Send, ^!5 ; CTRL+ALT+5: Win8 to go to "List View"
; Send, {LAlt}vl ; LEFTALT+V+L: Win7 to go to "List View" - but doesn't work consistently
SendEvent, {F3}{tab}{right 2}{down}{end}{up 3}{enter} ; Navigate to "View" drop-down-list starting from from search bar
sleep, 250
IfEqual, Type, Open ; If the dialog was a File Open
{
Send, !p ; ALT+P: Toggles preview pane
sleep, 250
}
IfEqual, Type, Movie ; If the dialog was for MoviePlus
{
Send, ^!p ; Ctrl+ALT+P: Toggles preview pane? Google the keyboard shortcuts (I didn't check)
sleep, 250
}
Send, !n ; back to Filename textbox
WinWaitClose ; wait to close the dialog
SetTimer, MaxAll, On ; turn timer back on
return
}
+esc::ExitApp ; Shift+Esc ends script
HTH,
找到适合我的 AutoIt UDF。它被称为automating windows explorer。下面的代码是我根据论坛示例编写的,它显示了一个获取视图并通过递增现有状态来更改它的工作示例。
因为它适用于 Windows 7 我跳过了缩略图和拇指条视图——我认为它们适用于 Vista。 Vista 也不支持内容视图。
我用谷歌搜索了 Windows 常量名称和值。我根据自己的结果 experimenting/looking 找到了正确的视图大小。
#include "Includes\AutomatingWindowsExplorer.au3"
;Icon sizes are standard: 16, 48, 96, 196
;Details & list: 16
;Tiles: 48
;Content: 32 (!)
;~ FVM_ICON = 1, (48, 96, 196)
;~ FVM_SMALLICON = 2, (16)
;~ FVM_LIST = 3,
;~ FVM_DETAILS = 4,
;~ FVM_THUMBNAIL = 5, (seems to be same as ICON in win7)
;~ FVM_TILE = 6,
;~ FVM_THUMBSTRIP = 7, (seems to be same as ICON in win7)
;~ FVM_CONTENT = 8,
Opt( "MustDeclareVars", 1 )
Example()
Func Example()
; Windows Explorer on Vista, 7, 8
Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" )
If Not $hExplorer Then
MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." )
Return
EndIf
; Get an IShellBrowser interface
GetIShellBrowser( $hExplorer )
If Not IsObj( $oIShellBrowser ) Then
MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." )
Return
EndIf
; Get other interfaces
GetShellInterfaces()
; Get current icon view
Local $view = GetIconView() ;returns array [view,size]
; Determine the new view
Local $iView, $iSize, $iNewView, $iNewSize
$iView = $view[0] ; Icon view
$iSize = $view[1] ; Icon size
If $iView = 8 Then
$iNewView = 1
$iNewSize = 48
Else
$iNewView = $iView + 1
If $iNewView = 5 Or 7 Then
$iNewView += 1 ;skip from 5 to 6, or from 7 to 8
EndIf
EndIf
Switch $iNewView
Case 2 To 4
$iNewSize = 16
Case 6
$iNewSize = 48
Case 8
$iNewSize = 32
EndSwitch
;MsgBox( 0, "NewView", $iNewView )
SetIconView( $iNewView, $iNewSize ) ; Set details view
Sleep( 1000 ) ; Wait
SetIconView( $iView, $iSize ) ; Restore old view
EndFunc