AutoHotkey C++ Powerhouse: Introduction

Talk about things C/C++, some related to AutoHotkey
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

AutoHotkey C++ Powerhouse: Introduction

21 Aug 2018, 01:46

- The C++ Powerhouse is intended as a place to teach and discuss how best to write AHK source code in C++.

- An introduction here on downloading and compiling the AHK source code and making some 'hello world' changes.

- Discuss/optimise basic and more advanced C++ code examples.
- C++: AHK source code: demo functions
- C++: AHK source code: potential functions
- C++: AHK source code: demo A_ variables
- C++: AHK source code: potential A_ variables

- Discuss reading/editing the source code. Including coding tips and style guides.
- Discuss basic/intermediate/expert C++ queries relevant to AutoHotkey.
- Work on machine code functions.

- The ideas were originally outlined here:
- new forum proposal: C++ For AutoHotkey
Last edited by jeeswg on 08 Sep 2018, 03:59, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey C++ Powerhouse: Introduction

21 Aug 2018, 01:47

==================================================

TIPS ON DOWNLOADING/COMPILING/MODIFYING THE AUTOHOTKEY SOURCE CODE

==================================================

TO DOWNLOAD THE SOURCE CODE

[AHK v1.1/v2.0 source code zips]
Releases · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/releases

[AHK v1.0 source code zips][older versions]
Releases · AutoHotkey/AutoHotkey · GitHub
https://github.com/AutoHotkey/AutoHotkey/releases

==================================================

TO COMPILE

the AHK v1.1/v2.0 README.md file states:
AutoHotkey is developed with [Microsoft Visual Studio Community 2015 Express](https://www.visualstudio.com/products/v ... mmunity-vs), which is a free download from Microsoft.
...
The project should also build in Visual C++ 2010, 2012 or 2013.
check the README.md file for more details regarding compiling AutoHotkey

download and install one of Visual C++ 2010/2012/2013/2015
this could require around 6-7 gigabytes of hard disk space

to compile (as 32-bit Unicode):
open AutoHotkeyx.sln in Visual C++ 2010/2012/2013/2015,
Build, Configuration Manager...,
Active selection configuration:, choose Release,
Build, Build Solution

note: it creates an exe that is identical or *almost* identical to the official one
depending on the Visual C++ version used and the settings used

==================================================

TO ADD/ALTER FUNCTIONALITY (FUNCTIONS + 'A_' VARIABLES)

3 main files need to be changed to add/modify BIFs/BIVs (built-in functions/variables):
script.cpp/script.h (trivial changes), script2.cpp (main code).

(I would recommend using a text editor such as Notepad2 or Notepad++ to edit the files since Notepad cannot handle LF-delimited text correctly.)

Some examples of text to search for to find BIF/BIV code:

[AHK v1 functions]
e.g. BIF: Abs:
[script.cpp] BIF_DECL(BIF_Abs);
[script.h] bif = BIF_Abs;
[script2.cpp] BIF_DECL(BIF_Abs)

[AHK v2 functions]
e.g. BIF: Abs:
[script.cpp] BIF1(Abs, 1, 1),
[script.h] BIF_DECL(BIF_Abs);
[script2.cpp] BIF_DECL(BIF_Abs)

[AHK v1/v2 'A_' variables]
e.g. BIV: A_PtrSize:
[script.cpp] A_(PtrSize),
[script.h] BIV_DECL_R (BIV_PtrSize);
[script2.cpp] VarSizeType BIV_PtrSize(LPTSTR aBuf, LPTSTR aVarName)

See the demo and potential function/A_ variable links above for more details on adding/modifying BIFs/BIVs.

After editing the relevant source code files, choose 'Build, Build Solution' in Visual Studio (Visual C++), to compile a new exe.

==================================================

TO ADD/ALTER FUNCTIONALITY (AHK V1) (INPUTBOX)

INPUTBOX - FROM FONT SIZE 10 TO 18

[AutoHotkey.rc]

//before:
FONT 10, "MS Shell Dlg", 400, 0, 0x0
//after:
FONT 18, "MS Shell Dlg", 400, 0, 0x0

[script2.cpp]
//before:
CURR_INPUTBOX.font = CreateFont(FONT_POINT(hdc, 10), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
//after::
CURR_INPUTBOX.font = CreateFont(FONT_POINT(hdc, 18), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

==================================================
Last edited by jeeswg on 07 Nov 2018, 00:56, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey C++ Powerhouse: Introduction

08 Sep 2018, 04:42

==================================================

AUTOHOTKEY: SOURCE CODE/CHANGELOG LINKS

==================================================

DOWNLOAD SOURCE CODE

[AHK v1.0 source code zips]
Releases · AutoHotkey/AutoHotkey · GitHub
https://github.com/AutoHotkey/AutoHotkey/releases

[AHK v1.1/v2.0 source code zips]
Releases · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/releases

==================================================

CHANGELOGS

[AHK v1.0]
Archived Changes | AutoHotkey
https://autohotkey.com/docs/ChangeLogHelp.htm

[AHK v1.1]
Changes & New Features | AutoHotkey
https://autohotkey.com/docs/AHKL_ChangeLog.htm

[AHK v2.0]
AutoHotkey v2 alpha (UPDATES) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=2120

[version information for all AHK features (v1.0/v1.1/v2.0)]
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 42#p131642

==================================================

ALL AHK SOURCE CODE CHANGES (COMMITS)

[AHK v1.0 commits]
Commits · AutoHotkey/AutoHotkey · GitHub
https://github.com/AutoHotkey/AutoHotkey/commits/master

[AHK v1.1 commits]
Commits · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/commits/master

[AHK v2.0 commits]
Commits · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/commits/alpha

==================================================

AHK V1.1/V2.0 PROPOSED SOURCE CODE CHANGES (PULL REQUESTS)

[AHK v1.1/v2.0 pull requests]
Pull Requests · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/pulls

==================================================

SELECTED AHK V1.1/V2.0 SOURCE CODE CHANGE EXAMPLES (COMMITS)

[command: SetRegView (+ A_RegView)][v1.1.08.00]
Added SetRegView 32/64 and A_RegView. · Lexikos/AutoHotkey_L@508b424 · GitHub
https://github.com/Lexikos/AutoHotkey_L ... 0293a06f4d

[command: SendLevel][v1.1.06.00]
[directive: #InputLevel][v1.1.06.00]
Merge branch 'InputLevel' of git://github.com/russelldavis/AutoHotkey_L · Lexikos/AutoHotkey_L@f85a680 · GitHub
https://github.com/Lexikos/AutoHotkey_L ... b12114dd4e

[functions: Min/Max][v1.1.27.00]
Add Min/Max built-in functions · Lexikos/AutoHotkey_L@ef4be3a · GitHub
https://github.com/Lexikos/AutoHotkey_L ... 2e71604bd2
Fixed Min/Max with mixed type and negative numbers. · Lexikos/AutoHotkey_L@0693042 · GitHub
https://github.com/Lexikos/AutoHotkey_L ... 54d179bab2

[functions: ControlGetClassNN/SysGetIPAddresses][v2.0-a100-52515e2]
Added ControlGetClassNN(). · Lexikos/AutoHotkey_L@7ba87ec · GitHub
https://github.com/Lexikos/AutoHotkey_L ... 06b4da325f
Replaced A_IPAddressX with SysGetIPAddresses(). · Lexikos/AutoHotkey_L@47e9f12 · GitHub
https://github.com/Lexikos/AutoHotkey_L ... a22b2aa642

[variables: A_ListLines (+ other A_ variables)][v1.1.28.00]
Merge branch 'edge' · Lexikos/AutoHotkey_L@46882eb · GitHub
https://github.com/Lexikos/AutoHotkey_L ... 350e373b1f

[object method: Count][v1.1.29.00]
Merge branch 'edge-obj' · Lexikos/AutoHotkey_L@bb8e921 · GitHub
https://github.com/Lexikos/AutoHotkey_L ... 873ddd472b

[operators: remove <>, modify !=, add !==][v2.0-a098-59ec6aa]
Removing the <> operator. by HelgeffegleH · Pull Request #105 · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/pull/105
Adding binary operator: !== and changing !=. by HelgeffegleH · Pull Request #104 · Lexikos/AutoHotkey_L · GitHub
https://github.com/Lexikos/AutoHotkey_L/pull/104

[control flow statements]
[no recent examples]

==================================================
Last edited by jeeswg on 07 Nov 2018, 00:39, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey C++ Powerhouse: Introduction

08 Sep 2018, 04:43

==================================================

OTHER C++ LINKS

==================================================

new forum proposal: C++ For AutoHotkey - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=3&t=42273

[AutoHotkey source code locations]
C++ for AutoHotkey: list of command/function locations etc - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=55399
C++: AHK source code: where is it located? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=59084

[DllCall/PostMessage/SendMessage/struct info retrieved via C++]
C++: DllCall: get parameter types/sizes - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=39426
List of Windows Messages - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=74&t=39218
C++: structs: get struct sizes, get member offsets/sizes - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=61987

[machine code functions via C++/FASM]
best AutoHotkey machine code functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=32242
binary data: copy ('move'), compare, search, replace nulls - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=30869
InBuf function currently 32-bit only (machine code binary buffer searching) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28393
C++: C++ to machine code via TDM-GCC - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=49554
ASM: ASM (assembly language) to machine code via FASM (flat assembler) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=49638
C++: TDM-GCC: error with bool (and other VC++/AHK to TDM-GCC issues) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=59979
C++: TDM-GCC: minimising includes - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=59986

[TCC (libtcc.dll) and a qwerty12 example]
how to dll Inject - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=67&t=27047&p=165896#p165896
get full paths of selected files on Desktop and Common File Dialogs - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=31135
Explorer column interaction (get/set: which appear, width, ascending/descending order) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=33129
TCC : Tiny C Compiler - Utilities - AutoHotkey Community
https://autohotkey.com/board/topic/15894-tcc-tiny-c-compiler/

[C++ equivalent to AHK's DllCall and struct handling]
which languages should I learn to learn DllCall and Windows API Functions? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=59780&p=252092#p252092

[AHK DllCall code as C++ pseudocode]
AutoHotkey via DllCall: AutoHotkey functions as custom functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=37871
GUIs via DllCall: MsgBox - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=30688
GUIs via DllCall: control zoo - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=32106
GUIs via DllCall: list windows/child windows (controls) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=36405
GUIs via DllCall: text functions (get/set internal/external control text) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40514

[C++ tutorials/info]
[Learn C++ In One Video]
C++ Programming - YouTube
https://www.youtube.com/watch?v=Rub-JsjMhWY
resources for learning a programming language - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=17&t=56140

==================================================
Last edited by jeeswg on 16 Mar 2019, 22:15, edited 4 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey C++ Powerhouse: Introduction

08 Sep 2018, 04:44

[RESERVED]
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey C++ Powerhouse: Introduction

08 Sep 2018, 04:44

[RESERVED]
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
lmstearn
Posts: 681
Joined: 11 Aug 2016, 02:32
Contact:

Re: AutoHotkey C++ Powerhouse: Introduction

18 Feb 2019, 00:27

Thanks for the links & info. :) Just a heads up in loading the source code, the installed toolset may not be the latest, e.g.:
https://stackoverflow.com/questions/50750024/visual-studio-2017-build-tools-150
Same, if fresh out of the Windows 8.1 SDK:
https://stackoverflow.com/questions/43704734/how-to-fix-the-error-windows-sdk-version-8-1-was-not-found
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: AutoHotkey C++ Powerhouse: Introduction

22 Feb 2019, 07:37

Nice list. And I will definitely vote for TCC as a useful tool, that some might not know about.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 10 guests