Guest User

Untitled

a guest
Apr 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. require 'ffi'
  2.  
  3. # button constants
  4. BUTTONS_OK = 0
  5. BUTTONS_OKCANCEL = 1
  6. BUTTONS_ABORTRETRYIGNORE = 2
  7. BUTTONS_YESNO = 4
  8.  
  9. # return code constants
  10. CLICKED_OK = 1
  11. CLICKED_CANCEL = 2
  12. CLICKED_ABORT = 3
  13. CLICKED_RETRY = 4
  14. CLICKED_IGNORE = 5
  15. CLICKED_YES = 6
  16. CLICKED_NO = 7
  17.  
  18. extend FFI::Library
  19.  
  20. ffi_lib 'user32'
  21. ffi_convention :stdcall
  22.  
  23. attach_function :msgbox, 'MessageBoxA', [:pointer, :string, :string, :uint], :int
  24.  
  25. def message_box(txt, title=APP_TITLE, buttons=BUTTONS_OK)
  26. r = msgbox(nil, txt, title, buttons)
  27. return r
  28. end
  29.  
  30. response = message_box("Are you sure you want to proceed?",
  31. "Proceed?", BUTTONS_YESNO)
  32.  
  33. if response == CLICKED_YES
  34. # insert your code here
  35. end
Add Comment
Please, Sign In to add comment