我想自动化安装在我机器上的软件。我正在使用 AutoIt,但在一个屏幕上我无法获取控件 ID 或标题,因此我可以访问该控件,然后在其中查找文本。我想点击那个文本,所以我需要那个文本的坐标。我如何使用 c# 代码或任何其他第三方工具来协调该文本?我在谷歌上查过,但我找不到任何有趣或有用的东西。任何与此问题相关的事情将不胜感激。
问问题
2238 次
1 回答
0
正如其他人所说,你问的问题有点模糊。您希望自动化哪种软件?你想更精确地自动化什么?(鼠标动作?点击?软件上有什么特别的东西?..)
例如,关于鼠标点击,有 2 种主要方法可以自动执行流程:基于屏幕坐标的点击或基于窗口坐标的点击。下面,您可以找到一个示例,以从“Web 平台安装程序 5.0”(您可以从 Microsoft 网站 @https ://azure.microsoft.com/en-us/tools/下载)自动安装特定应用程序—— >视觉工作室 2015)
;Gives Admin rights to autoIT
#RequireAdmin
;launches the program in the same directory as the installer
Run(@ScriptDir & '\azure.exe')
;Sets the coordinates as window coordinates with "0" (VS screen coordinates)
AutoItSetOption('MouseCoordMode',0)
;Waits for the program to open and to display a text like "Microsoft Web Platform Installer"
WinWait("Web Platform Installer 5.0","Microsoft Web Platform Installer")
;wait 1.5 seconds
sleep(1500)
;When the window is visible, le cursor is set as active ont that window (IMPORTANT)
WinActivate("Web Platform Installer 5.0")
;the following commands are mouseclicks on specific boxes of the program to automate specific installs on the installer
;MouseClick('primary', x, y, 1, speed (1 to 10))
; You will find those coordinates in the "AU3info.exe file" after you've installed autoIT ( Au3info allows to find coordinates
; by targeting specific places on a window)
MouseClick('primary', 155, 60, 1, 10)
sleep(1500)
;selects 4 apps to be installed (4 installs), clics INSTALL and waits 1.5 sec
MouseClick('primary', 817, 122, 1, 10)
MouseClick('primary', 821, 163, 1, 10)
MouseClick('primary', 815, 401, 1, 10)
MouseClick('primary', 828, 519, 1, 10)
MouseClick('primary', 692, 587, 1, 10)
sleep(1500)
;Prepaing the install and waiting till a text like "Review the following list" apprears
WinWait("Web Platform Installer 5.0","Review the following list")
WinActivate("Web Platform Installer 5.0")
sleep(1500)
MouseClick('primary', 43, 350, 1, 10)
MouseClick('primary', 603, 433, 1, 10)
;starts the installation and waits till the installation is finished (when "The following"..programm has installed ..blabla
WinWait("Web Platform Installer 5.0","The following")
MouseClick('primary', 612, 434, 1, 2)
;gets rid of some issues stemming from microsoft edge (the send functions allows to send keyboard keys (like ESC, SPACE, ALT, etc..))
sleep(1000)
Send("{ENTER}")
MouseClick('primary', 612, 434, 1, 2)
sleep(1000)
Send("{ENTER}")
;quits all the windows with ALT + F4
WinWait("Web Platform Installer 5.0")
WinActivate("Web Platform Installer 5.0")
Sleep(1000)
Send("{ALT down}{F4 down}{F4 up}{ALT up}")
Sleep(1000)
Send("{ALT down}{F4 down}{F4 up}{ALT up}")
于 2016-08-29T14:53:54.237 回答