I found 4 versions. Line counts: 555, 572, 625, 633.
==================================================
I tested these with AutoHotkeyU32 v1.1.25.01, and a script which I have posted lower down:
[555 lines (488 sloc) 20.7 KB][works][COM_L.zip (UNICODE)]
COM.AHK/com.ahk at master · ttnnkkrr/COM.AHK · GitHub
https://github.com/ttnnkkrr/COM.AHK/blob/master/com.ahk
[572 lines][runs, but with error message][COM_L.zip (ANSI)]
[worked when I replaced the COM_SysString function]
[625 lines (558 sloc) 26 KB][wouldn't open]
AHKs/COM.ahk at master · camerb/AHKs · GitHub
https://github.com/camerb/AHKs/blob/mas ... ty/COM.ahk
[633 lines (564 sloc) 25.1 KB][runs, but with error message]
[worked when I replaced the COM_SysString function]
Autohotkey-Scripts/com.ahk at master · dufferzafar/Autohotkey-Scripts · GitHub
https://github.com/dufferzafar/Autohotk ... ib/com.ahk
Perhaps there is yet another, better version?
Usual text comparisons in WinMerge, and things like checking for new parameters in the function definitions, proved indecisive in determining which was the best version.
==================================================
My quick-fix function:
Code: Select all
COM_SysString(ByRef wString, sString)
{
VarSetCapacity(wString,3+2*nLen:=1+StrLen(sString))
if !A_IsUnicode
Return NumPut(DllCall("kernel32\MultiByteToWideChar","Uint",0,"Uint",0,"Uint",&sString,"int",nLen,"Uint",&wString+4,"int",nLen,"Uint")*2-2,wString)
else
{
DllCall("msvcrt\memcpy", "uint", &wString+4, "uint", &sString, "uint", StrLen(sString)*2)
Return NumPut(3+2*nLen:=1+StrLen(sString),wString)
}
}
The code I tested it on:
IE_Add() or COM_AtlAxCreateContainer() or AtlAxWin() - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/3213 ... ntry204552
Code: Select all
SetWorkingDir, %A_ScriptDir%
#include %A_ScriptDir%\com.ahk
;~ #include %A_ScriptDir%\ie.ahk
Gui +LastFound +Resize +MinSize600x300
Gui, Show, center h600 w600, Test
COM_AtlAxWinInit()
pweb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),25, 203, 550, 372, "Shell.Explorer") )
COM_Invoke(pweb, "Silent", True)
COM_Invoke(pweb, "Navigate2", "http://www.google.com/")
Return
GuiSize:
WinMove, % "ahk_id " . COM_AtlAxGetContainer(pweb), , 25, 203, A_GuiWidth - 50, A_GuiHeight - 228
Return
GuiClose:
COM_Release(psink)
COM_Release(pweb)
Gui, Destroy
COM_AtlAxWinTerm()
ExitApp
Why I'm interested in COM.ahk.
The script above and COM.ahk give you a way to create a simple GUI with an 'Internet Explorer_Server' control. This is useful for understanding GUIs generally, understanding how AutoHotkey works, creating GUIs in AHK v1 that are not #Persistent (i.e. they do not use the Gui command), and creating GUIs in other programming languages.
I was trying to make a SplashImage replacement that can handle more filetypes like animated gifs and svg files.
Reading through COM.ahk is also a very good way to understand AutoHotkey's native COM. I intend to recommend that for my objects tutorial, however, I need to pick a version first!
jeeswg's objects tutorial (not yet complete) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?t=29232
==================================================
[EDIT:]
In general, I am in interested in having GUIs that don't use the Gui command, this allows you to have GUIs in script libraries that do not cause a script to become #Persistent (i.e. you would otherwise have to modify the script by changing lines to ExitApp etc, otherwise they would never close, unless closed manually).
[EDIT:]
Some advantages of making GUIs via DllCall only, and not the Gui command, are that they can be simpler to write and maintain, and for example (unless AHK brings in this functionality) allow you to choose a GUI class name, or specify a window with no icon.
==================================================
All roads lead to COM.
COM one, COM all.
TweedleCOM and TweedleRelease.
Will the real COM Query please stand up?
I'm SpartaCOM!