Jump to content

det54

Members
  • Posts

    6
  • Joined

  • Last visited

det54's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. 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.
  2. 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
  3. 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. Sub 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
  4. Hi all, I am very new to AutoIt (day two), and am having trouble figuring out how to access a toolbar button. Here is the Window Info: >>>> Window <<<< Title: SolidWorks Premium 2012 x64 Edition - [PS High 9env SW2012 - 120907.SLDPRT *] Class: Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000009060387 Position: 0, 0 Size: 1440, 860 Style: 0x150B8000 ExStyle: 0x00000000 Handle: 0x0000000000010682 >>>> Control <<<< Class: ToolbarWindow32 Instance: 7 ClassnameNN: ToolbarWindow327 Name: Advanced (Class): [CLASS:ToolbarWindow32; INSTANCE:7] ID: 59392 Text: Position: 1, 642 Size: 1438, 24 ControlClick Coords: 412, 15 Style: 0x5600084E ExStyle: 0x00000000 Handle: 0x0000000000190CF4 >>>> Mouse <<<< Position: 413, 657 Cursor ID: 0 Color: 0xF0F0F0 >>>> StatusBar <<<< 1: SolidWorks Premium 2012 x64 Edition 2: 3: 4: 5: Editing Part 6: 7: 8: 9: 10: >>>> ToolsBar <<<< 1: 59 2: 60 3: 0 4: 58 5: 44 6: 45 >>>> Visible Text <<<< swCmdMgr swCaption swMenu SearchBox SearchBox Auto Hider Task Pane Tabs Wnd EM Frame header expandCollapse pin swInnerFrame PS High 9env SW2012 - 120907.SLDPRT * Tree Container Wnd uiTreeCtrlView_c FeatureFilter uiVisualSketchEditorView_c Dve sheet Surface Parameters dvePage ScrollView e:\Temp\NIK579E.tmp More Parameters... Show Export to Excel Selection Parameters Time History Options SolidWorks Premium 2012 x64 Edition Standard Formatting Features Task Pane >>>> Hidden Text <<<< swTags Tags: pUppIntFrame inner HTML view swInnerFrame ... Import Annotations Design Annotations DimXpert Annotations Include items from hidden features Auto-start projected view Options swInnerFrame PNGBUTTON uiVisualSketchEditorView_c Dve sheet Properties dvePage ScrollView Select an entity to view or to modify its properties. Message uiConfigMgrView_c uiSwiftTreeCtrlView_c uiDisplayManagerView_c uiFeatureMgrActiveXView_c uiTreeCtrlView_c FeatureFilter PNGBUTTON Dve sheet Properties dvePage ScrollView Select an entity to view or to modify its properties. Message e:\Temp\NIK57B1.tmp Surface Parameters.xlt e:\Temp\NIKDF70.tmp Message uiConfigMgrView_c uiSwiftTreeCtrlView_c uiDisplayManagerView_c uiFeatureMgrActiveXView_c MotionToolbar AnimationTree AnimControllerView CAnimTaskManagerView AnimGanttView Flow Simulation Display Flow Simulation Results Features Flow Simulation Results Flow Simulation Features Flow Simulation Main Fastening Feature Screen Capture SolidWorks Office Display States <Default>_Display State 1 Tools Standard Views Web http://www.solidworks.com Macro View Standard Quick Snaps Selection Filter Line Format Layer Formatting Blocks Reference Geometry DimXpert Table Weldments CommandManager Explode Sketch 2D to 3D Align Curves Surfaces Sheet Metal Mold Tools Features Annotation Drawing Assembly Layout Tools Task Pane Spline Tools Render Tools Dimensions/Relations Sketch uiWindowHeapHelper_c What I want to access is item 6 under the "Toolsbar" heading: button 45. I have been trying for the last hour or so to get ControlClick to work with this, but have not stumbled on the correct parameters to pass. The following works for the "Show" button: ControlClick("SolidWorks Premium 2012 x64 Edition - [PS High 9env SW2012 - 120907.SLDPRT *]","swCaption","Button21") I tried similar code for the toolbar button with various values for controlID and button with no luck. Worst case, I will use a ClickMouse command, but it seems less elegant Thanks, Dan
  5. Sorry, I wasn't trying to be lazy - I should have been more specific. I had already figured out WinActivate, MsgBox, and ClipGet functions from the help file. My questions follow the particular code I was having trouble with below: I looked at the Control commands (specifically ControlClick), used the Spy tool to try to identify the tree item identifiers, and even tried the macro recorder to produce the correct code for me, but I could not figure out what exactly to put in for "title", "text", or controlID to make this work. I was hoping that by including the above snippet from WinTask that someone might be able to tell me how to use the "TreeView", "1", and "Surface Parameters 1" in the ControlClick command. The macro editor just skips this part of the process and gives a message that TreeView32 objects are not supported. Note that I have nine individual "Surface Parameters X" items in the feature tree that I want to access and change. I appended the loop iteration number to this string in the old code. What has to happen is that I need to right-click each Surface Parameters item, then select Edit (or send "e"). I then click "Copy Entire Table" to put the values into the clipboard, then I click the "OK" button (or just send "Enter") to close the dialog and move on to the next Surface Parameters item. Below is some other code from WinTask and what I tried in AutoIt with some success. I'd appreciate any help or tips for improvement. [i]WinTask Code:[/i] UseWindow("SLDWORKS.EXE|SysTreeView32|",1) ChooseMenu(Context,"&Edit Definition...") [i]AutoIt Code:[/i] ControlClick("SolidWorks Premium 2012 x64 Edition - [PS High 9env SW2012 - 120907.SLDPRT *]","swCaption","SysTreeView326","Right") ;Surface Parameters 1 Send("e") [i]WinTask Code:[/i] UseWindow("SLDWORKS.EXE|#32770|"+file$+" *|3",1) Click(Button,"Show ") [i]AutoIt Code:[/i] ControlClick("SolidWorks Premium 2012 x64 Edition - [PS High 9env SW2012 - 120907.SLDPRT *]","swCaption","Button21") [i];Show[/i] UseWindow("SLDWORKS.EXE|AfxFrameOrView90u|"+file$+" *|35",1) ChooseItem(ToolBar, "|1", "|45", single, left ) 'Copy table of values to clipboard I couldn't figure this one out at all, the macro recorder gives the message that "AutoIt supports no ToolbarWindow32" (AutoIt Macro Generator V 0.21 beta - it is old). AutoIt Code: ControlClick("SolidWorks Premium 2012 x64 Edition - [PS High 9env SW2012 - 120907.SLDPRT *]","swCaption","Button28") ;OK button This works for the OK button, but I could also just send the "Enter" key. Do I need to include the entire window title here, or will "SolidWorks" suffice? Thanks! - Dan
  6. Hi all, I am working on automating SolidWorks Flow Simulation, and had successfully written a script using WinTask a while back that I would like to convert to run in AutoIt. Most of the changes I have made to the script so far involve renaming variables or functions. There are some instances where I think AutoIt should be able to access some of the lists or tables in SolidWorks, but I can't figure out how to make this happen. I have tried using the included Window Info tool and also Spy++, but some of the menus only open when a TreeView item is right-clicked, and they go away as soon as I change focus to the spy tools, so I have not been able to find the proper ID for the controls. For the time being, I am using MouseClick to handle everything, but I would much rather access list items by name. Below is a sample of my WinTask code - it contains window names/handles that I think AutoIt should be able to utilize. I think I want to use ControlClick to access some of the controls, but I could not get it to work for some of these items. Can anyone help me with converting the UseWindow, ChooseItem, and Click(Button, "Name") commands? Any help is much appreciated! - Dan PS - I will be searching for some Excel workbook access functions (read cells, write cells, etc) - if anyone has some helpful links please share '------------------------------------------------------------------------------------------------------ 'Gets 9 individual Surface Parameters concentrations 'This assumes that the Results tree has been expanded, otherwise it will not find Surface Parameters Ends Sub GetSurfParams() y = 1 While y < 10 'Repeat 9 times UseWindow("SLDWORKS.EXE|AfxOleControl90u|"+file$+" *|2",1) ChooseItem(TreeView, "1", "Surface Parameters "+Str$(y), single, right ) 'Pause 10 ticks 'UseWindow("SLDWORKS.EXE|SysTreeView32|"+file$+" *|8",1) UseWindow("SLDWORKS.EXE|SysTreeView32|",1) ChooseMenu(Context,"&Edit Definition...") UseWindow("SLDWORKS.EXE|#32770|"+file$+" *|3",1) Click(Button,"Show ") UseWindow("SLDWORKS.EXE|NIKFlexGrid8L|"+file$+" *|3",1) 'Make sure mouse is not obscuring Copy Table bitmap ClickMouse(Left,Down,264,69) MoveMouse(265,69) MoveMouse(265,68) ClickMouse(Left,Up,265,68) Pause until Bitmap("C:\Program Files (x86)\WinTask\Scripts\CopyTable.bmp") InWindow("SLDWORKS.EXE|ToolbarWindow32|"+file$+" *|7",1) PauseFalse MsgBox("'Wait for' at line " + #ErrorLine$ + " has failed !") End EndPause UseWindow("SLDWORKS.EXE|AfxFrameOrView90u|"+file$+" *|35",1) ChooseItem(ToolBar, "|1", "|45", single, left ) 'Copy table of values to clipboard Pause 10 ticks a$=GetClipboard$() 'MsgBox(a$) 'for debugging UseWindow("SLDWORKS.EXE|Button|"+file$+" *|18",1) SendKeys("<Enter>") excel_file$="Testing1.xlsm" 'Working file for clipboard functions macro$="Macro1" workbook$="Sheet1" ExecExcelMacro(excel_file$,macro$,30) 'Pause 10 clicks ReadExcel(excel_file$,"D2",b$()) 'MsgBox(b$(0)) 'for debugging Surf_Param$(y)=b$(0) y = y + 1 Wend EndSub 'End of GetSurfParams
×
×
  • Create New...