Not wishing to stick this into Chuck's thread but
- Assuming WB can create a window from XAML [see code below]
- WB/CLR [right now] cannot control events, i.e. OnClick()[/r][/r][/r]
- Could adding UI.Automation code to the script permit handling a button and through Sendkeys or WB Mouse Click simulate the OnClick()
More a non-relevant question at this point. WB can build a better looking dialog w/out CLR and work with controls. And, seems UI. Automation is a lot of excessive code for a simple click..... However, I do see a future with windows.forms
NOTE: change
' back to ' if using code
;CLR - test XAML Buttons
XAML = $"
<Window
xmlns="http:://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns::x="http:://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="300" Width="300">
<StackPanel>
<Button x::Name="button0" Content="Main Menu"/>
<Button x::Name="button1" Content="First App"/>
<Button x::Name="button2" Content="Second App"/>
<Button x::Name="button3" Content="Third App"/>
<Button x::Name="button4" Content="Fourth App"/>
<Button x::Name="button5" Content="Exit"/>
<ScrollViewer x::Name="scrollViewer" Height="150">
<TextBlock x::Name="msg" TextWrapping="Wrap"/>
</ScrollViewer>
</StackPanel>
</Window>
$"
Message("XAML",XAML)
_True = ObjectType('BOOL',1)
_False = ObjectType('BOOL',0)
ObjectClrOption('useany','System')
ObjectCLrOPtion('useany','PresentationFramework')
ObjectCLrOPtion('useany','PresentationCore')
ObjectClrOption('useany','System.Xml')
oDOc = ObjectClrNew('System.Xml.XmlDocument')
oDoc.LoadXml(XAML)
oXML = ObjectClrNew('System.Xml.XmlNodeReader',oDoc)
;create list pair to identify Buttons
;====================================================================================================
blist =""
elements = oDoc.GetElementsByTagName("Button")
n = elements.Count
For i = 0 To n-1
n1 = elements.Item(i).Attributes.Count
att = ""
For j=0 To n1-1
att = att:elements.Item(i).Attributes.Item(j).Name:"="
att = att:elements.Item(i).Attributes.Item(j).Value:","
Next
blist = blist:strsub(att,1,strlen(att)-1):@LF
Next
Message("XAML Buttons",blist)
;====================================================================================================
;Load Xaml
oXamlReader = ObjectClrNew('System.Windows.Markup.XamlReader')
oWin = oXamlReader.Load(oXML)
oWin = ObjectClrType( 'System.Windows.Window', oWin )
;Display Window for 5 seconds then close
;otherwise oWin.ShowDialog() will keep Window Open
oWin.Show()
TimeDelay(5)
oWin.Close()
Exit
;====================================================================================================