Sign in to follow this  
Followers 0
tanis0

Problem Using ControlSend("^v") to Paste in Firefox

2 posts in this topic

Hi, I'm brand new to Autoit. I've searched and read around, but I haven't been able to figure this one out.

As the topic says, when I attempt to paste from the clipboard in Firefox, sometimes it pastes the thing twice and sometimes all I get is "v" instead of CTRL-V. Here's some sample code:

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

ControlSend($winHandle, "", "[CLASS:MozillaWindowClass]", "^f")
Sleep(1000)
ClipPut("comments")
Sleep(250)
ControlSend($winHandle, "", "[CLASS:MozillaWindowClass]", "^v")

The following are the three things I see sent to the Find text box in Firefox, though sometimes it remains blank:

comments

commentscomments

v

I've messed with SendKeyDelay and SenKeyDownDelay as I assume that is the root of the problem, but it seems no matter what I do, the problem is unaffected. Perhaps there is some way to verify the field after I do the paste to check if it was done correctly? Any ideas?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I tried your code, and I too got the 'comments' appearing twice consistently.

Opt("Wintitlematchmode",2)

AutoItSetOption ("SendKeyDelay", 100)

AutoItSetOption ("SendKeyDownDelay", 0)

WinActivate("Firefox")

ControlSend("Firefox", "", "[CLASS:MozillaWindowClass]", "^f")

Sleep(1000)

ClipPut("comments")

Sleep(250)

ControlSetText("Firefox", "", "[CLASSNN:MozillaWindowClass1]", "")

ControlFocus("Firefox", "", "[CLASSNN:MozillaWindowClass1]")

Send("^v")

I'm first setting focus on the field and using Send instead of ControlSend. It's not the perfect approach, but it seemed to work.

I'm not sure why ControlSend is working that way (seeming to past twice). See if the above solution works for you..

Cheers

--Edit--

You could use ClassnameNN to accurately work on controls. You can use the window info tool to see what the classnameNN is (which will also give u the instance). In your control statement, you use [CLASSNN:<classnameNN>].

To verify text, you can use ControlGetText from that field and verify its contents.

Edited by hydroxide

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