Jump to content

How to handle two different possibilties for control window


Go to solution Solved by MikahS,

Recommended Posts

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

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 by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

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 by blehbloo
Link to comment
Share on other sites

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 by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

Sounds good @blehbloo ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

Fixed due to not having correct value in $title when calling WinWaitActive(), see >post 4

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

  • Solution

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 ~ getENVvars
My 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

glad to hear @blehbloo ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...