Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=98723
- ; dont forget to create .ini file
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- #SingleInstance, Force
- SetKeyDelay, -1
- clip := [], maxClips := 2, maxTitleLen := 20
- Loop, %maxClips% {
- Menu, %A_Index%, Add, Copy, Copy
- Menu, clips, Add, CLIP%A_Index% =, :%A_Index% ; Create a main menu item
- }
- Menu, clips, Add
- Menu, clips, Add, Clear All, ClearAll
- !LButton Up::
- KeyWait, Alt
- Menu, clips, Show
- Return
- Copy:
- myinipath = C:\Users\Name\Desktop\test1.ini ; file content [Section]
- Clipboard =
- Send ^c
- ClipWait, 0
- If !ErrorLevel {
- clip[A_ThisMenu] := Clipboard ; Store the full clip
- Menu, clips, Rename, %A_ThisMenu%&, % SubStr(Clipboard, 1, maxTitleLen) ; Change item name to short title
- Menu, %A_ThisMenu%, Add, Paste
- Menu, %A_ThisMenu%, Add, Clear
- } Else MsgBox, 48, Error, An error occurred while waiting for the clipboard.
- IniWrite, % SubStr(Clipboard, 1, maxTitleLen), %myinipath%, Section, %A_ThisMenu%
- Return
- ; use ini variable in template
- ;~ myinipath = C:\Users\Name\Desktop\test1.ini
- ;~ IniRead, OutputVar, %myinipath%, Section, 1
- ;~ MsgBox, %OutputVar%
- Paste:
- content := clip[A_ThisMenu]
- Clipboard := content
- send, ^v
- ;SendInput % "{Text}" clip[A_ThisMenu] ; Paste clip by menu item number
- clip.RemoveAt(A_ThisMenu)
- Menu, clips, Rename, %A_ThisMenu%&, CLIP%A_ThisMenu% =
- Menu, %A_ThisMenu%, Delete, Paste
- Menu, %A_ThisMenu%, Delete, Clear
- emptyVar =
- IniWrite, %emptyVar%, %myinipath%, Section, %A_ThisMenu%
- Return
- Clear:
- clip.RemoveAt(A_ThisMenu)
- Menu, clips, Rename, %A_ThisMenu%&, CLIP%A_ThisMenu% =
- Menu, %A_ThisMenu%, Delete, Paste
- Menu, %A_ThisMenu%, Delete, Clear
- emptyVar =
- IniWrite, %emptyVar%, %myinipath%, Section, %A_ThisMenu%
- Return
- ClearAll:
- myinipath = C:\Users\Name\Desktop\test1.ini
- emptyVar =
- loop, 3 {
- x++
- IniWrite, %emptyVar%, %myinipath%, Section, %x%
- }
- Reload
- return
Add Comment
Please, Sign In to add comment