NullReferenceException
NullReferenceException

Reputation: 279

AutoIt: Send("{DOWN}") not working

I am running an "autoit3.chm" file. When it runs, I would like to send a down key arrow but it doesn't work:

$file = FileGetShortName("C:\Users\PHSD100-SIC\Desktop\AutoIt3.chm")
Run(@ComSpec & " /c start " & $file)
WinWaitActive("AutoIT Help")
Send("{DOWN}")

Upvotes: 2

Views: 5482

Answers (3)

TUSH2
TUSH2

Reputation: 29

Use following syntax for down key enter

Send("{DOWN 2}") 

and similar for Up key enter

Send("{UP 2}")

Upvotes: -1

Ryflex
Ryflex

Reputation: 5769

If you use the AutoIt Window Info tool, it helps with these issues, and it's also good practice to debug with ConsoleWrite(...)s.

For example, a simple one would be as before. However, you should probably use timeouts or variables and use the return for success/fail.

WinWaitActive("Window")
ConsoleWrite("Success")
Send("{DOWN}")
ConsoleWrite("Success")

Upvotes: 1

Samoth
Samoth

Reputation: 1707

Well, you're just waiting for the wrong Window Title... Try WinWaitActive("AutoIt Help") and it will work... Your "T" must be a "t"...
To find this out, you just need to check your script output and after your CHM-File has been opened you'll see that your script is still running. But you would have expected it to execute the Send(...) and then terminate. So your script must still be waiting for the expected window to appear. Which will lead you to double check your window title, probably you'll directly copy the window title with the AutoIt Window Info Tool, and this shows your mistake. Correct it. Viola, be happy =)

Besides: You don't need to run a Command-Prompt first, you can call ShellExecute($file) directly instead.

Upvotes: 5

Related Questions