I was playing with fonts with this test script
used installed C:\WINDOWS\FONTS , see how FONT's look like, from user Alguimist
https://autohotkey.com/boards/viewtopic.php?f=5&t=14838
Code: Select all
;-------- saved at Sonntag, 13. März 2016 11:14:50 --------------
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=14838 ---
;-------- from user = Alguimist
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
Gui,3: default
Gui,3:Color, Black
Gui,3:Color, ControlColor, Black
Gui,3:Font,,FixedSys
Menu,S1,add,Script_tmplinshi ,MH1
Menu,S1,add,Script_Source ,MH1
Menu,S1,add,Script_ZIP ,MH1
Menu,S1,add,Script_alguimist ,MH1
Menu,S1,add,Ahk_Font_Help ,MH1
Menu,S1,add,OTFINFO_HELP ,MH1
Menu,S1,add,OTFINFO_Download ,MH1
Menu,S1,add,SKAN ,MH1
Menu,S1,add,Latofonts ,MH1
Menu,S1,add,FontsOldSchool ,MH1
Menu,S1,add,Fontsquirrel ,MH1
Menu,S2,add,AHK_Version ,MH2
Menu,S3,add,WindowsFonts ,MH3
;----------------------------
menu,myMenuBar,Add,Font_Links ,:S1
menu,myMenuBar,Add,AHK_Version ,:S2
menu,myMenuBar,Add,WindowsFonts ,:S3
;----------------------------
gui,3:menu,MyMenuBar
;----------------------------
Gui,3: Add, ListView, x10 y10 w270 h360 sort gLV1 vLVA1 cYellow +hscroll altsubmit, Font name
LV_ModifyCol(1, 250)
gosub,functionx
Loop, % FontList.MaxIndex()
LV_Add("", FontList[A_Index])
e4x:=""
loop,15
e4x .= "This is a testline. This is Line- #@-" . a_index . "`r`n"
Gui,3:add,edit ,x290 y10 h360 w470 vED1 hwndhText cTeal,%e4x%
Gui,3:add,edit ,x290 y380 h25 w470 readonly cRed vED2,Fixedsys
Gui,3:add,button ,x10 y380 h25 w80 gStart1 vSt1,Start
Gui,3:add,button ,x100 y380 h25 w80 gStop1 ,Stop
Gui,3:show ,x10 y10 h420 w800,WINDOWS-FONTS_TEST
Guicontrol,3:focus,st1
return
;---------------------------------------------------------------
3Guiclose:
exitapp
;---------------------------------------------------------------
LV1:
Gui,3:default
Gui,3:ListView,LVA1
Gui,3:submit,nohide
;RN:=LV_GetNext("C") ;2 selected checked
;RF:=LV_GetNext("F") ;2 selected focused
;GC:=LV_GetCount() ;4 total
if A_GuiEvent = Normal
{
LV_GetText(C1,A_EventInfo,1)
;Gui,3: font, s14 cF16400 strike, %c1% ;- change text-COLOR / SIZE / FONT
Gui,3: font, s12 cYellow normal , %c1%
Guicontrol,3: ,ED2,%c1%
Guicontrol,3: Font, ED1
Guicontrol,3: ,ED1,%ed1% ;- maybe CHANGE TEXT
}
return
;----------------------------------------
;----------------------------------------
start1:
breakloop=0
Gui,3:ListView,LVA1
i=0
loop,
{
if (breakloop=1)
break
LV_Modify(I, "-Select -Focus")
i++
LV_Modify(I, "+Select +Focus")
RF:=LV_GetNext("F") ;2 selected focused
LV_GetText(C1,RF,1)
LV_Modify(RF, "Vis") ;- scrolltox
Gui,3: font, s16 cF16400, %c1% ;- change text-COLOR / SIZE / FONT
Guicontrol,3: ,ED2,%c1%
Guicontrol,3: Font, ED1
Guicontrol,3: ,ED1,%ed1% ;- maybe CHANGE TEXT
sleep,1000
}
return
;-----------------------------
;----------------
stop1:
breakloop=1
return
;----------------
;--------------------------------------------------------------
mh1:
if A_thisMenuItem=Script_tmplinshi
run,https://autohotkey.com/boards/viewtopic.php?f=6&t=813 ;- classcustomfont tmplinshi
if A_thisMenuItem=Script_Source
run,https://gist.github.com/tmplinshi/7717340
if A_thisMenuItem=Script_ZIP
run,https://www.dropbox.com/s/4h4e559tggvk1cq/Class_CustomFont_Samples.7z?raw=1
if A_thisMenuItem=Script_alguimist
run,https://autohotkey.com/boards/viewtopic.php?f=5&t=14838
if A_thisMenuItem=Ahk_Font_Help
run,https://autohotkey.com/docs/misc/FontsStandard.htm
if A_thisMenuItem=otfinfo_Help
run,http://www.lcdf.org/type/otfinfo.1.html
if A_thisMenuItem=otfinfo_Download
run,http://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe
if A_thisMenuItem=SKAN
run,https://autohotkey.com/board/topic/29396-crazy-scripting-include-and-use-truetype-font-from-script/
if A_thisMenuItem=Latofonts
run,http://www.latofonts.com/lato-free-fonts/
if A_thisMenuItem=Fontsquirrel
run,http://www.fontsquirrel.com/tools/webfont-generator
if A_thisMenuItem=FontsOldSchool
run,http://int10h.org/oldschool-pc-fonts/
Guicontrol,3:focus,st1
return
mh2:
if A_thisMenuItem=AHK_version
msgbox, 262208,AHK_Version ,Ahk-Version =%A_AHKVERSION%
Guicontrol,3:focus,st1
return
mh3:
ifexist,C:\windows\fonts
run,C:\windows\fonts
Guicontrol,3:focus,st1
return
;--------------------------------------------------------------
;----------- from user alguimist ------------------------------
;-https://autohotkey.com/boards/viewtopic.php?f=5&t=14838
functionx:
Global FontList := []
EnumFonts() {
hDC := DllCall("GetDC", "UInt", DllCall("GetDesktopWindow"))
Callback := RegisterCallback("EnumFontsCallback", "F")
DllCall("EnumFontFamilies", "UInt", hDC, "UInt", 0, "Ptr", Callback, "UInt", lParam := 0)
DllCall("ReleaseDC", "UInt", hDC)
}
EnumFontsCallback(lpelf) {
FontList.Push(StrGet(lpelf + 28, 32))
Return True
}
EnumFonts()
aa:=FontList.MaxIndex()
return
;--------------------------------------------------------------
;==============================================================
other examples if don't know the FONT-name
needs to download otfinfo.exe to get FONT-name
Code: Select all
;- Modified = 20160312
;- Created = 20160312
;- Description = a testscript to show/select/change [ fonts , font-size, text-color ]
/*
https://autohotkey.com/boards/viewtopic.php?f=6&t=813
CustomFont v2.00 (2016-2-24) user tmplinshi
Description: Load font from file or resource, without needed install to system.
https://gist.github.com/tmplinshi/7717340
https://www.dropbox.com/s/4h4e559tggvk1cq/Class_CustomFont_Samples.7z?raw=1
*/
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
ifnotexist,otfinfo.exe
{
msgbox,download otfinfo.exe from=`nhttp://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe
exitapp
}
;- maybe automatically download otfinfo.exe
; ifnotexist,otfinfo.exe
; urldownloadtofile,http://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe,otfinfo.exe
extensions:="otf,ttf"
Gui,3: default
Gui,3:Color, Black
Gui,3:Color, ControlColor, Black
Gui,3:Font,,FixedSys
Menu,S1,add,Script_Forum_AHK ,MH1
Menu,S1,add,Script_Source ,MH1
Menu,S1,add,Script_Script_ZIP ,MH1
Menu,S1,add,Ahk_Font_Help ,MH1
Menu,S1,add,OTFINFO_HELP ,MH1
Menu,S1,add,OTFINFO_Download ,MH1
Menu,S1,add,SKAN ,MH1
Menu,S1,add,Latofonts ,MH1
Menu,S1,add,FontsOldSchool ,MH1
Menu,S1,add,Fontsquirrel ,MH1
Menu,S2,add,AHK_Version ,MH2
Menu,S3,add,WindowsFonts ,MH3
;----------------------------
menu,myMenuBar,Add,FONT_Help ,:S1
menu,myMenuBar,Add,AHK_Version ,:S2
menu,myMenuBar,Add,WindowsFonts ,:S3
;----------------------------
gui,3:menu,MyMenuBar
;----------------------------
Gui,3:add,edit ,x10 y10 h180 w470 vED1 hwndhText cYellow,Line1_Test`nLine2_Test`nLine3_Test
Gui,3:add,edit ,x10 y200 h25 w470 readonly cRed vED2,Fixedsys
Gui,3:add,button ,x10 y240 h25 w80 gStart1,Start
Gui,3:add,button ,x100 y240 h25 w80 gStop1 ,Stop
Gui,3:show ,x10 y10 h275 w500,FONTS_TEST
Guicontrol,3:focus,ed2
return
;---------------------------------------------------------------
3Guiclose:
exitapp
;---------------------------------------------------------------
start1:
breakloop=0
sleep,2000 ;- see FONT from GUI
gosub,a1 ;- see FONT example-1
sleep,3000
gosub,a2 ;- see FONTs from C:\WINDOWS\FONTS
return
stop1:
breakloop=1
return
mh1:
if A_thisMenuItem=Script_Forum_AHK
run,https://autohotkey.com/boards/viewtopic.php?f=6&t=813 ;- classcustomfont tmplinshi
if A_thisMenuItem=Script_Source
run,https://gist.github.com/tmplinshi/7717340
if A_thisMenuItem=Script_ZIP
run,https://www.dropbox.com/s/4h4e559tggvk1cq/Class_CustomFont_Samples.7z?raw=1
if A_thisMenuItem=Ahk_Font_Help
run,https://autohotkey.com/docs/misc/FontsStandard.htm
if A_thisMenuItem=otfinfo_Help
run,http://www.lcdf.org/type/otfinfo.1.html
if A_thisMenuItem=otfinfo_Download
run,http://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe
if A_thisMenuItem=SKAN
run,https://autohotkey.com/board/topic/29396-crazy-scripting-include-and-use-truetype-font-from-script/
if A_thisMenuItem=Latofonts
run,http://www.latofonts.com/lato-free-fonts/
if A_thisMenuItem=Fontsquirrel
run,http://www.fontsquirrel.com/tools/webfont-generator
if A_thisMenuItem=FontsOldSchool
run,http://int10h.org/oldschool-pc-fonts/
Guicontrol,3:focus,ed2
return
mh2:
if A_thisMenuItem=AHK_version
msgbox, 262208,AHK_Version ,Ahk-Version =%A_AHKVERSION%
Guicontrol,3:focus,ed2
return
mh3:
ifexist,C:\windows\fonts
run,C:\windows\fonts
Guicontrol,3:focus,ed2
return
;------ example-1 or ahk ------------------------------------------------------
a1:
Gui,3:submit,nohide
;- color c510B01 =brown
filex:="CHOCD TRIAL___.otf"
ifexist,%filex%
{
Font1 := New CustomFont(filex)
Gui,3: Font, s100 cGray, Chocolate Dealer ;- change text-COLOR / SIZE / FONT
Guicontrol,3: ,ED2,Chocolate Dealer
}
else
{
;Gui,3: font, cGray, ;- change text-COLOR Edit ED1
Gui,3: font, s14 cGray, Lucida Console ;- change text-COLOR / SIZE / FONT
Guicontrol,3: ,ED2,Lucida Console
}
Guicontrol,3: Font, ED1
Guicontrol,3: ,ED1,%ed1% ;- maybe CHANGE TEXT
return
;---- example-2 --------------------------------------------------------
a2:
Gui,3:submit,nohide
fdx=C:\WINDOWS\Fonts
;fdx=%a_scriptdir%
ifexist,%fdx%
{
Loop,%fdx%\*.*
{
if (BreakLoop = 1)
break
If A_LoopFileExt in %Extensions%
{
f1=%A_loopfilefullpath%
if f1=
continue
pr=otfinfo -a "%f1%"
pr:=pr
F2:=StdoutToVar_CreateProcess(pr)
stringtrimright,f2,f2,2
font1:=""
fontx=res:%f1%
fontx:=fontx
;msgbox,F2=%f2%`nFONTX=%fontx%
;font1 := New CustomFont("res:moonhouse.ttf", "moonhouse", 50)
font1 := New CustomFont(fontx,F2, 50) ;- ( res:fullpath , otfinfo-name , size )
font1.applyTo(hText) ;- hwnd Edit ED1
guicontrol,3: ,ED2,%f2% ;- show otfinfo-name
fontx:=""
F2:=""
sleep,1600
}
}
}
return
;================================================================
/*
;- sample-1
#Include Class_CustomFont.ahk
Font1 := New CustomFont("CHOCD TRIAL___.otf")
Gui, Margin, 30, 10
Gui, Color, DECFB2
Gui, Font, s100 c510B01, Chocolate Dealer
Gui, Add, Text, w400, Chocolate
Gui, Show
Return
GuiClose:
ExitApp
*/
/*
;sample-2
#Include Class_CustomFont.ahk
font1 := New CustomFont("res:moonhouse.ttf", "moonhouse", 50)
font2 := New CustomFont("res:Selavy.otf", "Selavy-Regular", 20)
Gui, Color, Black
Gui, Add, Text, hwndhText1 w500 h50 c00FF00 Center, AutoHotkey
Gui, Add, Text, hwndhText2 wp hp cWhite Center, https://www.autohotkey.com/
Gui, Add, Button, xm gRemoveFont1, Remove Font1
font1.applyTo(hText1)
font2.applyTo(hText2)
Gui, Show
Return
RemoveFont1:
font1 := ""
WinSet, Redraw,, A
Return
GuiClose:
ExitApp
FileInstall, moonhouse.ttf, -
FileInstall, Selavy.otf, -
*/
;================= CustomFont.ahk tmplinshi =================================================
;- https://autohotkey.com/boards/viewtopic.php?f=6&t=813
/*
CustomFont v2.00 (2016-2-24)
---------------------------------------------------------
Description: Load font from file or resource, without needed install to system.
---------------------------------------------------------
Useage Examples:
* Load From File
font1 := New CustomFont("ewatch.ttf")
Gui, Font, s100, ewatch
* Load From Resource
Gui, Add, Text, HWNDhCtrl w400 h200, 12345
font2 := New CustomFont("res:ewatch.ttf", "ewatch", 80) ; <- Add a res: prefix to the resource name.
font2.ApplyTo(hCtrl)
* The fonts will removed automatically when script exits.
To remove a font manually, just clear the variable (e.g. font1 := "").
*/
Class CustomFont
{
static FR_PRIVATE := 0x10
__New(FontFile, FontName="", FontSize=30) {
if RegExMatch(FontFile, "i)res:\K.*", _FontFile) {
this.AddFromResource(_FontFile, FontName, FontSize)
} else {
this.AddFromFile(FontFile)
}
}
AddFromFile(FontFile) {
DllCall( "AddFontResourceEx", "Str", FontFile, "UInt", this.FR_PRIVATE, "UInt", 0 )
this.data := FontFile
}
AddFromResource(ResourceName, FontName, FontSize = 30) {
static FW_NORMAL := 400, DEFAULT_CHARSET := 0x1
nSize := this.ResRead(fData, ResourceName)
fh := DllCall( "AddFontMemResourceEx", "Ptr", &fData, "UInt", nSize, "UInt", 0, "UIntP", nFonts )
hFont := DllCall( "CreateFont", Int,FontSize, Int,0, Int,0, Int,0, UInt,FW_NORMAL, UInt,0
, Int,0, Int,0, UInt,DEFAULT_CHARSET, Int,0, Int,0, Int,0, Int,0, Str,FontName )
this.data := {fh: fh, hFont: hFont}
}
ApplyTo(hCtrl) {
SendMessage, 0x30, this.data.hFont, 1,, ahk_id %hCtrl%
}
__Delete() {
if IsObject(this.data) {
DllCall( "RemoveFontMemResourceEx", "UInt", this.data.fh )
DllCall( "DeleteObject" , "UInt", this.data.hFont )
} else {
DllCall( "RemoveFontResourceEx" , "Str", this.data, "UInt", this.FR_PRIVATE, "UInt", 0 )
}
}
; ResRead() By SKAN, from http://www.autohotkey.com/board/topic/57631-crazy-scripting-resource-only-dll-for-dummies-36l-v07/?p=609282
ResRead( ByRef Var, Key ) {
VarSetCapacity( Var, 128 ), VarSetCapacity( Var, 0 )
If ! ( A_IsCompiled ) {
FileGetSize, nSize, %Key%
FileRead, Var, *c %Key%
Return nSize
}
If hMod := DllCall( "GetModuleHandle", UInt,0 )
If hRes := DllCall( "FindResource", UInt,hMod, Str,Key, UInt,10 )
If hData := DllCall( "LoadResource", UInt,hMod, UInt,hRes )
If pData := DllCall( "LockResource", UInt,hData )
Return VarSetCapacity( Var, nSize := DllCall( "SizeofResource", UInt,hMod, UInt,hRes ) )
, DllCall( "RtlMoveMemory", Str,Var, UInt,pData, UInt,nSize )
Return 0
}
}
;=========================================================================
;--------- http://ahkscript.org/boards/viewtopic.php?f=6&t=791 ---
;-- from user cyruz
;-- Last edited by cyruz on Sun Mar 09, 2014 12:51 pm, edited 6 times in total
StdoutToVar_CreateProcess(sCmd, sDir:="", ByRef nExitCode:=0) {
DllCall( "CreatePipe", PtrP,hStdOutRd, PtrP,hStdOutWr, Ptr,0, UInt,0 )
DllCall( "SetHandleInformation", Ptr,hStdOutWr, UInt,1, UInt,1 )
VarSetCapacity( pi, (A_PtrSize == 4) ? 16 : 24, 0 )
siSz := VarSetCapacity( si, (A_PtrSize == 4) ? 68 : 104, 0 )
NumPut( siSz, si, 0, "UInt" )
NumPut( 0x100, si, (A_PtrSize == 4) ? 44 : 60, "UInt" )
NumPut( hStdInRd, si, (A_PtrSize == 4) ? 56 : 80, "Ptr" )
NumPut( hStdOutWr, si, (A_PtrSize == 4) ? 60 : 88, "Ptr" )
NumPut( hStdOutWr, si, (A_PtrSize == 4) ? 64 : 96, "Ptr" )
If ( !DllCall( "CreateProcess", Ptr,0, Ptr,&sCmd, Ptr,0, Ptr,0, Int,True, UInt,0x08000000
, Ptr,0, Ptr,sDir?&sDir:0, Ptr,&si, Ptr,&pi ) )
Return ""
, DllCall( "CloseHandle", Ptr,hStdOutWr )
, DllCall( "CloseHandle", Ptr,hStdOutRd )
DllCall( "CloseHandle", Ptr,hStdOutWr ) ; The write pipe must be closed before reading the stdout.
VarSetCapacity(sTemp, 4095)
While ( DllCall( "ReadFile", Ptr,hStdOutRd, Ptr,&sTemp, UInt,4095, PtrP,nSize, Ptr,0 ) )
sOutput .= StrGet(&sTemp, nSize, A_FileEncoding)
DllCall( "GetExitCodeProcess", Ptr,NumGet(pi,0), Ptr,&nExitCode ), nExitCode := NumGet(nExitCode)
DllCall( "CloseHandle", Ptr,NumGet(pi,0) )
DllCall( "CloseHandle", Ptr,NumGet(pi,A_PtrSize) )
DllCall( "CloseHandle", Ptr,hStdOutRd )
Return sOutput
}
;------------------------------------------------------------------------------------------------------
;====================== end script ====================================================================
used installed C:\WINDOWS\FONTS ( in this case without function ClassCustomFont )
downloads otfinfo.exe to get FONT-name
Code: Select all
;- Modified = 20160312
;- Created = 20160312
;- Description = a testscript to show/select/change [ fonts , font-size, text-color ] with ahk
; this script uses C:\WINDOWS\FONTS
;- Needs = downloads otfinfo.exe to get FONT-name
---------------------------------------------------------
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
ifnotexist,otfinfo.exe
urldownloadtofile,http://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe,otfinfo.exe
extensions:="otf,ttf"
Menu,S2,add,AHK_Version ,MH2
Menu,S3,add,WindowsFonts ,MH3
;----------------------------
menu,myMenuBar,Add,AHK_Version ,:S2
menu,myMenuBar,Add,WindowsFonts ,:S3
;----------------------------
gui,3:menu,MyMenuBar
;----------------------------
Gui,3: default
Gui,3:Color, Black
Gui,3:Color, ControlColor, Black
Gui,3:Font,,FixedSys
Gui,3:add,edit ,x10 y10 h180 w470 vED1 hwndhText cYellow,Line1_Test`nLine2_Test`nLine3_Test
Gui,3:add,edit ,x10 y200 h25 w470 readonly cRed vED2,Fixedsys
Gui,3:add,edit ,x10 y230 h25 w470 readonly cYellow vED3,
Gui,3:add,button ,x10 y270 h25 w80 gStart1,Start
Gui,3:add,button ,x100 y270 h25 w80 gStop1 ,Stop
Gui,3:show ,x10 y10 h305 w500,WINDOWS-FONTS_TEST
Guicontrol,3:focus,ed2
return
;---------------------------------------------------------------
3Guiclose:
exitapp
;---------------------------------------------------------------
start1:
breakloop=0
sleep,2000 ;- see FONT from GUI
gosub,a1 ;- see FONT example-1
sleep,3000
gosub,a2 ;- see FONTs from C:\WINDOWS\FONTS
return
stop1:
breakloop=1
return
mh2:
if A_thisMenuItem=AHK_version
msgbox, 262208,AHK_Version ,Ahk-Version =%A_AHKVERSION%
Guicontrol,3:focus,ed2
return
mh3:
ifexist,C:\windows\fonts
run,C:\windows\fonts
Guicontrol,3:focus,ed2
return
;------ example-1 ------------------------------------------------------
a1:
Gui,3:submit,nohide
Gui,3: font, s14 cGray, Lucida Console ;- change text-COLOR / SIZE / FONT
Guicontrol,3: ,ED2,Lucida Console
Guicontrol,3: Font, ED1
Guicontrol,3: ,ED1,%ed1% ;- maybe CHANGE TEXT
return
;---- example-2 --------------------------------------------------------
a2:
Gui,3:submit,nohide
fdx=C:\WINDOWS\Fonts
ifexist,%fdx%
{
Loop,%fdx%\*.*
{
if (BreakLoop = 1)
break
If A_LoopFileExt in %Extensions%
{
f1=%A_loopfilefullpath%
if f1=
continue
SplitPath,f1, name, dir, ext, name_no_ext, drive
pr=otfinfo -a "%f1%"
pr:=pr
F2:=StdoutToVar_CreateProcess(pr)
stringtrimright,f2,f2,2
Gui,3: font, s40 cTeal,%f2% ;- change text-COLOR / SIZE / FONT
Guicontrol,3: ,ED2,%f2%
Guicontrol,3: ,ED3,%name%
Guicontrol,3: Font, ED1
Guicontrol,3: ,ED1,%ed1%
F2:=""
pr:=""
sleep,1500
}
}
}
return
;================================================================
;--------- http://ahkscript.org/boards/viewtopic.php?f=6&t=791 ---
;-- from user cyruz
;-- Last edited by cyruz on Sun Mar 09, 2014 12:51 pm, edited 6 times in total
StdoutToVar_CreateProcess(sCmd, sDir:="", ByRef nExitCode:=0) {
DllCall( "CreatePipe", PtrP,hStdOutRd, PtrP,hStdOutWr, Ptr,0, UInt,0 )
DllCall( "SetHandleInformation", Ptr,hStdOutWr, UInt,1, UInt,1 )
VarSetCapacity( pi, (A_PtrSize == 4) ? 16 : 24, 0 )
siSz := VarSetCapacity( si, (A_PtrSize == 4) ? 68 : 104, 0 )
NumPut( siSz, si, 0, "UInt" )
NumPut( 0x100, si, (A_PtrSize == 4) ? 44 : 60, "UInt" )
NumPut( hStdInRd, si, (A_PtrSize == 4) ? 56 : 80, "Ptr" )
NumPut( hStdOutWr, si, (A_PtrSize == 4) ? 60 : 88, "Ptr" )
NumPut( hStdOutWr, si, (A_PtrSize == 4) ? 64 : 96, "Ptr" )
If ( !DllCall( "CreateProcess", Ptr,0, Ptr,&sCmd, Ptr,0, Ptr,0, Int,True, UInt,0x08000000
, Ptr,0, Ptr,sDir?&sDir:0, Ptr,&si, Ptr,&pi ) )
Return ""
, DllCall( "CloseHandle", Ptr,hStdOutWr )
, DllCall( "CloseHandle", Ptr,hStdOutRd )
DllCall( "CloseHandle", Ptr,hStdOutWr ) ; The write pipe must be closed before reading the stdout.
VarSetCapacity(sTemp, 4095)
While ( DllCall( "ReadFile", Ptr,hStdOutRd, Ptr,&sTemp, UInt,4095, PtrP,nSize, Ptr,0 ) )
sOutput .= StrGet(&sTemp, nSize, A_FileEncoding)
DllCall( "GetExitCodeProcess", Ptr,NumGet(pi,0), Ptr,&nExitCode ), nExitCode := NumGet(nExitCode)
DllCall( "CloseHandle", Ptr,NumGet(pi,0) )
DllCall( "CloseHandle", Ptr,NumGet(pi,A_PtrSize) )
DllCall( "CloseHandle", Ptr,hStdOutRd )
Return sOutput
}
;------------------------------------------------------------------------------------------------------
;====================== end script ====================================================================