【问题标题】:How do I enter a value in a text box using AutoIt?如何使用 AutoIt 在文本框中输入值?
【发布时间】:2012-07-25 03:30:48
【问题描述】:

我有两个文本框和一个按钮。如何在文本框中输入值并使用 AutoItEnter 到按钮?

【问题讨论】:

  • 欢迎来到 Stack Overflow!我们鼓励您research your questions。如果您有 tried something already,请将其添加到问题中 - 如果没有,请先研究并尝试您的问题,然后再回来。
  • 我试过 ControlstText 不工作

标签: autoit


【解决方案1】:

举个例子就这么简单:

$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 Window Info”tool。并开始阅读一些非常好的文档。祝你好运!

【讨论】:

    【解决方案2】:
    1. 您可以使用 ControlSend 功能如下:

      ControlSend("窗口标题", "", "", "MyUsername{TAB}MyPassword{ENTER}")

    2. 也可以使用发送功能来完成:

      发送(“用户名”)
      发送(“{TAB}”)
      发送(“密码”)
      发送(“{ENTER}”)

    【讨论】:

      【解决方案3】:
      AutoItX x = new AutoItX(); 
      x.controlSend("Login Station - Third party App","","","StringToBeEntered",false);
      

      【讨论】:

      • 回答时不要只写代码,最好写一些解释。
      猜你喜欢
      • 2021-10-11
      • 2015-09-03
      • 1970-01-01
      • 1970-01-01
      • 2013-09-04
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多