2012-09-14 62 views
0

我想自動安裝在我的機器上的軟件。我正在使用AutoIt,但在一個屏幕上,我無法獲得控件ID或標題,因此我可以訪問該控件,然後在其中找到文本。我想單擊該文本,所以我需要該文本的座標。如何使用c#代碼或任何其他第三方工具獲得協調的文本可以幫助我做到這一點? 我檢查了谷歌,但我無法得到任何有趣或有用的東西。 任何與此問題有關的事情將不勝感激。如何在屏幕上查找文本並使用c#獲取其座標?

+0

你有沒有嘗試過使用「[AutoIt v3窗口信息](http://www.autoitscript.com/autoit3/docs/intro/au3spy.htm)」? – Samoth

+0

是的,我已經嘗試過,但問題是AutoIT捕獲樹視圖控制作爲一個單一的實體。所以它不允許我在treeview控件中選擇/搜索一些文本。你有任何想法如何找到選擇特定的文本,並發現文本協調,使我可以點擊該特定的鏈接。 –

+0

嗯,你能提供一個例子嗎?否則就會猜測到藍色。窗口信息工具中的「可見文本」字段或「隱藏文本」字段中是否有一些內容? – Samoth

回答

0

正如其他人所說,你問的問題有點模糊。你想要什麼樣的軟件自動化?你想更精確地自動化? (鼠標操作?點擊?軟件上的一些特殊功能?)

關於鼠標點擊舉例,有兩種主要的方法來自動化進程: 基於屏幕座標的點擊或基於窗口座標的點擊。 下面,你可以找到一個例子來具體實現自動化的應用程序從「web平臺安裝5.0」(你可以從微軟網站下載@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}")