Do things using the edge Topic is solved
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Do things using the edge
I've just discovered an amazing use of AHK: Send Alt-Tab when the mouse is on the left edge of the screen (https://www.dcmembers.com/skrommel/download/altedge/).
Now I'd like to do more things using the edge because I think it's super-cool. Eg. Split the screen horizontally in 3 parts: top, middle, bottom. I'd like to use the top left edge to go back to the previous page, the middle left edge to change the tabs open in my browser (like I do with ctrl+pag^), and keep the bottom left edge to send alt-tab (like in the script I linked).
How can I do that?
Now I'd like to do more things using the edge because I think it's super-cool. Eg. Split the screen horizontally in 3 parts: top, middle, bottom. I'd like to use the top left edge to go back to the previous page, the middle left edge to change the tabs open in my browser (like I do with ctrl+pag^), and keep the bottom left edge to send alt-tab (like in the script I linked).
How can I do that?
Re: Do things using the edge
AHH, that good ol' @Skrommel stuff from a century ago!
Re: Do things using the edge
It's just looping and checking the mouse position every 50 ms. It returns the y-position as variable my, so you can simply use its value to decide what to do. Your screen height is given by A_ScreenHeight.
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
Could you please help me? I don't know how to do that.
Re: Do things using the edge
Code: Select all
#Persistent
browser = chrome.exe
Process, Priority,, B
CoordMode, Mouse
SetTimer, Check, 200
Check:
WinGet, proc, ProcessName, A
MouseGetPos, xpos, ypos
lastZone := zone, zone := xpos > 1 ? 0 : Max(Ceil(3 * ypos / A_ScreenHeight), 1)
If !zone || lastZone = "" || zone = lastZone || proc != browser && zone < 3
Return
SoundBeep, 600 + 200 * zone, 20
Switch zone {
Case 1: Send !{Left}
Case 2: Send ^{Tab}
Case 3: Send !{Tab}
}
Return
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
I made a new script with your code and it doesn't work. Do I have to add your code to the script I posted above?
Also, why you wrote Chrome browser? Thanks a lot.
Also, why you wrote Chrome browser? Thanks a lot.
Re: Do things using the edge
Does this script work in your Chrome browser?
This script is self-contained and requires no additional code.
Should I try to debug your new script without seeing it?
You can change the browser to anything you want.
This script is self-contained and requires no additional code.
Should I try to debug your new script without seeing it?
You can change the browser to anything you want.
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
I disabled the script I posted above and now your script works in Chrome.
I am just wondering how to make a universal script that work everywhere in Windows just like the previous did.
I am just wondering how to make a universal script that work everywhere in Windows just like the previous did.
Re: Do things using the edge
You want to change tabs in your browser while you are not looking at your browser?
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
Sorry, I was not clear.
I'd like to have the alt-tab working everywhere AND the other 2 functions workign in every browser.
Is it possible?
I'd like to have the alt-tab working everywhere AND the other 2 functions workign in every browser.
Is it possible?
Re: Do things using the edge Topic is solved
Code: Select all
#Persistent
browsers = chrome|firefox
Process, Priority,, B
CoordMode, Mouse
SetTimer, Check, 200
Check:
WinGet, proc, ProcessName, A
MouseGetPos, xpos, ypos
lastZone := zone, zone := xpos > 1 ? 0 : Max(Ceil(3 * ypos / A_ScreenHeight), 1)
If !zone || lastZone = "" || zone = lastZone || !(proc ~= "(" browsers ")\.exe") && zone < 3
Return
SoundBeep, 600 + 200 * zone, 20
Switch zone {
Case 1: Send !{Left}
Case 2: Send ^{Tab}
Case 3: Send !{Tab}
}
Return
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
Since this script is working great for me, I'd like to make a step further: using the top edge as well (now it works on the left edge). How can I do that? Thanks.
PS: Since the script checks mouse position every 100 ms, is it onerous for the PC system?
PS: Since the script checks mouse position every 100 ms, is it onerous for the PC system?
Re: Do things using the edge
The shorter your interval, the greater the performance impact would be. You might not notice anything with an interval of 100 ms or 200 ms, but that would depend on your hardware and the running software.
You can use xpos and ypos to define new zones wherever you like. Your Switch statement can then act accordingly.
You can use xpos and ypos to define new zones wherever you like. Your Switch statement can then act accordingly.
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
Thanks. I have no idea how to do that. Could you please help me?
Re: Do things using the edge
I leave that to you, but all you need is this sort of thing:
If (ypos < 10 && xpos < 100)
zone := 4
You are just using the mouse position to define a zone.
Give it a go!
If (ypos < 10 && xpos < 100)
zone := 4
You are just using the mouse position to define a zone.
Give it a go!
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
You're right. So I want to learn and tried this but nothing happens:
[Mod edit: [code][/code] tags added.]
Code: Select all
CoordMode, Mouse
SetTimer, Check, 200
Check:
MouseGetPos, xpos, ypos
If (ypos < 10 && xpos > 1500)
MsgBox, Hello
return
Re: Do things using the edge
Since you did not see a message box, what were the actual values of xpos and ypos at that time? You can add a new line to your script to display those values.
-
- Posts: 26
- Joined: 07 Dec 2020, 15:01
Re: Do things using the edge
I've done several attempts and each of them had ypos < 10 && xpos > 1500. I know it because of this script:
MouseGetPos, xpos, ypos
MsgBox, The cursor is at X%xpos% Y%ypos%
So Idk where the issue is.
MouseGetPos, xpos, ypos
MsgBox, The cursor is at X%xpos% Y%ypos%
So Idk where the issue is.
Re: Do things using the edge
What does the following script show? Before running the script, make a visual note to yourself about the position of the mouse on the screen.
Code: Select all
CoordMode, Mouse
MouseGetPos, xpos, ypos
MsgBox, %xpos% %ypos%