SHARE
TWEET

WindowsのWin+Oをfoobar起動・表示/最小化に置換.ahk

hosomi Feb 5th, 2020 570 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DetectHiddenWindows, On
  2. #WinActivateForce
  3.  
  4. ; ===== ここから設定 =====
  5. ; foobar2000.exeのパス
  6. fb2k_path = %A_ProgramFiles%\foobar2000\foobar2000.exe
  7.  
  8. ; TaskTrayIcon変更
  9. ;Menu,TRAY,Icon,%fb2k_path%
  10.  
  11. return
  12. ; ===== 設定ここまで =====
  13.  
  14.  
  15. #o::
  16. fb2k_win := WinExist("ahk_exe foobar2000.exe")
  17. ;MsgBox, %fb2k_win%
  18. If !fb2k_win
  19. {
  20.     Run, %fb2k_path%
  21.     Loop 600
  22.     {
  23.         Sleep, 100
  24.         fb2k_win := WinExist("ahk_exe foobar2000.exe")
  25.         ;MsgBox, %fb2k_win%
  26.         If fb2k_win
  27.         {
  28.             Sleep, 100
  29.             WinActivate, ahk_id %fb2k_win%
  30.             PostMessage, 0x112, 0xF120,,, ahk_id %fb2k_win% ahk_class {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}
  31.             Break
  32.         }
  33.     }
  34.     return
  35. }
  36.  
  37. WinGet, fb2k_pid, PID, ahk_id %fb2k_win%
  38. ;MsgBox, %fb2k_pid%
  39. WinGet, ret, MinMax, ahk_pid %fb2k_pid% ahk_class {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}
  40. ;MsgBox, %ret%
  41. If ret > -1
  42. {
  43.     WinMinimize, ahk_pid %fb2k_pid%
  44.     SendMessage, 0x112, 0xF020,,, ahk_pid %fb2k_pid% ahk_class {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}
  45. }
  46. Else
  47. {
  48.     WinActivate, ahk_pid %fb2k_pid%
  49.     SendMessage, 0x112, 0xF120,,, ahk_pid %fb2k_pid% ahk_class {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}
  50. }
  51. ;MsgBox, %ErrorLevel%
  52.  
  53. return
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top