Jump to content

Calling Windows By Class


Thunder
 Share

Recommended Posts

Good day to you all.

I am in a pinch and really would appreciate help from someone experienced with AutoIt3 than myself, which won't be hard considering I just downloaded it yesterday! I am new to scripting as well, so be gentle, please:)

My problem lies with calling a window by its class rather than its title. I need to call a particular window during an unattended uninstallation of various versions of Check Point VPN client software. The window will be named differently, depending on which version of the application is installed, which is why I can't call it by name. I have tried using WinTitleMatchMode 2 & 4 in addition to the default. I have also tried to call the window by "Check" or "Check Point" as that is a constant between the various versions but that failed as well; the window still pops up with no action being taken place. I have also tried using 32770 without the # symbol but it didn't make a difference. Windows 2K/XP environment.

Below is my code for review. What am I doing wrong?

======================================================================

Opt("WinTitleMatchMode", 2)

Run(@COMSPEC & " /c RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\engine\6\INTEL3~1\ctor.dll,LaunchSetup ""C:\Program Files\InstallShield Installation Information\{9FCF2FC0-8268-11D4-A313-0006290D766E}\setup.exe"" ADD_REMOVE")

WinWaitActive("Confirm File Deletion")

ControlClick("Confirm File Deletion", "", "[CLASS:Button; TEXT:OK; INSTANCE:1]")

WinWaitActive("[CLASS:#32770]", "")

ControlClick("[CLASS:#32770]", "", "[CLASS:Button; TEXT:No, I will restart my computer later.; INSTANCE:2]")

ControlClick("[CLASS:#32770]", "", "[CLASS:Button; TEXT:Finish; INSTANCE:4]")

Exit

=====================================================================

Thanks,

Thunder

post-26905-1189169201_thumb.jpg

Link to comment
Share on other sites

  • Moderators

I don't see this window "Confirm File Deletion", so my first assumption is that you never get any further in your script than past that point.

A good thing to do when your testing is either do a ConsoleWrite() or a MsgBox() right after each of those steps, so you can see exactly where it is failing or hanging.

Edit:

I didn't iterate what ssubirias3 said, but he's right, just assumed you'd understand by reading the documentation that you can only use Match mode 4 with the options you are trying to do, but I thought I'd go ahead and iterate it anyway.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I don't see this window "Confirm File Deletion", so my first assumption is that you never get any further in your script than past that point.

A good thing to do when your testing is either do a ConsoleWrite() or a MsgBox() right after each of those steps, so you can see exactly where it is failing or hanging.

Edit:

I didn't iterate what ssubirias3 said, but he's right, just assumed you'd understand by reading the documentation that you can only use Match mode 4 with the options you are trying to do, but I thought I'd go ahead and iterate it anyway.

I only posted the screen capture for the window I am having difficulties with. The first one goes off without a hitch. Thank you for the tip with the MsgBox(), I will try that to see if it helps (after I read up on how to use it, LOL).

Link to comment
Share on other sites

You're using the wrong parameter with Opt("WinTitleMatchMode", 2). Check the Help file for "WinTitleMatchMode" and you'll see what the number should be. :)

Thank you for the response. I tried default, 2 and 4. The only one left is three, and that won't work for this case. Any other ideas?

Link to comment
Share on other sites

Thank you for the response. I tried default, 2 and 4. The only one left is three, and that won't work for this case. Any other ideas?

Opt("WinTitleMatchMode", 4) is the correct command you need if you are going to use classes for titles. If it doesn't work for you then you're not using the window class correctly in your command. This is from the Help file :)

Advanced Window Descriptions

A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:

TITLE - Window title

CLASS - The internal window classname

REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2)

LAST - Last window used in a previous AutoIt command

ACTIVE - Currently active window

INSTANCE - The 1-based instance when all given properties match

e.g. Wait a window of classname "Notepad"

WinWaitActive("[CLASS:Notepad]", "")
Link to comment
Share on other sites

Opt("WinTitleMatchMode", 4) is the correct command you need if you are going to use classes for titles. If it doesn't work for you then you're not using the window class correctly in your command. This is from the Help file :)

Advanced Window Descriptions

A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:

TITLE - Window title

CLASS - The internal window classname

REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2)

LAST - Last window used in a previous AutoIt command

ACTIVE - Currently active window

INSTANCE - The 1-based instance when all given properties match

e.g. Wait a window of classname "Notepad"

WinWaitActive("[CLASS:Notepad]", "")

Thank you for the response. I did read the Help file regarding Advanced Window Titles, which is why I mentioned I tried default, 2 and 4, none of which worked. I understand I am not using the class properly somehow, which is why I posted for help. I don't see the error of my ways:) Anyone?

Much help on the MsgBox() - greatly appreciated!

Link to comment
Share on other sites

I understand I am not using the class properly somehow ... I don't see the error of my ways:) Anyone?

Okey Dokey, after looking at your code a second time I'm going to guess the problem is with your ControlClick() syntax missing the "optional" stuff like button, clicks, x, y.

ControlClick

--------------------------------------------------------------------------------

Sends a mouse click command to a given control.

ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )

You are using
ControlClick("[CLASS:#32770]", "", "[CLASS:Button; TEXT:Finish; INSTANCE:4]")oÝ÷ Ù:ò²¶§X¤y«­¢+Ù
½¹Ñɽ±
±¥¬ ÅÕ½Ðím
±ÍÌèÌÈÜÜÁtÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðím
±ÍÍ98é  ÕÑѽ¸ÑtÅÕ½Ðì°ÅÕ½Ðí±ÐÅÕ½Ðì°Ä¤ì쥹Íѽѡ½Ù½

Sorry I can't guide you better, but I don't have the same files or systems your are testing with. Also tell us where the script is sticking now that you know about Opt("TrayIconDebug", 1). The script line isn't important to us, rather what area of the script is last performed before it gets stuck or crashes. If you're using SciTE4AutoIt3 in the console the last lines will be orange if there was an error. What is that orange text.

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...