forked from Descolada/UIA-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample21_NotificationEvent.ahk
27 lines (23 loc) · 1.09 KB
/
Example21_NotificationEvent.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#Requires AutoHotkey v2
;#include <UIA> ; Uncomment if you have moved UIA.ahk to your main Lib folder
#include ..\Lib\UIA.ahk
Run "calc.exe"
Sleep 1000
cEl := UIA.ElementFromHandle("A")
MsgBox "Press OK to create a new EventHandler for the Notification event.`nTo test this, interact with the Calculator window, and a tooltip should pop up.`n`nTo exit the script, press F5."
handler := UIA.CreateNotificationEventHandler(NotificationEventHandler)
UIA.AddNotificationEventHandler(handler, cEl)
OnExit(ExitFunc) ; Set up an OnExit call to clean up the handler when exiting the script
return
NotificationEventHandler(sender, notificationKind, notificationProcessing, displayString, activityId) {
ToolTip "Sender: " sender.Dump()
. "`nNotification kind: " notificationKind " (" UIA.NotificationKind[notificationKind] ")"
. "`nNotification processing: " notificationProcessing " (" UIA.NotificationProcessing[notificationProcessing] ")"
. "`nDisplay string: " displayString
. "`nActivity Id: " activityId
SetTimer ToolTip, -3000
}
ExitFunc(*) {
UIA.RemoveAllEventHandlers()
}
F5::ExitApp