Obsolete test build - Functions and Objects as Labels (etc.)

Community news and information about new or upcoming versions of AutoHotkey
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: New test build - Functions and Objects as Labels (and m

24 Jan 2015, 23:14

lexikos wrote:To save further derailing the topic, I've moved the OnMessage discussion to Wish List.

evilC: Use bind v1.2 from the top post.

Is it possible for RegisterCallback() to able to accept bound functions also?
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Functions and Objects as Labels (and m

25 Jan 2015, 02:02

It effectively already can; you just need a different kind of bound function.

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


You could take it further than that - convert parameters to the appropriate types, and such.

One potential pitfall is that you need to ensure the CCallback object isn't deleted before you're finished with the callback. The way I've designed it, you manage the lifetime of the object and the object takes care of freeing the callback. With normal callbacks, usually the script just ignores memory management (or more rarely, calls DllCall("GlobalFree", "ptr", cb)).

Changing RegisterCallback to accept an object wouldn't add much value, and would have a higher cost to retain backward-compatibility. That has to do with how it overrides the behaviour of the parg* parameter (see above) to pass a pointer instead of an array.

Another problem is that RegisterCallback returns a pointer to an opaque data structure, which you free with GlobalFree. Instead, we would need a function for freeing the callback structure and any associated object.
GeekDude
Posts: 742
Joined: 02 Oct 2013, 22:13

Re: New test build - Functions and Objects as Labels (and m

25 Jan 2015, 10:12

Not to mention the script you had me draft up at 1AM last night :yawn:

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



Edit: added a return
Last edited by GeekDude on 25 Jan 2015, 19:31, edited 1 time in total.
GeekDude
Posts: 742
Joined: 02 Oct 2013, 22:13

Re: New test build - Functions and Objects as Labels (and m

25 Jan 2015, 10:16

Nah, it works fine. What I was doing at the end there was making it so it would infer the number of parameters in the registered callback function. I had pasted my finished version not long before leaving ;)
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: New test build - Functions and Objects as Labels (and m

25 Jan 2015, 19:30

Well I actually have GeekDude's code working in there now, will look at lex's example and see if I can digest what either of you are doing. I vaguely get the idea.

For now though, my last major niggle with AHK code structuring has bitten the dust and AHK feels like a new toy.

This thread is so full of win it deserves a little dance.

:dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance:
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Functions and Objects as Labels (and m

31 Jan 2015, 06:10

Update

I've uploaded a new build. It's not very interesting since it mostly consists of internal changes, but needs to be tested on a variety of scripts.

v1.1.19.02-17+gcd46158:
  • Simplified pre-parsing of #if/static var initializers.
  • Refactored pre-parsing of blocks and if/else/loop/etc. to fix bugs and reduce code size.
    • Fixed crash on load when an auto-include ends with if/else/loop/etc.
    • Fixed crash when stepping past RETURN in a function at the very end of an auto-included file.
    • Fixed try global x := fail(), y := fail() not applying try to the second declaration.
  • Fixed break n to not terminate the thread when until is present.

Look out for any changes in behaviour (i.e. bugs) related to #if expressions, static var initializers, or grouping of statements (under if/else/loop/for/while/try/catch/finally).
User avatar
fincs
Posts: 500
Joined: 30 Sep 2013, 14:17
GitHub: fincs
Location: Seville, Spain
Contact:

Re: New test build - Functions and Objects as Labels (and m

31 Jan 2015, 07:58

TillaGoto.ahk line 1116:

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


GenDocs/RetrieveDocs.ahk line 118: same error
fincs
Windows 10 x64 Build 14393 / AutoHotkey v1.1.24.04
Get SciTE4AutoHotkey v3.0.06.01 - [My project list]
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: New test build - Functions and Objects as Labels (and m

31 Jan 2015, 11:31

I can confirm that my Input command Bind technique using #if blocks which add hotkeys when a class property is TRUE, still works fine with this build.
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Functions and Objects as Labels (and m

31 Jan 2015, 19:19

Thanks fincs and evilC.

I've uploaded a build fixing the issue fincs reported - v1.1.19.02-20+gaa8308b.
GeekDude
Posts: 742
Joined: 02 Oct 2013, 22:13

Re: New test build - Functions and Objects as Labels (and m

02 Feb 2015, 20:53

I've just replaced my binaries with the latest ones from the original post in this thread (Not just GeekBot's). So far everything seems to be working fine
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: New test build - Functions and Objects as Labels (and m

06 Feb 2015, 00:22

Hi Lex, I tested the new build and can confirm working.

Also, I wrote AHK-EXE-Swapper to let people easily swap in/out test builds etc.

I notice you are making changes to localization, not really sure I understand the implications of what you are saying yet.

I have a user with an AZERTY keyboard complaining that when one of my scripts sends 1, it holds Shift, seemingly because 1 is a shifted character on his keyboard.

I made a post but nobody seems to know how to work around.
Is that something that is adressed by this build? Is it a fundamental limitation? Or am I just missing an existing way to do it?
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Functions and Objects as Labels (and m

06 Feb 2015, 02:40

evilC wrote:I notice you are making changes to localization,
Not specifically. Just fixing a bug. It wasn't even the point of the test build.
I have a user with an AZERTY keyboard complaining that when one of my scripts sends 1, it holds Shift, seemingly because 1 is a shifted character on his keyboard.
Does it produce the right character? If so, it's working properly and the complaint is unfounded.
Is that something that is adressed by this build?
Clearly not.
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: New test build - Functions and Objects as Labels (and m

06 Feb 2015, 03:41

Yes, but it hits another key that you didn't ask it to, and I can see no way around it.

On QWERTY keyboard, I suppose the inverse is true - you cannot send ! " $ etc without hitting shift, but in this case (A game), it kind of nobbles AHK completely as a way of sending actions if you cannot send 1 on it's own without shift.

Again, with a QWERTY keyboard, you have {Blind} to mitigate this, but apparently Send {Blind}{1} on an AZERTY keyboard does not send & (The unshifted character on the 1 key) as I hoped it might.
This means that writing scripts that send number keys problematic if you wish them to work with QWERTY or AZERTY keyboards in games.
Would it maybe be possible to get something similar to {Blind} to cater for this case?

If you do not wish to derail this thread any more, I have a thread on this subject here.
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Functions and Objects as Labels (and m

06 Feb 2015, 04:26

evilC wrote:If you do not wish to derail this thread any more,
You've derailed it quite enough. My terse responses had an intended air of "I don't care to discuss this here". Obviously I was too subtle.
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Functions and Objects as Labels (and m

07 Feb 2015, 22:16

Update - v1.1.19.02-27+gf3cb786

Changed the way OnMessage works with function references/objects.

OnMessage(Msg, Object [, MaxThreads])
  • If MaxThreads is omitted or non-zero, registers Object to be called when Msg is received.
  • If MaxThreads is 0, unregisters and releases the object.
  • If registration failed, an exception is thrown.
  • No return value.
  • Multiple objects/functions can monitor the same message. The most recently registered handler is called first.
  • Monitors can safely unregister themselves or other monitors.

Each message also has a single "legacy mode" handler, so OnMessage with a function name or empty string behaves exactly as before and does not affect the new handlers.

So OnMessage(x, "Fn") behaves as before, but OnMessage(x, Func("Fn")) does not affect other handlers (unless Fn returns a value when called, in which case the other handlers are not called).

Minor fixes from master branch:
  • Use GetGUIThreadInfo instead GetFocus to retrieve focused control (thanks HotKeyIt).
  • Improved remapping to allow scXXX::Y when scXXX has no corresponding VK.
  • Fixed ListView to not raise '*' events for unknown notifications.
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: New test build - Functions and Objects as Labels (and m

08 Feb 2015, 03:44

Nice, convenient. Works fine here.
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: New test build - Functions and Objects as Labels (and m

08 Feb 2015, 09:22

Damned sweet, but would it be possible to allow setting an option to switch the order? It would be nice if it were possible to have the messages fire in the order they were registered.

Say you have a library that uses OnMessage to handle GUI scrollbars - if someone writes a script using this library that listens to mouse wheel messages, it would be desirable for the scroll library to be able to intercept the message first and have a chance to do it's thing before the script using the library gets the message.
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: New test build - Functions and Objects as Labels (and m

08 Feb 2015, 18:54

Any suggestions as to whether it is possible to compile a script using these test builds?

It seems the normal AHK2Exe needs .bin files, which I do not have for this test build.
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Functions and Objects as Labels (and m

08 Feb 2015, 20:20

No. You would need to download the source code and compile AutoHotkeySC.bin first.

Return to “Announcements”

Who is online

Users browsing this forum: No registered users and 1 guest