開発者のためのトップ8のマクロはAHKとの生産性を最大化する


カバー写真Ken Suarez on Unsplash

内容

  • Short short Intro
  • 1. Run command prompt in the currently focused folder
  • 2. Run command prompt followed by certain commands
  • 3. Search on Google the currently selected text
  • 4. Open applications/websites using shortcuts
  • 5. Open new explorer window with the same path as the currently focused folder
  • 6. Copy to clipboard the HEX color of the pixel under your cursor
  • 7. Adjust the main volume using the mouse scroll wheel
  • 8. Auto-complete syntaxes with Hotstrings

  • Honorable mentions
  • Put PC to sleep
  • Empty recycle bin
  • Get the current date/hour
  • Use arrow keys as Home/End while holding RAlt
  • Disable CapsLock key
  • Fin
  • ショートイントロ


    この投稿では、AutoHotKey (AHK) 前の部分(+ extras)で.しかし、AHKを設定する方法については、迅速かつ短期間のステップガイドを提供するので、これらの部品を読む必要はありません.
    始めましょう!

    1 .現在フォーカスしているフォルダでコマンドプロンプトを実行する


    あなたがautohotkeyをインストールしていない場合は、単にhere , 次にセットアップを実行します.今私たちはファイルを作成する必要があります.ahk エクステンション.myMacros.ahk ). このファイルを実行したら、小さな緑色のhのアイコンが、スクリプトがバックグラウンドで実行されていることを知らせるポップアップ表示されます.さあ、開けましょう.ahk 任意のテキストエディタでファイルを追加します.
    ^!u::     ; Use ctrl+alt+u to open cmd in current selected folder
    {
      Send, !d
      Send, ^c
      Sleep 50
      Run cmd, %clipboard%
      Return
    }
    

    このファイルを保存してReload This Script AHKアイコンから.今、任意のフォルダを開き、プレスctrl+alt+u CMDプロンプトをフォルダの現在のパスで開くには、次の手順に従います.

    また、AKKの重要な記法を念頭に置いておくことができますControl , Shift , Windows , and Alt :
    AKKのキー表記法
    実際のキー
    ^
    コントロール
    +
    シフト
    !
    alt
    #
    Windowsキー

    2 .コマンドプロンプトの実行


    今から再開しますmyMacros.ahk テキストエディタで、我々はちょうどより多くのマクロを追加し、ファイルを保存しReload this Script .
    コマンドプロンプトを開いた後にコマンドを追加できます.例えば、我々は走ることができるgit status 直後にnpm start , python ./manage.py runserver など)
    ^!+u::     ; Use ctrl+alt+shift+u to open cmd in current selected folder and run git status
    {
      Send, !d
      Send, ^c
      Sleep 50
      Run cmd, %clipboard%
      Sleep 100
      Send, git status
      Sleep 100
      Send, {Enter}
      Return
    }
    
    または使用するならJupyter Notebook 特定のドライブパーティションおよび/または環境では、コマンドプロンプトでそれを開く代わりに、あなただけのようなショートカットを使用することができますctrl+alt+j (あるいはctrl+win+j すべての対応するコマンドを自動的に書きます.ちょっとこのマクロを加えてください
    ^!j::                                  ; use ctrl+alt+j
    {                                      ; to open jupyter notebook in g: in tf_gpu conda env
      Run cmd, g:
      Sleep 100
      Send, activate tf_gpu
      Sleep 1000
      Send, {Enter}
      Send, jupyter notebook
      Sleep 2000
      Send, {Enter}
      Return
    }
    
    または、高速でコマンドプロンプトでPythonを開くことができますctrl+alt+p :
    ^!p::                                  ; use ctrl+alt+p
    {                                      ; to open cmd prompt in python
      Run cmd, C:\Users\MyUserName
      Sleep 100
      Send, python
      Sleep 100
      Send, {Enter}
      Return
    }
    

    Google上で検索


    これらの線をあなたの中に加えなさいmyMacros.ahk Googleを使用して選択したテキストを検索するにはCtrl+Alt+c :
    ^!c:: ; use ctrl+alt+c to search on google
    {
      Send, ^c
      Sleep 50
      Run, http://www.google.com/search?q=%clipboard%
      Return
    }
    
    3つのサイドボタンを持つマウスがあれば、左側のマウスボタンを押しながら左クリックを押してこのマクロを割り当てることもできます.
    XButton2 & LButton:: ; Search currently selected text on Google
    {
      Send, ^c
      Sleep 100
      If InStr(clipboard, "http")
        Run, %clipboard%
      Else
        Run, https://www.google.com/search?q=%clipboard%
      Return
    }
    
    ; Note: if the selected text is a link, open it in a new tab
    ; Otherwise, search the selected text on Google
    
    我々はまた、などの他のウェブサイトで検索することができますPexels and Unsplash .
    ^#u:: ; use ctrl+win+u to search on Unsplash
    {
      Send, ^c
      Sleep 50
      Run, https://unsplash.com/s/photos/%clipboard%
      Return
    }
    
    ^#p:: ; use ctrl+win+p to search on Pexels
    {
      Send, ^c
      Sleep 50
      Run, https://www.pexels.com/search/%clipboard%
      Return
    }
    

    ショートカットを使用したオープンアプリケーション/ウェブサイト


    任意のショートカットキーを使用して任意のアプリケーションを開くことができます.参考のために、以下のキーを使用することができます(システムのショートカットなしで).
  • RAlt+(anyKeyLetter) or RAlt+(anyNumber)
  • Ctrl+Alt+(anyKey) (しかし、いくつかのアプリケーションがこれらのキーの組み合わせを使用するかもしれないことに注意してください.you can check using DefKey.com )
  • Ctrl+Shift+Alt+(anyKey)
  • Alt+Shift+(anyKey) ( Check here )
  • Ctrl+Win+(anyKey)
  • Ctrl+Win+Alt+(anyKey)
  • 以下に例を示します:
    ^#1::Run "https://mail.google.com/mail/u/0/#inbox"   ; use ctrl+win+1 to open gmail 1
    ^#2::Run "https://mail.google.com/mail/u/1/#inbox"   ; use ctrl+win+2 to open gmail 2
    ^#3::Run "https://translate.google.ro/?hl=ro&tab=wT" ; use ctrl+win+3 to open Google Translate
    
    ^+!1::Run "https://www.google.com"      ; use ctrl+shift+alt+1
    ^+!2::Run "https://dev.to"              ; use ctrl+shift+alt+2
    ^+!3::Run "https://www.linkedin.com"    ; use ctrl+shift+alt+3
    ^+!4::Run "https://www.spotify.com/"    ; use ctrl+shift+alt+4
    ^+!5::Run "https://www.mixcloud.com/"   ; use ctrl+shift+alt+5
    ^+!6::Run "https://www.freecodecamp.org/learn/"
    
    ^!t::Run cmd, C:\Users\Username         ; use ctrl+alt+t to run Cmd
    ^!w::Run winamp.exe                     ; use ctrl+alt+w to run Winamp
    ^!s::Run C:\Program Files\Sublime Text 3\sublime_text.exe
    ^!v::Run C:\Users\Username\AppData\Local\Programs\Microsoft VS Code\Code.exe
    

    5現在開いているフォルダと同じパスを開く新しいエクスプローラウィンドウ


    よく使うWin+E デフォルトのショートカットをエクスプローラを開くには、私は同じ場所に移動する/いくつかのファイルを整理する新しいウィンドウを開く必要があります.では、なぜ使用しないCtrl+Win+E それをする近道?
    ^#e::                                  ; use ctrl+win+e 
    {                                      ; to open new explorer window with the same selected folder
      Send, !d
      Sleep 50
      Send, ^c
      Sleep 100
      Run, Explorer "%clipboard%" 
      Return
    }
    
    私たちは、新しいエクスプローラを開くことによってさらに行うことができますし、ウィンドウの両側にも、新しいウィンドウを1つのレベルを行くことができます.
    ^+#e::                                  ; use ctrl+shift+win+e 
    {                                       ; to open new explorer window with the same selected folder
      Send, #{Left}
      Sleep 50  
      Send, !d
      Sleep 50
      Send, ^c
      Sleep 100
      Run, Explorer "%clipboard%"
      Sleep 900
      Send, !{Up}
      Sleep 600
      Send, #{Right}
      Return
    }
    

    あなたのカーソルの下のピクセルの16進色をクリップボードにコピーしてください


    我々はカーソルを使用して16進数の色をコピーすることができますCtrl+Win+LeftClick :
    ; Copy to clipboard the HEX color of the pixel under your cursor using CTRL+Win+LeftClick
    ^#LButton::
    {
      MouseGetPos, MouseX, MouseY
      PixelGetColor, color, %MouseX%, %MouseY%, RGB
      StringLower, color, color
      clipboard := SubStr(color, 3)
      Return
    }
    

    7 .マウススクロールホイールを使用してメインボリュームを調整する


    あなたのようなキーの組み合わせでメインボリュームを調整することができますRAlt & NumpadAdd/RAlt & NumpadSub , または保持しながらマウスホイールでRight Alt :
    RAlt & WheelUp::Volume_Up
    RAlt & WheelDown::Volume_Down
    
    または、スクロールしながらマウスのサイドボタンのいずれかを保持することができます
    XButton1 & WheelUp::Volume_Up
    XButton1 & WheelDown::Volume_Down
    
    また、再生することができます/私たちの現在再生中の曲を左マウスボタンを使用して一時停止:
    XButton1::Media_Play_Pause
    
    我々は、はるかに我々の側のマウスボタンを使用して行うことができます!マウスマクロについてもっと読みます.

    ホットストリングによる自動補完構文


    これらは厳密にはキーボードショートカットではなく、省略形の拡張です.さらに重要なことは、任意のプログラミング言語で、print文やloopのような自動補完構文を作成するために必要なキーワードを使うことができます.
    :*:printc::printf('%d\n', num);
    
    :*:logjs::
    {
    Send, console.log();{Left}{Left}
    Return
    }
    
    :*:printjava::
    {
    Send, System.out.println();{Left}{Left}
    Return
    }
    
    :*:writecs::
    {
    Send, Console.WriteLine();{Left}{Left}
    Return
    }
    

    ::forC::
    (
    for (int i = 0; i < n; i++) {
    )
    
    ::forJs::
    (
    for (let i = 0; i < arr.length; i++) {
    )
    
    ::forPy::for i in range(0, len(arr)):
    
    :*:forMatlab::
    (
    for i = 1:step:length(arr)
    
    end
    )
    

    ::switchJs::
    (
    switch() {
    case 0:
    
    break;
    case 1:
    
    break;
    default:
    )
    

    私はautohotkeyのhotstringsを使用して完全なガイドを作った.

    佳作


    PCをスリープ状態にする


    我々は、スリープモードには、キーショートカットを使用してPCを得ることができますRAlt+PauseKey :
    ; Put PC in sleep mode
    RAlt & Pause::DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
    

    空きリサイクルビン


    リサイクルビンを空にできるWinKey+Del :
    #Del::FileRecycleEmpty ; use win+del to empty recycle bin
    

    現在の日付/時刻を取得する


    オートホットキーのホットストリングを使って現在のシステムの日付と時刻を書くことができます.
    :*:datenow::
    {
      FormatTime, DateString, , dddd, MMMM dd, yyyy
      Send %DateString%
      Return
    }
    
    :*:timenow::
    {
      FormatTime, DateString, , HH:mm
      Send %DateString%
      Return
    }
    

    :*:datetoday::
    {
      FormatTime, DateString, , yyyy-MM-dd
      Send %DateString%
      Return
    }
    
    :*:datetmr::
    {
      Date += 1, Days
      FormatTime, DateString, %Date%, yyyy-MM-dd
      Send %DateString%
      Reload ; Return and clear variables
    }
    

    矢印キーをホーム/エンドとして使用します


    あなたがカット、貼り付け、テキストの多くを選択するような場合.これらの"マクロ"は便利です.
    ; Arrow keys as Home/End
    RAlt & Left::
    {
      If GetKeyState("Shift", "P")
        Send +{Home}
      Else
        Send {Home}
      Return
    }
    RAlt & Right::
    {
      If GetKeyState("Shift", "P")
        Send +{End}
      Else
        Send {End}
      Return
    }
    

    キーを無効にする


    さて、あなたが誤って時間からcapslock状態を切り替えることを見つける場合.実際にそれを完全に無効にすることができます.の最初の始まりで.ahk ファイルを追加します
    ; Set Lock Keys permanently off
    SetCapsLockState, AlwaysOff
    Return
    
    これは特に60 %のキーボードを使用している場合に便利です.しかし、あなたが今CapsLockを使用する必要がある場合は、少しそれを押すことによって状態を切り替えるには少し難しくすることができますAlt+CapsLock 代わりに
    ; Set Lock Keys permanently off by default
    SetCapsLockState, AlwaysOff
    Return
    
    Alt & CapsLock::
    If GetKeyState("CapsLock","T")
      SetCapsLockState, AlwaysOff
    Else
      SetCapsLockState, On
    Return
    
    あなたはAhk ' sの詳細を見つけることができますGetKeyState() here .

    フィン



    マウンテンフォトBenjamin Voros on Unsplash
    それでした私はあなたがこれらのマクロのいくつかを実際にあなたの日の生活の中で役に立つことを望んでいる.または多分あなたのワークフローのためのいくつかの他のアイデアを得た.
    素敵な一日を.
    R . B .