caramen

[SOLVED]Copy a file to clipboard

3 posts in this topic

#1 ·  Posted (edited)

Hello Guys,

I am trying to make a screenshoot copy it to clipboard and paste it into a word document i want to do that to simplify my procedures création. 

 

I am trying to use the way of sending Keys "^c" & "^v" i tryed also CTRLDOWN and c but no one of these is working. 

 

First question :

Why that's not working? 

Is there anyother way i can work with ?

 

I watched the help file for FileCopy but it s only moving Files and not copy them. 

 

Maybe you can see somthing going wrong in my script but i guess it s not a syntax problem. 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <ScreenCapture.au3>
#include <MsgBoxConstants.au3>

HotKeySet("{F2}", "Capture")
HotKeySet("{F3}", "Windows")
HotKeySet("{F4}", "Copy")

Global $Numero = 0

Attendre ()

Capture()

Func Capture()
    ; Capture full screen
    $Numero = $Numero+1
    _ScreenCapture_Capture (@DesktopDir & "\ScreenCapture\Image"&$Numero&".jpg")
    ShellExecute( @DesktopDir &"\ScreenCapture\Image"&$Numero&".jpg")
    Sleep (500)
    Run("C:\WINDOWS\EXPLORER.EXE /Select, /n,/e," & @DesktopDir & "\ScreenCapture\Image"&$Numero&".jpg" )
    WinWaitActive("ScreenCapture")
    Sleep(1500)
    Send("^c")
;~  Send ("{CTRLDOWN}")
;~     Sleep(10)
;~  Send ("C")
;~  Sleep(10)
;~  Send ("{CTRLUP}")
EndFunc   ;==>Example

Func Windows ()
   Global $Windows = WinGetTitle("[active]")
   MsgBox($MB_SYSTEMMODAL, "Windows", "Windows selected for copy is : "&@CRLF&$Windows)
EndFunc

Func Copy ()
   WinActivate (""&$Windows)
   Sleep (100)
   Send("^v")
;~      Send ("{CTRLDOWN}")
;~     Sleep(10)
;~  Send ("V")
;~  Sleep(10)
;~  Send ("{CTRLUP}")
EndFunc

Func Attendre ()
    While 1
       Sleep (10)
;~     GUICreate ("Help",100,100)
    WEnd
EndFunc

 

Edited by caramen

Share this post


Link to post
Share on other sites



You have absolutely no error checking in your script.
What is the return value and the value of @error after

_ScreenCapture_Capture

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I dont need to check if the copy is working because i am openning the directory just after the capture and then i can see the file is properly copyed. 

 

The probleme is solved with 

Send("{CTRLDOWN}v{CTRLUP}")

that way is working.

 

Evenwithout probleme i am gonna listen anytips you whould like to learn to me. 

btw: this is the help file : 

#include <ScreenCapture.au3>
_ScreenCapture_Capture ( [$sFileName = "" [, $iLeft = 0 [, $iTop = 0 [, $iRight = -1 [, $iBottom = -1 [, $bCursor = True]]]]]] )

There is no @error checking with return value . Or i am missing somthing with that ?

@error Is just if not file as been created. 
Edited by caramen

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

  • Similar Content

    • rudi
      By rudi
      Hello.
      I fail trying to save content from WhatsApp other then plain text to a file that way, that non-char-content will be preserved in it's correct encoding. e.g. Emojis are spoiled.
      I've tried to do so using just filewrite() as well as forcing UTF
      #include <clipboard.au3> MsgBox(0,"Ready to read clipboard","Mark some WhatsApp content with non-char elements, e.g. Emojis, copy that to your clipboard (CTRL+c), then click OK here.") $ClipContent=_ClipBoard_GetData() ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ClipContent = ' & $ClipContent & @CRLF & '>Error code: ' & @error & @CRLF & "Extended: " & @extended & @CRLF) ;### Debug Console $File="C:\temp\ClipSaveToFile.txt" $h=FileOpen($File,2+8+64) ; overwrite, create path, UTF16 FileWrite($h,$ClipContent) FileClose($h) $h=FileOpen($File,64) $NeuGelesen=FileRead($h) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $NeuGelesen = ' & $NeuGelesen & @CRLF & '>Error code: ' & @error & @CRLF & StringLen ($NeuGelesen) & @CRLF ) ;### Debug Console FileClose($h) _ClipBoard_SetData($NeuGelesen) MsgBox(0,"Done","Re-read content of TEMP file was placed to the clipboard. Now paste this into WhatsApp. (Emojis will be spoiled)") I've also tried other encodings (16, 32, 64, 512)

      Or what is a different, functional approach to save WhatsApp Content to File in a way, to be able to to get it back to post it back to WhatsApp?

      Regards, Rudi.
    • AndreyS
      By AndreyS
      Hello to you, dear developers!
      Could you please tell me if there is an easy way to determine if the information was pasted from the clipboard?
      Without any variation of the insertion via Ctrl+V, or through the context menu.
      I revised the Help and many forum topics, but found nothing suitable.
      Can there be any WinAPI system events that determine this event?
    • Nareshm
      By Nareshm
      Hi All,
      I have excel file like this
      and i want to cut cell/text from excel to other software.

       
      I have to cut the cell of B column one by one and past into other software
      If Winexists("No Data Found")
      then restore cuted cell and goto next/down side cell
      How to do it ?
    • Nareshm
      By Nareshm
      Its possible to past previously copied text to somewhere with autoit script ?
      If yes, How it ?
      example : Before I copied ABCD and then copied the PQRS, how to past the previously copied ABCD ?
    • Mag91
      By Mag91
      Hey Community,
      cause im too new in the Auto it world i will try it with the your help. hopefully.
      I woud like to know how i can handle my Problem.
      ----
      I have a Excel Data with 362 random numbers.
      For Example:
      1166642335374 1172899897343
      .....
      this numbers are a part of the filepath ...example
      D:\Projekte\1166_64233_5374
      as u can see its the first number of the Excel data. After the first 4 numbers it shoud make a "_" than another 5 "_"
      This is my first question. How can i handle this to make it Shell execute.
       
      --------
      Second question:
      If i am in the path.
      For Example:
      D:\Projekte\1166_64233_5374
      the code shoud search for specific PDF Files.
      They are named like: 0050569E364B1ED79B900F73E62660EC.pdf
      the first 15 letters are always the same
      0050569E364B1ED
      when he found this data he has to copy it on a Folder on the Desktop.
      (There can also be 2 or 3 pdfs in one Folder with this letters)
      ----
      Please give me some help :-)