Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; TODO: adapt file path below
- ; Ctr+3 copies the highlighted word, the surrounding paragraph, and the URL to a csv file
- #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.
- ^3::
- tmp := clipboard
- clipboard := ""
- Send, ^c
- ClipWait, 2
- word := RegExReplace( RegExReplace(RegExReplace(clipboard, "\r?\n"," "), "(^\s+|\s+$)"), ";", "," )
- clipboard := ""
- bLength := StrLen(clipboard)
- newLineRegex := "\r*\n\s*\r*\n"
- rReplaceRegex := "(.+)\r*\n\s*\r*\n.*"
- lReplaceRegex := ".*\r*\n\s*\r*\n(.*+)"
- Send, +{Down}
- IfWinActive ahk_exe firefox.exe
- Loop
- {
- Send, ^c
- ClipWait, 2
- aLength := StrLen(clipboard)
- if ( RegExMatch( clipboard, newLineRegex ) or bLength == aLength )
- break ; Terminate the loop
- else {
- Send, +{Down}
- clipboard := ""
- bLength := aLength
- continue ; Skip the below and start a new iteration
- }
- }
- rContext := RegExReplace( clipboard, rReplaceRegex, "$1" )
- clipboard := ""
- Sleep, 200
- bLength := StrLen(clipboard)
- Send, +{Up}
- IfWinActive ahk_exe firefox.exe
- Loop
- {
- Send, ^c
- ClipWait, 2
- aLength := StrLen(clipboard)
- if ( RegExMatch( clipboard, newLineRegex ) or bLength == aLength )
- break ; Terminate the loop
- else {
- Send, +{Up}
- clipboard := ""
- bLength := aLength
- continue ; Skip the below and start a new iteration
- }
- }
- context := RegExReplace( clipboard, lReplaceRegex, "$1" ) rContext
- context := RegExReplace( RegExReplace(RegExReplace( context, "\r?\n"," "), "(^\s+|\s+$)"), ";", "," )
- clipboard := ""
- Sleep, 200
- IfWinActive ahk_exe firefox.exe
- Send, ^l
- Sleep, 100
- Send, ^c
- ClipWait, 2
- link := RegExReplace(RegExReplace(clipboard, "\r?\n"," "), "(^\s+|\s+$)")
- clipboard := tmp ; restores original clipboard
- Sleep, 100
- ClipWait
- Sleep, 100
- ClipWait
- FileAppend, %word%;%context%;%link%;`n, C:\Users\TODO\Documents\Anki.txt
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement