Advertisement
Guest User

指定のウィンドウ内のボタンをクリック

a guest
Mar 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; 指定のウィンドウ内のボタンをクリック
  2.  
  3. Gui, Add, Button, w100, はい(S)
  4. Gui, Add, Button, wp, ほげ(w)
  5. Gui, Add, Button, wp, いいえ(N)
  6. Gui, Show
  7. Run notepad.exe
  8. return
  9.  
  10. F1::ToolTip % ButtonClick("A", "はい|保存|開く|Yes|OK|Save|Open") ; A=アクティブウィンドウ
  11. F2::ToolTip % ButtonClick("A", "いいえ|保存しない|キャンセル|No|Cancel")
  12. F3::ToolTip % ButtonClick("メモ帳 ahk_exe notepad.exe", "はい|保存|開く|Yes|OK|Save|Open")
  13. F4::ToolTip % ButtonClick("メモ帳 ahk_exe notepad.exe", "いいえ|保存しない|キャンセル|No|Cancel")
  14. F5::Run notepad.exe
  15.  
  16. GuiClose:
  17. Esc::ExitApp
  18.  
  19. ; MGLの場合、関数はユーザー定義サブルーチンに記述 > MouseGestureL\Config\MG_User.ahk
  20. ButtonClick(WinTitle, ButtonText) { ; ButtonText=正規表現
  21.     if WinActive(WinTitle) {
  22.         WinGet, ClassNN, ControlList
  23.         Loop, Parse, ClassNN, `n
  24.         {
  25.             if (A_LoopField ~= "Button\d+") {
  26.                 ControlGetText, Text, %A_LoopField%
  27.                 if (Text ~= ButtonText) {
  28.                     ControlClick, %A_LoopField%
  29.                     return ErrorLevel "`n" WinTitle "`n" A_LoopField "`n" Text
  30.                 }
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement