 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
schling
Joined: 06 Mar 2006 Posts: 8
|
Posted: Sat Mar 11, 2006 12:32 am Post subject: ControlClick unreliable |
|
|
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 |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1238
|
Posted: Sat Mar 11, 2006 12:49 am Post subject: |
|
|
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  |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2397
|
Posted: Sat Mar 11, 2006 5:13 am Post subject: |
|
|
| 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 |
|
 |
Lemming
Joined: 20 Dec 2005 Posts: 150 Location: Malaysia
|
Posted: Sat Mar 11, 2006 6:46 am Post subject: Re: ControlClick unreliable |
|
|
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 |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 437 Location: Germany
|
Posted: Sat Mar 11, 2006 11:23 am Post subject: |
|
|
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 |
|
 |
Thalon
Joined: 12 Jul 2005 Posts: 640
|
Posted: Sat Mar 11, 2006 5:33 pm Post subject: |
|
|
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 |
|
 |
aarondellis
Joined: 15 Aug 2005 Posts: 57
|
Posted: Tue Mar 28, 2006 9:45 pm Post subject: Same Problem |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|