ahka

Assorted ease-of-use and functionality tools using AutoHotkey.
Log | Files | Refs

ahk-assistant.ahk (23280B)


      1 ; ahk-assistant
      2 ; ^ctrl #win !alt +shift
      3 
      4 ; environment
      5 #NoEnv
      6 #SingleInstance,Force
      7 #Include, *i %A_ScriptDir%\variables.ahk ; include physical and ip address completions, only included if exists. See .gitignore for details
      8 CoordMode,Mouse
      9 SetWorkingDir %A_MyDocuments%\..\
     10 SetWinDelay,0
     11 SetKeyDelay,0
     12 SetControlDelay,0
     13 SetCapsLockState, AlwaysOff
     14 SetScrollLockState, AlwaysOff
     15 SetNumLockState, AlwaysOn
     16 SetTimer, changeReload, 1000
     17 
     18 ; custom tray menu
     19 menu, tray, icon, %A_ScriptDir%\%A_ScriptName%.ico ; tray icon
     20 menu, tray, nostandard
     21 menu, tray, add, Edit script source, scriptEdit ; edit scriptname.ahk
     22 menu, tray, add, Edit variable source, scriptEditVariables ; edit variable.ahk
     23 menu, tray, add, Autorun Script, scriptAutorun ; autorun tray indicator
     24 menu, tray, add ; seperator for menu
     25 menu, tray, standard
     26 
     27 ; global hotkeys
     28 #q::Run notepad
     29 ^q::Send !{F4} ; quit most programs
     30 #w::Run firefox
     31 #+w::Run firefox.exe -private-window
     32 #e::Run %A_WorkingDir%\Downloads
     33 #+e::Run %A_WorkingDir%\Vault
     34 ^!e::Run ::{20d04fe0-3aea-1069-a2d8-08002b30309d} ; my computer
     35 ^!r::Run mstsc ; remote desktop connection
     36 ^!+r::Run mstsc /v:%serverRemoteAddress% ; rdp to a destination defined by variable file
     37 ^!t::Run *RunAs cmd ; C-A-t admin cmd
     38 #t:: ; overflow
     39 #Enter::Run cmd ; command prompt
     40 #p:: ; overflow
     41 #+Enter:: Run putty
     42 *CapsLock::BackSpace
     43 RWin::AppsKey ; remap key for Rosewill keyboards
     44 #\::SendMessage 0x112, 0xF170, 2, , Program Manager ; W-\ - screen standby
     45 ^!\::DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) ; C-A-\ - system standby
     46 ^!+x::forceClose() ; C-A-S-x force close application
     47 #c::Run calc
     48 ^+v::pasteClipboard()
     49 ^!m::ControlSend, , {Space}, ahk_exe mpv.exe ; global hotkey to toggle mpv pause/play
     50 ^!n::dailyNotes()
     51 ^!Space::toggleAudioDevice()
     52 RAlt & j::ShiftAltTab
     53 RAlt & k::AltTab
     54 RAlt & PgUp::Send {WheelUp}
     55 RAlt & PgDn::Send {WheelDown}
     56 SC029::Send, 0 ; Backtick send zeroes
     57 +SC029::Send, `` ; S-Backtick send backticks
     58 #SC029::Run %A_ScriptDir%\..\clickcall-dialhandler\dial.exe %clipboard%
     59 ^SC029::Send, `¬ ; C-Backtick send negations
     60 !^0::Send {Volume_Mute} ; C-A-0 volume mute toggle
     61 !^-::Send {Volume_Down 1} ; C-A-- volume down
     62 !^=::Send {Volume_Up 1} ; C-A-+ volume up
     63 Insert::appendClipboard()
     64 #LButton::WinSet, Style, -0x840000, A ; W-Click - remove window borders
     65 !LButton::kdeMove() ; kde style window moving
     66 !RButton::kdeResize() ; kde style window resizing
     67 #+Down::Send !{Esc} ; Send to bottom instead of minimise
     68 #Numpad5::WinMaximize, A ; maximise window
     69 #NumpadClear::WinSet, AlwaysOnTop, , A ; W-S-Num5 toggles current window to always on top
     70 
     71 ; spotify global hotkeys
     72 ^Numpad7::PostMessage, 0x319,, 0xC0000,, ahk_exe Spotify.exe ; prev track spotify
     73 ^Numpad8::PostMessage, 0x319,, 0xE0000,, ahk_exe Spotify.exe ; pause toggle spotify
     74 ^Numpad9::PostMessage, 0x319,, 0xB0000,, ahk_exe Spotify.exe ; next track spotify
     75 
     76 
     77 ; application specific hotkeys
     78 #IfWinActive ahk_class #32770 ; misc save/load/time-date/find boxes and more!
     79 CapsLock::Send !{F4} ; quit
     80 F1::Send, {F2} ; rename, help is useless in explorer
     81 /::Send, \ ; forward slashes paths aren't accepted
     82 !/::Send, / ; just in case you need an incorrect slash
     83 #IfWinActive
     84 
     85 #IfWinActive ahk_class CabinetWClass ; explorer
     86 CapsLock:: ; overflow
     87 RAlt & Up::Send {AltDown}{Up}{AltUp}
     88 Alt & Enter:: ; overflow
     89 Ralt & Enter::Send {AppsKey}{Up}{Enter} ; ralt-enter properties
     90 ^+Enter::Send {AppsKey}e ; C-S-enter opens in new window
     91 F1:: ; overflow to rename, help is useless in explorer
     92 F3::Send, {F2} ; rename for fun, nobody uses F3
     93 F6::Send !d ; addressbar
     94 ^Backspace::Send ^+{Left}{Backspace} ; backspace a word
     95 ^f::Return ; disable search in explorer, was always pretty useless
     96 ^h::explorerHidden()
     97 ^p::Send, !p ; C-p also works for toggle preview
     98 ^-::Send ^{WheelDown 2} ; zoom out
     99 ^=::Send ^{WheelUp 2} ; zoom in
    100 #IfWinActive
    101 
    102 #IfWinActive ahk_class ShockwaveFlashFullScreen ; full screen flash
    103 Ralt & Enter:: ; overflow
    104 Alt & Enter::toggleFullscreen() ; leave flash full screen with a keyboard command
    105 #IfWinActive
    106 
    107 #IfWinActive ahk_class FontViewWClass ; font previewer
    108 CapsLock::Send !{F4} ; quit
    109 #IfWinActive
    110 
    111 #IfWinActive ahk_exe fontview.exe ; windows 10 font viewer
    112 q:: ; overflow
    113 ^w:: ; overflow
    114 CapsLock::Send !{F4} ; quit
    115 #IfWinActive
    116 
    117 #IfWinActive ahk_exe 7zFM.exe ; 7zip file manager
    118 !Up::Send {Backspace}
    119 #IfWinActive
    120 
    121 #If WinActive("ahk_exe AppMgrEX.exe") or WinActive("ahk_exe AppMgr.exe") or WinActive("ahk_exe AppMgrPx.exe") ; NEC programming tools
    122 global necUsername
    123 global necPassword
    124 global necPort
    125 :*?:__login::
    126    Send tech{Tab}12345678{Enter}
    127 Return
    128 Alt & Enter:: ; connect, paste IP, enter credentials, connect
    129 Send {F5}{Sleep 250}{Tab 5}{Sleep 250}
    130 pasteClipboard()
    131 Send {Tab}{Enter}{Tab}%necPort%{Tab 2}{Enter}{Tab}%necUsername%{Tab}%necPassword%{Tab}{Enter}{Sleep 250}{Enter}
    132 Return
    133 #If
    134 
    135 #If WinActive("ahk_class SciCalc") or WinActive("ahk_class CalcFrame") ; windows xp or windows 7 calculator
    136 CapsLock::Send !{F4} ; quit
    137 #IfWinActive
    138 
    139 #IfWinActive ahk_class ShImgVw:CPreviewWnd ; photoviewer windows xp
    140 ^w:: ; overflow
    141 CapsLock::Send !{F4} ; quit
    142 ^-::Send {-} ; zoom out
    143 ^=::Send {+} ; zoom in
    144 #IfWinActive
    145 
    146 #IfWinActive ahk_class Photo_Lightweight_Viewer ; photoviewer windows 7
    147 q:: ; overflow
    148 ^w:: ; overflow
    149 CapsLock::Send !{F4} ; quit
    150 Up:: ; overflow
    151 Down::Return ; fixes up/down breaking left/right navigation
    152 #IfWinActive
    153 
    154 #IfWinActive ahk_exe nomacs.exe
    155 q:: ; overflow
    156 ^w:: ; overflow
    157 CapsLock::Send !{F4} ; quit
    158 !Left::Send {AltDown}e9{AltUp} ; CCW rotation
    159 !Right::Send, {AltDown}e0{AltUp} ; CW rotation
    160 #IfWinActive
    161 
    162 #IfWinActive ahk_exe SumatraPDF.exe ; sumatra pdf
    163 CapsLock::Send !{F4} ; quit
    164 ^b::Send {F12} ; C-b toggles bookmarks
    165 ^t::Send !vt ; C-t toggles toolbar
    166 Alt & Enter:: ; overflow
    167 Ralt & Enter::Send ^l ; fullscreen
    168 #IfWinActive
    169 
    170 #IfWinActive ahk_class MediaPlayerClassicW ; mpc-hc
    171 1::Send 2^1 ; 1 keeps borders
    172 Ralt & Enter::Send !{Enter} ; ralt-enter fullscreens
    173 CapsLock::Send !{F4} ; quit
    174 p::Send ^7 ; p for playlist
    175 #IfWinActive
    176 
    177 #If WinActive("ahk_exe mpv.exe") or WinActive("ahk_exe mpvnet.exe") ; mpv and mpv.net
    178 Alt & Enter:: ; overflow to fullscreen below
    179 Ralt & Enter::Send f ; ralt-Enter fullscreens
    180 q:: ; overflow to quit, for mpv.net
    181 CapsLock::Send !{F4} ; quit
    182 #IfWinActive
    183 
    184 #IfWinActive ahk_class rctrl_renwnd32 ; outlook
    185 ^Enter::Return ; disable accidentally send email shortcut
    186 ^f::Send ^e ; C-f finds instead of forwards
    187 ^t::Send !go ; C-t goes to today, on calendar view
    188 #IfWinActive
    189 
    190 #IfWinActive ahk_class OpusApp ; word 2003
    191 ^=::Send ^{WheelUp} ; zoom in
    192 ^-::Send ^{WheelDown} ; zoom out
    193 ^0::Send !vzp{Enter} ; fit to page zoom
    194 #IfWinActive
    195 
    196 #IfWinActive ahk_class XLMAIN ; excel 2003/2007
    197 ^!t::Send {AppsKey}f{Tab}{End}{Up 2}{Enter} ; sets cell format to text to allow leading zeroes
    198 ^+v::Send ^'{Down} ; C-S-v copies above cell contents into current
    199 ^!+v::pasteClipboard() ; C-A-S-v past clipboard as above steals C-A-v
    200 ^+n::Send !iw ; new sheet
    201 ^+w::Send !el ; delete current sheet
    202 !F2:: ; overflow
    203 ^F2::Send !ohr ; rename sheet
    204 F3::Send +{F4} ; f3 searches for the same string again
    205 F6::Send {F2} ; shortcut to formula bar
    206 F11::Send !vu ; fullscreen
    207 ^Tab::Send ^{PgDn} ; next sheet
    208 ^+Tab::Send ^{PgUp} ; prev sheet
    209 ^0::Send !vz1{Enter} ; reset zoom
    210 ^-::Send ^{WheelDown} ; zoom out
    211 ^=::Send ^{WheelUp} ; zoom in
    212 ^Backspace::Send {CtrlDown}{ShiftDown}{Left}{CtrlUp}{ShiftUp}{Backspace} ; C-Backspace deletes word when in formula bar, can't ^!LB due to it not releasing and deleting the whole line
    213 #IfWinActive
    214 
    215 #IfWinActive ahk_class wxWindowNR ; hydrus client
    216 CapsLock::Send !{F4} ; quit
    217 #IfWinActive
    218 
    219 #IfWinActive ahk_class ConsoleWindowClass ; command prompt
    220 ^l::Send ^c{Enter}cls{Enter} ; clear screen as in linux
    221 #IfWinActive
    222 
    223 #IfWinActive ahk_class MozillaWindowClass ; firefox
    224 ^+w::Send ^w ; quit window closes tab
    225 ^+n::Send ^+p ; new incognito window
    226 ^q::Send ^w ; quit now closes tab, the two keys are too close for this sort of thing
    227 ^!d::Send ^j ; why Downloads is ctrl+j while addons is ctrl+alt+a will never make sense
    228 ^d::Send ^f ; bookmark remapped to find
    229 ^b::Send ^v ; replace bookmarks with paste
    230 ^+m::Send, ^+n ; why is this feature even a thing
    231 #o::Send, ^c{F6}^v{Enter} ; copy selected uri and open in current tab
    232 #+o::Send, ^c^t^v{Enter} ; copy selected uri and open in new tab
    233 ^+o::Send, !t{sleep 150}s ; C-S-o options
    234 F1:: ; overflow
    235 F2::Send {Sleep 25}{Esc}{Sleep 25}{F6}{ShiftDown}{Tab 2}{ShiftUp}{AppsKey}w{Sleep 250} ; split current tab from window
    236 F7:: ; overflow
    237 F6::Send ^l ; F6 jumps to address bar
    238 +PgDn::Send {Space 4}{Down 5} ; scroll down to specific part of a specific page, not really
    239 +PgUp::Send {Home} ; makes sense, kinda
    240 RAlt & Left::Send, !{Left}
    241 RAlt & Right::Send, !{Right}
    242 Ralt & Enter:: ; overflow
    243 Alt & Enter::toggleFullscreen() ; leave flash full screen with a keyboard command
    244 #IfWinActive
    245 
    246 #IfWinActive ahk_exe mspaint.exe ; mspaint
    247 ^=::Send ^{PgUp} ; zoom in
    248 ^-::Send ^{PgDn} ; zoom out
    249 #IfWinActive
    250 
    251 #If WinActive("ahk_class Notepad2") or WinActive("ahk_class Notepad3") ; notepad 2 and 3
    252 ^0::Send ^/ ; remap transparency feature to reset zoom level, in keeping with other hotkeys
    253 !t::Return ; disable always on top
    254 ^+Down:: ; overflow
    255 ^Down::Send {Down} ; disable (alt) shift line down feature
    256 ^+Up:: ; overflow
    257 ^Up::Send {Up} ; disable (alt) shift line up feature
    258 !u::Send ^a!o ; remap delete last character to sort lines, after selecting everything
    259 #IfWinActive
    260 
    261 #IfWinActive ahk_class Notepad++ ; notepad++
    262 !o::Send {AltDown}el{Up 9}{AltUp}{Enter}{AltDown}el{Down}{AltUp}{Enter} ; remove duplicates and sort
    263 #IfWinActive
    264 
    265 #IfWinActive ahk_exe calibre-parallel.exe ; calibre reader
    266 q:: ; overflow
    267 CapsLock::Send !{F4} ; quit
    268 #IfWinActive
    269 
    270 #IfWinActive ahk_exe audacity.exe ; audacity
    271 ^=::Send ^1 ; zoom in
    272 ^-::Send ^3 ; zoom out
    273 ^0::Send ^2 ; zoom reset
    274 #IfWinActive
    275 
    276 #IfWinActive ahk_class WinClass_FXS ; civilization 5
    277 F11::borderlessFullscreen()
    278 ^h::send {Home}{Esc} ; return to capital city, then close home screen
    279 #IfWinActive
    280 
    281 #IfWinActive ahk_exe Teams.exe ; i hate ms teams
    282 ^a::Send {End}{CtrlDown}{ShiftDown}{Home}{CtrlUp}{ShiftUp}
    283 #IfWinActive
    284 
    285 #IfWinActive ahk_class SunAwtFrame ; vidyascape
    286 ^LButton::osrsDropItem()
    287 #IfWinActive
    288 
    289 ; text insertion/replacements
    290 :*?:_date::
    291    insertDate()
    292 Return
    293 :*?:_time::
    294    insertTime()
    295 Return
    296 :*?:_dttime::
    297    insertBlogDateTime()
    298 Return
    299 :*?:_dtime::
    300    insertDateTime()
    301 Return
    302 :*?:_week::
    303    insertWeek()
    304 Return
    305 :*?:_gw::
    306    insertGateway()
    307 Return
    308 :*?:_lip::
    309    Send, %A_IPAddress1%
    310 Return
    311 :*?:_sig::
    312    insertSignature()
    313 Return
    314 :*?:_reg::
    315    Send,`n`nRegards,`n%firstName%.
    316 Return
    317 :*?:_kreg::
    318    Send,`n`nKind regards,`n%firstName%.
    319 Return
    320 :*:_hem::
    321    Send, %homeEmailAddress%
    322 Return
    323 :*:_wem::
    324    Send, %workEmailAddress%
    325 Return
    326 :*:_wip::
    327    Send, %workIPAddress%
    328 Return
    329 :*:_cbip::
    330    Send, %workCBIPAddress%
    331 Return
    332 :*:_ntp::
    333    Send, 0.uk.pool.ntp.org
    334 Return
    335 :*:_mac::
    336    Send, %remoteMAC%
    337 Return
    338 :*:_htel::
    339    Send, %homePhoneNumber%
    340 Return
    341 :*:_wtel::
    342    Send, %workPhoneNumber%
    343 Return
    344 :*:_wddi::
    345    Send, %workPhoneNumberDDI%
    346 Return
    347 :*:_mob::
    348    Send, %mobilePhoneNumber%
    349 Return
    350 :*:_wmob::
    351    Send, %workMobilePhoneNumber%
    352 Return
    353 :*:_xmraddr::
    354    Send, %xmrAddress%
    355 Return
    356 :*:_xrbaddr::
    357    Send, %xrbAddress%
    358 Return
    359 :*:_banaddr::
    360    Send, %banAddress%
    361 Return
    362 :*:_proid::
    363    Send, %prolificID%
    364 Return
    365 :*:_haddr::
    366    Send, %homeAddress%
    367 Return
    368 :*:_waddr::
    369    Send, %workAddress%
    370 Return
    371 :*:_hpc::
    372    Send, %homePostCode%
    373 Return
    374 :*:_wpc::
    375    Send, %workPostCode%
    376 Return
    377 :*:_salu::
    378    insertSalutation()
    379 Return
    380 :*:_db::
    381    Send, %A_WorkingDir%\Vault\
    382 Return
    383 :*:_md::
    384    Send, %A_WorkingDir%
    385 Return
    386 :*?:_foot::
    387    insertFooter()
    388 Return
    389 
    390 ; special character insertion
    391 ; swedish
    392 :c*?:(Ao)::Å
    393 :c*?:(AO)::Å
    394 :c*?:(ao)::å
    395 :c*?:(Ai)::Ä
    396 :c*?:(ai)::ä
    397 :c*?:(Oi)::Ö
    398 :c*?:(oi)::ö
    399 ; norwegian/danish
    400 :c*?:(AE)::Æ
    401 :c*?:(Ae)::Æ
    402 :c*?:(ae)::æ
    403 :c*?:(O/)::Ø
    404 :c*?:(o/)::ø
    405 :*:(norquote)::«»{Left}
    406 :*:kronor::kroner
    407 ; german
    408 :c*?:(Ui)::Ü
    409 :c*?:(ui)::ü
    410 :*?:(ss)::ß
    411 ; dutch and/or maxïmo park
    412 :c*?:(Ei)::Ë
    413 :c*?:(ei)::ë
    414 :c*?:(Ii)::Ï
    415 :c*?:(II)::Ï
    416 :c*?:(ii)::ï
    417 ; icelandic/faroese
    418 :c*?:(-D)::Ð
    419 :c*?:(-d)::ð
    420 :c*?:(/P)::Þ
    421 :c*?:(/p)::þ
    422 :c*?:(Y-)::Ý
    423 :c*?:(y-)::ý
    424 ; italian
    425 :c?*:(A\)::À
    426 :c?*:(a\)::à
    427 :c?*:(E\)::È
    428 :c?*:(e\)::è
    429 :c?*:(I\)::Ì
    430 :c?*:(i\)::ì
    431 :c?*:(O\)::Ò
    432 :c?*:(o\)::ò
    433 :c?*:(U\)::Ù
    434 :c?*:(U\)::ù
    435 ; spanish
    436 :c?*:(N~)::Ñ
    437 :c?*:(n~)::ñ
    438 :c?*:(A-)::Á
    439 :c?*:(a-)::á
    440 :c?*:(E-)::É
    441 :c?*:(e-)::
    442    Send {ASC 130} ; C-A-e insertion for é is weird
    443 Return
    444 :c?*:(I-)::Í
    445 :c?*:(i-)::í
    446 :c?*:(O-)::Ó
    447 :c?*:(o-)::ó
    448 :c?*:(U-)::Ú
    449 :c?*:(u-)::ú
    450 :*?:(!!)::¡
    451 :*?:(??)::¿
    452 ; ...latin?
    453 :c*?:(OE)::Œ
    454 :c*?:(Oe)::Œ
    455 :c*?:(oe)::œ
    456 
    457 ; symbols
    458 :*?:(c)::©
    459 :*?:(r)::®
    460 :*?:(tm)::™
    461 :*?:(ee)::€
    462 :*?:(deg)::°
    463 :*?:(half)::½
    464 :*?:(quart)::¼
    465 :*?:(div)::÷
    466 :*?:(micro)::µ
    467 :*?:(bull)::•
    468 :*?:(middot)::·
    469 
    470 ; typos, abbreviations and common mistakes
    471 :*:addon::add-on
    472 :*:adn::and
    473 :*:afaik::as far as I know
    474 :*:aging::ageing
    475 :*:ahve::have
    476 :*:aquire::acquire
    477 :*:atm ::at the moment{space} ; space is for when I type atmosphere
    478 :*:attendent::attendant
    479 :*:bbs::be back soon
    480 :*:bene ::been{space} ; space is for when typing benefit
    481 :*:bolognaise::bolognese
    482 :*:brb::be right back
    483 :*:bredth::breadth
    484 :*:btu::but
    485 :*:btw::by the way
    486 :*:cinammon::cinnamon
    487 :*:comaraderie::camaraderie
    488 :*:competative::competitive
    489 :*:componant::component
    490 :*:consistant::consistent
    491 :*:differnet::different
    492 :*:enterance::entrance
    493 :*:equivelant::equivalent
    494 :*:excercise::exercise
    495 :*:fiber::fibre
    496 :*:fourty::forty
    497 :*:fyi::for your information
    498 :*:goverment::government
    499 :*:habe::have
    500 :*:iirc::if I recall correctly
    501 :*:imediate::immediate
    502 :*:imho::in my honest opinion
    503 :*:imo::in my opinion
    504 :*:independant::independent
    505 :*:intermitent::intermittent
    506 :*:liase::liaise
    507 :*:liasing::liaising
    508 :*:license::licence
    509 :*:liek::like
    510 :*:micheal::michael
    511 :*:neice::niece
    512 :*:occurance::occurrence
    513 :*:occured::occurred
    514 :*:ommitted::omitted
    515 :*:parliment::parliament
    516 :*:persue::pursue
    517 :*:persuit::pursuit
    518 :*:pronounciation::pronunciation
    519 :*:propogate::propagate
    520 :*:recieve::receive
    521 :*:refridgeration::refrigeration
    522 :*:secratery::secretary
    523 :*:segway::segue
    524 :*:seperate::separate
    525 :*:sieze::seize
    526 :*:supercede::supersede
    527 :*:taht::that
    528 :*:tbh::to be honest
    529 :*:tbqh::to be quite honest
    530 :*:teh ::the{space} ; space is for the rare occurence where I type tehran
    531 :*:tehm::them
    532 :*:tehy::they
    533 :*:wifi::Wi-Fi
    534 :*:woth::with
    535 :*:yhe::the
    536 :*:yuo::you
    537 :c?*:ASAP::as soon as possible
    538 :c?*:i'd::I'd
    539 :c?*:i'll::I'll
    540 :c?*:i'm::I'm
    541 :c?*:i've::I've
    542 :c?*:paypal::PayPal
    543 
    544 ; work related abbreviations
    545 :*:ctsty::Called to speak to you, their number is
    546 :*:gtacb::Called to speak to you, can you give them a call back?
    547 :*:ccwi::Customer called regarding an issue relating to
    548 :*:ctt::Feel free to close the ticket.
    549 :*:yctt::You can close this ticket.
    550 
    551 ; week day casing
    552 :c?*:monday::Monday
    553 :c?*:tuesday::Tuesday
    554 :c?*:wednesday::Wednesday
    555 :c?*:thursday::Thursday
    556 :c?*:friday::Friday
    557 :*:saturday::Saturday
    558 :*:sunday::Sunday
    559 
    560 ; functions
    561 insertGateway() {
    562    RunWait , %comspec% /c ipconfig > %A_Temp%\gw.txt,, Hide
    563    ArrayCount = 0
    564    Loop, Read, %A_Temp%\gw.txt
    565    {
    566       Count := RegExMatch(A_LoopReadLine, ".*Default Gateway .+ ((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)).*",ip)
    567       If ( %Count% != 0) {
    568          ArrayCount += 1
    569          IP_Array%ArrayCount% := ip1
    570          gateway := ip1
    571       }}
    572    FileDelete %A_Temp%\gw.txt
    573    Send, %gateway%
    574 }
    575 
    576 insertSignature() {
    577    global firstName
    578    global lastName
    579    StringLeft, firstInitial, firstname, 1
    580    StringLeft, lastInitial, lastname, 1
    581    Send, %A_Space%-%firstInitial%%lastInitial%
    582 }
    583 
    584 insertFooter() {
    585    Send, {Enter}
    586    insertDateTime()
    587    insertSignature()
    588    Return
    589 }
    590 
    591 insertSalutation() {
    592    If(A_Hour <12)
    593       Send, Morning
    594    Else If (A_Hour <17)
    595       Send, Afternoon
    596    Else
    597       Send, Evening
    598    Return
    599 }
    600 
    601 insertDate() {
    602    FormatTime, CurrentDateTime,, yyyy-MM-dd
    603    Send %CurrentDateTime%
    604    Return
    605 }
    606 
    607 insertTime() {
    608    FormatTime, CurrentDateTime,, HH:mm
    609    Send %CurrentDateTime%
    610    Return
    611 }
    612 
    613 insertBlogDateTime() {
    614    FormatTime, CurrentDateTime,, yyyy-MM-ddTHH:mm:00
    615    Send %CurrentDateTime%
    616    Return
    617 }
    618 
    619 insertDateTime() {
    620    FormatTime, CurrentDateTime,, yyyy-MM-dd HH:mm
    621    Send %CurrentDateTime%
    622    Return
    623 }
    624 
    625 insertWeek() {
    626    yearWeek = %A_YDay%
    627    yearWeek /= 7
    628    yearWeek++ ; Convert from 0-base to 1-base
    629    Send %yearWeek%
    630 }
    631 
    632 appendClipboard() {
    633    backupClipboard = %clipboard%
    634    Send, ^c
    635    clipboard = %backupClipboard%`r`n%clipboard%
    636    backupClipboard =
    637    Return
    638 }
    639 
    640 pasteClipboard() {
    641    ; manually paste clipboard, minus most formatting
    642    tempClipboard = %clipboard%
    643    StringReplace, tempClipboard, tempClipboard, ?,, All ; remove bullet points
    644    StringReplace, tempClipboard, tempClipboard, ·,, All ; remove middots
    645    StringReplace, tempClipboard, tempClipboard, %A_Tab%,, All ; remove tabs
    646    StringReplace, tempClipboard, tempClipboard, /,%A_Space%, All ; forward slashes mess up linux paths
    647    StringReplace, tempClipboard, tempClipboard, +44,0, All ; remove international dialling code without a space
    648    StringReplace, tempClipboard, tempClipboard, `r,, All ; remove half of line breaks
    649    StringReplace, tempClipboard, tempClipboard, `n,, All ; remove other half of line breaks
    650    StringReplace, tempClipboard, tempClipboard, https:,, All ; remove other half of line breaks
    651    StringReplace, tempClipboard, tempClipboard, http:,, All ; remove other half of line breaks
    652    tempClipboard = %tempClipboard% ; trim whitespace
    653    SendRaw %tempClipboard%
    654    tempClipboard =
    655    Return
    656 }
    657 
    658 toggleFullscreen() {
    659    ;double click the window
    660    CoordMode, Mouse, Relative
    661    MouseMove, 250, 250
    662    Send {Click 2}
    663    Return
    664 }
    665 
    666 explorerHidden() {
    667    ; toggle show/hide hidden folders, stolen from http://www.autohotkey.com/board/topic/68131-turn-off-show-hidden-files-at-boot/
    668    RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
    669    If HiddenFiles_Status = 2
    670    RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
    671    Else
    672       RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2
    673    WinGetClass, eh_Class,A
    674    Send, {F5}
    675    Return
    676 }
    677 
    678 borderlessFullscreen() {
    679    ;borderless fullscreen script from PCGW (http://pcgamingwiki.com/wiki/Glossary:Borderless_fullscreen_windowed#Borderless_scripts)
    680    WinGet, WindowID, ID, A
    681    WinSet, Style, -0xC40000, ahk_id %WindowID%
    682    WinMove, ahk_id %WindowID%, , 0, 0, A_ScreenWidth, A_ScreenHeight
    683    Return
    684 }
    685 
    686 osrsDropItem() {
    687 	SendInput {Click Right}
    688 	Sleep 25
    689 	Mousemove ,0 ,50 ,0 ,R
    690 	Sleep 15
    691 	SendInput {Click}
    692 	Sleep 15
    693 	Mousemove ,0 ,-50 ,0 ,R
    694 }
    695 
    696 forceClose() {
    697    WinGet, PID, PID, % "ahk_id " WinExist("A")
    698    Process, Close, %PID%
    699 }
    700 
    701 dailyNotes() {
    702    formattime, todaysDate,, yyyy-MM-dd
    703    noteFilename := A_WorkingDir . "\Vault\docs\wfh\notes " . todaysDate . ".txt"
    704    Run notepad "%noteFilename%"
    705    Return
    706 }
    707 
    708 toggleAudioDevice() {
    709    ;toggle between default audio output (http://ml.pe/optimizing/2013/changing-the-default-sound-device-using-autohotkey/)
    710    switch := !switch
    711    If (switch)
    712       usePlaybackDevice(3)
    713    Else
    714       usePlaybackDevice(4)
    715    Return
    716 }
    717 
    718 usePlaybackDevice(device) {
    719    Run, mmsys.cpl
    720    WinWaitActive, Sound ahk_class #32770
    721    ControlSend, SysListView321,{Down %device%}, Sound ahk_class #32770
    722    ControlClick, Button2, Sound ahk_class #32770
    723    WinClose, Sound ahk_class #32770
    724 }
    725 
    726 kdeMove() {
    727    ;kde-windows (Easy Window Dragging -- KDE style (requires XP/2k/NT) -- by Jonny)
    728    MouseGetPos,KDE_X1,KDE_Y1,KDE_id
    729    WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
    730    If KDE_Win
    731    WinRestore, A
    732    WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
    733    Loop
    734    {
    735       GetKeyState,KDE_Button,LButton,P ; Break if Button has been released.
    736       If KDE_Button = U
    737       Break
    738       MouseGetPos,KDE_X2,KDE_Y2 ; Get the current Mouse position.
    739       KDE_X2 -= KDE_X1 ; Obtain an offset from the initial Mouse position.
    740       KDE_Y2 -= KDE_Y1
    741       KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position.
    742       KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
    743       WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
    744    }
    745    Return
    746 }
    747 
    748 kdeResize() {
    749    MouseGetPos,KDE_X1,KDE_Y1,KDE_id
    750    WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
    751    If KDE_Win
    752    WinRestore, A
    753    ; Get the initial window position and size.
    754    WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
    755    ; Define the window region the mouse is currently in.
    756    ; The four regions are Up and Left, Up and Right, Down and Left, Down and Right.
    757    If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
    758       KDE_WinLeft := 1
    759    Else
    760       KDE_WinLeft := -1
    761    If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
    762       KDE_WinUp := 1
    763    Else
    764       KDE_WinUp := -1
    765    Loop
    766    {
    767       GetKeyState,KDE_Button,RButton,P ; Break if Button has been released.
    768       If KDE_Button = U
    769       Break
    770       MouseGetPos,KDE_X2,KDE_Y2 ; Get the current Mouse position.
    771       ; Get the current window position and size.
    772       WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
    773       KDE_X2 -= KDE_X1 ; Obtain an offset from the initial Mouse position.
    774       KDE_Y2 -= KDE_Y1
    775       ; Then, act according to the defined region.
    776       WinMove,ahk_id %KDE_id%,, KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2  ; X of Resized window
    777       , KDE_WinY1 +   (KDE_WinUp+1)/2*KDE_Y2  ; Y of resized window
    778       , KDE_WinW  -     KDE_WinLeft  *KDE_X2  ; W of resized window
    779       , KDE_WinH  -       KDE_WinUp  *KDE_Y2  ; H of resized window
    780       KDE_X1 := (KDE_X2 + KDE_X1) ; Reset the initial position for the next iteration.
    781       KDE_Y1 := (KDE_Y2 + KDE_Y1)
    782    }
    783    Return
    784 }
    785 
    786 scriptEdit:
    787 {
    788    Run notepad "%A_ScriptDir%\%A_ScriptName%"
    789    Return
    790 }
    791 
    792 scriptEditVariables:
    793 {
    794    Run notepad "%A_ScriptDir%\variables.ahk"
    795    Return
    796 }
    797 
    798 ; autorun script section in tray menu
    799 scriptAutorun:
    800 {
    801    ; delete and recreate registry key
    802    RegDelete, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, %A_ScriptName%
    803    RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, %A_ScriptName%, "%A_ScriptDir%\%A_ScriptName%"
    804    Return
    805 }
    806 
    807 ; auto-reload script on source change
    808 changeReload:
    809 {
    810    FileGetAttrib, FileAttribs, %A_ScriptFullPath%
    811    IfInString, FileAttribs, A
    812    {
    813       FileSetAttrib, -A, %A_ScriptFullPath%
    814       TrayTip, Reloading Script..., %A_ScriptName%, , 1
    815       Reload
    816       Sleep, 5000
    817       TrayTip
    818    }
    819    Return
    820 }