Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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.
- ;;;;;;;;;;GENERAL SETTINGS;;;;;;;;;;;;;;;
- ;reload script automatic
- #SingleInstance force
- ;------------------------------------------------------------------------------
- ; Window on Top
- ;------------------------------------------------------------------------------
- ^+SPACE::
- WinGetTitle, activeWindow, A
- if IsWindowAlwaysOnTop(activeWindow) {
- notificationMessage := "The window """ . activeWindow . """ is now always on top."
- notificationIcon := 16 + 1 ; No notification sound (16) + Info icon (1)
- }
- else {
- notificationMessage := "The window """ . activeWindow . """ is no longer always on top."
- notificationIcon := 16 + 2 ; No notification sound (16) + Warning icon (2)
- }
- Winset, Alwaysontop, , A
- TrayTip, Always-on-top, %notificationMessage%, , %notificationIcon%
- Sleep 3000 ; Let it display for 3 seconds.
- HideTrayTip()
- IsWindowAlwaysOnTop(windowTitle) {
- WinGet, windowStyle, ExStyle, %windowTitle%
- isWindowAlwaysOnTop := if (windowStyle & 0x8) ? false : true ; 0x8 is WS_EX_TOPMOST.
- return isWindowAlwaysOnTop
- }
- HideTrayTip() {
- TrayTip ; Attempt to hide it the normal way.
- if SubStr(A_OSVersion,1,3) = "10." {
- Menu Tray, NoIcon
- Sleep 200 ; It may be necessary to adjust this sleep.
- Menu Tray, Icon
- }
- }
- Return
- ;================================================================================================
- ; CAPS REMAPS
- ;================================================================================================
- ; Functionality:
- ; - Deactivates capslock for normal (accidental) use.
- ; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
- ; - Access the following functions when pressing Capslock:
- ; Cursor keys - J, K, L, I
- ; Enter - Space
- ; Home, PgDn, PgUp, End - (IN PROGRESS)
- ; Backspace and Del - N, M
- ;
- ; Insert - B
- ; Close tab, window - W, R
- ; Next, previous tab - Tab, Q
- ; Undo, redo - , and .
- ;
- ; This script is mostly assembled from modified versions of the following awesome scripts:
- ;
- ; # Home Row Computing by Gustavo Duarte: http://duartes.org/gustavo/blog/post/home-row-computing for
- ; Changes:
- ; - Does not need register remapping of AppsKey using SharpKeys.
- ; - Uses normal cursor key layout
- ; - Added more hotkeys for insert, undo, redo etc.
- #Persistent
- SetCapsLockState, AlwaysOff
- ; Make Win Key + Capslock work like Capslock (in case it's ever needed)
- #Capslock::
- If GetKeyState("CapsLock", "T") = 1
- SetCapsLockState, AlwaysOff
- Else
- SetCapsLockState, AlwaysOn
- Return
- ; ShareX Commands via CapsLock
- Capslock & s::SendInput !{F1}
- Capslock & e::SendInput !{F2}
- Capslock & o::SendInput !{F3}
- Capslock & r::SendInput !{F5}
- ; Powertoys ColorPiker
- Capslock & p::SendInput #+C
- ; Get DEFINITION of selected word.
- CapsLock & d::
- ClipboardGet()
- Run, http://www.google.com/search?q=define+%clipboard% ; Launch with contents of clipboard
- ClipboardRestore()
- Return
- ; GOOGLE the selected text.
- CapsLock & g::
- ClipboardGet()
- Run, http://www.google.com/search?q=%clipboard% ; Launch with contents of clipboard
- ClipboardRestore()
- Return
- ; Do THESAURUS of selected word
- CapsLock & t::
- ClipboardGet()
- Run http://www.thesaurus.com/browse/%Clipboard% ; Launch with contents of clipboard
- ClipboardRestore()
- Return
- ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;CapsLock & V to open Vivaldi
- CapsLock & v::
- Run, "C:\Users\Brian\AppData\Local\Vivaldi\Application\vivaldi.exe"
- Return
- ;CapsLock & n to open Obsidian
- CapsLock & n::
- Run, "C:\Users\Brian\AppData\Local\Obsidian\Obsidian.exe"
- Return
- ;CapsLock & m to open eMClient
- CapsLock & m::
- Run, "C:\Program Files (x86)\eM Client\MailClient.exe"
- Return
- ;================================================================================================
- ; Caps Delay functions.
- ;================================================================================================
- AutoTrim On ; Strip out any leading and trailing whitespace from selection
- ;------------------------------
- ; "Smart Titles" RegEx function - short words keep lower-case
- ; thanks to Gogo http://www.autohotkey.com/forum/post-495722.html
- Needle =
- (join ltrim comments ; first (in the sentence) acronym (upper case $U3)
- (^|[.!?:;])\W*\K(([A-Z]{2,4})\b
- |([\w']+)) ; any other first word (title case $T4)
- ; not first small words (lower case $L5)
- |\b(?i)(a|an|and|as|at|but|by|for|from
- |if|in|nor|of|off|on|or|so|the|to|up|yet)\b
- |\b(?-i)([A-Z]{2,4})\b ; not first acronym (upper case $U6)
- |\b([\w']+) ; any other word (title case $T7)
- )
- ;------------------------------
- ; Clip() function
- ;http://www.autohotkey.com/forum/viewtopic.php?p=467710
- Clip(Text="", Reselect="") {
- Static BackUpClip, Stored
- If (A_ThisLabel = "Clip")
- Return Stored := "", Clipboard := BackUpClip, BackUpClip := ""
- If Stored
- SetTimer, Clip, Off
- Else {
- Stored := True
- BackUpClip := ClipboardAll
- }
- Clipboard := ""
- If (Text = "") {
- Send, ^c
- ClipWait, 0.15
- } Else {
- Clipboard := Text
- ClipWait, 3
- Send, ^v
- }
- SetTimer, Clip, -700
- If (Text = "")
- Return Clipboard
- Else If (ReSelect = True) or (Reselect and (StrLen(Text) < 3000)) {
- StringReplace, Text, Text, `r, , All
- Send, % "{Shift Down}{Left " StrLen(Text) "}{Shift Up}"
- }
- Return
- Clip:
- Return Clip()
- }
- ;------------------------------
- ; TabsToSpaces function
- ; http://www.autohotkey.com/forum/viewtopic.php?p=495999
- TabsToSpaces(Str, outEOL="`r`n", EOL="`n", Omit="`r"){ ;
- Loop Parse, Str, %EOL%, %Omit% ;
- { ;
- index := 0 ; Used instead of A_Index
- Loop Parse, A_LoopField ; since we can change it
- { ;
- index++ ; increment manually
- If (A_LoopField = A_Tab){ ;
- Loop % 2-Mod(index, 2) ;
- r .= " " ;
- index := -1 ; it's aligned now,
- } ; so next tab will be 2
- else r .= A_LoopField ;
- } ;
- r .= outEOL ;
- } ;
- StringTrimRight, r, r, % StrLen(outEOL) ; remove trailing `r`n
- return r ;
- } ;
- ;------------------------------
- ; Main menu
- ;
- ; *=Fire the hotkey even if extra modifiers are being held down
- *^CapsLock::
- Gosub,MENU
- Return
- MENU:
- Menu,main,Add,&UPPER CASE,UPPER
- Menu,main,Add,&lower case,LOWER
- Menu,main,Add,&Title Case,TITLE
- Menu,main,Add,&First word only,SENTENCE
- Menu,main,Add,T&abs to spaces,TAB2SPACES
- Menu,main,Add,Spaces to &_,UNDERSCORES
- Menu,main,Add,_ to &spaces,_2SPACES
- Menu,main,Add,&camelCase,CAMEL_CASE
- Menu,main,Add,&NO_CAMEL_CASE,NO_CAMEL_CASE
- Menu,main,Add,&iNVERT cASE,INVERT
- Menu,main,Add,Cancel (Esc),EMPTY
- Menu,main,Show
- Return
- ;============================================================
- ; Case/String Conversion
- UPPER:
- selection := Clip()
- StringUpper,selection,selection
- Clip( selection, True )
- Return
- LOWER:
- selection := Clip()
- StringLower,selection,selection
- Clip( selection, True )
- Return
- TITLE:
- selection := Clip()
- StringLower,selection,selection,T
- Clip( selection, True )
- Return
- SENTENCE:
- Clip( RegExReplace(Clip(),"(\w)([^?.:!]*)","$U1$L2"), True )
- Return
- INVERT:
- Clip( RegExReplace(Clip(),"([^a-z]+)|([^A-Z]+)","$L1$U2"), True )
- Return
- CAMEL_CASE:
- ; thanks to jpjazzy and Gogo http://www.autohotkey.com/forum/post-495722.html
- ; from phrase separated_by_or-to lowerCamelCase
- ; with customizable delimiters [ -_]
- string := Clip()
- Clip( RegExReplace(string, "(([A-Z]+)|(?i)((?<=[a-z])|[a-z])([a-z]*))[ _-]([a-z]|[A-Z]+)", "$L2$L3$4$T5"))
- Return
- NO_CAMEL_CASE:
- ; from camelCase to ALL_UPPER
- ; this not working, waiting on Gogo for RegEx version?
- ; Clip(RegExReplace(Clip(), "[a-z]\K[A-Z]", "_$U0"))
- AutoTrim,Off
- StringCaseSense,On
- selection := Clip()
- lower=abcdefghijklmnopqrstuvwxyzaoa
- upper=ABCDEFGHIJKLMNOPQRSTUVWXYZAOA
- StringLen,length,selection
- iter:=0
- Loop,%length%
- { ; translation notes
- StringLeft,char,selection,1 ; store leftmost char in %char%
- StringGetPos,pos,lower,%char% ; look in lower, return -1 if not
- pos+=1 ; add 1, 0 means not lowercase alpha
- If pos<>0 ; if lowercase alpha
- StringMid,char,upper,%pos%,1 ; convert %char% to uppercase
- Else ;pos==0 ; if not lowercase alpha
- { ;
- StringGetPos,pos,upper,%char% ; look in upper, return -1 if not
- pos+=1 ;
- If pos<>0 ; if uppercase alpha
- { ;
- StringMid,char,upper,%pos%,1 ; ? %char% already upper, why get it?
- If iter<>0 ; don't lead with an underscore
- char=_%char% ; insert an underscore
- } ;
- } ;
- StringTrimLeft,selection,selection,1 ; remove the leftmost character
- selection=%selection%%char% ; append %char% to end
- iter+=1 ; iterate the loop counter and loop
- }
- Clip( selection, True )
- Return
- UNDERSCORES:
- selection := Clip()
- StringReplace, selection, selection, %A_Space%, _, 1
- Clip( selection, True )
- Return
- _2SPACES:
- selection := Clip()
- StringReplace, selection, selection, _, %A_Space%, 1
- Clip( selection, True )
- Return
- TAB2SPACES:
- ;Tabs2Spaces(Str, AlignNum=8, ... )
- ; Replace both 8's with the parameter's name.
- ; MsgBox, Replace TABs with how many spaces?
- Clip(TabsToSpaces(clip()), True)
- return
- ;--------------------
- EMPTY:
- Return
- ;===================
- ; HOTKEYS
- ;
- ;================================================================================================
- ; Clipboard helper functions.
- ;================================================================================================
- ClipboardGet()
- {
- OldClipboard:= ClipboardAll ;Save existing clipboard.
- Clipboard:= ""
- Send, ^c ;Copy selected test to clipboard
- ClipWait 0
- If ErrorLevel
- {
- MsgBox, No Text Selected!
- Return
- }
- }
- ClipboardRestore()
- {
- Clipboard:= OldClipboard
- }
- ; ------------------ EM and EN Dashes ------------------
- ; Alt+Minus = Em dash
- !-::
- Send {—}
- return
- ; Shift+Alt+Minus = En dash
- +!-::
- Send {–}
- return
- ; ---------------- Select Line with CapsLock+A -------------------
- CapsLock & a::
- Send {Home}
- Send +{End}
- Return
- ; ---------------- Strikethrough (gdocs) with CapsLock+C -------------------
- CapsLock & c::
- Send {Home}
- Send +{End}
- Send +!{5}
- Return
- ; -----------Cut Line with Caps+X--------------
- CapsLock & x::
- Send {Home}
- Send +{End}
- Send ^x ; CUT
- Return
- ;paragraph?
- ;$LButton::RapidHotkey("{Click}""{Click 2}")
- ;#include RapidHotKey.ahk ; the file must be in the same folder, or, specify the full path to it
- ;$h::RapidHotKey("h""you press h twice""you press h three times","1")
- ;If you press h one time it will send a "h", press two time it will send the sentence "you press h twice", press h tree times and it will send the sentence "you press h three times".
- ;^!t::
- ;Send, {Click 3}
- ;Return
- ; --------------Copy/Cut w/o formatting------------
- ^+x:: ; Text-only to ClipBoard
- Clip0 = %ClipBoardAll%
- ClipBoard =
- StringRight x,A_ThisHotKey,1 ; C or X
- Send ^%x% ; For best compatibility: SendPlay
- ClipWait 2 ; Wait for text, up to 2s
- If ErrorLevel
- ClipBoard = %Clip0% ; Restore original ClipBoard
- Else
- ClipBoard = %ClipBoard% ; Convert to text
- VarSetCapacity(Clip0, 0) ; Free memory
- Return
- ; --------------Paste w/o formatting------------
- ^+v::
- ; Trim leading/trailing white space from empty lines
- Clipboard:=RegExReplace(Clipboard,"m)^[ \t]*$","`r`n")
- ; copied from http://ahkscript.org/docs/commands/StringReplace.htm
- ; Remove all blank lines from the text in a variable:
- Loop
- {
- StringReplace, ClipBoard, ClipBoard, `r`n`r`n, --[ahkparagraphmarker]--, UseErrorLevel
- if ErrorLevel = 0 ; No more replacements needed.
- break
- }
- ;Replace all new lines with a space topreventjoinedwords
- StringReplace, ClipBoard, ClipBoard, `r`n, %A_Space%, All
- ; Remove all double spaces (useful for justified text)
- Loop
- {
- StringReplace, ClipBoard, ClipBoard, %A_Space%%A_Space%, %A_Space%, UseErrorLevel
- if ErrorLevel = 0 ; No more replacements needed.
- break
- }
- ; re-create paragraphs again
- StringReplace, ClipBoard, ClipBoard,--[ahkparagraphmarker]--,`r`n`r`n, All
- ; remove any leftover remaining leading spaces
- Clipboard:=RegExReplace(Clipboard,"m)^[ \t]*")
- Send ^v
- Return
- ;------------------------------------------------------------------------------
- ; Caps Typing
- ;------------------------------------------------------------------------------
- ; partaially Based on davebrny's https://gist.github.com/davebrny/088c48d6678617876b34f53571e92ee6 and others
- ;| shortcut | description | result |
- ;|:------------:|:------------------------:|:----------------:|
- ;| caps + / | code block | ```int main()``` |
- ;| caps + l | start "link wizard" | [text](url) |
- ;| CapsLock & ' | quote | "text" |
- ;| CapsLock & ` | inline code | `text` |
- ;| CapsLock & 9 | parens | (text) |
- ;| CapsLock & [ | wikilink | [[text]] |
- ;| CapsLock & ] | template | {{text}} |
- ;| CapsLock & , | angle brackets | < text > |
- ;| CapsLock & i | italics | *text* |
- ;| CapsLock & b | bold | **text** |
- ;| CapsLock & z | strikethrough | ~~text~~ |
- ;| CapsLock & h | html | <kbd>text</kbd> |
- ;| !del:: | delete 2char either side | --text-- → text |
- sendMode input
- return ; end of auto-execute
- ;---------------------------
- CapsLock & '::
- ::w'::
- goTo, wrap_quote ; "text"
- CapsLock & `::
- ::w``::
- goTo, wrap_grave ; `text`
- CapsLock & 9::
- ::w9::
- goTo, wrap_parenthesis ; (text)
- CapsLock & [::
- ::w[[::
- goTo, wrap_bracket ; [[text]]
- CapsLock & ]::
- ::w]::
- goTo, wrap_brace ; {{text}}
- CapsLock & ,::
- ::w,::
- goTo, wrap_angle ; <text>
- CapsLock & i::
- ::w8::
- goTo, wrap_asterisk ; *text*
- CapsLock & b::
- ::w*::
- goTo, wrap_2_asterisk ; **text**
- CapsLock & z::
- ::w~::
- goTo, wrap_tilde ; ~~text~~
- CapsLock & h::
- ::wkbd::
- goTo, wrap_kbd ; <kbd>text</kbd>
- !del::
- ::wdel::
- goTo, wrap_delete ; _text_ ---> text
- ;-----------------------
- wrap_quote:
- wrap_grave:
- wrap_parenthesis:
- wrap_bracket:
- wrap_brace:
- wrap_angle:
- wrap_asterisk:
- wrap_2_asterisk:
- wrap_tilde:
- wrap_kbd:
- this_label := a_thisLabel
- clipboard_text := get_clipboard()
- for what, with in { "wrap_quote" : """" clipboard_text """"
- , "wrap_grave" : "``" clipboard_text "``"
- , "wrap_parenthesis" : "(" clipboard_text ")"
- , "wrap_bracket" : "[[" clipboard_text "]]"
- , "wrap_brace" : "{{" clipboard_text "}}"
- , "wrap_angle" : "<" clipboard_text ">"
- , "wrap_asterisk" : "*" clipboard_text "*"
- , "wrap_2_asterisk" : "**" clipboard_text "**"
- , "wrap_tilde" : "~~" clipboard_text "~~"
- , "wrap_kbd" : "<kbd>" clipboard_text "</kbd>" }
- stringReplace, this_label, this_label, % what, % with, all
- new_text := this_label
- goSub, send_wrap
- return
- wrap_delete:
- clipboard_text := get_clipboard()
- loop, 2
- {
- stringLeft, left_character, clipboard_text, 1
- stringRight, right_character, clipboard_text, 1
- if regExMatch(left_character, "[\Q'%*-_""~``([{><\E]")
- and if regExMatch(right_character, "[\Q'%*-_""~)``]}><\E]") ; if '%*-_"~`([{
- {
- stringTrimLeft, clipboard_text, clipboard_text, 1
- stringTrimRight, clipboard_text, clipboard_text, 1
- }
- else break
- }
- new_text := clipboard_text
- goSub, send_wrap
- return
- get_clipboard(){
- global
- if !inStr(a_thisHotkey, ":") ; if hotkey was used
- {
- revert_clipboard := clipboardAll
- clipboard =
- send ^{c}
- clipWait, 0.3
- if clipboard is space
- clipboard =
- }
- return clipboard
- }
- send_wrap:
- if !inStr(a_thisHotkey, ":") and if (clipboard = "") ; if hotkey was used
- position := "{Left " round( strLen(new_text) / 2) "}" ; move cursor between symbols
- else position := ""
- clipboard := new_text
- send % "^{v}" . position
- sleep 150
- clipboard := revert_clipboard
- return
- ;Markdown code block
- CapsLock & /::
- Send {``` 3}
- Send {Enter}{Enter}
- Send {``` 3}
- Send {Up}
- return
- ;Markdown links [text](http://example.com) will translate into <a href="http://example.com>text</a>
- CapsLock & l::
- ;Clipboard :=
- SendInput ^c
- MDurl = %Clipboard%
- MDtext = %Clipboard%
- IfNotInString, MDurl, ://
- MDurl = http://%MDurl%
- Gui, +AlwaysOnTop +Owner
- Gui, Add, Text,, Text to display
- Gui, Add, Edit, vMDtext w320 r1, %MDtext%
- Gui, Add, Text,, URL
- Gui, Add, Edit, vMDurl w320 r1, %MDurl%
- Gui, Add, Button, Default, OK
- Gui, Show, w350, MDLink
- Return
- ButtonOK:
- Gui, Submit
- Gui, Destroy
- Clipboard = [%MDtext%](%MDurl%)
- Return
- GuiClose:
- Gui, Destroy
- Return
- ;------------------------------------------------------------------------------
- ; Typography / symbols
- ;------------------------------------------------------------------------------
- ::|c::© ; copyright symbol
- ::(c)::©
- ::|r::® ; registered symbol
- ::(r)::®
- ::|s::§ ; section symbol
- ::(tm)::™ ; trademark symbol
- :c:|o::• ; bullet
- ::|bull::•
- ::|bullet::•
- ; Arrows
- :?*:-->::→
- :?*:<--::←
- :?*:<->::↔
- ::|^::↑
- ::|v::↓
- ; ------- SET REPLACEMENTS -----------
- :?:]d:: ; This hotstring replaces "]d" with the current date and time via the commands below.
- FormatTime, CurrentDateTime,, yyyy-MM-dd HH:mm ; It will look like 2005-09-01 15:53
- SendInput %CurrentDateTime%
- return
- ; ----------------------- markdown link ---------------
- ; #If WinActive("ahk_class Chrome_WidgetWin_1 ahk_exe chrome.exe")
- $F1::
- Clipboard := ""
- Send ^l
- while !Clipboard {
- Sleep, 50
- Send ^c
- }
- Send {End}
- WinGetActiveTitle, title
- Clipboard := "[" . title . "](" . Clipboard . ")"
- MsgBox, % Clipboard
- Return
- ;------------------------------------------------------------------------------
- ; ❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓POTENTIALS❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓
- ;------------------------------------------------------------------------------
- ; ----------------------- URL replacement? ---------------
- ;^+7:: ; Ctrl+Shift+7 (/)
- ;Clipboard := ""
- ;Send ^l
- ;while !Clipboard {
- ;Sleep, 50
- ;Send ^c
- ;}
- ;Send {End}
- ;WinGetActiveTitle, title
- ;If !WinActive("ahk_class Chrome_WidgetWin_1 ahk_exe chrome.exe")
- ;{
- ;;Perform the RegEx find and replace operation,
- ;;where the needle is what we want to replace.
- ;haystack := Clipboard
- ;needle := "\\"
- ;replacement := "/"
- ;result := RegExReplace(haystack, needle, replacement)
- ;haystack := result
- ;needle := " "
- ;replacement := "%20"
- ;result := RegExReplace(haystack, needle, replacement)
- ;;Empty the Clipboard
- ;Clipboard =
- ;;Copy the result to the Clipboard.
- ;Clipboard := result
- ;Clipboard := "[" . title . "](file:///" . Clipboard . ")"
- ;;Wait for the Clipboard to fill.
- ;ClipWait
- ;return
- ;}
- ;If WinActive("ahk_class Chrome_WidgetWin_1 ahk_exe chrome.exe")
- ;{
- ;Clipboard := "[" . title . "](" . Clipboard . ")"
- ;}
- ;Return
- ;------------------------------------------------------------------------------
- ;💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀 GRAVEYARD 💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀
- ;------------------------------------------------------------------------------
- ; Turns capslock off while this script is running.
- ;SetCapsLockState, AlwaysOff
- ; You can make capslock your modifier by putting
- ; CapsLock & <Whatever Key>
- ;CapsLock & a::MsgBox, You pressed Capslock And A
- ;CapsLock & b::
- ; WinGetActiveTitle, titleName
- ; MsgBox, The name of this window is:`n%titleName%.
- ;return
- ;CapsLock & z to open Zotero
- ;CapsLock & z::
- ; Run, "C:\Program Files (x86)\Zotero\zotero.exe"
- ; Return
- ; Do WIKIPEDIA of selected word -- caps & w for wrapping text
- ;CapsLock & w::
- ; ClipboardGet()
- ; Run, https://en.wikipedia.org/wiki/%clipboard% ; Launch with contents of clipboard
- ; ClipboardRestore()
- ;Return
- ;------------------------------------------------------------------------------
- ; Home/End w Capslock
- ;------------------------------------------------------------------------------
- ; This section was designed to get around keyboards that did not have home/end keys.
- ; Capslock & Numpad7::SendInput {Blind}{Home Down}
- ; Capslock & Numpad7 up::SendInput {Blind}{Home Up}
- ; Capslock & Numpad1::SendInput {Blind}{End Down}
- ; Capslock & Numpad1 up::SendInput {Blind}{End Up}
- ; Capslock & Numpad3::SendInput {Blind}{PgDn Down}
- ; Capslock & Numpad3 up::SendInput {Blind}{PgDn Up}
- ; Capslock & Numpad9::SendInput {Blind}{PgUp Down}
- ; Capslock & Numpad9 up::SendInput {Blind}{PgUp Up}
- ;
- ; #If GetKeyState("Shift", "P")
- ; Capslock & NumpadHome::SendInput {Blind}+{Home Down}
- ; Capslock & NumpadHome up::SendInput {Blind}+{Home Up}
- ; Capslock & NumpadEnd::SendInput {Blind}+{End Down}
- ; Capslock & NumpadEnd up::SendInput {Blind}+{End Up}
- ; Capslock & NumpadPgUp::SendInput {Blind}+{PgUp Down}
- ; Capslock & NumpadPgUp up::SendInput {Blind}+{PgUp Up}
- ; Capslock & NumpadPgDn::SendInput {Blind}+{PgDn Down}
- ; Capslock & NumpadPgDn up::SendInput {Blind}+{PgDn Up}
- ;
- ; #If
- ; Capslock & NumpadHome::SendInput {Blind}{Home Down}
- ; Capslock & NumpadHome up::SendInput {Blind}{Home Up}
- ; Capslock & NumpadEnd::SendInput {Blind}{End Down}
- ; Capslock & NumpadEnd up::SendInput {Blind}{End Up}
- ; Capslock & NumpadPgUp::SendInput {Blind}{PgUp Down}
- ; Capslock & NumpadPgUp up::SendInput {Blind}{PgUp Up}
- ; Capslock & NumpadPgDn::SendInput {Blind}{PgDn Down}
- ; Capslock & NumpadPgDn up::SendInput {Blind}{PgDn Up}
- Return
- ;Markdown  will translate into <img src="http://example.com/pic.jpg" alt="text" />
- ;offer preview dialog, to see the picture which should included
- ;CapsLock & p::
- ;pictureLabel:
- ;Gui 2:Add, Text,, Please enter URL to the Picture:
- ;Gui 2:Add, Edit, vPicUrl
- ;Gui 2:Add, Text,, Please enter alternative text for the Picture:
- ;Gui 2:Add, Edit, vPicAlt
- ;Gui 2:Add, Button, default ys, &Preview
- ;Gui 2:Add, Button,, &OK
- ;Gui 2:Add, Button,, &Cancel
- ;Gui 2:Show
- ;return
- ;2ButtonOK:
- ;Gui, 2:Submit
- ;Send {!}{[}
- ;Send %PicAlt%
- ;Send {]}{(}
- ;Send %PicUrl%
- ;Send {)}
- ;Gui, 2:Destroy
- ;return
- ;2ButtonCancel:
- ;2GuiClose:
- ;2GuiEscape:
- ;Gui, 2:Destroy
- ;return
- ;2ButtonPreview:
- ;Gui, 2:Submit, NoHide ;NoHide prevent GUI 1 for being closed
- ;UrlDownloadToFile, %PicUrl%, %temp%\foobar ;download file local, to show preview
- ;Gui, 3:Add, Picture, w300 h300, %temp%\foobar ;2:Foo access the second window, up to 99 windows are possible
- ;Gui, 3:Add, Button,, Close
- ;Gui, 3:Show
- ;return
- ;3ButtonClose:
- ;3GuiClose:
- ;3GuiEscape:
- ;Gui, 3:Destroy
- ;return
- ; ---------------- Hotstring Helper ------------------------------
- ; Andreas Borutta suggested the following script, which might be useful if you are a heavy user of hotstrings. By pressing Win+H (or another hotkey of your choice), the currently selected text can be turned into a hotstring. For example, if you have "by the way" selected in a word processor, pressing Win+H will prompt you for its abbreviation (e.g. btw) and then add the new hotstring to the script. It will then reload the script to activate the hotstring.
- ; Note: The Hotstring function can be used to create new hotstrings without reloading. Take a look at the first example in the example section of the function's page to see how this could be done.
- #h:: ; Win+H hotkey
- ; Get the text currently selected. The clipboard is used instead of
- ; "ControlGet Selected" because it works in a greater variety of editors
- ; (namely word processors). Save the current clipboard contents to be
- ; restored later. Although this handles only plain text, it seems better
- ; than nothing:
- AutoTrim Off ; Retain any leading and trailing whitespace on the clipboard.
- ClipboardOld := ClipboardAll
- Clipboard := "" ; Must start off blank for detection to work.
- Send ^c
- ClipWait 1
- if ErrorLevel ; ClipWait timed out.
- return
- ; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring:
- ; The same is done for any other characters that might otherwise
- ; be a problem in raw mode:
- StringReplace, Hotstring, Clipboard, ``, ````, All ; Do this replacement first to avoid interfering with the others below.
- StringReplace, Hotstring, Hotstring, `r`n, ``r, All ; Using `r works better than `n in MS Word, etc.
- StringReplace, Hotstring, Hotstring, `n, ``r, All
- StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
- StringReplace, Hotstring, Hotstring, `;, ```;, All
- Clipboard := ClipboardOld ; Restore previous contents of clipboard.
- ; This will move the InputBox's caret to a more friendly position:
- SetTimer, MoveCaret, 10
- ; Show the InputBox, providing the default hotstring:
- InputBox, Hotstring, New Hotstring, Type your abreviation at the indicated insertion point. You can also edit the replacement text if you wish.`n`nExample entry: :R:btw`::by the way,,,,,,,, :R:`::%Hotstring%
- if ErrorLevel ; The user pressed Cancel.
- return
- if InStr(Hotstring, ":R`:::")
- {
- MsgBox You didn't provide an abbreviation. The hotstring has not been added.
- return
- }
- ; Otherwise, add the hotstring and reload the script:
- FileAppend, `n%Hotstring%, %A_ScriptFullPath% ; Put a `n at the beginning in case file lacks a blank line at its end.
- Reload
- Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
- MsgBox, 4,, The hotstring just added appears to be improperly formatted. Would you like to open the script for editing? Note that the bad hotstring is at the bottom of the script.
- IfMsgBox, Yes, Edit
- return
- MoveCaret:
- IfWinNotActive, New Hotstring
- return
- ; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.
- Send {Home}{Right 3}
- SetTimer, MoveCaret, Off
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement