Sign in to follow this  
Followers 0
Badriel

ControlSend issue

4 posts in this topic

Hello, I'm new to this forum and AutoIt in general.

I'm trying to use a ControlSend to send a mouseclick, and keystrokes into an application.

Even though, I get it working (application receives mouseclicks), after end of the function it always sends "1".

So, after each mousehold, it adds "1" into the target window.

Here's the script.

Global $ItemPick


HotKeySet("{F5}", "_ItemPick")
HotKeySet("{F11}", "_Exit")

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;



Func _ItemPick()
    $ItemPick = NOT $ItemPick
    While $ItemPick
        WinWaitActive("Bez tytułu — Notatnik")
        Sleep(Random(20, 80, 1))
        ControlSend ("Bez tytułu — Notatnik", "", "Edit1", MouseDown("left"), "") 
        Sleep (2000)
        ControlSend("Bez tytułu — Notatnik", "", "Edit1", MouseUp("left"), "")
    WEnd
EndFunc



Func _Exit()
      Exit  
EndFunc

"Bez tytułu — Notatnik" = Notepad in this case.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I suspect it has something to do with the fact that mousedown("button") returns "1" if on sucess. I don't think you should use controlsend with that function because you are probably sending the result AND performing the function. What if instead you just looped the activation of the window and the mousedown("left"), mouseup("left") without controlsend?

[edit: I tested it and it works ...]

WinWaitActive("Untitled - Notepad")

Sleep(Random(20, 80, 1))

MouseDown("left")

MsgBox("","","MouseDown",1)

Sleep (2000)

MouseUp("left")

MsgBox("","","MouseDown",1

JFish

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

I suspect it has something to do with the fact that mousedown("button") returns "1" if on sucess. I don't think you should use controlsend with that function because you are probably sending the result AND performing the function. What if instead you just looped the activation of the window and the mousedown("left"), mouseup("left") without controlsend?

JFish

Well, I guess that's the only option, but I really wanted to do it through controlsend. :)

Thank you for your support.

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