0

AutoHotKey を使用して、クリップボードに別のコピーを別のキーに割り当てることは可能ですか? たとえば、1 つの数字をコピーして F11 キーに割り当てたいので、F11 を押すとその数字が出力されます。しかし、別の番号をコピーして、その番号を F12 に割り当てたいと思います。これを行うことは可能ですか?スクリプトを編集して 1 つのキーに 1 つの数字を割り当てることができることはわかっていますが、これらのキーに割り当てる数字は急速に変化するため、毎回スクリプトを変更するのはあまり効率的ではありません。無理だと思いますが、質問させてください。AutoHotKey とスクリプトは初めてです。現在使用しているコードは次のとおりです。

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
~F11::
clipboard = %clipboard%
send %clipboard%
4

1 に答える 1

0

いくつかのオプションがあります:

オプション1。

+F11::  ; [Shift]+[F11] = ADD data to clipboard SHORT VERSION
    ClipBoard = ; Clear ClipBoard
    Send ^c ; Copy currently highlighted data
    Sleep, 50
    F11Save = %ClipBoard% ; Store ClipBoard data in variable %F11Save%
Return

+F11::  ; [Shift]+[F11] = ADD data to clipboard LONG VERSION
    TmpCB =%ClipBoard% ; Store previous ClipBoard Data
    ClipBoard = ; Clear ClipBoard
    Send ^c ; Copy currently highlighted data
    Sleep, 50
    F11Save = %ClipBoard%
    ClipBoard = %TmpSave% ; Restore previous ClipBoard TEXT content.
Return

F11::  ; paste text only...SHORT VERSION
    Send, %F11Save%
Return

F11::  ; paste text only...LONG VERSION
    ClipBoard = %F11Save%
    Send, ^v
Return

他のファンクション キーについても繰り返します。

オプション 2 は、私が以前に書いたものを使用します。

#SingleInstance Force
#installKeybdHook
#Persistent
; Written by Robert Ilbrink, The Netherlands
Menu, Tray, Icon , Shell32.dll, 100, 1
SetTitleMatchMode, 2
Global Nr := 1
x:=A_ScreenWidth-250
y:=A_ScreenHeight/2
; ================================== GUI ================================== 
ShowListBox:
Gui, Add, ListBox, h270 w195 vMyListBox gMyListBox, 01 %Array_1%|02 %Array_2%|03 %Array_3%|04 %Array_4%|05 %Array_5%|06 %Array_6%|07 %Array_7%|08 %Array_8%|09 %Array_9%|10 %Array_10%|11 %Array_11%|12 %Array_12%|13 %Array_13%|14 %Array_14%|15 %Array_15%|16 %Array_16%|17 %Array_17%|18 %Array_18%|19 %Array_19%|20 %Array_20%
Gui, Add, Button, x10  y275 w45 h20, Paste
Gui, Add, Button, x60  y275 w45 h20, Refresh
Gui, Add, Button, x110 y275 w45 h20, Help
Gui, Add, Button, x160 y275 w45 h20, Special
Gui, +AlwaysOnTop
WinGet, State, MinMax, 
If (State = -1)
    Return
Else
    Gui, Show, x%x% y%y%,MultiClipBoard
Exit
; ================================== SHORTCUTS ================================== 
+^1::MySend(Array_1)  ; [Shift]+[Ctrl]+1 pastes item 1
+^2::MySend(Array_2)  ; [Shift]+[Ctrl]+2 pastes item 2
+^3::MySend(Array_3)  ; [Shift]+[Ctrl]+3 pastes item 3
+^4::MySend(Array_4)  ; [Shift]+[Ctrl]+4 pastes item 4
+^5::MySend(Array_5)  ; [Shift]+[Ctrl]+5 pastes item 5
+^6::MySend(Array_6)  ; [Shift]+[Ctrl]+6 pastes item 6
+^7::MySend(Array_7)  ; [Shift]+[Ctrl]+7 pastes item 7
+^8::MySend(Array_8)  ; [Shift]+[Ctrl]+8 pastes item 8
+^9::MySend(Array_9)  ; [Shift]+[Ctrl]+9 pastes item 9
+^0::MySend(Array_10) ; [Shift]+[Ctrl]+0 pastes item 10
+^q::MySend(Array_11) ; [Shift]+[Ctrl]+q pastes item 11
+^w::MySend(Array_12) ; [Shift]+[Ctrl]+w pastes item 12
+^e::MySend(Array_13) ; [Shift]+[Ctrl]+e pastes item 13
+^r::MySend(Array_14) ; [Shift]+[Ctrl]+r pastes item 14
+^t::MySend(Array_15) ; [Shift]+[Ctrl]+t pastes item 15
+^y::MySend(Array_16) ; [Shift]+[Ctrl]+y pastes item 16
+^u::MySend(Array_17) ; [Shift]+[Ctrl]+u pastes item 17
+^i::MySend(Array_18) ; [Shift]+[Ctrl]+i pastes item 18
+^o::MySend(Array_19) ; [Shift]+[Ctrl]+o pastes item 19
+^p::MySend(Array_20) ; [Shift]+[Ctrl]+p pastes item 20
; ================================== NUMPAD SHORTCUTS ================================== 
^Numpad1::MySend(Array_1)  ; [Ctrl]+1 pastes item 1
^Numpad2::MySend(Array_2)  ; [Ctrl]+2 pastes item 2
^Numpad3::MySend(Array_3)  ; [Ctrl]+3 pastes item 13
^Numpad4::MySend(Array_4)  ; [Ctrl]+4 pastes item 4
^Numpad5::MySend(Array_5)  ; [Ctrl]+5 pastes item 5
^Numpad6::MySend(Array_6)  ; [Ctrl]+6 pastes item 6
^Numpad7::MySend(Array_7)  ; [Ctrl]+7 pastes item 7
^Numpad8::MySend(Array_8)  ; [Ctrl]+8 pastes item 8
^Numpad9::MySend(Array_9)  ; [Ctrl]+9 pastes item 9
^Numpad0::MySend(Array_10)  ; [Ctrl]+0 pastes item 10
+^Numpad1::MySend(Array_11)  ; [Shift]+[Ctrl]+1 pastes item 11
+^Numpad2::MySend(Array_12)  ; [Shift]+[Ctrl]+2 pastes item 12
+^Numpad3::MySend(Array_13)  ; [Shift]+[Ctrl]+3 pastes item 13
+^Numpad4::MySend(Array_14)  ; [Shift]+[Ctrl]+4 pastes item 14
+^Numpad5::MySend(Array_15)  ; [Shift]+[Ctrl]+5 pastes item 15
+^Numpad6::MySend(Array_16)  ; [Shift]+[Ctrl]+6 pastes item 16
+^Numpad7::MySend(Array_17)  ; [Shift]+[Ctrl]+7 pastes item 17
+^Numpad8::MySend(Array_18)  ; [Shift]+[Ctrl]+8 pastes item 18
+^Numpad9::MySend(Array_19)  ; [Shift]+[Ctrl]+9 pastes item 19
+^Numpad0::MySend(Array_20)  ; [Shift]+[Ctrl]+0 pastes item 20
; ================================== SEND FUNCTION ================================== 
MySend(Item)
{
    ClipBoard = %Item%
    IfWinActive, MultiClipBoard
        Send, !{Esc}
    Sleep, 100
    Send, ^v
}
; ================================== SINGLE or DOUBLE CLICK ================================== 
MyListBox: ; Single Click (Normal) or Double Click (DoubleClick) to paste data back to other application
if A_GuiControlEvent <> Normal ; Alternatively use "DoubleClick"
    return
GuiControlGet, MyListBox  ; Retrieve the ListBox's current MultiClipBoard.
StringTrimLeft, ClipBoard, MyListBox, 3 
Send, !{Esc}
Sleep, 200
Send, ^v
;Send, {Enter}
;SendInput, %MyListBox%{Tab}
return
; ================================== PASTE BUTTON ================================== 
ButtonPaste: ; Select an item with [Up] / [Down] arrows and press [Paste] to paste data back to other application
Gui, Submit, NoHide
StringTrimLeft, ClipBoard, MyListBox, 3 
Send, !{Esc}
Sleep, 200
Send, ^v
;SendInput, %MyListBox%{Tab}
Return
; ================================== EXIT / CLOSE BUTTONS ================================== 
GuiClose:
GuiEscape:
Gui, Destroy
ExitApp
; ================================== REFRESH BUTTON ================================== 
ButtonRefresh:
Gui,+LastFound
WinGetPos,x,y,w,h
Gui, Destroy
GoSub, ShowListBox
Return
; ================================== Copy Into the List ================================== 
Browser_Favorites:: ; [Star] key to copy to clipboard.
!c:: ; [Alt]+c to copy to multiClipboard.
#c:: ; [Win]+c to copy to multiClipboard.
Send, ^c
Sleep, 100
Array_%Nr% := ClipBoard
Nr++
If (Nr >20) ; wrap around after 20 entries
    Nr:=1
WinGet, State, MinMax, MultiClipBoard
If (State = -1)
    Return ; GUI, Show
Gui,+LastFound
WinGetPos,x,y,w,h
Gui, Destroy
GoSub, ShowListBox
Return
; ================================== CLEAR / OPEN / SAVE ================================== 
ButtonSpecial:
SetTimer, ChangeButtonNames, 30 
MsgBox, 4098, Special Action, [Clear]`, Clears all items`n[Upload]`, Upload a txt file`n[Save]`, Save current list.
IfMsgBox, Abort ;  ================================== CLEAR ================================== 
{
    MsgBox, 4100,, Are you sure to clear the list?
    IfMsgBox No
        Return
    Nr := 1
    Loop, 20
    {
        Array_%Nr% = 
        Nr++
    }
    Nr := 1
    Gui,+LastFound
    WinGetPos,x,y,w,h
    Gui, Destroy
    GoSub, ShowListBox
    Exit
}
Else ifMsgBox, Retry ;  ================================== OPEN ================================== 
{
    FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt)
    If SelectedFile =
        Exit
    Else
    {
        Loop, read, %SelectedFile%
        {
            If A_LoopReadLine =
                Break
            Array_%A_Index% := A_LoopReadLine
            If (A_Index > 20)
                Break
            Nr := A_Index + 1
        }
    }
    
    Gui,+LastFound
    WinGetPos,x,y,w,h
    Gui, Destroy
    GoSub, ShowListBox
    Exit
}
Else ifMsgBox, Ignore ;  ================================== SAVE ================================== 
{
        FileSelectFile, SelectedFile, S, , Save the list as a Text Document, (*.txt)
        StringReplace, SelectedFile, SelectedFile, `.txt, 
        FileDelete, %SelectedFile%.txt
        Loop, 20
        {
            CurrentLine := Array_%A_Index%
            FileAppend, %CurrentLine%`n, %SelectedFile%.txt ; % Array_%A_Index%, doesn't work
        }
}
Exit
; ================================== HELP BUTTON ================================== 
ButtonHelp:
MsgBox, , MultiClipBoard Help, Press [Alt]+c or [Win]+c to copy highlighted data onto the clipboard (TEXT only).`n`nClick on an item to paste it to the last active application.`n`nPress [Refresh] to refresh the screen after items were added while minimized.`n`nPress [Special] to select`n[Clear] to clear the list (after confirmation),`n[Load] to load items from a file or`n[Save] to save current items to a file. `n`n[Shift]+[Ctrl]+[nr] (1...0) will paste item 1...10.`n[Shift]+[Ctrl]+[letter] (qwertyuiop) will paste item 11...20.
; ================================== RENAME STANDARD MSGBOX BUTTONS FOR SPECIAL MENU ================================== 
ChangeButtonNames: 
IfWinNotExist, Special Action
    return  ; Keep trying.
SetTimer, ChangeButtonNames, off 
WinActivate 
ControlSetText, Button1, &Clear 
ControlSetText, Button2, &Open
ControlSetText, Button3, &Save 
return
; ================================== END ================================== 

これにより、最大 20 個のアイテムを保存 ( win+c または+c)できる小さなウィンドウが表示されます。Altリスト内の項目の 1 つをクリックすると、開いているアプリケーションに送信されます。

Shift+ Ctrl+Nrまたは数字の下の文字を使用して、保存されたデータを送信する機能を追加しました。

于 2013-04-02T18:56:14.237 に答える