LButton Down And Up Does Not Work With This Program Window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PhuketRoger
Posts: 7
Joined: 07 Apr 2017, 12:18

LButton Down And Up Does Not Work With This Program Window

10 Apr 2017, 11:41

The program in question is "Everything Search" by VoidTools: https://www.voidtools.com/

I run it on Windows 10. The following script works fine on XP. Its function is to move the window clicked on to a specific position:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2     ; Can match any bit of title
CoordMode, Mouse, Screen ; All mouse movements are relative to whole screen
SetMouseDelay, 30        ; Milliseconds to recognise each mouse click

#Include c:\s\Macros\SetScreenEnvVars.ahk ; Set up NMWidth and NMHeight variables for this PC

KeyWait, LButton, D     ; Wait for the left mouse button to be pressed down.
KeyWait, LButton, U     ; Wait for the left mouse button to be released
WinGetActiveTitle,  Title
WinMove          , %Title%, , 1, 1, NMWidth, NMHeight
I narrowed the problem down to the fact that the line "KeyWait, LButton, D" does not work on this program's window on Windows 10.

I modified the script to be:

Code: Select all

KeyWait, LButton, D     ; Wait for the left mouse button to be pressed down.
msgbox ,,, Down

KeyWait, LButton, U     ; Wait for the left mouse button to be released
msgbox ,,, Up
This works - i.e. displays the Message Box - on all windows I've tried, except the "Everything Search" window.

Any thoughts?
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: LButton Down And Up Does Not Work With This Program Window

13 Apr 2017, 09:44

Could it be that "Everything Search" hides this 'key down' event?

Do other keys have the same problem. I.e. what happens when you wait for another key?

If "Everything Search" is running as admin, AutoHotkey (when not running as admin) has no idea about the window or the keypresses. Something similar is happenning between 32bits processes and 64 bits processes.

Hope I gave you a clue.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: LButton Down And Up Does Not Work With This Program Window

13 Apr 2017, 11:29

Code: Select all

KeyWait, LButton, D     ; Wait for the left mouse button to be pressed down.
KeyWait, LButton, U     ; Wait for the left mouse button to be released
WinGetActiveTitle,  Title
WinMove          , %Title%, , 1, 1, NMWidth, NMHeight
Not sure I see the point of this code - it will work only once, when the script is first run.

Do you not want something more like:

Code: Select all

~LButton up::
	WinGetActiveTitle,  Title
	WinMove          , %Title%, , 1, 1, NMWidth, NMHeight
	return
PhuketRoger
Posts: 7
Joined: 07 Apr 2017, 12:18

Re: LButton Down And Up Does Not Work With This Program Window

15 Apr 2017, 12:21

DyaTactic wrote:Could it be that "Everything Search" hides this 'key down' event?

Do other keys have the same problem. I.e. what happens when you wait for another key?

If "Everything Search" is running as admin, AutoHotkey (when not running as admin) has no idea about the window or the keypresses. Something similar is happenning between 32bits processes and 64 bits processes.

Hope I gave you a clue.
Sorry for the late reply as I've been busy on other PCs.
Thanks for the input and I'll be checking out what you mention - other keys, admin status and 32/64 bit processes. Lots to consider!

Regards.
PhuketRoger
Posts: 7
Joined: 07 Apr 2017, 12:18

Re: LButton Down And Up Does Not Work With This Program Window

15 Apr 2017, 12:39

evilC wrote:

Code: Select all

KeyWait, LButton, D     ; Wait for the left mouse button to be pressed down.
KeyWait, LButton, U     ; Wait for the left mouse button to be released
WinGetActiveTitle,  Title
WinMove          , %Title%, , 1, 1, NMWidth, NMHeight
Not sure I see the point of this code - it will work only once, when the script is first run.

Do you not want something more like:

Code: Select all

~LButton up::
	WinGetActiveTitle,  Title
	WinMove          , %Title%, , 1, 1, NMWidth, NMHeight
	return
Yes, you're right - the script is only run once. I forgot to say that this script is not used as a hotkey. In fact I don't have AutoHotkey running all the time.

The script is used as the target in a shortcut. The shortcut has this in its "target" field:

"C:\Program Files\AutoHotkey\AutoHotkey.exe" /f "c:\s\Macros\NM Quick Desktop.ahk"

So I click on the shortcut, AutoHotkey runs, reads the .ahk file and waits for the left button down and then up. That activates the window I want moved, and then "WinGetActiveTitle" and "WinMove" do the rest to move the window to where I want.

I have a zillion of these scripts and shortcuts that do all sorts of common tasks, mostly opening Explorer windows, resizing and moving windows, running Firefox to a particular URL, etc and for example allowing me to copy files from my camera to the appropriate folders on another drive with just one click on a shortcut.

When I work on other people's PCs I find it amusing to see them click on "This PC", Users, Name, Documents, etc, etc, until they get to where they want to be.

Three cheers for AutoHotKey! :D
PhuketRoger
Posts: 7
Joined: 07 Apr 2017, 12:18

Re: LButton Down And Up Does Not Work With This Program Window

25 May 2017, 08:10

DyaTactic wrote:Could it be that "Everything Search" hides this 'key down' event?

Do other keys have the same problem. I.e. what happens when you wait for another key?

If "Everything Search" is running as admin, AutoHotkey (when not running as admin) has no idea about the window or the keypresses. Something similar is happenning between 32bits processes and 64 bits processes.

Hope I gave you a clue.
Sorry for the very late reply... you nailed it!

After I changed the shortcut to the Autohotkey program to "Run as administrator" in the Advanced Properties, it worked fine.

So, just another Windows 10 "enhancement" !

Thanks very much.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Bing [Bot], serenite and 193 guests