也许,你不使用现成的牧师行为,更不用最充分地使用自动骑师,以完成整个行动,而不用介绍主要的新闻。
I can t be sure what your entire operation will entail based on the details given. For example, you did not indicate where hoge.jpg exists currently. Also, how should it determine whether it ends up in the 2023 or 2024? These things could be further automated instead of relying on the current state of Windows Explorer.
无论如何,例如,我举一个例子,表明我能做我认为你再次要求的事情,但根据你的情况,可能还有更好的办法。 只有提供充分的信息,才能适当解决这一问题。
<^z::
{
; get the HWND of the current active Windows Explorer window
If (!(WinHWND := WinActive("ahk_class CabinetWClass")) &&
!(WinHWND := WinActive("ahk_class ExploreWClass"))) {
; if no Explorer window is active, cancel and do nothing
return
}
; get the Window title to ensure proper tab
; (this logic can be skipped if not using tabbed Explorer)
winTitle := WinGetTitle("ahk_id " WinHWND)
for window in ComObject("Shell.Application").Windows {
; The following works for getting the active window (and tab) for
; Explorer in Windows 10/11, but it can mess up if two tabs in the same
; Explorer window have the same window title in Windows 11
if (window.hwnd == WinHWND && window.LocationName == winTitle) {
; get the COM Object of the FIRST selected item in Explorer
selectedFolder := window.Document.SelectedItems().Item(0)
; get the full path of the item above
selectedFolderPath := selectedFolder.Path
; Some other useful variables, albeit unnecessary in this example:
currentDirectory := window.Document.Folder.Self.Path
selectedFolderName := selectedFolder.Name ; just the folder name itself
; The active window was found, so stop looping the Explorer windows
break
}
}
; A_Clipboard contains the full path of the file in the clipboard (cut/copy)
; Move the file in the clipboard to the first folder selected in Explorer
FileMove A_Clipboard, selectedFolderPath
}