Sign in to follow this  
Followers 0
r0ssar00

click a button on a generic window

10 posts in this topic

i'm hacking together a bunch of scripts(ahk and non-ahk) and voxx open source (google it, its voice recognition software) to run certain functions using my voice. i already have itunes controlled somewhat using vb.net and a batch file compiler. i want to script support in(using autoit) for clicking generic buttons suck as ok and cancel but since ok may not be the default button on a window for some obscure reason i need to click the button with the text OK instead of sending enter. i tried using:

Opt("WinTitleMatchMode",4) 
ControlClick("[ACTIVE]","","[TEXT:OK]") 
['/code]

but it didn't work because as soon as i opened the script, all of a sudden a window is not active anymore so therefore it doesn't work. 

does anyone have any ideas how i can generically click a button named X in the active window (where X is any text)?


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                        





(adsbygoogle = window.adsbygoogle || []).push({});




                    
                
                    
                    
                    






    
    
        
PsaltyDS   

    
        
    
             25
    
        
    

        
            
                Most Venerable Penguin
            
            

            
                

    
        
    

            
            MVPs
            
                
            
            
                

    
        
    
             25
    
        
    

                13,093 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #2 · 
            Posted 
            
            
            
        
    

    


            
        
            
i'm hacking together a bunch of scripts(ahk and non-ahk) and voxx open source (google it, its voice recognition software) to run certain functions using my voice. i already have itunes controlled somewhat using vb.net and a batch file compiler.  i want to script support in(using autoit) for clicking generic buttons suck as ok and cancel but since ok may not be the default button on a window for some obscure reason i need to click the button with the text OK instead of sending enter. i tried using:
 

Opt("WinTitleMatchMode",4)

ControlClick("[ACTIVE]","","[TEXT:OK]")

['/code]

but it didn't work because as soon as i opened the script, all of a sudden a window is not active anymore so therefore it doesn't work.

does anyone have any ideas how i can generically click a button named X in the active window (where X is any text)?

You already have that with "[TEXT:OK]". Your problem is identifying the window, not the control, since "[ACTIVE]" is not necessarily a match. So, what do you want to ID the window with? Your "in the active window" doesn't make sense, since you just said the window might not be active.

If launching the script causes loss of focus, then you could have the script already running in the background to handle the window. It could be enabled/disabled as required, but wouldn't have to start up when needed. Otherwise, you need to identify the window somehow.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You already have that with "[TEXT:OK]". Your problem is identifying the window, not the control, since "[ACTIVE]" is not necessarily a match. So, what do you want to ID the window with? Your "in the active window" doesn't make sense, since you just said the window might not be active.

If launching the script causes loss of focus, then you could have the script already running in the background to handle the window. It could be enabled/disabled as required, but wouldn't have to start up when needed. Otherwise, you need to identify the window somehow.

:)

if i have it running in the background, then the code i have above when in a loop would work(given a set of activation conditions), right?

Share this post


Link to post
Share on other sites

if i have it running in the background, then the code i have above when in a loop would work(given a set of activation conditions), right?

Yes, I think it would. Put it in a loop, and maybe add a method to enable/disable it, if required.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

thanks for the help

Share this post


Link to post
Share on other sites

If you want the active window, just use a blank string for title and text.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

If you want the active window, just use a blank string for title and text.

problem, when voxx(the speech recognition program) detects a command, it pops up a tooltip like window above the mouse pointer which becomes the active window as the script executes hence i cannot use the active window, i have to use the last active window before the switch

inserting a delay(so that the tooltip disappears and the desired window becomes active again) is unacceptable because then the timer defeats the purpose of the speed of recognition. i can click the ok button faster than the time it takes for the window needed becomes active again

Edited by r0ssar00

Share this post


Link to post
Share on other sites

Why not just write your own speech recognizer? It's available in COM form.

Share this post


Link to post
Share on other sites

problem, when voxx(the speech recognition program) detects a command, it pops up a tooltip like window above the mouse pointer which becomes the active window as the script executes hence i cannot use the active window, i have to use the last active window before the switch

inserting a delay(so that the tooltip disappears and the desired window becomes active again) is unacceptable because then the timer defeats the purpose of the speed of recognition. i can click the ok button faster than the time it takes for the window needed becomes active again

The recognition can be quite fast, and the delay to prevent hogging the CPU doesn't have to be very long, i.e. Sleep(20). You seem confused about identifying the pop up though. It was your idea to match "[ACTIVE]". If you know more specific information about the pop up, like CLASS and TITLE, use them! Have you used AU3Info tool to gather information on these pop ups?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

The recognition can be quite fast, and the delay to prevent hogging the CPU doesn't have to be very long, i.e. Sleep(20). You seem confused about identifying the pop up though. It was your idea to match "[ACTIVE]". If you know more specific information about the pop up, like CLASS and TITLE, use them! Have you used AU3Info tool to gather information on these pop ups?

:)

ahh, i'm not trying to identify the popup, i'm trying to identify the window *under* the popup

by speed of recognition, i mean the delay between actual recognition and execution of command. as it is, execution is immediate and it is worth having speech recognition.

a home-grown solution seems the best bet right now because then i could develop a flexible plugin structure

thanks for the help though but the problem seems moot when considering a home-grown solution because then there won't be that annoying popup

Share this post


Link to post
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
Sign in to follow this  
Followers 0