2012-07-26 230 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”:也可以通过使用发送函数来完成)

相关问题