Examples.ahk 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #Requires AutoHotkey v2.0
  2. #SingleInstance
  3. #include Notify.ahk
  4. ;============================================================================================
  5. Notify.Show('The quick brown fox jumps over the lazy dog.')
  6. Notify.Show('Alert!', 'You are being warned.',,,, 'theme=!')
  7. Notify.Show('Error', 'Something has gone wrong!',,,, 'theme=x dur=6 pos=bl')
  8. Notify.Show('Info', 'Some information to show.',, 'soundi',, 'theme=idark style=edge show=slideNorth hide=slideSouth@250')
  9. ;============================================================================================
  10. ; 5 Ways to Destroy/Dismiss GUI
  11. ;============================================================================================
  12. Notify.Show('Destroy the GUI by clicking on it before the set duration ends.', 'Click on GUI',,,, 'theme=matrix style=edge dur=15 pos=bl maxw=325')
  13. mNotifyGUI := Notify.Show('Destroy the GUI using a Handle.', 'Press Ctrl+F1', 'none',,, 'theme=!Dark dur=0 pos=tc mali=center')
  14. ^F1::Notify.Destroy(mNotifyGUI['hwnd'])
  15. Notify.Show('Destroy the GUI with the TAG option. This destroys every GUI with the specified tag across all scripts.', 'Press Ctrl+F2',,,, 'theme=synthwave dur=0 pos=ct tag=myTAG style=edge mali=center maxw=375')
  16. ^F2::Notify.Destroy('myTAG')
  17. Notify.Show(strTitleDGTAG := 'Destroy the GUI with DG and TAG options. This destroys all GUIs with the tag before creating a new one.', 'Press Ctrl+F3',,,, 'theme=iDark dur=0 mali=center tag=thisTag maxw=325')
  18. ^F3::Notify.Show(strTitleDGTAG, 'Press Ctrl+F3',,,, 'theme=iDark mali=center dg=5 tag=thisTag maxw=325')
  19. ; Assign a hotkey to destroy GUIs one by one, starting with the oldest.
  20. HotIfWinExist('NotifyGUI_ ahk_class AutoHotkeyGUI')
  21. Hotkey('Esc', (*) => Notify.Destroy())
  22. HotIfWinExist()
  23. ;============================================================================================
  24. ; Change the icon and text upon left-clicking the GUI using a callback.
  25. ; Limitation: The GUI doesn’t automatically resize when text is updated.
  26. ;============================================================================================
  27. mNotifyGUI_CB := Notify.Show('Title', 'Click to change the icon and text using a callback.', A_WinDir '\system32\imageres.dll|Icon5',, NotifyGUICallback, 'theme=Dracula dur=0 dgc=0 pos=tl')
  28. NotifyGUICallback(*)
  29. {
  30. mNotifyGUI_CB['pic'].Value := A_WinDir '\system32\user32.dll'
  31. mNotifyGUI_CB['title'].Value := 'Title changed'
  32. SetTimer((*) => _UpdateNotifyGUI('msg', 'Message changed'), -2000)
  33. SetTimer((*) => Notify.Destroy(mNotifyGUI_CB['hwnd']), -4000)
  34. }
  35. ; Try, to prevent an error in case the GUI was destroyed.
  36. _UpdateNotifyGUI(ctrlName, value) {
  37. try mNotifyGUI_CB[ctrlName].Value := value
  38. }
  39. ;============================================================================================
  40. ; Progress Bar
  41. ;============================================================================================
  42. mNotifyGUI_Prog := Notify.Show('Progress Bar Example', '0%',,,, 'theme=Solarized Dark style=edge dur=0 prog=w325 dgc=0 mali=right')
  43. SetTimer((*) => UpdateNotifyGUI('prog', 50), -2000)
  44. SetTimer((*) => UpdateNotifyGUI('msg', '50%'), -2000)
  45. SetTimer((*) => UpdateNotifyGUI('prog', 100), -4000)
  46. SetTimer((*) => UpdateNotifyGUI('msg', 'Finished!'), -4000)
  47. SetTimer((*) => Notify.Destroy(mNotifyGUI_Prog['hwnd']), -6000)
  48. UpdateNotifyGUI(ctrlName, value) {
  49. try mNotifyGUI_Prog[ctrlName].Value := value
  50. }
  51. ;============================================================================================
  52. ; Set default theme
  53. ;============================================================================================
  54. Notify.SetDefaultTheme('Cyberpunk')
  55. Notify.Show('Cyberpunk', 'Cyberpunk is a subgenre of science fiction in a dystopian futuristic setting that tends to focus on a combination of low-life and high tech.',,,, 'pos=ct mali=center tali=center maxw=325')
  56. Notify.Show('Notify Title', 'Notify message with Cyberpunk theme.',,,, 'pos=ct style=edge bdr=default tali=center')
  57. Notify.SetDefaultTheme('Monokai')
  58. Notify.Show('Monokai', 'Monokai is a popular theme for coding environments, featuring a dark background with vibrant, neon colors for enhanced readability.',,,, 'pos=tl maxw=325')
  59. Notify.Show('Notify Title', 'Notify message with Monokai theme.',,,, 'pos=tl style=edge bdr=default')
  60. ;============================================================================================
  61. ; Lock keys indicators
  62. ;============================================================================================
  63. ~*NumLock::
  64. ~*ScrollLock::
  65. ~*Insert::
  66. {
  67. Sleep(10)
  68. thisHotkey := SubStr(A_ThisHotkey, 3)
  69. Notify.Show(thisHotkey ' ' (GetKeyState(thisHotkey, 'T') ? 'ON' : 'OFF'),,,,, 'theme=synthwave style=edge pos=bl dur=3 ts=35 show=none hide=none dg=5 tag=' thisHotkey)
  70. }
  71. ~*CapsLock::
  72. {
  73. Sleep(10)
  74. thisHotkey := SubStr(A_ThisHotkey, 3)
  75. Notify.Destroy(thisHotkey)
  76. if GetKeyState(thisHotkey, 'T')
  77. Notify.Show(thisHotkey ' ON',,,,, 'theme=matrix pos=bl dur=0 ts=35 dgc=0 tag=' thisHotkey)
  78. }