Jump to content

[SOLVED]Copy a file to clipboard


Recommended Posts

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

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
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
 Share

×
×
  • Create New...