Implement missing functions

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Implement missing functions

05 Dec 2018, 09:32

DllCall() wrote:
VarSetCapacity(var) will return its length
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Implement missing functions

05 Dec 2018, 10:27

- DllCallAddress: DllCall supports an address.
- Binary: (I have written a function for hex to binary data called JEE_HexPut.) [On my wish list as 'StrPut' or 'HexPut'.]
- BinaryMid: 2-liner. AHK v1 cannot return a binary variable from a function, AHK v2 can, hence a possibility is preparing some space via VarSetCapacity, and then using NumPut/StrPut/memmove (Winapi)/RtlMoveMemory (Winapi). [Related: my wish list mentions 'BinCopy'.]
- BinaryLen: VarSetCapacity with no parameters is similar, but not the same. Giving the capacity rather than the size. [lexikos mentioned something similar in 'v2-thoughts', on my wish list as 'VarGetSize' / 'SizeOf'.]
- BinaryToString: StrGet.

- In general it's interesting to hear of things that AutoIt has that AutoHotkey doesn't. I'm working on a general library at the moment which has solutions of some kind for everything above except 'VarGetSize'.
- I noticed that AutoIt really lacks in terms of operators.

StrPut/StrGet + hex/base64 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=50528

v2-thoughts
https://www.autohotkey.com/v2/v2-thoughts.htm
Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789

Variables and Expressions - Definition & Usage | AutoHotkey
https://autohotkey.com/docs/Variables.htm#Operators
Language Reference - Operators
https://www.autoitscript.com/autoit3/do ... rators.htm
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
quantum
Posts: 14
Joined: 04 Dec 2018, 05:37

Re: Implement missing functions

05 Dec 2018, 18:00

Right. So how do we get this kind of functionality in AHK v2?
https://www.autoitscript.com/forum/topi ... in-autoit/

And of course this. Now this is not the same as embedding it as a resource.
https://www.autoitscript.com/forum/topi ... rydll-udf/
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Implement missing functions

05 Dec 2018, 18:38

- You can store the function as a hex/base64 string, and convert it to binary data (via NumPut or CryptBinaryToString (Winapi)), and pass the address to DllCall.
- There's also an MCode function that's commonly used. There's a version of it here:
C++: C++ to machine code via TDM-GCC - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 23&t=49554
And one here:
MCode Tutorial (Compiled Code in AHK) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=32
- Btw I would welcome anybody else to expand on anything that I've said on this thread.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
quantum
Posts: 14
Joined: 04 Dec 2018, 05:37

Re: Implement missing functions

06 Dec 2018, 06:59

What if the C++ machine code has external calls? Such as WINAPI?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Implement missing functions

06 Dec 2018, 07:13

- I haven't tried to do that. I only use a handful of machine code functions for the quick reading/writing of bits/bytes. I'd use DllCall for calling Winapi functions.
- Can't you just use TDM-GCC or do something similar to what AutoIt does? What does AutoIt do?
- Btw if you have any comments re. the pros/cons of AutoIt/AutoHotkey, I would be interested to hear. You can be completely honest, I feel that both have their plus points. I'd been investigating it myself, considering writing functions in both languages to complement the other. Any other missing functions? Cheers.
- The one thing I'd like that I've seen in AutoIt is the greater support for FASM.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
quantum
Posts: 14
Joined: 04 Dec 2018, 05:37

Re: Implement missing functions

06 Dec 2018, 07:20

Like I said will this work?

#include <windows.h>
void main()
{
MessageBox(0, "Hello", "Welcome Message", 1);
}
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Implement missing functions

06 Dec 2018, 23:48

- (I meant to say more clearly above, I've only tried to compile pure C++ code, never with any Winapi functions.)
- I tried with MCode4GCC but it didn't work, if someone who's tried using MCode4GCC to compile C++ code with Winapi functions could chip in.
- It output some code, created without errors, but when input into the MCode function, and run via DllCall, it did nothing.
MCode4GCC -- C/C++ to MCode Generator - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=4642

- You might try using the FASM approach, if you're familiar with it. But it's not too well documented.
ASM: ASM (assembly language) to machine code via FASM (flat assembler) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 23&t=49638
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 12 guests