How to make .NET control work with Autoit as it can work only with STANDARD controls
I have the following c开发者_运维百科ode
#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?
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:
controlFocus($title, "", "[NAME:ctlSelector]")
controlsend($title, "", "[NAME:ctlSelector]", 'QWER67')
_GUICtrlComboBox_SelectString can work with partial strings. So instead of:
local $shcombo = ControlGetHandle($title, "", $hcombo)
local $sText = 'TYY Processor (QWERYY980) - Q00S00'
_GUICtrlComboBox_SelectString($shcombo, $sText)
Do:
local $shcombo = ControlGetHandle($title, "", $hcombo)
local $sText = 'TYY Processor'
_GUICtrlComboBox_SelectString($shcombo, $sText)
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.
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.
精彩评论