AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ControlClick unreliable

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
schling



Joined: 06 Mar 2006
Posts: 8

PostPosted: Sat Mar 11, 2006 12:32 am    Post subject: ControlClick unreliable Reply with quote

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
Back to top
View user's profile Send private message
evl



Joined: 24 Aug 2005
Posts: 1238

PostPosted: Sat Mar 11, 2006 12:49 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2397

PostPosted: Sat Mar 11, 2006 5:13 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Lemming



Joined: 20 Dec 2005
Posts: 150
Location: Malaysia

PostPosted: Sat Mar 11, 2006 6:46 am    Post subject: Re: ControlClick unreliable Reply with quote

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
Back to top
View user's profile Send private message
Micha



Joined: 15 Nov 2005
Posts: 437
Location: Germany

PostPosted: Sat Mar 11, 2006 11:23 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Thalon



Joined: 12 Jul 2005
Posts: 640

PostPosted: Sat Mar 11, 2006 5:33 pm    Post subject: Reply with quote

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
SacredVault
Back to top
View user's profile Send private message
aarondellis



Joined: 15 Aug 2005
Posts: 57

PostPosted: Tue Mar 28, 2006 9:45 pm    Post subject: Same Problem Reply with quote

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!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group