批处理不起作用
批处理脚本并不意味着与 GUI 一起操作。对于所选工具,描述的目标似乎几乎不可能。也许,批处理可以解决一些重新制定的任务,例如将项目相关发票的软链接放入 tmp 文件夹,这样您就可以在一个地方看到它们。尽管如此,恕我直言,解决方案将非常庞大且痛苦。不过,有一个好消息:
AutoIt会做
AutoIt是一种免费软件,类似 BASIC 的脚本语言,旨在自动化 Windows GUI 和一般脚本。
准确描述行为的整个脚本总共用了 10 行(不包括评论):
;script is supposed to be run from root folder of any individual project
#include <File.au3>
;split full project path into array of folder names
Global $aProjFolderTree = StringSplit(@WorkingDir, "\/")
;get name of the last folder. It should be project name like "356 - 22 St. Lewes Avenue"
Global $sProjLastFolderName = $aProjFolderTree[$aProjFolderTree[0]]
;split project name into words
Global $aProjNameWords = StringSplit($sProjLastFolderName, " ")
;get the first word which is project ID like "356"
Global $sProjId = $aProjNameWords[1]
;open invoice directory in explorer
Global $sInvoiceFolder = _PathFull("..\invoice", @WorkingDir)
Run('explorer.exe ' & $sInvoiceFolder)
;wait until it's ready
WinWaitActive("invoice", "", 10)
;click onto "search" control. NB! control ID may differ on your system, use "AutoIt Window Info" tool to check
ControlClick( "[LAST]", "", "[CLASS:DirectUIHWND; INSTANCE:1]")
;put project Id into it
ControlSend( "[LAST]", "", "[CLASS:DirectUIHWND; INSTANCE:1]", $sProjId)
为了运行:
- 安装 AutoIt
- 在您的项目文件夹中创建script_name.au3文本文件并粘贴提供的代码
- 双击
您可以将脚本打包成可执行文件,如果需要,它可以在没有 AutoIt 的机器上正常运行。