Run command when mouse is at edge of screen

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
subzero
Posts: 12
Joined: 03 Apr 2021, 18:46

Run command when mouse is at edge of screen

04 Sep 2021, 02:11

not sure if this is possible but I would like an audio file to play when the mouse is at the far-right edge of the screen for over 300ms, reason being that is when my sidebar pops in. can this be done?
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Run command when mouse is at edge of screen

04 Sep 2021, 06:27

Code: Select all

#Persistent
placeMargin := 12, timeMargin := 300
sound = %ProgramFiles%\Microsoft Office\root\Office16\MEDIA\LYNC_ringing.wav
CoordMode, Mouse
SetTimer, Check, %timeMargin% ; Or change to 100, for example
Check:
MouseGetPos, x
last := zone, dist := A_ScreenWidth - x, zone := dist <= placeMargin
ToolTip, %dist% ; OK to delete
Switch
{
 Case !zone: start =
 Case !last: start := A_TickCount
 Case A_TickCount - start > timeMargin:
  SoundPlay, %sound%, Wait
  start =
}
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Hansielein, Lpanatt and 328 guests