Hello,
i have no idea what is going on.
So i have been working with AHK now for quite a while and been able to solve most of my concerns on my own.
BUT
This one seems to be unsolvable for me. I hope someone will be able to help.
Thanks in advance.
MButton::
{
CoordMode, Mouse, Screen
MouseGetPos, MouseX, MouseY
If ((MouseX = %xMouse%) and (MouseY = %yMouse%) and (A_PriorKey = MButton))
{
Menu, Tray, Show
Gosub, TRAYREFRESH
}
Else
{
Send, {MButton}
}
xMouse := MouseX
yMouse := MouseY
Return
}
I tried splitting the if statements and it works fine.
so it has to be something with the 'and' i assume.
Please help.
Thanks, again.
IF statement does not work with 'AND' Topic is solved
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: IF statement does not work with 'AND'
You could try switching the and with && (which is the typical way to do and statements). Then your If statement would look like this
Code: Select all
If (MouseX = %xMouse%) && (MouseY = %yMouse%) && (A_PriorKey = MButton)
Re: IF statement does not work with 'AND'
Thanks for the quick reply.
I tried like a thousand things and this was one of 'em.
It does not work.
I tried like a thousand things and this was one of 'em.
It does not work.
Re: IF statement does not work with 'AND'
Since you have parentheses you should not use the %%. (%xMouse%) refers to the adress of xMouse.
Code: Select all
If ((MouseX = xMouse) and (MouseY = yMouse) and (A_PriorKey = MButton))
ciao
toralf
toralf
Re: IF statement does not work with 'AND'
Thanks, toralf
but it doesn't work either
the if statement is just never true
i even debug it and watch all necessary variables and they look fine and then it skips it
but it doesn't work either
the if statement is just never true
i even debug it and watch all necessary variables and they look fine and then it skips it
Re: IF statement does not work with 'AND'
As I said this works fine
I just really don't know why it doesn't work when I combine the IF-Statements into one
Code: Select all
MButton::
{
CoordMode, Mouse, Screen
MouseGetPos, MouseX, MouseY
If MouseX = %xMouse%
{
If MouseY = %yMouse%
{
If A_PriorKey = MButton
{
Menu, Tray, Show
Gosub, TRAYREFRESH
}
Else
{
Send, {MButton}
}
}
Else
{
Send, {MButton}
}
}
Else
{
Send, {MButton}
}
xMouse := MouseX
yMouse := MouseY
Return
}
Re: IF statement does not work with 'AND'
Try this: (A_PriorKey = "MButton")
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: IF statement does not work with 'AND'
tried that as well and it does not work
so as standalones the following work
If MouseX = %xMouse%
If MouseY = %yMouse%
If A_PriorKey = MButton
Just when i want to combine 'em it does not work
so as standalones the following work
If MouseX = %xMouse%
If MouseY = %yMouse%
If A_PriorKey = MButton
Just when i want to combine 'em it does not work
Re: IF statement does not work with 'AND' Topic is solved
without seeing the entire script one cant say for sure, but it is likely that u have no keyboard hooks installed which prevents A_PriorKey from working. The if statements are not the problem, the blank a_priorkey is
Code: Select all
$MButton:: ; hook hotkey or enable #InstallKeybdHook
CoordMode, Mouse, Screen
MouseGetPos, MouseX, MouseY
If ((MouseX = xMouse% && (MouseY = yMouse) && (A_PriorKey = "MButton"))
{
Menu, Tray, Show
Gosub, TRAYREFRESH
}
Else
{
Send, {MButton}
}
xMouse := MouseX
yMouse := MouseY
Return
Re: IF statement does not work with 'AND'
wow
that acutally works. thats weird because i had the #InstallKeybdHook already
but now i added the $ and it works!!
thanks a lot.
but can you explain what the $ is actually doing, please?
that acutally works. thats weird because i had the #InstallKeybdHook already
but now i added the $ and it works!!
thanks a lot.
but can you explain what the $ is actually doing, please?
Re: IF statement does not work with 'AND'
it enables the hook for this particular key, and also installs it if one isnt present already
Re: IF statement does not work with 'AND'
- Interesting, this appears to work:
(A_PriorKey = "MButton")
You don't need:
(A_PriorKey = "$MButton")
- [EDIT:] A_PriorKey v. A_PriorHotkey.
Variables and Expressions - Definition & Usage | AutoHotkey
https://autohotkey.com/docs/Variables.htm#PriorHotkey
(A_PriorKey = "MButton")
You don't need:
(A_PriorKey = "$MButton")
- [EDIT:] A_PriorKey v. A_PriorHotkey.
Variables and Expressions - Definition & Usage | AutoHotkey
https://autohotkey.com/docs/Variables.htm#PriorHotkey
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: ScottishSummer2012 and 251 guests