Docfxit Posted July 12, 2017 Posted July 12, 2017 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
Danyfirex Posted July 12, 2017 Posted July 12, 2017 Hello. Probably there is some no printable characters. try to write to a file and check the file contents. Filewrite("Somefile.txt",$UserCode1) Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Docfxit Posted July 12, 2017 Author Posted July 12, 2017 Thanks for the suggestion. The file was written with 0 bytes. Global $UserCode1 ClipPut("") ;Clear the clipboard ControlFocus($hWnd, "", "Edit3") Send("^{HOME}+^{END}") Send("{CTRLDOWN}c{CTRUP}") $UserCode1 = ClipGet() Filewrite("Somefile.txt",$UserCode1) MsgBox(0, "", "$UserCode1 = " & $UserCode1) Docfxit
Jfish Posted July 12, 2017 Posted July 12, 2017 (edited) EDIT: Guessing you key strokes are properly reading the value of the edit control into the clipboard ... my mistake. Edited July 12, 2017 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Danyfirex Posted July 12, 2017 Posted July 12, 2017 (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 July 12, 2017 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Docfxit Posted July 12, 2017 Author Posted July 12, 2017 (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 July 12, 2017 by Docfxit
Danp2 Posted July 12, 2017 Posted July 12, 2017 (edited) Have you tried using ControlGetText in lieu of the Send commands? Edited September 13, 2018 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs
Docfxit Posted July 12, 2017 Author Posted July 12, 2017 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
Mayar Posted September 13, 2018 Posted September 13, 2018 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
Docfxit Posted September 14, 2018 Author Posted September 14, 2018 Thank you very much for catching this. Docfxit
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