Jump to content

If Then MouseClick based on classNN


Recommended Posts

Good evening, I've had an enjoyable day getting acquainted with this scripting software, and as I mentioned in my first post, I can see there's a million things this can do, and I know I'm not going to be able to absorb it at the speed I'd like to.  I dream of the day we can plug a jump drive into our head and download the knowledge like on the Matrix :-)

I'm very close on completing this first big script, and I'm looking for a little explanation to help me figure out the rest. 

I have a valid AutoIt support question and kindly provide the details of my system:

AutoIt Version: V3.3.10.2 [X32]
Windows Version: WIN_2012 [X64]
Language: 0409

So I have a nice stack of steps being handled automatically with the script, I've got the mouse moving and clicking where I need it to, everything's perfect but the very end.  The final window that pops up is running a process.  There's a "cancel" button on the screen during the process, and once the process is complete, it turns to a "Close" button.  Same x/y location, just the name of the button changes.  I'm trying If/Then expressions with no luck, I'm not very strong in general loop understanding, and I can't really think of any search terms (because I don't really know the technical jargon) for what I'm asking.  So I haven't been able to find anything on the forum or the Help system that fits my needs. 

In English, what I'd like to communicate through the script, is:

 - as long as classNN="Cancel", do nothing. 

 - if classNN = "Close", then go ahead and click. 

I have the mouse already in position, and I'm seeing the information from the window spy application, I'm just not having much luck with the syntax for that.  Can somebody help me think this one through?  I'd greatly appreciate it.  Thanks so much!

Farns

 

 

AutoIt Version: V3.3.10.2 [X32]
Windows Version: WIN_2012 [X64]
Language: 0409
Link to comment
Share on other sites

I think ControlGetText is better than GuiCtrlRead. ;)

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Thanks for the input.  I put in the snippet you gave me, dropped in the proper window title, the button ID, and so far it's working great! 

So question - to help me understand better...  I used X,Y coords to get the mouse to that button.  But since I'm calling out the button with the button ID, there's no need for that, right?  This is pretty cool watching stuff happen automatically.  My head is spinning with ideas of how this can simplify my life.  Wish I'd found AutoITScript years ago!

Farns

AutoIt Version: V3.3.10.2 [X32]
Windows Version: WIN_2012 [X64]
Language: 0409
Link to comment
Share on other sites

  • Moderators

I would agree with jdelaney, if you already know you can get the window and button info, why bother with the mouseclicks at all?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Yes I can see there are ways to streamline the code.  I've removed other lines from the script already because I discovered I was doing redundant things.  This helpfile is extremely well written.  Once I know the right words to look for, I'm able to connect a lot of dots.  As a new user, I'm learning that I just don't know the right words to search for all the time.  The last solution like this I tried was a lot more simplified in terms of the syntax.  But not nearly as function as this, I don't believe. 

Right now I'm trying to figure out how to make a specific window become active.  After some of my steps, the window I need to access is not on top, and I'm trying to find the right syntax to search and study on making a window active.  I was just coming to the forum to search and I saw I had a couple more replies here. 

AutoIt Version: V3.3.10.2 [X32]
Windows Version: WIN_2012 [X64]
Language: 0409
Link to comment
Share on other sites

  • Moderators

Right now I'm trying to figure out how to make a specific window become active. 

 

WinActivate in the help file, although if you are using the Control Commands as has been suggested, the window does not need to be active.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Ok, so I used WinActivate and mouse controls to get the job done for now, since it is syntax that I understand a bit better.  The whole thing worked great from start to finish.  Now I want to simplify and improve the script.  So I'm reading up on the Control Commands, and I'm unclear how to interact with the menubar and sub menus in there.  (File, Edit, View, etc...) As I hover around those and their sub menus, I don't see anything revealed in the window spy app to help me see what I can reference there.  It seems like the CLASS or ID properties should be able to identify those.  I am working with Acrobat Pro XI, on Windows Server 2012.  I'm presently using the mouse control and X/Y to navigate through 2 or 3 menu commands, but if there's a way to manipulate those through the Control Commands, it seems that would be more efficient (albeit less "showy" for making it look like the computer is possessed by spirits!). :-)  

AutoIt Version: V3.3.10.2 [X32]
Windows Version: WIN_2012 [X64]
Language: 0409
Link to comment
Share on other sites

Thanks for the lead on that.  I read some of the gui functions and most of that blew straight over my head.  The WinMenuSelectItem seemed to make a lot more sense but I can't get it to work - I'm using Acrobat Pro XI, and I wonder if this statement from the help file is a factor with acrobat:

WinMenuSelectItem() will only work on standard menus. Unfortunately, many menus in use today are actually custom written or toolbars "pretending" to be menus. This is true for most Microsoft applications.

 

 

Does anybody have experience with this in Acrobat or know how their menus are structured? 

Farns

AutoIt Version: V3.3.10.2 [X32]
Windows Version: WIN_2012 [X64]
Language: 0409
Link to comment
Share on other sites

You can move your AutoIT Window Info tool over your toolbar.  If it comes back as no control, they it should work.  If it comes back as a toolbar, then you have to use ControlCommand, and send the proper commandID to initiate your action.  That can get difficult, if the application does not make those commands visible.

Use the tool (start menu, all programs, autoit), and paste in the output of the 'summary' tab.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • Moderators

I have had the same experience with Acrobat XI, the AcrobatSDIWindow class does not allow me to do WinMenuSelectItem. However, I am using a virtualized instance of the application; not sure if that is causing it or not.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

None shows up for me, that is why I said it may be because I virtualized the app. I've notice some oddities when interacting with sandboxed app windows. I don't have in actually installed anywhere to test.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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