Sign in to follow this  
Followers 0
aleph01

ControlClick to a non-existant window

4 posts in this topic

Greetings:

I have come to wonder how AutoIt responds to a command to ControlClick on a control that doesn't exist because the window doesn't exist.  Is the command simply executed and ignored (since the control doesn't exist,) or is this not considered best practices?  I get no errors when I use this method and my code is shorter, but I would prefer to learn best practices for obvious reasons, and if there is a reason for not doing this, I would like to know.

Thanks for being there for me (and so many others - you guys are awesome!)

_aleph_


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites



In my scripts and the scripts I've seen I time the controlclick to happen after I call for that new control to show up. You want to have as much direct control over what your script does as you can but at the end of the day it needs to do what you want it to do in a time frame that you can live with. You could say something like "If Control exists then..."


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

I see.  I can use ControlGetHandle to see if the control exists.  Thanks, computergroove.


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites

..., and if there is a reason for not doing this, I would like to know....

 

the only reason i can think of would be incase you are not exact with which window you call, your script could accidentally click a control with the same id but in a different window with a similar name, could cause a headache or even more serious problem.

i dont know about "best practices" but if i KNOW there is no chance of mistaken window control, i am very hackish and blunt with my scripting, so long as it performs the tasks that i tell it, i dont care how neat and proper my code is.

for example, i have a script that performs the same as the old "NagKill" program that wont run on anything newer than xp (looking for a replacement for "NagKill" when i upgraded to win7 is what lead me to find AutoIt) it runs all the time and closes specific windows that pop up in a program that i use for work, i used to say...

if winexists("title","text") then winclose("title","text")

now i just send the winclose or winkill command regardless of whether the window exists.

as far as i can tell, AutoIt does not receive any feedback from Windows when sending the commands unless you tell it to check.

in my opinion, sending commands to a window or control that does not exist should be no more harmful than typing words on your keyboard when your cursor is not in a text box to receive the input.

:alien:


if @error Then
	MsgBox(262192,"",@ComputerName&" slaps "&@UserName&" around a bit with a large trout!")
	EndIf

>Exit code: 0

REAL search results

"Yeah yeah yeah, patience. How long will that take?"  -Ed Gruberman

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