Sign in to follow this  
Followers 0
sladisch

Click an item in TreeView or SysTreeView32

5 posts in this topic

Hi @ all,

I'm quite new to autoit and I try to automate the postprocessing of an FEA using Autodesk Mechanical Simulation. For this I need to double click an item in a SysTreeView32. I think the tree view was modified by autodesk. Because on the top level I can only expand the activated item. Activating another item causes some calculation.

Here you can sse the tree:

autodesk.png

 

This what i have so far (some sleeps and console print to check the script):

Func _Au3Setup()
   Opt('WinDetectHiddenText',1)
   Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=10)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
 
 
 _Au3Setup()
 _WinWaitActivate("Autodesk Simulation Mechanical 2013","")
 
ConsoleWrite (@CRLF & "WinWaitActive")

#Include <GuiTreeView.au3>

$hwnd = ControlGetHandle ( "Autodesk Simulation Mechanical", "", "[CLASS:SysTreeView32; INSTANCE:2]" )
ControlTreeView  ( "Autodesk Simulation Mechanical", "", "[CLASS:SysTreeView32; INSTANCE:2]", "Expand", "#0" )
ConsoleWrite (@CRLF & "Collapse")
Sleep(1500)
ControlTreeView  ( "Autodesk Simulation Mechanical", "", "[CLASS:SysTreeView32; INSTANCE:2]", "Expand", "#0|#8" )
ConsoleWrite (@CRLF & "Expand")
Sleep(1500)
ControlTreeView  ( "Autodesk Simulation Mechanical", "", "[CLASS:SysTreeView32; INSTANCE:2]", "Select", "#0|#8" )
ConsoleWrite (@CRLF & "Select")
Sleep(1500)

$control=ControlTreeView  ( "Autodesk Simulation Mechanical", "", "[CLASS:SysTreeView32; INSTANCE:2]", "GetText", "#0|#8" )

_WinAPI_SetFocus(ControlGetHandle("Test", "", $hInput))

$find=_GUICtrlTreeView_FindItem ( $hwnd, $control )
$bla=_GUICtrlTreeView_ClickItem ( $hwnd, $find, "left", False, 2 )

ConsoleWrite (@CRLF & $control)

AutoIt Info says:

>>>> Window <<<<
Title:  Autodesk Simulation Mechanical 2013 - [Ergebnisse - [dynamische_lastffaelle : Stress]]
Class:  AlgFrame_MainWindow
Position:   -8, -8
Size:   1936, 1056
Style:  0x15CF0000
ExStyle:    0x00000110
Handle: 0x001F0AD6

>>>> Control <<<<
Class:  SysTreeView32
Instance:   2
ClassnameNN:    SysTreeView322
Name:   
Advanced (Class):   [CLASS:SysTreeView32; INSTANCE:2]
ID: 101
Text:   
Position:   10, 203
Size:   435, 819
ControlClick Coords:    255, 362
Style:  0x5010002F
ExStyle:    0x00000000
Handle: 0x001508A4

>>>> Mouse <<<<
Position:   265, 557
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<
1:  
2:  
3:  
4:  
5:  

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Ergebnisse - [dynamische_lastffaelle : Stress]
FEM-Editor - [dynamische_lastffaelle.fem]
AdImpApplicationFrame
QATHwndSource
InfoCenterHwndSource
RibbonBar
RibbonHwndSource
Autodesk Simulation Mechanical                                                                                                                                                               
Autodesk Simulation Mechanical                                                                                                                                                               


>>>> Hidden Text <<<<
Fatigue Wizard
Werkzeuge
Geometrie
Berechnung
Automatische Vernetzungswerkzeuge
Netz
Optionen anzeigen
Anzeigeoptionen
Blickwinkel
Auswahlform
Bearbeiten
Animation
Allgemeine Optionen
Schnittflächen
Lastfall
Ergebnisoptionen
Anzeigeoptionen
Auswahl
Auswahlform
Blickwinkel
Actions
Bearbeiten
Fenster
Datei
Menueleiste

Thank you for your help!

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe try...

ControlTreeView('[CLASS:AlgFrame_MainWindow]', '', '[CLASS:SysTreeView32; INSTANCE:2]', 'Check', 0) ; You might need to change the index.

Edit: Oh and welcome to the Forum, just saw the rest of the code and seems you know quite a bit already. hmm, dunno if that code above will work then?!

Edited by guinness
1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Now im running into another Problem. It seems, that the access via ControlTreeView doesn't work. I reduced the script to do some testing. Both Commands throw errors.

Func _Au3Setup()
   Opt('WinDetectHiddenText',1)
   Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=10)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
 

 
 _Au3Setup()
 _WinWaitActivate("Autodesk Simulation Mechanical 2013","")
 
ConsoleWrite (@CRLF & "WinWaitActive")

$class_treeview = "[CLASS:SysTreeView32; INSTANCE:2]"

   
ControlTreeView("Autodesk Simulation Mechanical 2013", "", $class_treeview, "Expand", "#0")
If @error Then
   MsgBox(4096, "Test", "Item not expanded", 10)
Else
    MsgBox(4096, "Test", "Item expanded", 10)
 EndIf
 
 ControlTreeView("Autodesk Simulation Mechanical 2013", "", $class_treeview, "Check", "#0")
If @error Then
   MsgBox(4096, "Test", "Item not checked", 10)
Else
    MsgBox(4096, "Test", "Item checked", 10)
EndIf

Share this post


Link to post
Share on other sites

Hi all,

I am new to autoit and I have an urgent question:

What if there are several trees in my GUI, and according to Autoit Windows Info, they all have the same class and instance such as

"[CLASS:SysTreeView32; INSTANCE:1]"

I only want to expand ONE specific tree.

Thanks!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

I never faced this, but you can try to enumerate the controls with the function _WinAPI_EnumChildWindows (available in the WinAPIEx UDF) and according to the class find the handle of the 2nd treeview.

Then you can manipulate it with the _GUICtrlTreeView* functions.

Edit: Please next time make another topic instead of hijacking this one.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0