Jump to content
Sign in to follow this  
erikson

Copy - paste with hotkeys

Recommended Posts

erikson

Hi all,

i try to make a script that copy some selected text and with a press on a hotkey will write that text in a .txt file. Can you give some hints where to start?

Share this post


Link to post
Share on other sites
water

You already found the solution :)

Open the AutoIt help and search for "Hotkey". If you need example scripts please search the forum for "hotkey" or even "hotkey copy paste".

This will get you started.

If you then have some code and still have questions please post question and code and we will try to help.


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
erikson

belive me that i first search the help file and the forum, but i don`t fine anything helpful ...

Share this post


Link to post
Share on other sites
water

Ok, to get you started. I use the following code in my scripts to mimic Ctrl+A (mark all) and Ctrl+C (copy to clipboard):

; Set two Dummy fields in the GUI
Global $hButtonStrgA = GUICtrlCreateDummy()
Global $hButtonStrgC = GUICtrlCreateDummy()

; Set accelerators for Strg+a and Strg+c
Global $asAccelKeys[2][2] = [["^a", $hButtonStrgA],["^c", $hButtonStrgC]]
GUISetAccelerators($asAccelKeys)

While 1
    $vMsg = GUIGetMsg(1)
        Case $vMsg[0] = $hButtonStrgA
            _SelectAll()
        Case $vMsg[0] = $hButtonStrgC
            _Clipboard()
    EndSelect
WEnd

Func _SelectAll()

    ; Mark all Entries in SysListView
    If ControlGetFocus($hForm1) = "SysListView321" Then
        _GUICtrlListView_SetItemSelected($hGUIUserList, -1, True)
    EndIf

EndFunc ;==>_SelectAll

Func _Clipboard()

    ; Copy selected items to clipboard
    $vZf = _GetSelectedItems()
    If $vZf = "" Then
        MsgBox(16, $sFormTitle, "Sie haben keine Datensätze ausgewählt!")
        Return
    EndIf

    ClipPut(StringStripWS($vZf, 2))

EndFunc ;==>_Clipboard

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
erikson

.

Edited by erikson

Share this post


Link to post
Share on other sites
erikson

So i figured out a little bit

hotkeyset ("{ESC}", "copy")
sleep (100)

func copy()
Send("{LCTRL}") ;Holds the A key down
send ("{c}" )
Send("{LCTRL}") ;Releases the A key

endfunc
$bak = ClipGet()
MsgBox(0, "Clipboard contains:", $bak)


$file= "G:\1.txt"
fileopen ($file, 1)
filewrite ($file , $bak )
fileclose ($file)

the question is , how do i make to run function only when i press ESC key

Share this post


Link to post
Share on other sites
water

Yes, this is just a code snipped and no complete solution for your problem.

The snipped shows how to establish CTRL+A and CTRL+C in a GUI. The functions _SelectAll and _Clipboard are tailored to my needs. They definitely have to be adapted by you.


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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.