Rich4rd

Text menu with separate actions of menu items

Jun 19th, 2020
1,367
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance Force
  2. ;Text Menu with words Function
  3. TextMenu(TextOptions)
  4. {
  5.  ;StringSplit, MenuItems, TextOptions , `,
  6.  StringSplit, MenuItems, TextOptions ,
  7.  Loop %MenuItems0%
  8.   {
  9.     Item := MenuItems%A_Index%
  10.     ;Menu, TxtMenu, add, %Item%, TxtMenuAction
  11.     Menu, TxtMenu, add, %Item%, TxtMenuAction
  12.   }
  13.  Menu, TxtMenu, Show
  14.  Menu, TxtMenu, DeleteAll
  15. }
  16.  
  17. TxtMenuAction:
  18. SendInput %A_ThisMenuItem%{Text}%A_EndChar%
  19. Return
  20.  
  21.  
  22. ;Text menu with separate actions of menu items
  23. :*:ryg::
  24.   TextMenu("It's red.¦It's yellow.¦It's green.")
  25. If A_thismenuitem = It's red.
  26. {
  27.   SendInput, ^+{Left 2}
  28.   SendInput, {Raw}
  29. (
  30.  Stop.
  31. )
  32. }
  33. Else If A_thismenuitem = It's yellow.
  34. {
  35.   SendInput, ^+{Left 2}  
  36.   SendInput, {Raw}
  37. (
  38.  Get ready.
  39. )
  40. }
  41. If A_thismenuitem = It's green.  
  42. {
  43.   SendInput, ^+{Left 2}  
  44.   SendInput, {Raw}
  45. (
  46.  Safe to drive.
  47. )
  48. }
  49. Return
RAW Paste Data