det54 Posted December 11, 2013 Posted December 11, 2013 (edited) Hi, I'm kind of new to AutoIt, and have been trying to see if I can make it work or if I'll need to purchase something like WinTask. I need to control some things in SolidWorks, and there is an API that helps me to do much of what I require. However, some very important output functions are not available, so I must manually generate cut plots and animations of results. My current control code is written in VBA (Excel 2010), and I am using Win7 x64. In the past, I had some good success with WinTask, and it was able to interact with TreeView32 items in SolidWorks. While looking through some code examples and the help file for AutoIt3, I was hoping I could do similar things using AutoItX from VBA, so that I have my code in the same place and don't have to call external applications/scripts. I found and modified some VBA code that searches for running windows and grabs their handles, but I can not seem to make the handles that get returned work for me at all. For example, if I use the following code: sText = AutoIt.ControlTreeView("SolidWorks Premium 2013 x64 Edition", "", "TreeView326", "GetText", "", "") a treeview32 item gets returned (not the correct one, but it's a start). However, if I replace "TreeView326" with the actual handle: sText = AutoIt.ControlTreeView("SolidWorks Premium 2013 x64 Edition", "", "000000000011073C", "GetText", "", "") nothing happens, and sText = 0. Can someone tell me what I'm doing wrong? The actual code I was trying out is included at the bottom. The returned values from this code are: hWin = 000000000043093C hSTV1 = 000000000011073C hSelection = 0 hNode = 0 Debug: sText = 0 I can't remember how I got it to work before, but at one point it was returning sText = Pit4000, which is not what I was looking for, but it is actually listed in one of the treeview32 items. expandcollapse popupSub Test() Dim hWin As String Dim hSTV1 As String Dim hNode As String Dim AutoIt As New AutoItX3Lib.AutoItX3 Set AutoIt = New AutoItX3Lib.AutoItX3 If Not IsObject(AutoIt) Then MsgBox ("not created") End If Debug.Print AutoIt.WinExists("SolidWorks Premium 2013 x64 Edition") If AutoIt.WinExists("SolidWorks Premium 2013 x64 Edition") = 0 Then Debug.Print "SolidWorks not running..." Else hWin = AutoIt.WinGetHandle("SolidWorks Premium 2013 x64 Edition") End If Debug.Print "hWin = " & hWin AutoIt.WinActivate "SolidWorks Premium 2013 x64 Edition" 'AutoIt.ControlSend "SolidWorks Premium 2013 x64 Edition", "", "swMenu", "!o" 'AutoIt.WinWaitActive (hWin) hSTV1 = AutoIt.ControlGetHandle("SolidWorks Premium 2013 x64 Edition", "swCaption", "SysTreeView326") Debug.Print "hSTV1 = " & hSTV1 ' Read current SysTreeView321 selected text to console hNode = "" While AutoIt.WinExists("SolidWorks Premium 2013 x64 Edition") hSelection = AutoIt.ControlTreeView("SolidWorks Premium 2013 x64 Edition", "", "TreeView326", "GetSelection", "", "") Debug.Print "hSelection = " & hSelection If hSelection <> hNode Then hNode = hSelection Debug.Print "hNode = " & hNode sText = AutoIt.ControlTreeView("SolidWorks Premium 2013 x64 Edition", "", "TreeView326", "GetText", "", "") Debug.Print ("Debug: sText = " & sText & vbCr) End If AutoIt.Sleep (100) Wend End Sub I know this code is a hack job, but I am just trying to quickly figure out if I can use AutoIt3. Like I said previously, WinTask was able to correctly navigate and use these tree items. What I need to do is select an item in the tree and send it a right-click to open a dialog. Here's a listing from the Window Info Tool: Class SysTreeView32 Instance 6 ClassnameNN SysTreeView326 Name Advanced Mode [CLASS:SysTreeView32; INSTANCE:6] ID 1234 Text Position -2,328 Size 417,465 ControlClick Coords 231,237 Style 0x5020000B ExStyle 0x00000000 Handle 0x000000000011073C Thanks, Dan Edited December 11, 2013 by det54
Moderators Melba23 Posted December 12, 2013 Moderators Posted December 12, 2013 det54,It would appear that you already have an account here. We do not permit multiple accounts, but i would be happy to merge the 2 if you can confirm that they are indeed both yours. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
det54 Posted December 16, 2013 Author Posted December 16, 2013 M23, Yes, that was me. I created this account when I was unable to recover the first one - sorry, I did not mean to break the rules. Please merge them into this one if you don't mind. I'm still hoping someone can give me some help with this. Thanks, Dan
Moderators Melba23 Posted December 16, 2013 Moderators Posted December 16, 2013 det54,Accounts merged. I am afraid that I cannot help with the problem, but at least you have had a free bump! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
det54 Posted December 16, 2013 Author Posted December 16, 2013 Thanks! I've been struggling with this all morning with no luck. I can see that the controls are in the SysTreeView32 class, but I can't get ControlTreeView to work with it at all. WinTask works beautifully, but I was trying to avoid that software since all of my code for this project is written in VBA (Excel) and I'd rather not have to call an external script. Either WinTask has more power under the hood, or I'm just doing something fundamentally wrong with AutoItX.
SlakrHakr Posted April 18, 2014 Posted April 18, 2014 Hi guys. Are y'all using the AutoItX3_x64.dll running your automation in 64bit? If so this is exactly what I have been experiencing unfortunately. I created the following bug but nothing seems to have happened with it yet: http://www.autoitscript.com/trac/autoit/ticket/2694 I am currently just trying to figure out if when AutoIt says it can run x64 if it is saying it can only manipulate x64 applications with AutoItX3_x64.dll or if it means what I thought it meant, that you can just run your automation in 64bit regardless of the ui tool's bitness being automated. Thanks!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now