Hey,
This code does work but I'm still left with the region problem and I had a variable wich had a separate Delay variable wich doesn't work.
The switchDeskTimerDelay works like this:
1. When mouse is within region the threshold timer variable runs
2. When threshold timer has run out it activates the case (so sends the command/msgbox)
3. The last sleep command has the switchDeskTimerDelay wich is kinda the new threshold aslong as my mouse is in the region/edge.
I have 4 cases since In the full program I have it so there's a 3rd case with a region on the left side of the taskbar that activates Win+Tab and a 4th case with a region on the right side of the taskbar wich activates AltTab. Case 3 and 4 are fully done and working. I just say this so you know that I need to be able to add more regions than only those 2.
The region problem I mean is that I have multiple more cases with multiple regions where I have set a variable for every direction each time (Left, Right, Top, Bottom).
Everytime the region variables are setup like this so I can always easily choose where I want the region to be:
Code: Select all
; --------- --------- --------- --------- --------- --------- ---------
; Standard: L: 2 R: 1918 T: 680 B: 170
switchDeskLeft := 2 ; From the left
switchDeskRight := A_ScreenWidth - switchDeskLeft ;
switchDeskTop := 680 ; From the top ; Do 1080-Height you want, type result here
switchDeskBottom:= A_ScreenHeight - 170 ; From the bottom
switchDeskTimer := 750 ; CHOOSE Switch Desktop TIME HERE
switchDeskTimerDelay := 500
; --------- --------- --------- --------- --------- --------- ---------
; Standard: L: 200 R: 720 (1920-720=1200) T: 40 B: 0
timelineLeft := 200 ; From the left
timelineRight := A_ScreenWidth - 1200 ; From the right ; 1920-Width you want, type result here
timelineTop := A_ScreenHeight - 40 ; From the bottom
timelineBottom := 0 ; From the bottom
; --------- --------- --------- --------- --------- --------- ---------
; Standard: L: 1100 R: 1675 (1920-1675=245) T: 40 B: 0
alttabLeft := 1100 ; From the left
alttabRight := A_ScreenWidth - 245 ; From the right ; 1920-Width you want, type result here
alttabTop := A_ScreenHeight - 40 ; From the bottom
alttabBottom := 0 ; From the bottom
Before the Switch zone with the cases I have this code running to send the left region to case 1, right region to case 2, LeftsideTaskbar region to case 3 and RightsideTaskbar region to case 4.
Code: Select all
SetTimer, Check, 100
Check:
CoordMode, Mouse
MouseGetPos, mx, my
last := zone, zone := mx <= switchDeskLeft && my >= switchDeskTop && my <= switchDeskBottom ? 1
: mx >= switchDeskRight && my >= switchDeskTop && my <= switchDeskBottom ? 2
: mx >= timelineLeft && mx <= timelineRight && my >= timelineTop && my >= timelineBottom ? 3
: mx >= alttabLeft && mx <= alttabRight && my >= alttabTop && my >= alttabBottom ? 4
: 0
If !zone || last = "" || zone = last
Return
I just can't find out how to make the new cases work with the multiple conditions:
Code: Select all
mx <= switchDeskLeft && my >= switchDeskTop && my <= switchDeskBottom ; Left edge
mx >= switchDeskRight && my >= switchDeskTop && my <= switchDeskBottom ; Right edge
mx >= timelineLeft && mx <= timelineRight && my >= timelineTop && my >= timelineBottom ; Leftside Taskbar
mx >= alttabLeft && mx <= alttabRight && my >= alttabTop && my >= alttabBottom ; Rightside Taskbar
instead of only:
Code: Select all
x <= margin
x >= A_ScreenWidth - margin
I tried replacing this code:
Code: Select all
{ Case x <= margin : zone := 1 ; Left edge
Case x >= A_ScreenWidth - margin: zone := 2 ; Right edge
With this code to not use the entire edge but only my regions:
Code: Select all
{ Case mx <= switchDeskLeft && my >= switchDeskTop && my <= switchDeskBottom : zone := 1 ; Left edge
Case mx >= switchDeskRight && my >= switchDeskTop && my <= switchDeskBottom : zone := 2 ; Right edge
Now it doesn't react anymore.
Here is the code right now:
Code: Select all
; Standard: L: 2 R: 1918 T: 680 B: 170
switchDeskLeft := 2 ; From the left
switchDeskRight := A_ScreenWidth - switchDeskLeft ;
switchDeskTop := 680 ; From the top ; Do 1080-Height you want, type result here
switchDeskBottom:= A_ScreenHeight - 170 ; From the bottom
switchDeskTimer := 750 ; CHOOSE Switch Desktop TIME HERE (first activation)
switchDeskTimerDelay := 500 ; After the first activation
; ===
Process, Priority,, B
margin := 30 ; Maximum distance from edge
threshold := 750 ; Minimum time to trigger
timer := 50 ; Frequency of check
switchDeskTimerDelay := 500 ; After the first activation
SetTimer, Check, %timer%
Check:
CoordMode, Mouse
MouseGetPos, x
last := zone ; Previous zone
Switch ; Define whatever zones you need
{ Case mx <= switchDeskLeft && my >= switchDeskTop && my <= switchDeskBottom : zone := 1 ; Left edge
Case mx >= switchDeskRight && my >= switchDeskTop && my <= switchDeskBottom : zone := 2 ; Right edge
;{ Case x <= margin : zone := 1 ; Left edge
; Case x >= A_ScreenWidth - margin: zone := 2 ; Right edge
Default : zone := 0 ; Middle
}
start := last && last = zone ? start : A_TickCount ; Update if zone changed or is middle
If (A_TickCount - start < threshold) ; Threshold has not been met
Return
Switch zone { ; Act according to zone
Case 1: MsgBox, 48, Boom!, Southpaw!, 1 ; Left edge
Case 2: MsgBox, 64, Boom!, Righty!, 1 ; Right edge
}
Sleep, %switchDeskTimerDelay% - timer ; Wait a little while before the next check
Return
This is the ENTIRE code of the program before you send your last code:
https://pastebin.com/g4J4zunw