Jump to content

ClipPut () doesn't work properly


Raizeno
 Share

Recommended Posts

So i have 2 strings $txt1 and $txt2 

What I'm trying to do is :

Hotkeyset ("{F9}","text1")

Hotkeyset ("{F10}","text2")

Func text1 ()

Clipput($txt1)

Send("^v")

Endfunc

Func text2 ()

Clipput($txt2)

Send("^v")

Endfunc

 

So i want to paste each of those strings at the press of a button 

Here is where it gets weird : when i try to do this in the android emulator Bluestacks if i press F9 then F10 instead of geting both strings pasted i get txt1 pasted twice and this goes on like that . Seems like clipput doesn't work properly with this emulator any ideeas why ?

I also tried this in notepad and works as intended so i dont think it's something wrong with my script...

 

 

Link to comment
Share on other sites

I opened it up too and get the same problem. Doesn't look like it's an issue with autoit but rather an issue with the way the android emulator stores the clipboard buffer. That or it's something to do with the Ctrl key. It seemed like there was an issue doing Ctrl+A when I was trying to highlight my editor.

You could try doing ControlSend instead. This script seemed to send the string pretty fast

AutoItSetOption("SendKeyDelay", 0)
AutoItSetOption("SendKeyDownDelay", 0)

Hotkeyset ("{F9}","text1")
Hotkeyset ("{F10}","text2")

Global $txt1 = "Test string 1"
Global $txt2 = "Test string 2"

While 1
    Sleep(100)
WEnd

Func text1()
    ControlSend("BlueStacks App Player", "", "", $txt1)
Endfunc

Func text2()
    ControlSend("BlueStacks App Player", "", "", $txt2)
Endfunc

 

Link to comment
Share on other sites

You have to give the OS time to store and organise the data in the clipboard. Try adding a short sleep after Clipput()

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Func text1()
    Do
        ClipPut($txt1)
        Sleep(10)
    Until ClipGet() = $txt1
    Send("^v")
EndFunc   ;==>text1

Func text2()
    Do
        ClipPut($txt2)
        Sleep(10)
    Until ClipGet() = $txt2
    Send("^v")
EndFunc

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Func text1()
    Do
        ClipPut($txt1)
        Sleep(10)
    Until ClipGet() = $txt1
    Send("^v")
EndFunc   ;==>text1

Func text2()
    Do
        ClipPut($txt2)
        Sleep(10)
    Until ClipGet() = $txt2
    Send("^v")
EndFunc

 

That's exactly what I did to! He's right though, it still didn't work.

Did a little googling and it turns out I was pretty close, it's something to do with the Control key. If you do {CtrlDown}, sleep, then {v} it will work properly. I guess it's same way the bluestacks player is getting the ctrl key from windows

Hotkeyset ("{F9}","text1")
Hotkeyset ("{F10}","text2")

Global $txt1 = "Test string 1"
Global $txt2 = "Test string 2"

While 1
    Sleep(100)
WEnd

Func text1()
    ClipPut($txt1)
    Send("{CtrlDown}")
    Sleep(500)
    Send("{v}")
    Send("{CtrlUp}")
Endfunc

Func text2()
    ClipPut($txt2)
    Send("{CtrlDown}")
    Sleep(500)
    Send("{v}")
    Send("{CtrlUp}")
Endfunc

This works for me

Link to comment
Share on other sites

Still doesn't work . 

I think android has it's own clipboard and there is a built in timer till it imports the windows clipboard. I mean the frequency of the recheck .

That's the only thing that makes sense. 

Edited by Raizeno
Link to comment
Share on other sites

me, me, me. I've got it !

AutoItSetOption("SendKeyDelay", 10)
AutoItSetOption("SendKeyDownDelay", 10)

Hotkeyset ("{ESC}","bye")
Hotkeyset ("{F9}","text1")
Hotkeyset ("{F10}","text2")

Global $txt1 = "Test string 1"
Global $txt2 = "Test string 2"

While 1
    Sleep(100)
WEnd

Func bye()
    Exit
EndFunc

Func text1()
    Send($txt1)
Endfunc

Func text2()
    Send($txt2)
Endfunc

try that :)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

I honestly don't even know what that means, my first encounter with a PC was windows xp about 7 years ago.

If I were to guess though, I'd the likes of send and it's windows api (probably sendinput) do not go near the actual keyboard, which is what I suspect it might have done in the dos.

When I've searched in the past for how to avoid automation detection, the same answer always pooped up... "if you want to do that, you need to write your own driver".

But when dos was out, probably a driver to me, was the man I paid my bus fare to.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Still doesn't work . 

I think android has it's own clipboard and there is a built in timer till it imports the windows clipboard. I mean the frequency of the recheck .

That's the only thing that makes sense. 

I don't think it works that way. I googled BlueStacks Ctrl v and people said to long press Ctrl and then v (also a and c for all/copy). Makes me more or less think that the window is waiting for the ctrl key to be registered to the GUI. When it recognizes that it's been pressed/is pressed it starts copying the clipboard from windows and starts converting it into a format that is valid for android. It's like there's a Hotkey (more than likely a thread) for the Control key and a second hotkey (or thread) for Ctrl + v that go to two separate functions.

So the application needs a few milis to finish getting clipboard from windows and converting/setting in android. My example worked for me each time I used it, tested it 4-5 times alternating between F9 and F10, if it doesn't work for you maybe increase the sleep delay (I've got windows 7 x64, i5-3570k CPU @ 3.4ghz, 8gigs ram @ 2133hz)

Link to comment
Share on other sites

I don't think it works that way. I googled BlueStacks Ctrl v and people said to long press Ctrl and then v (also a and c for all/copy). Makes me more or less think that the window is waiting for the ctrl key to be registered to the GUI. When it recognizes that it's been pressed/is pressed it starts copying the clipboard from windows and starts converting it into a format that is valid for android. It's like there's a Hotkey (more than likely a thread) for the Control key and a second hotkey (or thread) for Ctrl + v that go to two separate functions.

So the application needs a few milis to finish getting clipboard from windows and converting/setting in android. My example worked for me each time I used it, tested it 4-5 times alternating between F9 and F10, if it doesn't work for you maybe increase the sleep delay (I've got windows 7 x64, i5-3570k CPU @ 3.4ghz, 8gigs ram @ 2133hz)

I ran this on 2 computers one being a bit old and the other is an i7 laptop 4 gb ram same results .

Just going to say, OP computer might just be plop.

Last time I installed bluestacks it hammered the resources and ran like a bag of shite.

I later tried Andy and it was well better.

As far as Andy goes it is good for small period of times with a bonus for ease of use. But if your trying to automate something in Andy over a long period of time it has severe memory leaks it goes up to the point it crashes my computer.

The best emulator i found so far was Genymotion but it has a more difficult setup than the usual emulators. Might have to get back on that .

 

me, me, me. I've got it !

AutoItSetOption("SendKeyDelay", 10)
AutoItSetOption("SendKeyDownDelay", 10)

Hotkeyset ("{ESC}","bye")
Hotkeyset ("{F9}","text1")
Hotkeyset ("{F10}","text2")

Global $txt1 = "Test string 1"
Global $txt2 = "Test string 2"

While 1
    Sleep(100)
WEnd

Func bye()
    Exit
EndFunc

Func text1()
    Send($txt1)
Endfunc

Func text2()
    Send($txt2)
Endfunc

try that :)

I tried that too but the ammount of text is about 100 char long and since i want this script to run on my low performance computer it take a lot of time to send that even with SendKeyDelay 0 so i realy need the use of clipboard.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...