Jump to content

ControlSend() with no Title

Recommended Posts

I am confused as to a return value I get when I use ControlSend() to send text to a control when I give an empty string for the window title. At first I was going to use this to send text to a window that had text that could not be counted on to be the same, but I realised this can be solved with WinTitleMatchMode 4. However, I am confused why the following code works the way it does. I expected a return value of 0 from the ControlSend() function because

Failure: Returns 0 if window/control is not found.

Since the text was not pasted into the explorer window in the sample code, doesn't this mean that the window was not found? And if so, why does the message box show that the return was 1?

;sample code to illustrate the issue
;for this code to work, please have an explorer window open when you run it
;also, please change the directory in the sample to a real directory on your system
;you should also not run the script in the directory you list in the code

$t = ControlSend("", "FolderView", "Edit1", "C:\TestDirectory{ENTER}")
MsgBox(0, "Value of $t", "$t = " & $t)

The reason I ask that you not run this script from the directory you tell it to ControlSend is because, if you do, you will not know if the script worked, or it you just stayed in your same directory. Since this script doesn't change directory for me, I assume that it failed to find the control in question. So why does $t become 1?

Also note that I do not need a soution to my problem of sending text to a variable titled explorer window. For the curious (and I know you're out there :D ) below is an example of what I did to solve my problem.

;solution to the problem of ControlSending text to an explorer window with a changing title

Opt("WinTitleMatchMode", 4)
$t = ControlSend("classname=ExploreWClass", "FolderView", "Edit1", "C:\TestDirectory{ENTER}")

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...