Jump to content

Recommended Posts

Posted

I am trying to put something in the clipboard and then get it out.

Global $UserCode1
ClipPut("") ;Clear the clipboard

ControlFocus($hWnd, "", "Edit3")
Send("^{HOME}+^{END}")
Send("{CTRLDOWN}c{CTRUP}")
$UserCode1 = ClipGet()
MsgBox(0, "", "$UserCode1 = " & $UserCode1)

When MsgBox is displayed it doesn't show anything in $UserCode1.

If I bring up Notepad and do a <Ctrl>V it pastes in what is in the clipboard.

What am I doing wrong?

Thanks,

Docfxit

Posted

Hello. Probably there is some no printable characters. try to write to a file and check the file contents.

Filewrite("Somefile.txt",$UserCode1)

Saludos

Posted (edited)

So probably the clipboard content isn't raw text. So it's proceesed different. Probably you can paste to a dummy edit control them read the text back. I'm by phone right now so I can't build a sample script.

Saludos

Edited by Danyfirex
Posted (edited)
19 minutes ago, Jfish said:

where are you storing anything to the clipboard?  Looks like you are resetting it to blank and then reading it.  The send command is not putting those values to the clipboard.  See what I mean with the below:

ClipPut("")
send ("test")test
$val=ClipGet()
MsgBox(0,'',$val)
ClipPut("test put")
$val=ClipGet()
MsgBox(0,'',$val)

 

Thank you for catching that:

So I tried this:

Global $UserCode1
ClipPut("") ;Clear the clipboard

ControlFocus($hWnd, "", "Edit3")
Send("^{HOME}+^{END}")
Send("{CTRLDOWN}c{CTRUP}")
ClipPut($UserCode1)
Filewrite("Somefile.txt",$UserCode1)
MsgBox(0, "", "$UserCode1 = " & $UserCode1)

I thought the Send("{CTRLDOWN}c{CTRUP}") would put the text into the clipboard.

I thought all I needed to do was take it from the clipboard and put it into $UserCode1

If I bring up Notepad and do a <Ctrl>V it pastes in what is in the clipboard.

The file gets written with 0 bytes.

The MsgBox is displayed with nothing for $UserCode1

Docfxit

Edited by Docfxit
Posted
35 minutes ago, Danp2 said:

Have you tried using CongrolGetText in lieu of the Send commands?

That solved the problem.

Thank you very much,

Docfxit

  • 1 year later...
Posted

Hi,

Glad that the last fix worked for you.  Just a note for others, your original script may still work, but you had a typo:

 

Global $UserCode1
ClipPut("") ;Clear the clipboard

ControlFocus($hWnd, "", "Edit3")
Send("^{HOME}+^{END}")
Send("{CTRLDOWN}c{CTRUP}")
$UserCode1 = ClipGet()
MsgBox(0, "", "$UserCode1 = " & $UserCode1)

 

CTRUP should be CTRLUP. (you were missing the L)  Maybe this will make your script to work.

Note: you can also do the following to copy the selected text, since the ^ is equal to holding CTRL down before the letter. 

Send("^c")

see the Remarks from this page

https://www.autoitscript.com/autoit3/docs/functions/Send.htm

I hope it helps

 

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
  • Recently Browsing   0 members

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