diakonos1984 Posted April 1, 2013 Share Posted April 1, 2013 I am trying to write some automation tools for a $10K piece of engineering software, which unfortunately means most of you won't be able to test run anything to solve my problem (unless we arrange for a screen share in a PM). This is my first attempt with AutoIt, and so far I love it! Creating a GUI for my script was easy, the documentation was easy, and everything works great EXCEPT ONE ITEM: The software I am automating is SKM Power*Tools, and it's not the most up-to-date software, but at one point my script pulls up a window inside the program. The window has two plot areas, which I'll refer to as "TCC" and "Oneline". Both of those areas have "Datablocks" which can be toggled on and off my clicking a button on a toolbar in the program main window. The area to toggle the "Datablock" in is determined by which ever area has been clicked in most recently. If neither have been clicked it defaults to the "TCC" plot area. When this window is opened, "Datablocks" are ON for the "TCC" area, and OFF for the "Oneline" area. Using the script to toggle the "Datablock" in the "TCC" area is no problem, since that area has default focus. However, I have not been able to get the "Datablock" in the "Oneline" area to toggle. My script clicks in the "Oneline" area (and I know it works, because plot objects that were initially selected are unselected as soon as my script clicks), and then clicks the toggle button in the toolbar. However, the "Datablock" in the "Oneline" area does not toggle, and instead the "Datablock" in the "TCC" area toggles, indicating to me that the focus did not stay on the "Oneline" area when the toggle button was clicked... Below are some code snippets. I would really appreciate any help you can give! This bug is all that stands between me and a 50% labor reduction for certain aspects of some engineering projects! $HandleTCC = WinWait($HandleSKM,"TCC") ;wait until window is up. ;$HandleSKM is previously defined as the program main window ConsoleWrite("TCC window has come up now: " & $HandleTCC & @CRLF) ;Oneline zoom and datablock toggle ConsoleWrite("Attempting to click oneline..." & @CRLF) ;The following line appears to successfully click the "Oneline" area, because ;any selected devices in the area are unselected when this runs, ;just as they would be if I manually clicked in the area. $SuccessTest = ControlClick($HandleTCC,"","[CLASS:AfxFrameOrView42; INSTANCE:1]","primary",2,147,167) If $SuccessTest = 1 Then ConsoleWrite("Succeeded." & @CRLF) If $OData = 1 Then ;a condition based on a radio button in my GUI ConsoleWrite("Attempting to toggle oneline datablock..." & @CRLF) $SuccessTest = ControlClick($HandleSKM,"","[ID:33002]","primary",1,137,12) ConsoleWrite("Oneline datablock toggle success: " & $SuccessTest & @CRLF) Else ConsoleWrite("Oneline datablocks not toggled." & @CRLF) EndIf Else ConsoleWrite("Failed." & @CRLF) EndIf All of my $SuccessTest checks show that the clicks succeeded. It just doesn't work right in my software! I've tried several different ways to define the control to be clicked (as determined by the Window Info tool), but nothing has solved this problem. Again, it appears my control IS getting clicked, it's just not changing the focus so that the toggle button will work correctly. Thanks a lot, Diakonos1984 Link to comment Share on other sites More sharing options...
diakonos1984 Posted April 1, 2013 Author Share Posted April 1, 2013 I should add, I just tried MouseClick() and it works. Problem is, the window is not always in the same place, so I'd rather use something that isn't location specific. Link to comment Share on other sites More sharing options...
JohnOne Posted April 1, 2013 Share Posted April 1, 2013 (edited) First thing to do is search forum for "CLASS:Afx", such classes seem to be non standard controls and can be difficult if not impossible to work with. All is not lost though, look at... Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client This will enable you to use mouse no matter where window is, if your controlclick fails. EDIT: might be worth looking at ControlFocus also, but might have same problem as other control* functions. Edited April 1, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
diakonos1984 Posted April 1, 2013 Author Share Posted April 1, 2013 Thanks JohnOne, I ran that forum search and it looks like you've given this advice before... thanks for being willing to give it again! So basically, not matter how I try to talk to the Afx item it's probably not going to cooperate? (I'm glad I posted with that class in the command--my earlier code just used the ID and you'd not have known it was an Afx) That doesn't surprise me too much--while the software I am trying to automate may be cutting edge engineering, it sure isn't cutting edge software development, and a lot of it feels like it's still running on Windows 95! I'd already tried ControlFocus with no luck, so I'll try the relative mouse coordinates... Link to comment Share on other sites More sharing options...
JohnOne Posted April 1, 2013 Share Posted April 1, 2013 Code might look something like this. Opt("MouseCoordMode", 0) $HandleTCC = WinWait($HandleSKM,"TCC") _ClickWinPos($HandleTCC, 147, 167) Func _ClickWinPos($hWnd, $iX, $iY) WinActivate($hWnd) WinWaitActive($hWnd) MouseClick("Primary", $iX, $iY) EndFunc ;==>_ClickWinPos AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
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