Jump to content

Recommended Posts

Posted

Hi,

The following code has several glitches. Maybe I'm writing it wrong.

1) I'm using Windows XP SP2 and BlockInput has no effect (user can type during autoit script execution). I understand it should block user input.

2) the expected behavior of the ControlClick call in the example below is the selection of the word "test". It is NOT selected.

3) ControlSend fails to send the {DELETE} key. The last ControlSend call in the example below writes " test" to Notepad after "This is a test" (so I get "This is a test test") but it does not delete anything (ie. the {DEL} or {DELETE} keys are not sent or are ignored).

Any ideas?

$WINTITLE = "[CLASS:Notepad]"
$WINTEXT = "This is a test"
$CONTROL = "[CLASS:Edit; INSTANCE:1]"

WinActivate($WINTITLE, $WINTEXT)

If @OSVersion <> "WIN_98" And @OSVersion <> "WIN_ME" Then
    BlockInput(1)
EndIf

ControlFocus($WINTITLE, $WINTEXT, $CONTROL)
ControlClick($WINTITLE, $WINTEXT, $CONTROL, 2)
ControlSend($WINTITLE, $WINTEXT, $CONTROL, "{DELETE}{DEL}")
ControlSend($WINTITLE, $WINTEXT, $CONTROL, " test{DEL}{DEL}{DEL}{DEL}{DEL}")

BlockInput(0)
Posted (edited)

$WINTITLE = "[CLASS:Notepad]"
$WINTEXT = "This is a test"
$CONTROL = "Edit1"

WinActivate("Untitled - Notepad")

If @OSVersion <> "WIN_98" And @OSVersion <> "WIN_ME" Then
    BlockInput(1)
EndIf



ControlSend($WINTITLE, "", $CONTROL, "test")
controlsend($WINTITLE, "", $CONTROL, "{HOME}")
ControlSend($WINTITLE, "", $CONTROL, "{DELETE}{DEL}")

BlockInput(0)

You're trying to "delete" something after typing "test"..? That also does not work if you type "test" in notepad first, and then hit delete twice.

First use HOME, or use backspace.

Edited by notsure
Posted

First use HOME, or use backspace.

My bad. You're right. Point 3 was a silly mistake.

What about 1) and 2) ?

Any ideas?

Posted (edited)

1) Does it work when you leave the If out?

2) That you click the control twice doesn't have to mean "doubleclick". I'd use something like this:

controlsend($WINTITLE, "", $CONTROL, "{HOME}{SHIFTDOWN}{END}{SHIFTUP}")

to select the whole text.

Im not sure what you're trying to accomplish with it, so i dont know wheter this is the right way to do it or not.

Edited by notsure
Posted

My bad. You're right. Point 3 was a silly mistake.

What about 1) and 2) ?

Any ideas?

Another dumb mistake.

This works:

ControlClick($WINTITLE, $WINTEXT, $CONTROL, "left", 2)

So I'm left only with point 1).

Posted

I didn't try yet but @OSVersion yields WIN_XP.

Try sleep(5000) after the ControlClick

Your code is too fast to notice the Blockinput with the eye.

Then you'll see it works, blocks mouse and keyboard.

Posted

Try sleep(5000) after the ControlClick

Your code is too fast to notice the Blockinput with the eye.

Then you'll see it works, blocks mouse and keyboard.

You're right! I used sleep(1000) and it worked.

Maybe Blockinput should check internally that it's really blocking (if possible) before returning. That way a "sleep" would not be necessary. If a dev sees this... ;-)

Thanks for your feedback!

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...