Trouble with a funtion when named "Scale" or "vk1234" Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
wolf_II
Posts: 1587
Joined: 08 Feb 2015, 20:55

Trouble with a funtion when named "Scale" or "vk1234"

15 Aug 2017, 13:48

Hi all,

I have trouble when I want to name a function "Scale".
Here is an example with a function named "xScale" and it works as intended.
When I rename the function to "Scale" as I desire (yes, I renamed all 3 occurrences of its name), the function does not work any more.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Can anybody confirm, please? Better yet, can anybody explain please why this is?

I also have trouble with "vk1234" as a function name, which lets me think there might be some interference with scan code and/or virtual key code.
To clarify: I have no desire to name a function "vk1234", but I did test my "scan code" theory.

https://autohotkey.com/docs/Variables.htm explains about variable names.
I can't find a help topic about function names. I have assumed up til now that both are treated as "idioms" (if that is the correct term?), whose rules are explained in the docs.
I am obviously wrong about that too. :(

Thanks for reading! :)

Edit: I will likely change the function name to "Zoom()", but I still want to learn about this problem.
Helgef
Posts: 2476
Joined: 17 Jul 2016, 01:02
Contact:

Re: Trouble with a funtion when named "Scale" or "vk1234"  Topic is solved

15 Aug 2017, 16:38

This works fine,

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

scan()
scan(){
msgbox
}

your problem is that the one line hotkey is being interpreted as a remapping hotkey, ^WheelUp::sca, that is, ^WheelUp remapped to 9.
Try this in notepad, you see

Code: [Select all] [Download] GeSHi © Codebox Plus

a::scan()
b::scaHELLOWORLD()

Keyhistory,

Code: [Select all] [Expand] [Download] (Untitled.txt)GeSHi © Codebox Plus



Hotkeys wrote:However, if a hotkey needs to execute only a single line, that line can be listed to the right of the double-colon. In other words, the return is implicit:

So it is a bug.

Workaround,

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

a::
Scan()
return

or

Cheers.

Edit: Tested on AHK 1.1.26.00 and latest (I think) v2
wolf_II
Posts: 1587
Joined: 08 Feb 2015, 20:55

Re: Trouble with a funtion when named "Scale" or "vk1234"

15 Aug 2017, 17:28

Thanks Helgef. :thumbup:

I did notice before in the key history the 9 and did not understand where it came from.
So, Scale() is interpreted as only sca, where a is a hexadecimal 10, and apparently scan code 10 is the 9-key in the top row of the keyboard. The remaining le() is disregarded. Somewhat unintuitive.

I noticed in your example for me to test in Notepad that the script executes without even a function scaHELLOWORLD() being defined in the script. Excellent example!!
Thank you for taking the time and looking into this.

I probably should have mentioned that I tested on Win10 64-bit. The most recent update came a couple of days ago, it is called "Creators Update" I think, but that is irrelevant to the problem.
What is relevant: I tested with AHK v1.1.26.01 64-bit.

I will wait about two days from now to see if there will be more responses, then I will mark your post as "accepted answer" and post in the subforum "Bug Reports".
Unless you want to post a bug report yourself, which is OK by me. After all, you have done all the work.

I highly appreciate your input. :D
Helgef
Posts: 2476
Joined: 17 Jul 2016, 01:02
Contact:

Re: Trouble with a funtion when named "Scale" or "vk1234"

15 Aug 2017, 17:50

So Scale() [...]

Indeed, that is how it seems.
Waiting is good, maybe someone knows where it is documented or if it has already been reported. You can post.

Return to “Ask For Help”

Who is online

Users browsing this forum: J63A7bqKgl, john_c, mithrilsaber and 47 guests