Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2021
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6.  
  7. ;;;;;;;;;;GENERAL SETTINGS;;;;;;;;;;;;;;;
  8. ;reload script automatic
  9. #SingleInstance force
  10.  
  11.  
  12. ;------------------------------------------------------------------------------
  13. ; Window on Top
  14. ;------------------------------------------------------------------------------
  15.  
  16. ^+SPACE::
  17.     WinGetTitle, activeWindow, A
  18.     if IsWindowAlwaysOnTop(activeWindow) {
  19.         notificationMessage := "The window """ . activeWindow . """ is now always on top."
  20.         notificationIcon := 16 + 1 ; No notification sound (16) + Info icon (1)
  21.     }
  22.     else {
  23.         notificationMessage := "The window """ . activeWindow . """ is no longer always on top."
  24.         notificationIcon := 16 + 2 ; No notification sound (16) + Warning icon (2)
  25.     }
  26.     Winset, Alwaysontop, , A
  27.     TrayTip, Always-on-top, %notificationMessage%, , %notificationIcon%
  28.     Sleep 3000 ; Let it display for 3 seconds.
  29.     HideTrayTip()
  30.  
  31.     IsWindowAlwaysOnTop(windowTitle) {
  32.         WinGet, windowStyle, ExStyle, %windowTitle%
  33.         isWindowAlwaysOnTop := if (windowStyle & 0x8) ? false : true ; 0x8 is WS_EX_TOPMOST.
  34.         return isWindowAlwaysOnTop
  35.     }
  36.  
  37.     HideTrayTip() {
  38.         TrayTip  ; Attempt to hide it the normal way.
  39.         if SubStr(A_OSVersion,1,3) = "10." {
  40.             Menu Tray, NoIcon
  41.             Sleep 200  ; It may be necessary to adjust this sleep.
  42.             Menu Tray, Icon
  43.         }
  44.     }
  45. Return
  46.  
  47.  
  48. ;================================================================================================
  49. ; CAPS REMAPS
  50. ;================================================================================================
  51. ; Functionality:
  52. ; - Deactivates capslock for normal (accidental) use.
  53. ; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
  54. ; - Access the following functions when pressing Capslock:
  55. ;     Cursor keys           - J, K, L, I
  56. ;     Enter                 - Space
  57. ;     Home, PgDn, PgUp, End - (IN PROGRESS)
  58. ;     Backspace and Del     - N, M
  59. ;
  60. ;     Insert                - B
  61. ;     Close tab, window     - W, R
  62. ;     Next, previous tab    - Tab, Q
  63. ;     Undo, redo            - , and .
  64. ;  
  65.  
  66. ; This script is mostly assembled from modified versions of the following awesome scripts:
  67. ;
  68. ; # Home Row Computing by Gustavo Duarte: http://duartes.org/gustavo/blog/post/home-row-computing for
  69. ; Changes:
  70. ; - Does not need register remapping of AppsKey using SharpKeys.
  71. ; - Uses normal cursor key layout
  72. ; - Added more hotkeys for insert, undo, redo etc.
  73.  
  74. #Persistent
  75. SetCapsLockState, AlwaysOff
  76.  
  77.  
  78. ; Make Win Key + Capslock work like Capslock (in case it's ever needed)
  79. #Capslock::
  80. If GetKeyState("CapsLock", "T") = 1
  81.     SetCapsLockState, AlwaysOff
  82. Else
  83.     SetCapsLockState, AlwaysOn
  84. Return
  85.  
  86.  
  87.  
  88. ; ShareX Commands via CapsLock
  89. Capslock & s::SendInput !{F1}
  90. Capslock & e::SendInput !{F2}
  91. Capslock & o::SendInput !{F3}
  92. Capslock & r::SendInput !{F5}
  93.  
  94. ; Powertoys ColorPiker
  95.  
  96. Capslock & p::SendInput #+C
  97.  
  98. ; Get DEFINITION of selected word.    
  99. CapsLock & d::  
  100.     ClipboardGet()
  101.     Run, http://www.google.com/search?q=define+%clipboard%     ; Launch with contents of clipboard
  102.     ClipboardRestore()
  103. Return
  104.  
  105. ; GOOGLE the selected text.
  106. CapsLock & g::
  107.     ClipboardGet()
  108.     Run, http://www.google.com/search?q=%clipboard%             ; Launch with contents of clipboard
  109.     ClipboardRestore()
  110. Return
  111.  
  112. ; Do THESAURUS of selected word
  113. CapsLock & t::
  114.     ClipboardGet()
  115.     Run http://www.thesaurus.com/browse/%Clipboard%             ; Launch with contents of clipboard
  116.     ClipboardRestore()
  117. Return
  118.  
  119.  
  120.  
  121. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  122.  
  123.  
  124. ;CapsLock & V to open Vivaldi
  125. CapsLock & v::
  126.     Run, "C:\Users\Brian\AppData\Local\Vivaldi\Application\vivaldi.exe"
  127.     Return
  128.  
  129. ;CapsLock & n to open Obsidian
  130. CapsLock & n::
  131.     Run, "C:\Users\Brian\AppData\Local\Obsidian\Obsidian.exe"
  132.     Return
  133.  
  134. ;CapsLock & m to open eMClient
  135. CapsLock & m::
  136.     Run, "C:\Program Files (x86)\eM Client\MailClient.exe"
  137.     Return
  138.  
  139.  
  140.  
  141. ;================================================================================================
  142. ; Caps Delay functions.
  143. ;================================================================================================
  144.  
  145.  
  146.  
  147. AutoTrim On  ; Strip out any leading and trailing whitespace from selection
  148.  
  149. ;------------------------------
  150. ; "Smart Titles" RegEx function - short words keep lower-case
  151. ; thanks to Gogo http://www.autohotkey.com/forum/post-495722.html
  152. Needle =
  153. (join ltrim comments         ; first (in the sentence) acronym (upper case $U3)
  154.   (^|[.!?:;])\W*\K(([A-Z]{2,4})\b
  155.                   |([\w']+))          ; any other first word   (title case $T4)
  156.                                        ; not first small words (lower case $L5)
  157.   |\b(?i)(a|an|and|as|at|but|by|for|from
  158.   |if|in|nor|of|off|on|or|so|the|to|up|yet)\b
  159.   |\b(?-i)([A-Z]{2,4})\b                  ; not first acronym  (upper case $U6)
  160.   |\b([\w']+)                               ; any other word   (title case $T7)
  161. )
  162.  
  163. ;------------------------------
  164. ; Clip() function
  165. ;http://www.autohotkey.com/forum/viewtopic.php?p=467710
  166. Clip(Text="", Reselect="") {
  167.    Static BackUpClip, Stored
  168.    If (A_ThisLabel = "Clip")
  169.       Return Stored := "", Clipboard := BackUpClip, BackUpClip := ""
  170.    If Stored
  171.       SetTimer, Clip, Off
  172.    Else {
  173.       Stored := True
  174.       BackUpClip := ClipboardAll
  175.    }
  176.    Clipboard := ""
  177.    If (Text = "") {
  178.       Send, ^c
  179.       ClipWait, 0.15
  180.    } Else {
  181.       Clipboard := Text
  182.       ClipWait, 3
  183.       Send, ^v
  184.    }
  185.    SetTimer, Clip, -700
  186.    If (Text = "")
  187.       Return Clipboard
  188.    Else If (ReSelect = True) or (Reselect and (StrLen(Text) < 3000)) {
  189.       StringReplace, Text, Text, `r, , All
  190.       Send, % "{Shift Down}{Left " StrLen(Text) "}{Shift Up}"
  191.    }
  192.    Return
  193.    Clip:
  194.   Return Clip()
  195. }
  196.  
  197.  
  198. ;------------------------------
  199. ; TabsToSpaces function
  200. ; http://www.autohotkey.com/forum/viewtopic.php?p=495999
  201. TabsToSpaces(Str, outEOL="`r`n", EOL="`n", Omit="`r"){ ;
  202.   Loop Parse, Str, %EOL%, %Omit%             ;
  203.   {                                          ;
  204.      index := 0                              ; Used instead of A_Index
  205.      Loop Parse, A_LoopField                 ;  since we can change it
  206.      {                                       ;
  207.              index++                         ; increment manually
  208.              If (A_LoopField = A_Tab){       ;
  209.                      Loop % 2-Mod(index, 2)  ;
  210.                              r .= " "        ;
  211.                      index := -1             ; it's aligned now,
  212.              }                               ;  so next tab will be 2
  213.              else    r .= A_LoopField        ;
  214.      }                                       ;
  215.      r .= outEOL                             ;
  216.   }                                          ;
  217.   StringTrimRight, r, r, % StrLen(outEOL)    ; remove trailing `r`n
  218.   return r                                   ;
  219. }                                            ;
  220.  
  221.  
  222. ;------------------------------
  223. ; Main menu
  224. ;
  225. ; *=Fire the hotkey even if extra modifiers are being held down
  226. *^CapsLock::
  227. Gosub,MENU
  228. Return
  229.  
  230. MENU:
  231. Menu,main,Add,&UPPER CASE,UPPER
  232. Menu,main,Add,&lower case,LOWER
  233. Menu,main,Add,&Title Case,TITLE
  234. Menu,main,Add,&First word only,SENTENCE
  235. Menu,main,Add,T&abs to spaces,TAB2SPACES
  236. Menu,main,Add,Spaces to &_,UNDERSCORES
  237. Menu,main,Add,_ to &spaces,_2SPACES
  238. Menu,main,Add,&camelCase,CAMEL_CASE
  239. Menu,main,Add,&NO_CAMEL_CASE,NO_CAMEL_CASE
  240. Menu,main,Add,&iNVERT cASE,INVERT
  241. Menu,main,Add,Cancel (Esc),EMPTY
  242. Menu,main,Show
  243. Return
  244.  
  245. ;============================================================
  246. ; Case/String Conversion
  247.  
  248. UPPER:
  249. selection := Clip()
  250. StringUpper,selection,selection
  251. Clip( selection, True )
  252. Return
  253.  
  254. LOWER:
  255. selection := Clip()
  256. StringLower,selection,selection
  257. Clip( selection, True )
  258. Return
  259.  
  260. TITLE:
  261. selection := Clip()
  262. StringLower,selection,selection,T
  263. Clip( selection, True )
  264. Return
  265.  
  266. SENTENCE:
  267. Clip( RegExReplace(Clip(),"(\w)([^?.:!]*)","$U1$L2"), True )
  268. Return
  269.  
  270. INVERT:
  271. Clip( RegExReplace(Clip(),"([^a-z]+)|([^A-Z]+)","$L1$U2"), True )
  272. Return
  273.  
  274. CAMEL_CASE:
  275. ; thanks to jpjazzy and Gogo http://www.autohotkey.com/forum/post-495722.html
  276. ; from phrase separated_by_or-to lowerCamelCase
  277. ; with customizable delimiters [ -_]
  278. string := Clip()
  279. Clip( RegExReplace(string, "(([A-Z]+)|(?i)((?<=[a-z])|[a-z])([a-z]*))[ _-]([a-z]|[A-Z]+)", "$L2$L3$4$T5"))
  280. Return
  281.  
  282. NO_CAMEL_CASE:
  283. ; from camelCase to ALL_UPPER
  284. ; this not working, waiting on Gogo for RegEx version?
  285. ; Clip(RegExReplace(Clip(), "[a-z]\K[A-Z]", "_$U0"))  
  286. AutoTrim,Off
  287. StringCaseSense,On
  288. selection := Clip()
  289. lower=abcdefghijklmnopqrstuvwxyzaoa
  290. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZAOA
  291. StringLen,length,selection
  292. iter:=0
  293. Loop,%length%
  294. {                                        ; translation notes
  295.   StringLeft,char,selection,1            ; store leftmost char in %char%
  296.   StringGetPos,pos,lower,%char%          ; look in lower, return -1 if not
  297.   pos+=1                                 ; add 1, 0 means not lowercase alpha
  298.   If pos<>0                              ; if lowercase alpha
  299.     StringMid,char,upper,%pos%,1         ;   convert %char% to uppercase
  300.   Else ;pos==0                           ; if not lowercase alpha
  301.   {                                      ;
  302.     StringGetPos,pos,upper,%char%        ; look in upper, return -1 if not
  303.     pos+=1                               ;
  304.     If pos<>0                            ; if uppercase alpha
  305.     {                                    ;
  306.       StringMid,char,upper,%pos%,1       ; ? %char% already upper, why get it?
  307.       If iter<>0                         ; don't lead with an underscore
  308.         char=_%char%                     ; insert an underscore
  309.     }                                    ;
  310.   }                                      ;
  311.   StringTrimLeft,selection,selection,1   ; remove the leftmost character
  312.   selection=%selection%%char%            ; append %char% to end
  313.   iter+=1                                ; iterate the loop counter and loop
  314. }
  315. Clip( selection, True )
  316. Return
  317.  
  318. UNDERSCORES:
  319. selection := Clip()
  320. StringReplace, selection, selection, %A_Space%, _, 1
  321. Clip( selection, True )
  322. Return
  323.  
  324. _2SPACES:
  325. selection := Clip()
  326. StringReplace, selection, selection, _, %A_Space%, 1
  327. Clip( selection, True )
  328. Return
  329.  
  330. TAB2SPACES:
  331. ;Tabs2Spaces(Str, AlignNum=8, ... )
  332. ; Replace both 8's with the parameter's name.
  333. ; MsgBox, Replace TABs with how many spaces?
  334. Clip(TabsToSpaces(clip()), True)
  335. return
  336.  
  337. ;--------------------
  338.  
  339. EMPTY:
  340. Return
  341.  
  342.  
  343.  
  344. ;===================
  345. ; HOTKEYS
  346. ;
  347.  
  348.  
  349. ;================================================================================================
  350. ; Clipboard helper functions.
  351. ;================================================================================================
  352. ClipboardGet()
  353. {
  354.     OldClipboard:= ClipboardAll                         ;Save existing clipboard.
  355.     Clipboard:= ""
  356.     Send, ^c                                            ;Copy selected test to clipboard
  357.     ClipWait 0
  358.     If ErrorLevel
  359.         {
  360.         MsgBox, No Text Selected!
  361.         Return
  362.         }
  363. }
  364.  
  365.  
  366. ClipboardRestore()
  367. {
  368.     Clipboard:= OldClipboard
  369. }
  370.  
  371.  
  372. ; ------------------ EM and EN Dashes ------------------
  373.  
  374. ; Alt+Minus = Em dash
  375. !-::
  376. Send {}
  377. return
  378.  
  379. ; Shift+Alt+Minus = En dash
  380. +!-::
  381. Send {}
  382. return
  383.  
  384. ; ---------------- Select Line with CapsLock+A -------------------
  385.  
  386. CapsLock & a::
  387. Send {Home}
  388. Send +{End}
  389. Return
  390.  
  391.  
  392. ; ---------------- Strikethrough (gdocs) with CapsLock+C -------------------
  393.  
  394. CapsLock & c::
  395. Send {Home}
  396. Send +{End}
  397. Send +!{5}
  398. Return
  399.  
  400. ; -----------Cut Line with Caps+X--------------
  401.  
  402. CapsLock & x::
  403. Send {Home}
  404. Send +{End}
  405. Send ^x ; CUT
  406. Return
  407.  
  408. ;paragraph?
  409. ;$LButton::RapidHotkey("{Click}""{Click 2}")
  410. ;#include RapidHotKey.ahk ; the file must be in the same folder, or, specify the full path to it
  411.  
  412. ;$h::RapidHotKey("h""you press h twice""you press h three times","1")
  413. ;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".
  414. ;^!t::
  415. ;Send, {Click 3}
  416. ;Return
  417.  
  418. ; --------------Copy/Cut w/o formatting------------
  419. ^+x::                           ; Text-only to ClipBoard
  420.     Clip0 = %ClipBoardAll%
  421.     ClipBoard =
  422.         StringRight x,A_ThisHotKey,1  ; C or X
  423.         Send ^%x%                     ; For best compatibility: SendPlay
  424.         ClipWait 2                    ; Wait for text, up to 2s
  425.     If ErrorLevel
  426.         ClipBoard = %Clip0%        ; Restore original ClipBoard
  427.     Else
  428.         ClipBoard = %ClipBoard%    ; Convert to text
  429.         VarSetCapacity(Clip0, 0)      ; Free memory
  430. Return
  431.  
  432.  
  433. ; --------------Paste w/o formatting------------
  434.  
  435.  
  436. ^+v::
  437. ; Trim leading/trailing white space from empty lines
  438. Clipboard:=RegExReplace(Clipboard,"m)^[ \t]*$","`r`n")
  439.  
  440. ; copied from http://ahkscript.org/docs/commands/StringReplace.htm
  441. ; Remove all blank lines from the text in a variable:
  442. Loop
  443. {
  444.     StringReplace, ClipBoard, ClipBoard, `r`n`r`n, --[ahkparagraphmarker]--, UseErrorLevel
  445.     if ErrorLevel = 0  ; No more replacements needed.
  446.     break
  447. }
  448.  
  449. ;Replace all new lines with a space topreventjoinedwords
  450. StringReplace, ClipBoard, ClipBoard, `r`n, %A_Space%, All
  451.  
  452. ; Remove all double spaces (useful for justified text)
  453. Loop
  454. {
  455.     StringReplace, ClipBoard, ClipBoard, %A_Space%%A_Space%, %A_Space%, UseErrorLevel
  456.     if ErrorLevel = 0  ; No more replacements needed.
  457.         break
  458. }
  459.  
  460. ; re-create paragraphs again
  461. StringReplace, ClipBoard, ClipBoard,--[ahkparagraphmarker]--,`r`n`r`n, All
  462.  
  463. ; remove any leftover remaining leading spaces
  464. Clipboard:=RegExReplace(Clipboard,"m)^[ \t]*")
  465.  
  466. Send ^v
  467. Return
  468.  
  469. ;------------------------------------------------------------------------------
  470. ; Caps Typing
  471. ;------------------------------------------------------------------------------
  472. ; partaially Based on davebrny's https://gist.github.com/davebrny/088c48d6678617876b34f53571e92ee6 and others
  473. ;|   shortcut   |        description       |      result      |
  474. ;|:------------:|:------------------------:|:----------------:|
  475. ;| caps + /     |        code block        | ```int main()``` |
  476. ;| caps + l     |    start "link wizard"   |    [text](url)   |
  477. ;| CapsLock & ' |           quote          |      "text"      |
  478. ;| CapsLock & ` |        inline code       |      `text`      |
  479. ;| CapsLock & 9 |          parens          |      (text)      |
  480. ;| CapsLock & [ |         wikilink         |     [[text]]     |
  481. ;| CapsLock & ] |         template         |     {{text}}     |
  482. ;| CapsLock & , |      angle brackets      |     < text >     |
  483. ;| CapsLock & i |          italics         |      *text*      |
  484. ;| CapsLock & b |           bold           |     **text**     |
  485. ;| CapsLock & z |       strikethrough      |     ~~text~~     |
  486. ;| CapsLock & h |           html           |  <kbd>text</kbd> |
  487. ;| !del::       | delete 2char either side |  --text-- → text |
  488.  
  489. sendMode input
  490. return ; end of auto-execute
  491. ;---------------------------
  492.  
  493. CapsLock & '::
  494. ::w'::
  495. goTo, wrap_quote        ;   "text"
  496.  
  497. CapsLock & `::
  498. ::w``::
  499. goTo, wrap_grave        ;   `text`
  500.  
  501. CapsLock & 9::
  502. ::w9::
  503. goTo, wrap_parenthesis  ;   (text)
  504.  
  505. CapsLock & [::
  506. ::w[[::
  507. goTo, wrap_bracket      ;   [[text]]
  508.  
  509. CapsLock & ]::
  510. ::w]::
  511. goTo, wrap_brace        ;   {{text}}
  512.  
  513. CapsLock & ,::
  514. ::w,::
  515. goTo, wrap_angle        ;   <text>
  516.  
  517. CapsLock & i::
  518. ::w8::
  519. goTo, wrap_asterisk     ;   *text*
  520.  
  521. CapsLock & b::
  522. ::w*::
  523. goTo, wrap_2_asterisk   ;  **text**
  524.  
  525. CapsLock & z::
  526. ::w~::
  527. goTo, wrap_tilde        ;  ~~text~~
  528.  
  529. CapsLock & h::
  530. ::wkbd::
  531. goTo, wrap_kbd          ;   <kbd>text</kbd>
  532.  
  533. !del::
  534. ::wdel::
  535. goTo, wrap_delete       ;   _text_  --->  text
  536.  
  537. ;-----------------------
  538.  
  539. wrap_quote:
  540. wrap_grave:
  541. wrap_parenthesis:
  542. wrap_bracket:
  543. wrap_brace:
  544. wrap_angle:
  545. wrap_asterisk:
  546. wrap_2_asterisk:
  547. wrap_tilde:
  548. wrap_kbd:
  549. this_label := a_thisLabel
  550. clipboard_text := get_clipboard()
  551. for what, with in { "wrap_quote"       : """" clipboard_text """"
  552.                 , "wrap_grave"       : "``" clipboard_text "``"
  553.                 , "wrap_parenthesis" :  "(" clipboard_text ")"
  554.                 , "wrap_bracket"     :  "[[" clipboard_text "]]"
  555.                 , "wrap_brace"       :  "{{" clipboard_text "}}"
  556.                 , "wrap_angle"       :  "<" clipboard_text ">"
  557.                 , "wrap_asterisk"    :  "*" clipboard_text "*"
  558.                 , "wrap_2_asterisk"  : "**" clipboard_text "**"
  559.                 , "wrap_tilde"       : "~~" clipboard_text "~~"
  560.                 , "wrap_kbd"         :  "<kbd>" clipboard_text "</kbd>" }
  561.     stringReplace, this_label, this_label, % what, % with, all
  562. new_text := this_label
  563. goSub, send_wrap
  564. return
  565.  
  566.  
  567.  
  568. wrap_delete:
  569. clipboard_text := get_clipboard()
  570. loop, 2
  571.     {
  572.     stringLeft, left_character, clipboard_text, 1
  573.     stringRight, right_character, clipboard_text, 1
  574.     if regExMatch(left_character, "[\Q'%*-_""~``([{><\E]")
  575.         and if regExMatch(right_character, "[\Q'%*-_""~)``]}><\E]")  ; if  '%*-_"~`([{
  576.         {
  577.         stringTrimLeft, clipboard_text, clipboard_text, 1
  578.         stringTrimRight, clipboard_text, clipboard_text, 1
  579.         }
  580.     else break
  581.     }
  582. new_text := clipboard_text
  583. goSub, send_wrap
  584. return
  585.  
  586.  
  587.  
  588. get_clipboard(){
  589.     global
  590.     if !inStr(a_thisHotkey, ":")    ; if hotkey was used
  591.         {
  592.         revert_clipboard := clipboardAll
  593.         clipboard =
  594.         send ^{c}
  595.         clipWait, 0.3
  596.         if clipboard is space
  597.             clipboard =
  598.         }
  599.  
  600.     return clipboard
  601. }
  602.  
  603.  
  604.  
  605. send_wrap:
  606. if !inStr(a_thisHotkey, ":") and if (clipboard = "")       ; if hotkey was used
  607.     position := "{Left " round( strLen(new_text) / 2) "}" ; move cursor between symbols
  608. else position := ""
  609. clipboard := new_text
  610. send % "^{v}" . position
  611. sleep 150
  612. clipboard := revert_clipboard
  613. return
  614.  
  615.  
  616. ;Markdown code block
  617. CapsLock & /::
  618. Send {``` 3}
  619. Send {Enter}{Enter}
  620. Send {``` 3}
  621. Send {Up}
  622. return
  623.  
  624. ;Markdown links [text](http://example.com) will translate into <a href="http://example.com>text</a>
  625. CapsLock & l::
  626. ;Clipboard :=
  627. SendInput ^c
  628.  
  629. MDurl = %Clipboard%
  630. MDtext = %Clipboard%
  631.  
  632. IfNotInString, MDurl, ://
  633.   MDurl = http://%MDurl%
  634.  
  635. Gui, +AlwaysOnTop +Owner
  636. Gui, Add, Text,, Text to display
  637. Gui, Add, Edit, vMDtext w320 r1, %MDtext%
  638. Gui, Add, Text,, URL
  639. Gui, Add, Edit, vMDurl w320 r1, %MDurl%
  640. Gui, Add, Button, Default, OK
  641. Gui, Show, w350, MDLink
  642.  
  643. Return
  644.  
  645. ButtonOK:
  646.    Gui, Submit
  647.     Gui, Destroy
  648.     Clipboard = [%MDtext%](%MDurl%)
  649.     Return
  650.  
  651. GuiClose:
  652.     Gui, Destroy
  653.     Return
  654.  
  655.  
  656.  
  657.  
  658.  
  659. ;------------------------------------------------------------------------------
  660. ; Typography / symbols
  661. ;------------------------------------------------------------------------------
  662. ::|c::© ; copyright symbol
  663. ::(c)::©
  664. ::|r::® ; registered symbol
  665. ::(r)::®
  666. ::|s::§ ; section symbol
  667. ::(tm)::™ ; trademark symbol
  668.  
  669. :c:|o::•  ; bullet
  670. ::|bull::•
  671. ::|bullet::•
  672.  
  673. ; Arrows
  674. :?*:-->::→
  675. :?*:<--::←
  676. :?*:<->::↔
  677. ::|^::↑
  678. ::|v::↓
  679.  
  680. ; ------- SET REPLACEMENTS -----------
  681.  
  682. :?:]d::  ; This hotstring replaces "]d" with the current date and time via the commands below.
  683. FormatTime, CurrentDateTime,, yyyy-MM-dd HH:mm  ; It will look like 2005-09-01 15:53
  684. SendInput %CurrentDateTime%
  685. return
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693. ; ----------------------- markdown link ---------------
  694. ; #If WinActive("ahk_class Chrome_WidgetWin_1 ahk_exe chrome.exe")
  695. $F1::
  696.    Clipboard := ""
  697.    Send ^l
  698.    while !Clipboard {
  699.       Sleep, 50
  700.       Send ^c
  701.    }
  702.    Send {End}
  703.    WinGetActiveTitle, title
  704.    Clipboard := "[" . title . "](" . Clipboard . ")"
  705.    MsgBox, % Clipboard
  706.    Return
  707.  
  708. ;------------------------------------------------------------------------------
  709. ; ❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓POTENTIALS❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓❓
  710. ;------------------------------------------------------------------------------
  711.  
  712. ; ----------------------- URL replacement? ---------------
  713.  
  714. ;^+7:: ; Ctrl+Shift+7 (/)
  715. ;Clipboard := ""
  716. ;Send ^l
  717. ;while !Clipboard {
  718. ;Sleep, 50
  719. ;Send ^c
  720. ;}
  721. ;Send {End}
  722. ;WinGetActiveTitle, title
  723.  
  724. ;If !WinActive("ahk_class Chrome_WidgetWin_1 ahk_exe chrome.exe")
  725. ;{
  726. ;;Perform the RegEx find and replace operation,
  727. ;;where the needle is what we want to replace.
  728. ;haystack := Clipboard
  729. ;needle := "\\"
  730. ;replacement := "/"
  731. ;result := RegExReplace(haystack, needle, replacement)
  732. ;haystack := result
  733. ;needle := " "
  734. ;replacement := "%20"
  735. ;result := RegExReplace(haystack, needle, replacement)
  736. ;;Empty the Clipboard
  737. ;Clipboard =
  738. ;;Copy the result to the Clipboard.
  739. ;Clipboard := result
  740. ;Clipboard := "[" . title . "](file:///" . Clipboard . ")"
  741. ;;Wait for the Clipboard to fill.
  742. ;ClipWait
  743. ;return
  744. ;}
  745.  
  746. ;If WinActive("ahk_class Chrome_WidgetWin_1 ahk_exe chrome.exe")
  747. ;{
  748. ;Clipboard := "[" . title . "](" . Clipboard . ")"
  749. ;}
  750. ;Return
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757. ;------------------------------------------------------------------------------
  758. ;💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀 GRAVEYARD 💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀
  759. ;------------------------------------------------------------------------------
  760.  
  761.  
  762. ; Turns capslock off while this script is running.
  763. ;SetCapsLockState, AlwaysOff
  764.  
  765. ; You can make capslock your modifier by putting
  766. ; CapsLock & <Whatever Key>
  767. ;CapsLock & a::MsgBox, You pressed Capslock And A
  768.  
  769. ;CapsLock & b::
  770. ;    WinGetActiveTitle, titleName
  771. ;    MsgBox, The name of this window is:`n%titleName%.
  772. ;return
  773.  
  774. ;CapsLock & z to open Zotero
  775. ;CapsLock & z::
  776. ;    Run, "C:\Program Files (x86)\Zotero\zotero.exe"
  777. ;    Return
  778.  
  779.  
  780. ; Do WIKIPEDIA of selected word -- caps & w for wrapping text
  781. ;CapsLock & w::
  782. ;    ClipboardGet()
  783. ;    Run, https://en.wikipedia.org/wiki/%clipboard%              ; Launch with contents of clipboard
  784. ;    ClipboardRestore()
  785. ;Return
  786.  
  787.  
  788. ;------------------------------------------------------------------------------
  789. ; Home/End w Capslock
  790. ;------------------------------------------------------------------------------
  791.  
  792. ; This section was designed to get around keyboards that did not have home/end keys.
  793.  
  794. ;   Capslock & Numpad7::SendInput {Blind}{Home Down}
  795. ;   Capslock & Numpad7 up::SendInput {Blind}{Home Up}
  796. ;   Capslock & Numpad1::SendInput {Blind}{End Down}
  797. ;   Capslock & Numpad1 up::SendInput {Blind}{End Up}
  798. ;   Capslock & Numpad3::SendInput {Blind}{PgDn Down}
  799. ;   Capslock & Numpad3 up::SendInput {Blind}{PgDn Up}
  800. ;   Capslock & Numpad9::SendInput {Blind}{PgUp Down}
  801. ;   Capslock & Numpad9 up::SendInput {Blind}{PgUp Up}
  802. ;  
  803. ;   #If GetKeyState("Shift", "P")
  804. ;   Capslock & NumpadHome::SendInput {Blind}+{Home Down}
  805. ;   Capslock & NumpadHome up::SendInput {Blind}+{Home Up}
  806. ;   Capslock & NumpadEnd::SendInput {Blind}+{End Down}
  807. ;   Capslock & NumpadEnd up::SendInput {Blind}+{End Up}
  808. ;   Capslock & NumpadPgUp::SendInput {Blind}+{PgUp Down}
  809. ;   Capslock & NumpadPgUp up::SendInput {Blind}+{PgUp Up}
  810. ;   Capslock & NumpadPgDn::SendInput {Blind}+{PgDn Down}
  811. ;   Capslock & NumpadPgDn up::SendInput {Blind}+{PgDn Up}
  812. ;  
  813. ;   #If
  814. ;   Capslock & NumpadHome::SendInput {Blind}{Home Down}
  815. ;   Capslock & NumpadHome up::SendInput {Blind}{Home Up}
  816. ;   Capslock & NumpadEnd::SendInput {Blind}{End Down}
  817. ;   Capslock & NumpadEnd up::SendInput {Blind}{End Up}
  818. ;   Capslock & NumpadPgUp::SendInput {Blind}{PgUp Down}
  819. ;   Capslock & NumpadPgUp up::SendInput {Blind}{PgUp Up}
  820. ;   Capslock & NumpadPgDn::SendInput {Blind}{PgDn Down}
  821. ;   Capslock & NumpadPgDn up::SendInput {Blind}{PgDn Up}
  822. Return      
  823.  
  824.  
  825. ;Markdown ![text](http://example.com/pic.jpg) will translate into <img src="http://example.com/pic.jpg" alt="text" />
  826. ;offer preview dialog, to see the picture which should included
  827. ;CapsLock & p::
  828. ;pictureLabel:
  829. ;Gui 2:Add, Text,, Please enter URL to the Picture:
  830. ;Gui 2:Add, Edit, vPicUrl
  831. ;Gui 2:Add, Text,, Please enter alternative text for the Picture:
  832. ;Gui 2:Add, Edit, vPicAlt
  833. ;Gui 2:Add, Button, default ys, &Preview
  834. ;Gui 2:Add, Button,, &OK
  835. ;Gui 2:Add, Button,, &Cancel
  836. ;Gui 2:Show
  837. ;return
  838.  
  839. ;2ButtonOK:
  840. ;Gui, 2:Submit
  841. ;Send {!}{[}
  842. ;Send %PicAlt%
  843. ;Send {]}{(}
  844. ;Send %PicUrl%
  845. ;Send {)}
  846. ;Gui, 2:Destroy
  847. ;return
  848.  
  849. ;2ButtonCancel:
  850. ;2GuiClose:
  851. ;2GuiEscape:
  852. ;Gui, 2:Destroy
  853. ;return
  854.  
  855. ;2ButtonPreview:
  856. ;Gui, 2:Submit, NoHide                          ;NoHide prevent GUI 1 for being closed
  857. ;UrlDownloadToFile, %PicUrl%, %temp%\foobar     ;download file local, to show preview
  858. ;Gui, 3:Add, Picture, w300 h300, %temp%\foobar  ;2:Foo access the second window, up to 99 windows are possible
  859. ;Gui, 3:Add, Button,, Close
  860. ;Gui, 3:Show
  861. ;return
  862.  
  863. ;3ButtonClose:
  864. ;3GuiClose:
  865. ;3GuiEscape:
  866. ;Gui, 3:Destroy
  867. ;return
  868.  
  869.  
  870.  
  871.  
  872.  
  873. ; ---------------- Hotstring Helper ------------------------------
  874. ; 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.
  875.  
  876. ; 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.
  877.  
  878. #h::  ; Win+H hotkey
  879. ; Get the text currently selected. The clipboard is used instead of
  880. ; "ControlGet Selected" because it works in a greater variety of editors
  881. ; (namely word processors).  Save the current clipboard contents to be
  882. ; restored later. Although this handles only plain text, it seems better
  883. ; than nothing:
  884. AutoTrim Off  ; Retain any leading and trailing whitespace on the clipboard.
  885. ClipboardOld := ClipboardAll
  886. Clipboard := ""  ; Must start off blank for detection to work.
  887. Send ^c
  888. ClipWait 1
  889. if ErrorLevel  ; ClipWait timed out.
  890.     return
  891. ; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring:
  892. ; The same is done for any other characters that might otherwise
  893. ; be a problem in raw mode:
  894. StringReplace, Hotstring, Clipboard, ``, ````, All  ; Do this replacement first to avoid interfering with the others below.
  895. StringReplace, Hotstring, Hotstring, `r`n, ``r, All  ; Using `r works better than `n in MS Word, etc.
  896. StringReplace, Hotstring, Hotstring, `n, ``r, All
  897. StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
  898. StringReplace, Hotstring, Hotstring, `;, ```;, All
  899. Clipboard := ClipboardOld  ; Restore previous contents of clipboard.
  900. ; This will move the InputBox's caret to a more friendly position:
  901. SetTimer, MoveCaret, 10
  902. ; Show the InputBox, providing the default hotstring:
  903. 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%
  904. if ErrorLevel  ; The user pressed Cancel.
  905.     return
  906. if InStr(Hotstring, ":R`:::")
  907. {
  908.     MsgBox You didn't provide an abbreviation. The hotstring has not been added.
  909.     return
  910. }
  911. ; Otherwise, add the hotstring and reload the script:
  912. FileAppend, `n%Hotstring%, %A_ScriptFullPath%  ; Put a `n at the beginning in case file lacks a blank line at its end.
  913. Reload
  914. Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
  915. 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.
  916. IfMsgBox, Yes, Edit
  917. return
  918.  
  919. MoveCaret:
  920. IfWinNotActive, New Hotstring
  921.     return
  922. ; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.
  923. Send {Home}{Right 3}
  924. SetTimer, MoveCaret, Off
  925. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement