2012-07-26 227 views
1

我有兩個文本框和一個按鈕。如何在文本框中輸入值並按使用AutoIt輸入按鈕?如何使用AutoIt在文本框中輸入值?

+4

歡迎來到Stack Overflow!我們鼓勵你[研究你的問題](http://stackoverflow.com/questions/how-to-ask)。如果你已經[嘗試了某些東西](http://whathaveyoutried.com/),請將其添加到問題中 - 如果沒有,請先研究並嘗試您的問題,然後再回來。 – 2012-07-26 14:09:23

+0

我試過用ControlstText不能正常工作 – user1554488 2012-07-26 14:44:28

回答

4

就是這麼簡單的一個例子:

$gui = GUICreate("Test GUI", 640, 280) 
$input = GUICtrlCreateInput("Input field", 10, 10, 620, 20) 
$edit = GUICtrlCreateEdit("Edit Control with Text", 10, 40, 620, 200) 
$button = GUICtrlCreateButton("Button", 10, 250, 620, 20) 

GUISetState(@SW_SHOW) 

Sleep(2000) 

ControlSetText("Test GUI", "", $input, "New text for the input") 
ControlSetText("Test GUI", "", $edit, "New text for the edit... with some bla bla bla...") 
Sleep(500) 
ControlClick("Test GUI", "", $button) 
Sleep(500) 
ControlFocus("Test GUI", "", $input) 

Sleep(4000) 

ControlSetText("Test GUI", "", "[CLASS:Edit; INSTANCE:1]", "New text for the input, referenced as Edit1") 
ControlSetText("Test GUI", "", "[CLASS:Edit; INSTANCE:2]", "New text for the edit..., referenced as Edit2 with some bla bla bla...") 
Sleep(500) 
ControlClick("Test GUI", "", "[CLASS:Button; INSTANCE:1]") 
Sleep(500) 
ControlFocus("Test GUI", "", $input) 

Sleep(4000) 

再說,你的英語還不是很清楚,你應該把多一點的努力,你的問題;-)

如果你想找出,你必須使用什麼"[CLASS:Edit; INSTANCE:1]",試試「AutoIt v3窗口信息」tool。並開始閱讀一些非常好的文檔。祝你好運!

2
  1. 您可以使用如下ControlSend功能:

    ControlSend( 「窗口標題」, 「」, 「」, 「名爲myUsername {TAB} MyPassword輸入{ENTER}」)

  2. 它可以

    發送( 「用戶名」)
    發送( 「{TAB}」)
    發送( 「密碼」)
    發送( 「{} ENTER」:也可以通過使用發送函數來完成)

相關問題