AutoHotkey Community

It is currently May 27th, 2012, 7:03 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: ControlClick unreliable
PostPosted: March 11th, 2006, 12:32 am 
Offline

Joined: March 6th, 2006, 9:15 am
Posts: 8
Hi all,

I am using lots of ControlClick commands on Buttons, and sometimes they don't work, resulting in an unreliable script. Tried playing with SetControlDelay, and with different types of actions (several clicks, or only down action, etc.).

Maybe I'm missing something here ...

Is there an "ultra-reliable" way of scripting an invisible mouse click on a button ? Should the use of MouseClick instead be more reliable?

Thanks in advance for any hints

Robert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2006, 12:49 am 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
Have you tried using a long Sleep (e.g. "Sleep, 1000" or more) before and after the ControlClick to make sure the program is definitely ready (and not busy doing something else still from the last action)?

Is it always the same controls that cause problems or is it random?

It should be more reliable to use ControlClick than MouseClick ideally, but use whichever does the job best :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2006, 5:13 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
You might be able to use PostMessage for a bit more accuracy. Please have a look at the PostMessage tutorial in the help file for more info to see if this method might be useful for what you're trying to automate.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 11th, 2006, 6:46 am 
Offline

Joined: December 20th, 2005, 4:15 am
Posts: 165
Location: Malaysia
I've occasionally found ControlClick to be unreliable too. So I usually use a combo of ControlGetPos and MouseClick to get the job done:

1. Use ControlGetPos to get the position a control (X,Y).

2. Add 3-5 to X and Y, depending on size of control. This is to ensure the MouseClick will be within the control, and not on its upper-left corner.

3. Delay a bit (Sleep, 60).

4. Click on X,Y with MouseClick.

schling wrote:
Hi all,
....
Maybe I'm missing something here ...

Is there an "ultra-reliable" way of scripting an invisible mouse click on a button ? Should the use of MouseClick instead be more reliable?
...

Robert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2006, 11:23 am 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
Hi,
we are using testingsoftware from other companies (mercury) and even with "professional" software some clicks are not reliable.
Thus it's not the fault of AHK (only to mention it)

I made a small function as workaround.
The function clicks on the button (Parameter1) on the window (Parameter2) and waits till a new window appears with the title (Parameter3).
If the expected window does not appear within 2 seconds, the functions tries to click again. We never had problems again.

We click on a button and almost ever a new window should appear. Thus we can use that function.

Code:
KlickimmerWieder("Button2", "Windowtitle, "Select folder")
...
...
return
...
...
;Klickt auf dem Fenster "FensterTitel" solange auf den Button ButtonNummer, bis das Fenster "ErwarteterDialog" erscheint
KlickimmerWieder(ButtonNummer, FensterTitel, ErwarteterDialog)
{
   ;MsgBox %ButtonNummer% %FensterTitel% %ErwarteterDialog%
   loop,
   {
      ControlClick, %ButtonNummer%, %FensterTitel%      
      WinWait, %ErwarteterDialog%, , 2
      IfWinExist, %ErwarteterDialog%
      {         
         break
      }
   }
   return   
}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2006, 5:33 pm 
Offline

Joined: July 12th, 2005, 1:21 pm
Posts: 633
I got a good tip from BoBo:
Code:
Control,Enable,, Button1
Control,Check,, Button1

Works reliable in all scripts I use to Click fast!

Thalon

_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Same Problem
PostPosted: March 28th, 2006, 9:45 pm 
Offline

Joined: August 15th, 2005, 2:57 pm
Posts: 57
I have the same problem

Code:
  sleep 1000
  Control,Check,, Button1
  ControlClick, Next >, Choose Destination Location
  sleep 1000
  Control,Check,, Button2 
  ControlClick, Next >, Setup Type


The first button labeled "Next >" will be clicked but the second button labeled "Next >" will not be clicked. I have used Window Spy and determined the ClassName is correct for each button. I have tried the suggestion presented by Bobo in a post above by inserting the line "Control, Check,, Button1" and that does work for one but not the other.

It is interesting that "Check" works for buttons and "Enable" will not work for buttons. The help files says that "Check" is for check boxes and radio buttons. I have tried with just "Enable" and it will not work.

Oh well! I can still send keystrokes to accomplish what I want!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], migz99, sjc1000, Yahoo [Bot] and 75 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group