如何使 .NET 控件与 Autoit 一起使用,因为它只能与 STANDARD 控件一起使用
我有以下代码
#Include <GuiComboBox.au3>
#Include <GuiComboBoxEX.au3>
#include <GUIListBox.au3>
#include <GUIConstantsEx.au3>
;~#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
global $hcombo = "[NAME:ctlMsgQueueCombo]"
global $hcomboclass = "[CLASS:WindowsForms10.COMBOBOX.app.0.2bf8098_r15_ad12]"
global $title = "Test Form"
global $index = 0
WinActivate ($title)
;Start test executable
Run("Z:\test\Info.Test\bin\Debug\Info.Test.exe")
sleep(6000)
controlFocus("", "", "[NAME:ctlSelector]")
controlsend("", "", "[NAME:ctlSelector]", 'QWER67')
sleep(1000)
local $shcombo = ControlGetHandle($title, "", $hcombo)
local $sText = 'TYY Processor (QWERYY980) - Q00S00'
_GUICtrlComboBox_SelectString($shcombo, $sText)
,因为此代码从下拉列表中选择项目,但实际上没有设置对象引用。我怎样才能用 autoit 做到这一点?
I have the following code
#Include <GuiComboBox.au3>
#Include <GuiComboBoxEX.au3>
#include <GUIListBox.au3>
#include <GUIConstantsEx.au3>
;~#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
global $hcombo = "[NAME:ctlMsgQueueCombo]"
global $hcomboclass = "[CLASS:WindowsForms10.COMBOBOX.app.0.2bf8098_r15_ad12]"
global $title = "Test Form"
global $index = 0
WinActivate ($title)
;Start test executable
Run("Z:\test\Info.Test\bin\Debug\Info.Test.exe")
sleep(6000)
controlFocus("", "", "[NAME:ctlSelector]")
controlsend("", "", "[NAME:ctlSelector]", 'QWER67')
sleep(1000)
local $shcombo = ControlGetHandle($title, "", $hcombo)
local $sText = 'TYY Processor (QWERYY980) - Q00S00'
_GUICtrlComboBox_SelectString($shcombo, $sText)
As this code is selecting the item from the dropdown but actually not setting the object ref. How can I do it with autoit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AutoIt 可以很好地与 .NET 控件一起工作。 .NET 创建的控件属于标准控件类别。由 Java 或 WPF 制作的控件则不然。 COM 可访问与此无关。
也就是说,您的 AutoIt 代码中可能存在一些错误。我不能确切地说在哪里,因为我不明白“但实际上没有设置对象引用”是什么意思。
一些指针,尽可能使用 $title 而不是空字符串:
_GUICtrlComboBox_SelectString 可以处理部分字符串。因此,不要:
做:
看看它是否有效。请发回更多有关失败原因的信息。使用正确的调试程序,例如: 始终检查代码中的错误。不要假设 $shcombo 有效等。
AutoIt can work with .NET controls just fine. .NET created controls fall under the category standard controls. Controls such as those made by Java or WPF do not. Being COM accessible has nothing to do with it.
That said, it looks like there are probably some errors in your AutoIt code. I can't say exactly where because I don't understand what "but actually not setting the object ref" means.
Some pointers, use the $title where possible instead of empty string:
_GUICtrlComboBox_SelectString can work with partial strings. So instead of:
Do:
And see if it works. Please post back with some more information on exactly what is failing. Use proper debug procedures, for example: Always check errors in your code. Don't assume $shcombo is valid etc.
我猜你说的“标准”控件是指 COM 可访问的控件?
如果是这样,那么您可能需要使您的 .NET 控件/组件可由 COM 接口使用。这是简短说明,以及更详细的< /a>.
By "standard" controls I'm guessing you mean COM-accessible ones?
If so, then you probably need to make your .NET controls/components usable by the COM interface. Here's a short explanation, and a more detailed one.