Jump to content
Sign in to follow this  
mamut

How to "ControlSend" like pasting

Recommended Posts

mamut

Is it possible to use function ControlSend with NOT TYPING?

Explain:

$string="Some text"
$window=WinGetHandle("[active]")
ControlSend($window, "", "", $string)

and now function ControlSend doing something like:

1. send "Shit+S" to $window

2. send "o" to $window

3. send "m" to $window

4. send "e" to $window

etc...

now i want do to do something like this:

1. send "Some text" to $window (NOT TYPING JUST PASTE)

PS: Im using ControlSend because it's working even if windows is minimized so keep this in mind and I want solve my problem with ControlSend fucntion because if my PC is busy (CPU) then i have to increase Opt("SendKeyDelay", 500) and now if string is long i have to wait for soooo long.

Thanks in advance

Share this post


Link to post
Share on other sites
KaFu

Use controlsend not on windows but on controls. Obtain control id with au3info in Scite.

Assume you have an Edit control in the window, something like this might work:

ControlSend(WinGetHandle("[active]"), "", "[CLASS:Edit; INSTANCE:1]", "This is some text")
Edited by KaFu

Share this post


Link to post
Share on other sites
SpookMeister

Maybe?

ClipPut()

ControlSend($window,"","","^V")


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
KaFu

Maybe?

ClipPut()

ControlSend($window,"","","^V")

:) didn't thought that would work, but it does. If the receiving window 'knows' what to do with ^v this is fine, but if you want to paste to a certain control you'll have to obtain the id.

Share this post


Link to post
Share on other sites
SmOke_N

ControlSetText() if it's just text you're sending. It's much faster.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Andreik

Is it possible to use function ControlSend with NOT TYPING?

Explain:

$string="Some text"
$window=WinGetHandle("[active]")
ControlSend($window, "", "", $string)

and now function ControlSend doing something like:

1. send "Shit+S" to $window

2. send "o" to $window

3. send "m" to $window

4. send "e" to $window

etc...

now i want do to do something like this:

1. send "Some text" to $window (NOT TYPING JUST PASTE)

PS: Im using ControlSend because it's working even if windows is minimized so keep this in mind and I want solve my problem with ControlSend fucntion because if my PC is busy (CPU) then i have to increase Opt("SendKeyDelay", 500) and now if string is long i have to wait for soooo long.

Thanks in advance

Hope this example helps you:

AutoItSetOption("WinTitleMatchMode",2)
Run("notepad.exe")
WinWait("Notepad")
WinActivate("Notepad")
DefControlSend("Notepad","","Edit1","This is a test.")

Func DefControlSend($TITLE,$TEXT,$CONTROL,$STRING)
    ClipPut($STRING)
    ControlFocus($TITLE,$TEXT,$CONTROL)
    Send("^v")
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites
KaFu
mamut

ControlSetText() if it's just text you're sending. It's much faster.

Doesn't work, it sets window title, not pasting/sendig to window

Share this post


Link to post
Share on other sites
SmOke_N

Doesn't work, it sets window title, not pasting/sendig to window

To send the text, you need to send it to the control. You have it blank, of course it's not going to send to anything.

Using ControlSend() more than likely sends to the first edit control, or makes sure it's focused if you're not already focusing on it.

If it's too slow for you, and Send()/ControlSend() is the only thing working, then you may want to add in the Opt SendKeyDelay to 1 or 0.

If it's sending erroneous data, then try using the last parameter of ControlSend() and put 1 there for raw mode.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
ant1885

To send the text, you need to send it to the control. You have it blank, of course it's not going to send to anything.

Using ControlSend() more than likely sends to the first edit control, or makes sure it's focused if you're not already focusing on it.

If it's too slow for you, and Send()/ControlSend() is the only thing working, then you may want to add in the Opt SendKeyDelay to 1 or 0.

If it's sending erroneous data, then try using the last parameter of ControlSend() and put 1 there for raw mode.

sorry, may i ask, what if i already do that, using controlsend() with parameter 1, but there are still some error, like suddenly the text that i send become uppercase or like i press shift+character i wan to type.

for example, i want send "zero123" with ControlSend($window, "", "", "zero123",1) not somehow it become "zero!@#".

can somebody give some solution for this error, please?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.