v2.0-a079-be5df98 - not operator and Hotkey function Topic is solved

Report problems with documented functionality
User avatar
Ragnar
Posts: 613
Joined: 30 Sep 2013, 15:25

v2.0-a079-be5df98 - not operator and Hotkey function

21 Jun 2017, 06:40

Unlike the "!" operator, the "not" operator doesn't work. Is this intended?

The following example(s) from _If.htm:

Code: Select all

; Example 1: Adjust volume by scrolling the mouse wheel over the taskbar.
#If MouseIsOver("ahk_class Shell_TrayWnd")
WheelUp::Send "{Volume_Up}"
WheelDown::Send "{Volume_Down}"

MouseIsOver(WinTitle) {
    MouseGetPos ,, Win
    return WinExist(WinTitle " ahk_id " Win)
}

; Example 4: Dynamic hotkeys. Requires Example 1.
NumpadAdd::
Hotkey "If", MouseIsOver("ahk_class Shell_TrayWnd")
if (doubleup := !doubleup)
    Hotkey "WheelUp", "DoubleUp"
else
    Hotkey "WheelUp", "WheelUp"
return

DoubleUp:
Send "{Volume_Up 2}"
return
throws the following error if I press NumpadAdd on the taskbar. Did I do something wrong here?

Code: Select all

Error:  Parameter #2 must match an existing #If expression.

		Line#
		003: Return
		004: Send "{Volume_Down}"
		004: Return
		006: {
		007: MouseGetPos "", "", "Win"
		008: Return WinExist(WinTitle " ahk_id " Win)
		009: }
--->	013: Hotkey "If", MouseIsOver("ahk_class Shell_TrayWnd")
		014: if (doubleup := !doubleup)
		015: Hotkey "WheelUp", "DoubleUp"
		016: Else
		017: Hotkey "WheelUp", "WheelUp"
		018: Return
		021: Send "{Volume_Up 2}"
		022: Return

The current thread will exit.
Edit: Ah sorry, wrong topic. I thought this refers to the new version generally, not just to the loop statements.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: v2.0-a079-be5df98 - not operator and Hotkey function

21 Jun 2017, 23:09

I split the topic.

No, the not operator failing to work is not intended.

Many of the examples haven't been updated with the new syntax (perhaps the majority of examples, except on the main pages like "Scripts" and "Variables"). The syntax shown in that example is incorrect. The Hotkey function needs the text of the expression, not the result of evaluating it. Hotkey "If", MouseIsOver("ahk_class Shell_TrayWnd") calls MouseIsOver() immediately and passes the result to the Hotkey function.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: v2.0-a079-be5df98 - not operator and Hotkey function  Topic is solved

15 Jul 2017, 22:06

The not operator has been fixed in v2.0-a081.

Return to “Bug Reports”

Who is online

Users browsing this forum: Google [Bot] and 28 guests