我有一个长长的列表文件夹,我需要将以下两个信息自动电子表格到我们现有的Excel文档中:
我已经编写了脚本,直到现在我需要AHK来获取活动资源管理器窗口的文件计数,复制到剪贴板并将ALT + TAB /粘贴到电子表格中。我计划使用“ goto”循环播放此脚本,并对其进行监视直到到达最后一个文件夹,然后使用ESC结束该脚本。
获取活动窗口的数值文件计数并将其复制到剪贴板的最简单方法是什么?
到目前为止,我的代码基本上是使用F2来“重命名”,因此将文件夹名称,alt + tab复制到电子表格,粘贴到其中,移动到电子表格上的文件计数单元格,alt + tab返回活动的资源管理器窗口,进入文件夹-现在我卡住了(我需要在剪贴板上获取文件数)。值得注意的是,我希望文件计数忽略系统文件(如.DS_Store)(如果存在)。
`::
{
Send, {F2}
Sleep, 200
Send, {Ctrl Down}
Sleep, 50
Send, c
sleep, 50
Send, {Ctrl Up}
Sleep, 100
Send, {Alt Down}
Sleep, 50
Send, {Tab}
Sleep, 50
Send, {Alt Up}
Sleep, 100
Send, {Ctrl Down}
Sleep, 50
Send, v
sleep, 50
Send, {Ctrl Up}
Sleep, 100
Send, {Right}
Sleep, 50
Send, {Right}
Sleep, 50
Send, {Right}
Sleep, 100
Send, {Alt Down}
Sleep, 50
Send, {Tab}
Sleep, 50
Send, {Alt Up}
Sleep, 100
Send, {Enter}
^^^^^^^^^^^^^ Need my file count / copy to clipboard here
Esc::ExitApp
}
也许看看这样的东西(并在评论中跟进):
; Calculate the number of files in a folder and its subfolders:
SetBatchLines, -1 ; Make the operation run at maximum speed.
FileNum = 0
; FileSelectFolder, WhichFolder ; Ask the user to pick a folder.
WhichFolder := Clipboard ; assumes full path to folder is in clipboard
Loop, Files, %WhichFolder%\*.*, R
{
if A_LoopFileAttrib contains H,R,S ; Skip Hidden, Read-only, or System files
continue ; Skip this file and move on to the next one
FileNum += 1
}
Clipboard := FileNum
ClipWait ; Wait for the clipboard to contain text.
MsgBox %WhichFolder% has %FileNum% files in it (incl. subfolders).
然后,查看以下内容,其中说明了如何读取和循环浏览目录和文件:https : //autohotkey.com/docs/commands/LoopFile.htm。
恩,让我们知道您的表现。。。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句