Do things using the edge Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Do things using the edge

Post by iokinjormet » 09 Dec 2020, 12:10

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?

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Do things using the edge

Post by BoBo » 09 Dec 2020, 12:27

AHH, that good ol' @Skrommel stuff from a century ago! :lol: :thumbup:

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 09 Dec 2020, 17:20

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.

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 10 Dec 2020, 04:45

Could you please help me? I don't know how to do that.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 10 Dec 2020, 08:12

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

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 10 Dec 2020, 08:28

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.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 10 Dec 2020, 08:34

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.

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 10 Dec 2020, 08:44

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.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 10 Dec 2020, 08:46

You want to change tabs in your browser while you are not looking at your browser?

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 10 Dec 2020, 09:04

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?

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge  Topic is solved

Post by mikeyww » 10 Dec 2020, 09:27

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

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 10 Dec 2020, 09:49

thank you so much

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 22 Dec 2020, 06:23

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?

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 22 Dec 2020, 07:51

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.

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 22 Dec 2020, 07:59

Thanks. I have no idea how to do that. Could you please help me?

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 22 Dec 2020, 08:08

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!

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 22 Dec 2020, 08:37

You're right. So I want to learn and tried this but nothing happens:

Code: Select all

CoordMode, Mouse
SetTimer, Check, 200
Check:
MouseGetPos, xpos, ypos
If (ypos < 10 && xpos > 1500)
	MsgBox, Hello
return
[Mod edit: [code][/code] tags added.]

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 22 Dec 2020, 09:33

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.

iokinjormet
Posts: 26
Joined: 07 Dec 2020, 15:01

Re: Do things using the edge

Post by iokinjormet » 22 Dec 2020, 09:41

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.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Do things using the edge

Post by mikeyww » 22 Dec 2020, 09:56

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%

Post Reply

Return to “Ask for Help (v1)”