Double-clicking Desktop in specific areas to launch specific programs. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Double-clicking Desktop in specific areas to launch specific programs.

04 May 2019, 00:51

I always keep my desktop empty so that it looks aesthetically pleasing. I want to write a script which detects double-clicks on the Desktop and launches program tied to that area of click.
For example, when the x-coordinate is between 0 to 100, and y-coordinate is between 0 to 50, it should launch Windows Explorer.
Similarly, when the x-coordinate is between 100 to 200, and y-coordinate is between 0 to 50, it should launch Chrome. You get the idea.

Right now, I just have the script to detect whether Desktop is currently active.

Code: Select all

IsDesktopActive() {
    MouseGetPos,,,win
    WinGetClass, class, ahk_id %win%
    If class in Progman,WorkerW
        Return True
    Return False
}
I read some documentation and found out about #InstallMouseHook, but I don't know how to use it or whether it is helpful.
Any help is appreciated!
gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: Double-clicking Desktop in specific areas to launch specific programs.

04 May 2019, 01:17

The most essential command would probably be MouseGetPos to determine the mouse coordinates. I think there are a also few topics available that cover how to detect a doubleclick (probably you would create a context-sensitive hotkey for LButton and check if there was a double-click, while the desktop is active -> #Ifwinactive).
Rohwedder
Posts: 7769
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Double-clicking Desktop in specific areas to launch specific programs.

04 May 2019, 04:28

Hallo,
this script makes your desktop icons invisible (on/off) without losing their function.

Code: Select all

q::
WinGet,  Invisible, Transparent, ahk_class Progman
IF Invisible
	WinSet, Transparent, OFF, ahk_class Progman
Else
	WinSet, Transparent, 1, ahk_class Progman
Return
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Double-clicking Desktop in specific areas to launch specific programs.  Topic is solved

04 May 2019, 04:44

iamMG wrote:
04 May 2019, 00:51
... I want to write a script which detects double-clicks on the Desktop and launches program tied to that area of click. ...
Some like this ?

Code: Select all

~LButton::
    if (IsDesktopActive() ) {
        If (A_TimeSincePriorHotkey<400) and (A_PriorHotkey="~LButton") {    
            MouseGetPos,x,y
            if (y >=0 && y <=50) {
                if (x >=0 && x <=100 )
                    run, explorer
                if (x >100 && x <=200 )           
                    run, chrome                
            }
        } 
    }
return

IsDesktopActive() {
    MouseGetPos,x,y,win
    WinGetClass, class, ahk_id %win%
    return,  ( class ~= "Progman|WorkerW" ) ? true : false
}

____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Re: Double-clicking Desktop in specific areas to launch specific programs.

06 May 2019, 07:30

Odlanir wrote:
04 May 2019, 04:44
Some like this ?
Holy cow, this worked! Thanks @Odlanir. :D
I really appreciate how amazing and helpful this community is.
Also, thanks for the input @gregster and @Rohwedder. :)
garyshee
Posts: 1
Joined: 30 Dec 2021, 13:52

Re: Double-clicking Desktop in specific areas to launch specific programs.

30 Dec 2021, 14:09

Code: Select all

If (A_TimeSincePriorHotkey<700) and (A_PriorHotkey="~LButton")
			sendinput ^c
Great! the above code do the magic of detecting mouse double clicked.
Bliss,
--G

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Draken, Google [Bot] and 408 guests