Guest User

Autohotkeyでコマンドプロンプトランチャー

a guest
Sep 6th, 2013
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; スクリプト先頭でこう書いておく。ウィンドウ巡回用の初期設定
  2. GroupAdd launchers, ahk_class ConsoleWindowClass
  3. #WinActivateForce
  4.  
  5. ; Win+Rの設定。コマンドプロンプトがなかったら起動する。そうでなければ切り替える
  6. ; 連打すると複数あるコマンドプロンプトを巡回できる
  7. #r::
  8.   ifwinexist ahk_group launchers
  9.   {
  10.     GroupActivate launchers, R
  11.   } else {
  12.      run_launcher()
  13.   }
  14.   return
  15.  
  16. ; Shift+Win+Rの設定。巡回とかしないで新しくコマンドプロンプトを起動する
  17. +#r::run_launcher()
  18.  
  19. ; コマンドプロンプトを新しく開く処理
  20. run_launcher()
  21. {
  22.     ; lnk拡張子を省略しても起動できるように設定してコマンドプロンプトを起動する。
  23.     run %comspec% /k "prompt $t & set pathext=.lnk;%pathext%", %homepath%, , launcherpid
  24.  
  25.     ;; 普通にディレクトリ名出してほしいなら上の代わりにこっち
  26.     ;run %comspec% /k "set pathext=.lnk;%pathext%", %homepath%, , launcherpid
  27.  
  28.     ;; nyaos使うなら上の代わりにこっち
  29.     ; run nyaos.exe, %homepath%, , launcherpid
  30.    
  31.     ; 以下は起動したウィンドウを定位置に移動する処理
  32.     ; いらなかったら消しておk
  33.     SysGet workarea, MonitorWorkArea
  34.     winwait "ahk_pid %launcherpid%"
  35.     wingetpos, , , , launcher_height
  36.     launcher_height := launcher_height / 2
  37.     winmove "ahk_pid %launcherpid%", , , , , %launcher_height%
  38.     wingetpos, , , , launcher_height
  39.     launcher_y := workareabottom - launcher_height
  40.     winmove "ahk_pid %launcherpid%", , 0, %launcher_y%
  41. }
Advertisement
Add Comment
Please, Sign In to add comment