Advertisement
Zektrix1

Example DropDownList

Oct 30th, 2024 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #Requires AutoHotkey v2.0
  2. #SingleInstance Force
  3.  
  4. MyGui := Gui("+Resize -MaximizeBox -MinimizeBox", "Options Selector")
  5. MyGui.SetFont("s10", "Segoe UI")
  6. MyGui.Add("Text", "x20 y20", "Select an option:")
  7. OptionsDDL := MyGui.Add("DropDownList", "x150 y18 w200", ["Option 1", "Option 2", "Option 3"])
  8. OptionsDDL.OnEvent("Change", (Ctrl, *) => DisplaySelection(Ctrl.Text))
  9. DisplayText := MyGui.Add("Text", "x20 y70 w500 h50 Border", "Your selection will appear here...")
  10. MyGui.Add("Button", "x150 y140 w80 h30", "Reset").OnEvent("Click", (*) => OptionsDDL.Value := "")
  11. MyGui.Add("Button", "x250 y140 w80 h30", "Submit").OnEvent("Click", (*) => SubmitSelection(OptionsDDL.Text))
  12. MyGui.Show("w540 h200 Center")
  13. DisplaySelection(Text) {
  14. DisplayText.Value := "Currently Selected: " Text
  15. }
  16. SubmitSelection(Text) {
  17. DisplayText.Value := "You have submitted: " Text
  18. }
  19.  
  20. Numpad2::Reload
  21. Numpad0::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement