GetKeyState() for mouse buttons

Discuss the future of the AutoHotkey language
User avatar
boiler
Posts: 16949
Joined: 21 Dec 2014, 02:44

GetKeyState() for mouse buttons

10 Jul 2020, 13:09

Is there a reason the code below doesn't work without #InstallMouseHook? I don't see anything in the documentation about it. Did I miss some discussion on this? It's the same with other mouse buttons as well. Tested with a few recent versions.

Code: Select all

#InstallMouseHook ; required for code below to work
loop {
	ToolTip GetKeyState("LButton", "P") ? "Down" : "Up"
	Sleep 100
}
This works using v1:

Code: Select all

loop {
	ToolTip % GetKeyState("LButton", "P") ? "Down" : "Up"
	Sleep 100
}
lexikos
Posts: 9589
Joined: 30 Sep 2013, 04:07
Contact:

Re: GetKeyState() for mouse buttons

10 Jul 2020, 20:49

Ask For Help
Get help with using AutoHotkey and its commands and hotkeys
Subforums: Gaming, AutoHotkey v2 Help

Bug Reports
Report problems with documented functionality

AutoHotkey v2 Development
Discuss the future of the AutoHotkey language
Which subtitle do you think best fits your post?


It's a bug caused by
Changed MouseClick, MouseClickDrag, LButton and RButton to be unaffected by button swap.
Source: (1) AutoHotkey v2 alpha (UPDATES) - Page 4 - AutoHotkey Community
You can work around it by using VK_LBUTTON (vk1) and VK_RBUTTON (vk2).
User avatar
boiler
Posts: 16949
Joined: 21 Dec 2014, 02:44

Re: GetKeyState() for mouse buttons

10 Jul 2020, 21:14

If I knew it were a bug, I clearly would have posted in “Bug Reports.” However, given the relative fluidity of v2 and that sometimes changes occur as discussed in “AutoHotkey v2 Development” and aren’t yet fully documented, I didn’t want to be presumptuous and report it as a bug.

I know the subtitle for “Bug Reports” says “problems with documented functionality,” but in the case of v2, I realize documentation updates aren’t always top priority, so I chose what I thought was more respectful to the development team’s efforts which I greatly appreciate, but thank you for clarifying that I was in fact using faulty reasoning. And thank you for the information.
lexikos
Posts: 9589
Joined: 30 Sep 2013, 04:07
Contact:

Re: GetKeyState() for mouse buttons

11 Jul 2020, 04:01

I recently went through all of the topics in this subforum (v2 Dev) looking for (language) issues or suggestions that haven't been addressed, and there were (but are not anymore) a large number of topics that were clearly about bugs, asking for help with a script, or asking for clarification about current behaviour (and there were some topics even less relevant). It seemed to me that your post was like those, asking why some code isn't working.

I make it a point to try to document all intentional changes in v2-changes, the "updates" topic and the git commit history, and document the new behaviour in the official documentation (replacing the old), even if I don't update all of the examples and scattered paragraphs that might relate to the change. If some new behaviour isn't documented or even mentioned anywhere, the program or documentation needs to be fixed.

In this instance, I can't imagine a scenario where this change would be intentional.

Also, I've added quite a few bugs recently. :facepalm:
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: GetKeyState() for mouse buttons

11 Jul 2020, 06:26

98 bugs in the code. 98 bugs in the code. Take one down, patch it around. 99 bugs in the code.
A little humor 😊
User avatar
boiler
Posts: 16949
Joined: 21 Dec 2014, 02:44

Re: GetKeyState() for mouse buttons

11 Jul 2020, 08:59

I'm relatively new to using v2, and although I performed a search through the updates and this sub-forum in general, I thought it was possible I missed it. Thanks for the explanation and for your efforts.
kczx3 wrote:
11 Jul 2020, 06:26
98 bugs in the code. 98 bugs in the code. Take one down, patch it around. 99 bugs in the code.
A little humor 😊
Thanks for this, too. :D

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 60 guests