Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; v0.09 Added +Insert for manual typing out of clipboard
- ; v0.08 Commented out Outside_of_browser lines
- ; v0.07 Removed BlockInput and made a workaround for script-reloading
- ; v0.06 Removed !. Emote shortcut due to already having it in Keyboard
- ; v0.05 Added ~ to #Space
- ; v0.04 Attempted to add !s to Terminal
- ; v0.03 Added Cortile conditional auto-start
- ; v0.02 Added MsgBox confirmation to Audacity normalization script
- ; v0.01 Initialization
- ; Tasks:
- ; Add GIMP plugin hotkey
- #Persistent
- #SingleInstance Force
- #HotIf WinActive('ahk_exe xed') ; If the Xed text editor is the currently active window
- ~^s::{ ; Press Ctrl+S
- Reload
- ; Run(A_ScriptFullPath) ; In case Reload fails: run another instance of this script
- ; ExitApp ; Close this script
- }
- #HotIf
- ;^Alt::^PgDn
- ;^LWin::^PgUp ; malfunctions and disables the Super key!
- !/::Send '{AppsKey}' ; Press Alt + /
- ~$#Space:: { ; Press Super+Space
- WinWaitActive('ahk_exe nemo') ; Waits for Nemo to launch (keyboard custom shortcut)
- If (A_ComputerName = 'LMC-R10') {
- Sleep 450
- Send '^l/media/' . A_Username . '/Seagate-ext4{Enter}' ; cd to the Seagate's ext4 partition
- Sleep 250
- }
- Send '^f' ; Presses Ctrl+F
- SoundBeep
- }
- ; ===== Browsers
- GroupAdd 'browsers', 'Google Chrome'
- GroupAdd 'browsers', 'Microsoft Edge'
- GroupAdd 'browsers', 'Firefox'
- GroupAdd 'browsers', 'Floorp'
- GroupAdd 'browsers', 'Waterfox'
- GroupAdd 'browsers', 'LibreWolf'
- GroupAdd 'chromium', 'Google Chrome'
- GroupAdd 'chromium', 'Microsoft Edge'
- GroupAdd 'mozilla', 'Firefox'
- GroupAdd 'mozilla', 'Floorp'
- GroupAdd 'mozilla', 'Waterfox'
- GroupAdd 'mozilla', 'LibreWolf'
- ;#HotIf WinActive('ahk_group browsers')
- ~MButton::{ ; Hold down the scroll wheel for 0.35 sec to close the current tab
- Sleep 350
- If (not WinActive('Tinkercad')) && GetKeyState('MButton') ; If the middle mouse button is still held down
- Send '{Escape}^w'
- }
- ;#HotIf
- #HotIf WinActive('ahk_group mozilla')
- !z::{ ; Enter Mozilla browser tab-searching mode
- Send '^l'
- Sleep 250
- Send '{bs}%{space}'
- }
- #HotIf WinActive('WhatsApp') ; Adapt find command for WhatsApp
- ^f::!k
- #HotIf
- #HotIf WinActive('Software Manager')
- !Left::'{bs}'
- #HotIf
- ; =====
- #HotIf WinActive('Signal') ; If Signal is the active window
- ~$+Control::^+t ; Press Shift+Ctrl to focus on the text field
- #HotIf
- F1::{
- If WinActive('ahk_exe' 'Audacity') {
- result := MsgBox('Normalize this whole track? (Must be in Audacity)',, 'YesNo')
- If (result = 'No')
- Return
- Send '^a'
- Sleep 500
- Send '!c'
- Sleep 500
- Send '{Down 2}'
- Sleep 500
- Send '{Enter 3}'
- }
- Else {
- MouseGetPos(&LocationX, &LocationY)
- A_Clipboard := "MouseClick('L', A_ScreenWidth*" . LocationX . '/' . A_ScreenWidth . ', A_ScreenHeight*' . LocationY . '/' . A_ScreenHeight . ') `; Pixel Color: ' . PixelGetColor(LocationX,LocationY)
- ToolTip LocationX . 'x' . LocationY . ' (mouse), ' . A_ScreenWidth . 'x' . A_ScreenHeight . ' (screen)`nCopied KS click coordinates + pixel color ' . PixelGetColor(LocationX,LocationY) . ' to the clipboard.'
- SetTimer () => ToolTip(), -10000
- LocationX := "" ; Clear memory
- LocationY := ""
- }
- }
- ;Use "EncodeDecodeURI(clipboard, false)" to decode or "(clipboard, true)" to encode the URL in the clipboard
- EncodeDecodeURI(str,encode:=True,component:=True){
- #import Ks { Clr } static Web := Clr.Load("System.Web.HttpUtility") return Web.HttpUtility.Url%(encode?"en":"de")%code(str)
- }
- PurgeClipboardURL() { ; Remove all known trackers and change WWW Reddit links to Old
- keep_question_marks := ""
- A_Clipboard := A_Clipboard ; Convert to plain text
- If InStr(A_Clipboard, ' › ') ; Convert Bing's spaced carets to slashes
- A_Clipboard := StrReplace(A_Clipboard, ' › ', '/')
- If InStr(A_Clipboard, '%') ; Decode the encoded URL
- A_Clipboard := EncodeDecodeURI(A_Clipboard, false)
- If InStr(A_Clipboard, 'http://') ; Force HTTPS
- A_Clipboard := StrReplace(A_Clipboard, 'p', 'ps')
- If InStr(A_Clipboard, '://www.reddit.com') ; Force all Reddit links to Old Reddit {
- A_Clipboard := StrReplace(A_Clipboard, '://www', '://old')
- Else if InStr(A_Clipboard, '://reddit.com')
- A_Clipboard := StrReplace(A_Clipboard, '://', '://old.')
- prefixes := ['//click.alert.ally.com/CL0/', 'https://www.ojrq.net/p/?return=', 'ref=notif&']
- For each, prefix in prefixes
- If InStr(A_Clipboard, prefix) { ; Delete any found prefixes
- A_Clipboard := StrReplace(A_Clipboard, prefix)
- break
- }
- If InStr(A_Clipboard, 'instagram.com/_u/') ; Remove "/_u" if present
- A_Clipboard := StrReplace(A_Clipboard, '/_u')
- If InStr(A_Clipboard, 'bing.com') ; Purge Bing URLs of trackers between "form=" and "q="{
- A_Clipboard := RegExReplace(A_Clipboard, '(form=).*(&q=)', 'q=')
- Else if not (InStr(A_Clipboard, 'indeed.com') or InStr(A_Clipboard, 'ebay') or InStr(A_Clipboard, '&uu='))
- A_Clipboard := RegExReplace(A_Clipboard, ".*?(u=|q=|url=)") ; Attempt to delete prefix redirectors: everything before "u=", "q=", etc.
- If InStr(A_Clipboard, '%') ; Decode the encoded URL again
- A_Clipboard := EncodeDecodeURI(A_Clipboard, false)
- If InStr(A_Clipboard, '?') { ; If the clipboard contents include a question mark
- whitelist := ['?post_id=', 'musicnotes.com','humblebundle.com/?key=', 'soundgym.co', 'walgreens.com', 'boardgamearena.com', 'indeed', 'youtube', 'abcnews.go', 'piped.video', 'play.google.com', 'linkedin.com/jobs/search/?currentJobId', 'bing.com', '?profile_id=', 'profile.php?id=', '?fbid=', ' ?obId=', 'cloudskillsboost.google', '?notif_id=', 'multi_permalinks', '?_nkw=', 'node=', 'rlkey=', 'schafffuneralhome.com', 'churchandchapel.com', 'bvfh', 'google.com/calendar/embed', 'beckerritter.com', '?story_fbid=', 'productName=CONSUMER_DEBIT_CARD', 'finviz.com', '.amazon.com/your-orders/order-details?orderID=', '/referral?referralCode=', '.facebook.com/watch/live/', 'amazon.com/gp/css/summary/print.html?orderID=', '.facebook.com/watch/?v=', '.redcrossblood.org/give.html/drive-results?'] ; rlkey is a Dropbox file access key; productName is a PayPal URL thing
- For exception in whitelist { ; Check whitelist entries one by one
- If InStr(A_Clipboard, exception) {
- If (InStr(A_Clipboard, 'similar-jobs?currentJobId=') or !InStr(A_Clipboard, '?si=') or !InStr(A_Clipboard, '.youtube.com/channel/')) ; If the clipboard's contents contain the currently checked exception
- keep_question_marks := 1
- global_exception := exception
- break
- }
- }
- If InStr(A_Clipboard, 'node=') or InStr(A_Clipboard, 'Namecheap') { ; If this is a Namecheap or Amazon node link
- TrayTip('If it`'s always followed by "&ref_", adjust the URL purger to delete that and everything else','Check for possible Amazon node or Namecheap package link!')
- A_Clipboard := StrSplit(A_Clipboard, "&utm")[1]
- }
- Else If (keep_question_marks = '') {
- If RegExMatch(A_Clipboard, 'story_fbid=.+&id=') ; If the clipboard contains '?story_fbid + stuff + &id='
- RegExReplace(A_Clipboard, '^([^&]*&[^&]*)&.*') ; Delete everything from the second '&' and on
- else
- A_Clipboard := StrSplit(A_Clipboard, "?")[1] ; Remove everything including and after the question mark
- ClipWait 0
- }
- Else If (global_exception != '')
- TrayTip('Keeping "?" and clearing everything else.','Whitelisted domain detected: ' . global_exception)
- ;Else TrayTip('Keeping "?" and clearing everything else.','Whitelisted domain detected!')
- keep_question_marks := '' ; Clear memory
- }
- If InStr(A_Clipboard, 'http') {
- A_Clipboard := RegExReplace(A_Clipboard, '(from=).*(&jk=)', 'jk=') ; Remove from=appsharedroid& on Indeed webpages
- A_Clipboard := RegExReplace(A_Clipboard, '&feature=shared') ; Remove &feature=shared
- A_Clipboard := RegExReplace(A_Clipboard, "('?si='|&|/ref=)(.*)")
- If not InStr(A_Clipboard, 'send.canine.tools') ; If the clipboard has "http" in it, but not "send.canine.tools"
- A_Clipboard := RegExReplace(A_Clipboard, '(#)(.*)') ; Delete anchors
- }
- }
- #HotIf !WinActive('ahk_class Gnome-terminal')
- ; Type Ctrl+Shift+V to strip the clipboard of formatting, purge any unclean URL of "?", "#", or "/ref=" + subsequent content (with a couple of exceptions, such as YouTube links), or convert WWW Reddit to Old Reddit, and then paste the cleaner output
- ^+v::{
- SoundBeep
- PurgeClipboardURL()
- Send('^v')
- }
- #HotIf
- !s::{ ; Press Alt+S to use sudo on the previous Terminal line
- If WinActive('ahk_class Gnome-terminal')
- Send 'sudo {!}{!}'
- }
- !,::{ ; Copy the link at the cursor, purge it of trackers, and open it in a new tab
- KeyWait(',')
- If not (WinActive(' - Google Sheets') or WinActive(' - Google Drive')) {
- ; Outside_of_browser := 0
- MouseClick('R')
- Sleep 100
- OldClipboard := A_Clipboard ; Back up contents of the clipboard
- Sleep 100
- If WinActive(' - Search') { ; If on Bing
- Send '!{LButton 3}' ; Highlight the double-right-clicked URL
- actions := ['^c', '^l', '^v', '{Enter}'] ; Go to it in the current tab
- For action in actions {
- If (action = '^v') {
- A_Clipboard := StrReplace(A_Clipboard, ' › ', '/') ; Convert Bing's spaced carets to slashes
- Sleep 150
- ClipWait 1
- If ((OldClipboard = A_Clipboard) or InStr(A_Clipboard, "…")) {
- actions.Pop() ; Remove '{Enter}' from the array
- TrayTip('… and is still ' . OldClipboard,"Not submitting; it either has an ellipsis or didn't change")
- }
- }
- Else Sleep 200
- Send action
- }
- }
- Else {
- Sleep 100
- Send '{Escape}{RButton}' ; Bring up the context menu
- Sleep 10
- If WinActive('ahk_group chromium')
- Send 'o' ; Copy the link in Chromium browsers
- Else If WinActive('ahk_exe Signal.exe') {
- Sleep 500
- Send '{Down}'
- Sleep 125
- Send '{Enter}'
- ClipWait(1)
- WinActivate('ahk_group browsers') ; Go to a browser
- Sleep 250
- ; Outside_of_browser := 1
- }
- Else Send 'l' ; Copy the link in Mozilla browsers
- Sleep 100
- ClipWait 1
- If InStr(A_Clipboard, "https://www.indeed.com/pagead/") {
- TrayTip('Sadly, page ads hide their job link...','Canceling due to Indeed page ad!')
- Return
- }
- PurgeClipboardURL() ; Purge the clipboard
- ClipWait 1
- If (OldClipboard = A_Clipboard) { ; Check for any clipboard change
- TrayTip("It's still " . OldClipboard,'Canceling due to no change in clipboard!')
- Return
- }
- Else {
- If WinExist('ahk_class Progman')
- WinActivate('ahk_class Progman') ; Mozilla block
- If InStr(A_Clipboard, 'http')
- Run(A_Clipboard) ; Open the copied link in a new tab
- Else {
- TrayTip('... but the clipboard does not contain a URL:`n' . A_Clipboard, 'Attempted to open a link...')
- Return
- }
- Sleep 200
- ; If (Outside_of_browser != 1)
- ; Send '^{PgUp}' ; Return to the prior tab
- }
- }
- SoundBeep
- OldClipboard := '' ; Clear memory
- ; Outside_of_browser := ''
- }
- Else Send '{F2}'
- }
- ; ===== 2×3 Monitor Management
- ; Finds monitor based on window center
- GetCurrentMonitor(hWnd) {
- WinGetPos(&x, &y, &w, &h, hWnd)
- centerX := x + (w / 2)
- centerY := y + (h / 2)
- Loop MonitorGetCount() {
- MonitorGet(A_Index, &mL, &mT, &mR, &mB)
- if (centerX >= mL && centerX < mR && centerY >= mT && centerY < mB)
- return A_Index
- }
- return MonitorGetPrimary()
- }
- Loop 9
- Hotkey("#Numpad" . A_Index, MoveOrMaximize.Bind(A_Index))
- Hotkey("#Numpad0", MoveOrMaximize.Bind(0)) ; Left 2/3 (Keep Height)
- Hotkey("#NumpadDot", MoveOrMaximize.Bind(10)) ; Right 2/3 (Keep Height)
- MoveOrMaximize(Index, *) {
- if !hWnd := WinExist("A")
- return
- ; 1. Get Current Window Position (Moved up so we can reuse H and Y)
- WinGetPos(&currX, &currY, &currW, &currH, hWnd)
- ; 2. Identify Monitor and Work Area
- mIndex := GetCurrentMonitor(hWnd)
- MonitorGetWorkArea(mIndex, &L, &T, &R, &B)
- mW := R - L
- mH := B - T
- ; 3. Calculate target dimensions
- ; --- Special Case: Left 2/3rds (Keep Y and H) ---
- if (Index == 0) {
- targetW := mW * (2/3)
- targetX := L
- targetH := currH ; Preserve current Height
- targetY := currY ; Preserve current Y position
- }
- ; --- Special Case: Right 2/3rds (Keep Y and H) ---
- else if (Index == 10) {
- targetW := mW * (2/3)
- targetX := L + (mW / 3)
- targetH := currH ; Preserve current Height
- targetY := currY ; Preserve current Y position
- }
- ; --- Standard Grid (Numpad 1-9) ---
- else {
- targetW := mW / 3
- if (Index >= 1 && Index <= 3) { ; Bottom Row
- targetH := mH / 2
- col := Index - 1
- targetX := L + (col * targetW)
- targetY := T + targetH
- }
- else if (Index >= 4 && Index <= 6) { ; Middle Row (Full Height)
- targetH := mH
- col := Index - 4
- targetX := L + (col * targetW)
- targetY := T
- }
- }
- }
- +Backspace::{
- SoundBeep
- Reload
- }
- +Insert::{ ; Type out the clipboard, one character at a time
- Loop 2 {
- KeyWait('Shift')
- KeyWait('Insert')
- }
- A_Clipboard := A_Clipboard ; Convert to plain text
- If InStr(A_Clipboard, "`n") {
- result := MsgBox('Line break detected in passage-to-type! Hold Shift when pressing Enter?',, 'YNC')
- If (result = 'Cancel')
- Return
- Else if (result = 'Yes')
- HoldShift := 1
- Else HoldShift := 0
- }
- If InStr(A_Clipboard, " ") {
- result := MsgBox('Indent detected in clipboard! Press it? (If not, script will ignore it)',, 'YNC')
- If (result = 'Cancel')
- Return
- Else if (result = 'Yes')
- OmitTab := 1
- Else OmitTab := 0
- }
- Loop Parse A_Clipboard,,"`r" { ;Ignore '`r' if found
- If (A_Loopfield="`n") {
- If (HoldShift)
- Send '+{Enter}'
- Else Send '{Enter}'
- Sleep 50
- }
- If (A_Loopfield=" ") and (OmitTab := 1)
- Send ''
- Else Send('{Raw}' . A_Loopfield)
- Sleep 5
- }
- If (StrLen(A_Clipboard) > 100) ; If clipboard contained >100 chars
- SoundBeep ; Beeps when done
- HoldShift := 0 ; Clear memory
- }
Advertisement