-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmouse.clicks.fmfn
27 lines (24 loc) · 1.18 KB
/
mouse.clicks.fmfn
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
/*
* =====================================================
* mouse.clicks ( number ; identifier )
* RETURNS: (bool) If mouse has been clicked the number of times
* as tracked by the global variable $$mouse.clicks.count
* DEPENDENCIES: none
* NOTES:
* =====================================================
*
* WARNING! You can only use a call to this custom function once within any given script.
* Subsequent calls within the same script will mess up the variables.
*/
Let ( [
$$mouse.clicks.count = If ( IsEmpty( $$mouse.clicks.count ) ; 1 ; $$mouse.clicks.count + 1 );
$$mouse.clicks.previous = $$mouse.clicks.last;
$$mouse.clicks.last = Get ( CurrentTimeStamp );
$$mouse.clicks.duration = Seconds ( $$mouse.clicks.last - $$mouse.clicks.previous );
// Criteria required to be a valid subsequent click, identifier must match
$$mouse.clicks.valid = $$mouse.clicks.duration ≤ 1 and identifier = $$mouse.click.identifier; // Subsequent click within 1 second
$$mouse.clicks.count = If ( not $$mouse.clicks.valid ; "" ; $$mouse.clicks.count );
$$mouse.click.identifier = identifier
];
$$mouse.clicks.count = number // Return the count as boolean
)