Read mouse button state not working Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mikhail22
Posts: 19
Joined: 14 Jan 2018, 11:50

Read mouse button state not working

14 Jan 2018, 14:12

Hi! I am making a simple scroll script. Till now everything fine, but I can't figure how to read mouse button state.
It works with the keyboard but not with the mouse! And it is strange, I don't see what I am doing wromg .
The script must scroll down when a key is hold.
Here is full code tested on win7:

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.
mousegetpos, 	preX, preY
loop 
{
	sleep, 35
	exitmain := getkeystate("esc", P)
	pan := getkeystate("space", P)
	pan := getkeystate("rbutton", P)
	mousegetpos, X, Y
	if (pan = true) {
		tooltip, hello pan 
		send, {wheeldown 1}
	}else{
		tooltip, xy %X% %Y%
	}
	if (exitmain = true) {
		ExitApp
	}
	
	preX := X 
	preY := Y
}
   
esc::
rbutton::
space::
Any Idea why it works with the keyboard (spce key here), but not with a mouswe button?
AHK version 1.1.2704

Regards,
Mikhail
mikhail22
Posts: 19
Joined: 14 Jan 2018, 11:50

Re: Read mouse button state not working  Topic is solved

14 Jan 2018, 15:42

OOPS :)
Guys sorry, it seems that was just my fault - I made a typo:

Code: Select all

pan := getkeystate("rbutton", "P")
^This works (I forgot quotes around "P" in my first version)
Sorry

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: LAPIII, peter_ahk and 333 guests