blehbloo Posted August 18, 2014 Share Posted August 18, 2014 I've wrote a program that will successfully use ControlSend and ControlClick to work its way through an application. The issue I'm running into is that for some reason, the application will sometimes have a different Class and ClassnameNN, which will throw everything off. I believe that there are only two possible scenarios for the application to have as its Control information: Scenario 1: CLASS: WindowsForms10.Window.8.app.0.e4c6c4 ClassnameNN: WindowsForms10.EDIT.app.0.e4c6c42 Scenario 2: CLASS: CLASS:WindowsForms10.Window.8.app.0.3d90434 ClassnameNN: WindowsForms10.EDIT.app.0.3d904342 My question is, what is a good way to make my script smart enough to check what scenario it is and then use the appropriate CLASS and ClassNameNN to control the application? Link to comment Share on other sites More sharing options...
MikahS Posted August 18, 2014 Share Posted August 18, 2014 (edited) Wouldn't this be done with a simple conditional statement at the start of the script to check which class and classnameNN it is? Unless it changes while your script is running; is that the case? Edited August 18, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
blehbloo Posted August 18, 2014 Author Share Posted August 18, 2014 (edited) Wouldn't this be done with a simple conditional statement at the start of the script to check which class and classnameNN it is? Unless it changes while your script is running; is that the case? No, it doesn't change while the script it running. I'm not sure how to have your script check what the Window info it. I'm a AutoIt rookie but the only way I'm aware to get Window information is to use the AutoIt Window tool and visually look at what the Class and ClassnameNN names are and type that into your script. How do I tell my script to automatically check what class info is being presented and then follow that scenario's tree? Edited August 18, 2014 by blehbloo Link to comment Share on other sites More sharing options...
MikahS Posted August 18, 2014 Share Posted August 18, 2014 (edited) Is the class information the only info on the window you see? Does it have a title? You can make a conditional like so.. Local $title, $active, $class1 = ;first class goes here Local $class2 = ;second class goes here $title = WinExist($class1) If $title = 0 Then $title = WinExist($class2) If $title = 0 Then MsgBox(0, "title", "Could not find the window") Exit Else $title = $class2 EndIf Else $title = $class1 EndIf $active = WinWaitActive($title) If $active = 0 Then MsgBox(0, "title", "Could not make the window active") Exit EndIf ; rest of the script goes after this... EDIT: Let me know how it goes so I can help further if need be ; fixed solution to actually work. Slight oversight on my part Edited August 18, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
blehbloo Posted August 18, 2014 Author Share Posted August 18, 2014 Mikah, thanks for the help. I'm going to try this out this tonight and I'll let you know how it goes. Link to comment Share on other sites More sharing options...
MikahS Posted August 18, 2014 Share Posted August 18, 2014 Sounds good @blehbloo Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
MikahS Posted August 18, 2014 Share Posted August 18, 2014 Fixed due to not having correct value in $title when calling WinWaitActive(), see >post 4 Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
jguinch Posted August 18, 2014 Share Posted August 18, 2014 Did you try with REGEXPCLASS ? $hWnd = WinGetHandle("[REGEXPCLASS:WindowsForms10\.Window\.8\.app\.0\..+]") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Solution MikahS Posted August 19, 2014 Solution Share Posted August 19, 2014 Updated code to use jguinch's solution; it is another solution, but better ability to get the window handle Local $hWnd, $active $hWnd = WinGetHandle("[REGEXPCLASS:WindowsForms10\.Window\.8\.app\.0\..+]") If @error Then MsgBox(0, "error", "Could not get handle to the window") Exit EndIf $active = WinWaitActive($hWnd) If $active = 0 Then MsgBox(0, "error", "Could not find window to make it active") Exit EndIf ;rest of code goes here... Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
blehbloo Posted August 19, 2014 Author Share Posted August 19, 2014 Fixed due to not having correct value in $title when calling WinWaitActive(), see >post 4 Thanks, MikahS and jguinch. Using your code, I was able to work out what I needed. Link to comment Share on other sites More sharing options...
MikahS Posted August 19, 2014 Share Posted August 19, 2014 glad to hear @blehbloo Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ 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