AutoHotkey C++ Powerhouse: Introduction

Discuss other programming languages besides AutoHotkey
User avatar
jeeswg
Posts: 5271
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.
User avatar
jeeswg
Posts: 5271
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.
User avatar
jeeswg
Posts: 5271
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.
User avatar
jeeswg
Posts: 5271
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

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

[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 ... 23&t=49554
ASM: ASM (assembly language) to machine code via FASM (flat assembler) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 23&t=49638

[TCC (libtcc.dll) and a qwerty12 example]
how to dll Inject - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 96#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/1589 ... -compiler/

==================================================
User avatar
jeeswg
Posts: 5271
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey C++ Powerhouse: Introduction

08 Sep 2018, 04:44

[RESERVED]
User avatar
jeeswg
Posts: 5271
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AutoHotkey C++ Powerhouse: Introduction

08 Sep 2018, 04:44

[RESERVED]

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 2 guests