Raizeno Posted January 11, 2016 Share Posted January 11, 2016 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")EndfuncFunc 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 More sharing options...
InunoTaishou Posted January 11, 2016 Share Posted January 11, 2016 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 fastAutoItSetOption("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 More sharing options...
Bowmore Posted January 11, 2016 Share Posted January 11, 2016 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 More sharing options...
Raizeno Posted January 11, 2016 Author Share Posted January 11, 2016 I added sleep (2000) after ClipPut and it still doesn't work i get the same text pasted twice although im not pressing the same hotkey twice . Link to comment Share on other sites More sharing options...
JohnOne Posted January 11, 2016 Share Posted January 11, 2016 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 More sharing options...
Raizeno Posted January 11, 2016 Author Share Posted January 11, 2016 That doesn't solve it either i still get the same results . It's like the paste comes from somewhere else .... Link to comment Share on other sites More sharing options...
Danp2 Posted January 11, 2016 Share Posted January 11, 2016 Are you using any kind of clipboard manager? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Raizeno Posted January 11, 2016 Author Share Posted January 11, 2016 No .i even tried this on 2 computers and the results are the same . Link to comment Share on other sites More sharing options...
InunoTaishou Posted January 12, 2016 Share Posted January 12, 2016 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 windowsHotkeyset ("{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}") EndfuncThis works for me Link to comment Share on other sites More sharing options...
Raizeno Posted January 12, 2016 Author Share Posted January 12, 2016 (edited) 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 January 12, 2016 by Raizeno Link to comment Share on other sites More sharing options...
argumentum Posted January 12, 2016 Share Posted January 12, 2016 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) Endfunctry that Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted January 12, 2016 Share Posted January 12, 2016 @JohnOne , out of topic but still a somewhat relevant question. Back in the days of DOS, one would load the keyboard buffer. Can that be done with windows OS ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
JohnOne Posted January 12, 2016 Share Posted January 12, 2016 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. argumentum 1 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 More sharing options...
InunoTaishou Posted January 12, 2016 Share Posted January 12, 2016 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 More sharing options...
JohnOne Posted January 12, 2016 Share Posted January 12, 2016 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. 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 More sharing options...
Raizeno Posted January 12, 2016 Author Share Posted January 12, 2016 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) Endfunctry 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. argumentum 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now