|
2
|
Special User Sections / Site/Forum Features / Re: Discussion: How can we Improve DonationCoder?
|
on: April 28, 2010, 08:41:18 AM
|
 Love DC, great content, but the design is a bit dated. We need a changing start page to let everyone know what's inside, something like HowStuffWorks.com. Show the lastest threads in the most active forums, the latest test and reviews, the latest programs from Coding Snacks, the latest tutorials, the greates bargains, with pictures, movies and people. The forum too doesn't show the depth of things, it needs to be arranged, or get a better start page. It probably takes a new framework, but then we could have tags, clouds, likes and dislikes, Facebook integration and whatnot. Looking forward to the future. Skrommel
|
|
|
|
|
4
|
DonationCoder.com Software / Finished Programs / InEverything - Search inside files using the Everything search engine
|
on: June 20, 2009, 06:33:08 PM
|
 The worlds fastest unindexed search? InEverything - Search inside files using the Everything NTFS search engine. I use Everything to search for files, but it doesn't search inside files, so I've thrown together a solution. Beta. To run the script, you need to download Everything and ES from http://www.voidtools.com/download.php. Install Everything, turn on Tools - Options - ETP/FTP and check Start ETP/FTP server on startup. Plase ES.exe next to the script. Skrommel [ copy or print] ;InEverything.ahk ; Search fast inside files using the Everything NTFS search engine ;Skrommel @ 2009 find=*.ahk needle=Skrommel FileInstall,Everything.exe,Everything.exe FileInstall,Everything.chm,Everything.chm FileInstall,Everything.ini,Everything.ini FileInstall,ES.exe,ES.exe #NoEnv #SingleInstance,Force SetBatchLines,-1 SendMode,Input SetWorkingDir,%A_ScriptDir% SetTitleMatchMode=Slow applicationname=InEverything Gui,+Resize Gui,Add,Text,xm w200,Files: (supports wildcards * and ?) Gui,Add,Text,x+5 w300,Text: (case sensitive, no wildcards) Gui,Add,Edit,xm w200 Vfind,%find% Gui,Add,Edit,x+5 w300 Vneedle,%needle% Gui,Add,Button,x+5 yp-1 Default Vstart GSTART,&Search Gui,Add,Button,x+5 yp Vstop GSTOP,S&top Gui,Add,ListView,xm Vlistview GLISTVIEW AltSubmit,File|Path|Ext|Modified|Size|Attrib|Position|%A_Space% Gui,Show,,%applicationname% Gui,+LastFound guiid:=WinExist() LV_ModifyCol(5,"Integer") LV_ModifyCol(7,"Integer") LV_ModifyCol(8,"Integer") GuiControl,Disable,start GuiControl,Disable,stop WinSetTitle,ahk_id %guiid%,,%applicationname% - Waiting for Everything... Loop { IfWinNotExist,ahk_class EVERYTHING Run,Everything.exe,,Minimized Sleep,1000 WinGetText,text,ahk_class EVERYTHING IfInString,text,objects Break IfInString,text,selected Break If A_Index=30 { MsgBox,0,%applicationname%,Unable to start Everything! ExitApp } } WinSetTitle,ahk_id %guiid%,,%applicationname% GuiControl,Enable,start GuiControl,Enable,stop Return LISTVIEW: If A_GuiEvent=RightClick { LV_GetText(file,A_EventInfo,1) LV_GetText(path,A_EventInfo,2) sPath:=path "\" file ShellContextMenu(sPath<>"" ? sPath : 0x0011) } If A_GuiEvent=DoubleClick { LV_GetText(file,A_EventInfo,1) LV_GetText(path,A_EventInfo,2) Run,%path%\%file%,,UseErrorLevel If ErrorLevel=1 MsgBox,Could not open "%path%\%file%". } Return START: If stop<>1 Gosub,STOP LV_Delete() Gui,Submit,NoHide stop=0 total=0 searched=0 matching=0 SetTimer,FINISHED,-1000 Goto,SEARCH Return STOP: stop=1 WinClose,ahk_pid %cmdretPID% cmdretPID=0 Return FINISHED: If stop=1 { WinSetTitle,ahk_id %guiid%,,%applicationname% - Stopped searching through %searched% of %total% %find%-files for "%needle%". Found %matching% matching files. Return } Process,Exist,%cmdretPID% running:=ErrorLevel If (running=0 And searched=total) WinSetTitle,ahk_id %guiid%,,%applicationname% - Finished searching through %total% %find%-files for "%needle%". Found %matching% matching files. Else { WinSetTitle,ahk_id %guiid%,,%applicationname% - Searching through %searched% og %total% %find%-files for "%needle%". Found %matching% matching files... SetTimer,FINISHED,-1000 } Loop,8 LV_ModifyCol(A_Index,"AutoHdr") Return SEARCH: CMDret_Stream("es.exe " find) Return GuiClose: Gosub,STOP ;WinClose,ahk_class EVERYTHING ExitApp GuiSize: If ErrorLevel=1 ;minimized Return GuiControlGet,pos,Pos,listview width:=A_GuiWidth-posx-10 height:=A_GuiHeight-posy-10 GuiControl,Move,listview,W%width% H%height% Return CMDret_Output(CMDout, CMDname="") ; CMDout - each line of output returned (1 line each time) ; CMDname - type of output to process (Optional) { Global needle,stop,searched,matching If stop=1 Return If CMDout<> { offset=0 If needle<> offset:=FINDINFILE(CMDout,needle) If offset>-1 { FileGetAttrib,attrib,% CMDout FileGetTime,modified,% CMDout,M FormatTime,modified,%modified%,yyyy-MM-dd HH:mm:ss FileGetSize,size,% CMDout, SplitPath,CMDout,name,dir,ext,name_no_ext,drive LV_Add("",name,dir,ext,modified,size,attrib,offset) matching+=1 } } searched+=1 Return } FINDINFILE(file,needle) { offset:=InFile(file,&needle,StrLen(needle),0) Return,% offset } FINDALLINFILE(file,needle) { found= offset=-1 Loop { offset:=InFile(file,&needle,StrLen(needle),offset+1) If offset=-1 Break found.=offset "," } StringTrimRight,found,found,1 Return,% found } ;Stolen from wOxxOm at http://www.autohotkey.com/forum/topic25925.html ;InFile - InBuf based case-sensitive searching in file's contents of any* size ;*: even larger than 4GB, StartOffset may also be larger than 4GB. ;Usage: ;fileOffs:=InFile( "d:\filename", &needle, needleLen, StartOffset ) InFile( fileName, needleAddr, needleLen, StartOffset=0 ) { lRet=-1 IfEqual,needleLen,0, return lRet IfEqual,needleAddr,0, return lRet hFile:=DllCall("CreateFile", "str", fileName,"uint",0x80000000 ;GENERIC_READ ,"uint", 1 ;FILE_SHARE_READ ,"uint", 0, "uint",3 ;OPEN_EXISTING ,"uint",0x2000000 ;FILE_FLAG_BACKUP_SEMANTICS ,"uint", 0) ifEqual,hFile,-1, return lRet VarSetCapacity( lBufLen, 8, 0 ) NumPut( DllCall("GetFileSize","uint",hFile,"uint",&lBufLen+4), lBufLen ) DllCall( "RtlMoveMemory", "int64 *",lBufLen64, "uint",&lBufLen, "uint",8 ) lBufLen64 -= StartOffset If( lBufLen64>=0 ) { hMap:=DllCall("CreateFileMapping", "uint",hFile, "uint",0, "uint",2 ;PAGE_READONLY ,"uint",0,"uint",0,"uint",0) if( hMap ) { lMax32b=0xFFFFFFFF lMaxView=0x40000000 ;1GB VarSetCapacity( SI, 36, 0 ) DllCall("GetSystemInfo","uint",&SI) memAllocGranularity:=NumGet( SI, 28 ) loop { FileOffs:=(StartOffset//memAllocGranularity)*memAllocGranularity delta:=StartOffset-FileOffs lBufLenLo:=(lBufLen64+delta > lMaxView) ? lMaxView : lBufLen64+delta hView:=DllCall("MapViewOfFile", "uint",hMap, "uint", 4 ;FILE_MAP_READ ,"uint",FileOffs>>32,"uint",FileOffs & lMax32b,"uint",lBufLenLo) ifEqual,hView,0, break lRet:=InBuf( hView, needleAddr, lBufLenLo, needleLen, delta ) DllCall("UnmapViewOfFile","uint",hView) if( lRet!=-1 ) { lRet += FileOffs break } StartOffset += lBufLenLo-needleLen lBufLen64 -= lBufLenLo-needleLen IfLessOrEqual,lBufLen64,0, break } DllCall("CloseHandle","uint",hMap) } } DllCall("CloseHandle","uint",hFile) return lRet } InBuf(haystackAddr, needleAddr, haystackSize, needleSize, StartOffset=0) { Static fun IfEqual,fun, { h= ( LTrim join 5589E583EC0C53515256579C8B5D1483FB000F8EC20000008B4D108B451829C129D9410F8E B10000008B7D0801C78B750C31C0FCAC4B742A4B742D4B74364B74144B753F93AD93F2AE0F 858B000000391F75F4EB754EADF2AE757F3947FF75F7EB68F2AE7574EB628A26F2AE756C38 2775F8EB569366AD93F2AE755E66391F75F7EB474E43AD8975FC89DAC1EB02895DF483E203 8955F887DF87D187FB87CAF2AE75373947FF75F789FB89CA83C7038B75FC8B4DF485C97404 F3A775DE8B4DF885C97404F3A675D389DF4F89F82B45089D5F5E5A595BC9C2140031C0F7D0EBF0 ) VarSetCapacity(fun,StrLen(h)//2) Loop % StrLen(h)//2 NumPut("0x" . SubStr(h,2*A_Index-1,2), fun, A_Index-1, "Char") } Return DllCall(&fun , "uint",haystackAddr, "uint",needleAddr , "uint",haystackSize, "uint",needleSize , "uint",StartOffset) } ;Stolen from corrupt at http://www.autohotkey.com/forum/topic8606.html ; ****************************************************************** ; CMDret-AHK functions by corrupt ; ; CMDret_Stream ; version 0.03 beta ; Updated: Feb 19, 2007 ; ; CMDret code modifications and/or contributions have been made by: ; Laszlo, shimanov, toralf, Wdb ; ****************************************************************** ; Usage: ; CMDin - command to execute ; CMDname - type of output to process (Optional) ; WorkingDir - full path to working directory (Optional) ; ****************************************************************** ; Known Issues: ; - If using dir be sure to specify a path (example: cmd /c dir c:\) ; or specify a working directory ; - Running 16 bit console applications may not produce output. Use ; a 32 bit application to start the 16 bit process to receive output ; ****************************************************************** ; Additional requirements: ; - Your script must also contain a CMDret_Output function ; ; CMDret_Output(CMDout, CMDname="") ; Usage: ; CMDout - each line of output returned (1 line each time) ; CMDname - type of output to process (Optional) ; ****************************************************************** ; Code Start ; ****************************************************************** CMDret_Stream(CMDin, CMDname="", WorkingDir=0) { Global cmdretPID,total tcWrk := WorkingDir=0 ? "Int" : "Str" idltm := A_TickCount + 20 LivePos = 1 VarSetCapacity(CMDout, 1, 32) VarSetCapacity(sui,68, 0) VarSetCapacity(pi, 16, 0) VarSetCapacity(pa, 12, 0) Loop, 4 { DllCall("RtlFillMemory", UInt,&pa+A_Index-1, UInt,1, UChar,12 >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&pa+8+A_Index-1, UInt,1, UChar,1 >> 8*A_Index-8) } IF (DllCall("CreatePipe", "UInt*",hRead, "UInt*",hWrite, "UInt",&pa, "Int",0) <> 0) { Loop, 4 DllCall("RtlFillMemory", UInt,&sui+A_Index-1, UInt,1, UChar,68 >> 8*A_Index-8) DllCall("GetStartupInfo", "UInt", &sui) Loop, 4 { DllCall("RtlFillMemory", UInt,&sui+44+A_Index-1, UInt,1, UChar,257 >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&sui+60+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&sui+64+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&sui+48+A_Index-1, UInt,1, UChar,0 >> 8*A_Index-8) } IF (DllCall("CreateProcess", Int,0, Str,CMDin, Int,0, Int,0, Int,1, "UInt",0, Int,0, tcWrk, WorkingDir, UInt,&sui, UInt,&pi) <> 0) { Loop, 4 cmdretPID += *(&pi+8+A_Index-1) << 8*A_Index-8 Loop { idltm2 := A_TickCount - idltm If (idltm2 < 15) { DllCall("Sleep", Int, 15) Continue } IF (DllCall("PeekNamedPipe", "uint", hRead, "uint", 0, "uint", 0, "uint", 0, "uint*", bSize, "uint", 0 ) <> 0 ) { Process, Exist, %cmdretPID% IF (ErrorLevel OR bSize > 0) { IF (bSize > 0) { VarSetCapacity(lpBuffer, bSize+1, 0) IF (DllCall("ReadFile", "UInt",hRead, "Str", lpBuffer, "Int",bSize, "UInt*",bRead, "Int",0) > 0) { IF (bRead > 0) { IF (StrLen(lpBuffer) < bRead) { VarSetCapacity(CMcpy, bRead, 32) bRead2 = %bRead% Loop { DllCall("RtlZeroMemory", "UInt", &CMcpy, Int, bRead) NULLptr := StrLen(lpBuffer) cpsize := bread - NULLptr DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", (&lpBuffer + NULLptr + 2), "Int", (cpsize - 1)) DllCall("RtlZeroMemory", "UInt", (&lpBuffer + NULLptr), Int, cpsize) DllCall("RtlMoveMemory", "UInt", (&lpBuffer + NULLptr), "UInt", &CMcpy, "Int", cpsize) bRead2 -- IF (StrLen(lpBuffer) > bRead2) break } } VarSetCapacity(lpBuffer, -1) CMDout .= lpBuffer bRead = 0 } } } } ELSE break } ELSE break idltm := A_TickCount LiveFound := RegExMatch(CMDout, "m)^(.*)", LiveOut, LivePos) If (LiveFound) SetTimer, cmdretSTR, 5 } cmdretPID= DllCall("CloseHandle", UInt, hWrite) DllCall("CloseHandle", UInt, hRead) } } StringTrimLeft, LiveRes, CMDout, %LivePos% If LiveRes <> Loop, Parse, LiveRes, `n { FileLine = %A_LoopField% StringTrimRight, FileLine, FileLine, 1 total+=1 CMDret_Output(FileLine, CMDname) } StringTrimLeft, CMDout, CMDout, 1 cmdretPID = 0 Return, CMDout cmdretSTR: SetTimer, cmdretSTR, Off If (LivePosLast <> LiveFound) { FileLine = %LiveOut1% LivePos := LiveFound + StrLen(FileLine) + 1 LivePosLast := LivePos total+=1 CMDret_Output(FileLine, CMDname) } Return } ;Stolen from Sean at http://www.autohotkey.com/forum/topic22120.html ShellContextMenu(sPath) { CoInitialize() If sPath Is Not Integer DllCall("shell32\SHParseDisplayName", "Uint", Unicode4Ansi(wPath,sPath), "Uint", 0, "UintP", pidl, "Uint", 0, "Uint", 0) Else DllCall("shell32\SHGetFolderLocation", "Uint", 0, "int", sPath, "Uint", 0, "Uint", 0, "UintP", pidl) DllCall("shell32\SHBindToParent", "Uint", pidl, "Uint", GUID4String(IID_IShellFolder,"{000214E6-0000-0000-C000-000000000046}"), "UintP", psf, "UintP", pidlChild) DllCall(NumGet(NumGet(1*psf)+40), "Uint", psf, "Uint", 0, "Uint", 1, "UintP", pidlChild, "Uint", GUID4String(IID_IContextMenu,"{000214E4-0000-0000-C000-000000000046}"), "Uint", 0, "UintP", pcm) Release(psf) CoTaskMemFree(pidl) hMenu := DllCall("CreatePopupMenu") DllCall(NumGet(NumGet(1*pcm)+12), "Uint", pcm, "Uint", hMenu, "Uint", 0, "Uint", 3, "Uint", 0x7FFF, "Uint", 0) ; QueryContextMenu DetectHiddenWindows, On Process, Exist WinGet, hAHK, ID, ahk_pid %ErrorLevel% WinActivate, ahk_id %hAHK% Global pcm2 := QueryInterface(pcm,IID_IContextMenu2:="{000214F4-0000-0000-C000-000000000046}") Global pcm3 := QueryInterface(pcm,IID_IContextMenu3:="{BCFCE0A0-EC17-11D0-8D10-00A0C90F2719}") Global WPOld:= DllCall("SetWindowLong", "Uint", hAHK, "int",-4, "int",RegisterCallback("WindowProc")) DllCall("GetCursorPos", "int64P", pt) DllCall("InsertMenu", "Uint", hMenu, "Uint", 0, "Uint", 0x0400|0x800, "Uint", 2, "Uint", 0) DllCall("InsertMenu", "Uint", hMenu, "Uint", 0, "Uint", 0x0400|0x002, "Uint", 1, "Uint", &sPath) idn := DllCall("TrackPopupMenu", "Uint", hMenu, "Uint", 0x0100, "int", pt << 32 >> 32, "int", pt >> 32, "Uint", 0, "Uint", hAHK, "Uint", 0) NumPut(VarSetCapacity(ici,64,0),ici), NumPut(0x4000|0x20000000,ici,4), NumPut(1,NumPut(hAHK,ici,8),12), NumPut(idn-3,NumPut(idn-3,ici,12),24), NumPut(pt,ici,56,"int64") DllCall(NumGet(NumGet(1*pcm)+16), "Uint", pcm, "Uint", &ici) ; InvokeCommand ; VarSetCapacity(sName,259), DllCall(NumGet(NumGet(1*pcm)+20), "Uint", pcm, "Uint", idn-3, "Uint", 1, "Uint", 0, "str", sName, "Uint", 260) ; GetCommandString DllCall("GlobalFree", "Uint", DllCall("SetWindowLong", "Uint", hAHK, "int", -4, "int", WPOld)) DllCall("DestroyMenu", "Uint", hMenu) Release(pcm3) Release(pcm2) Release(pcm) CoUninitialize() pcm2:=pcm3:=WPOld:=0 } WindowProc(hWnd, nMsg, wParam, lParam) { Critical Global pcm2, pcm3, WPOld If pcm3 { If !DllCall(NumGet(NumGet(1*pcm3)+28), "Uint", pcm3, "Uint", nMsg, "Uint", wParam, "Uint", lParam, "UintP", lResult) Return lResult } Else If pcm2 { If !DllCall(NumGet(NumGet(1*pcm2)+24), "Uint", pcm2, "Uint", nMsg, "Uint", wParam, "Uint", lParam) Return 0 } Return DllCall("user32.dll\CallWindowProcA", "Uint", WPOld, "Uint", hWnd, "Uint", nMsg, "Uint", wParam, "Uint", lParam) } VTable(ppv, idx) { Return NumGet(NumGet(1*ppv)+4*idx) } QueryInterface(ppv, ByRef IID) { If StrLen(IID)=38 GUID4String(IID,IID) DllCall(NumGet(NumGet(1*ppv)), "Uint", ppv, "str", IID, "UintP", ppv) Return ppv } AddRef(ppv) { Return DllCall(NumGet(NumGet(1*ppv)+4), "Uint", ppv) } Release(ppv) { Return DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv) } QueryService(ppv, ByRef SID, ByRef IID) { If StrLen(SID)=38 GUID4String(SID,SID) If StrLen(IID)=38 GUID4String(IID,IID) GUID4String(IID_IServiceProvider,"{6D5140C1-7436-11CE-8034-00AA006009FA}") DllCall(NumGet(NumGet(1*ppv)+4*0), "Uint", ppv, "str", IID_IServiceProvider, "UintP", psp) DllCall(NumGet(NumGet(1*psp)+4*3), "Uint", psp, "str", SID, "str", IID, "UintP", ppv) DllCall(NumGet(NumGet(1*psp)+4*2), "Uint", psp) Return ppv } FindConnectionPoint(pdp, DIID) { DllCall(NumGet(NumGet(1*pdp)+ 0), "Uint", pdp, "Uint", GUID4String(IID_IConnectionPointContainer,"{B196B284-BAB4-101A-B69C-00AA00341D07}"), "UintP", pcc) DllCall(NumGet(NumGet(1*pcc)+16), "Uint", pcc, "Uint", GUID4String(DIID,DIID), "UintP", pcp) DllCall(NumGet(NumGet(1*pcc)+ 8), "Uint", pcc) Return pcp } GetConnectionInterface(pcp) { VarSetCapacity(DIID, 16, 0) DllCall(NumGet(NumGet(1*pcp)+12), "Uint", pcp, "str", DIID) Return String4GUID(&DIID) } Advise(pcp, psink) { DllCall(NumGet(NumGet(1*pcp)+20), "Uint", pcp, "Uint", psink, "UintP", nCookie) Return nCookie } Unadvise(pcp, nCookie) { Return DllCall(NumGet(NumGet(1*pcp)+24), "Uint", pcp, "Uint", nCookie) } /* Enumerate(penum, ByRef Result) { VarSetCapacity(varResult,16,0) If (0 = hResult:=DllCall(NumGet(NumGet(1*penum)+12), "Uint", penum, "Uint", 1, "Uint", &varResult, "UintP", 0)) Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(SysFreeString(bstr),1,0) : NumGet(varResult,8) Return hResult } */ Invoke(pdisp, sName, arg1="vT_NoNe",arg2="vT_NoNe",arg3="vT_NoNe",arg4="vT_NoNe",arg5="vT_NoNe",arg6="vT_NoNe",arg7="vT_NoNe",arg8="vT_NoNe",arg9="vT_NoNe") { nParams:=0 Loop, 9 If (arg%A_Index% == "vT_NoNe") Break Else ++nParams VarSetCapacity(DispParams,16,0), VarSetCapacity(varResult,16,0), VarSetCapacity(IID_NULL,16,0), VarSetCapacity(varg,nParams*16,0) NumPut(&varg,DispParams,0), NumPut(nParams,DispParams,8) If (nFlags := SubStr(sName,0) <> "=" ? 3 : 12) = 12 NumPut(&varResult,DispParams,4), NumPut(1,DispParams,12), NumPut(-3,varResult), sName:=SubStr(sName,1,-1) Loop, % nParams If arg%A_Index% Is Not Integer NumPut(8,varg,(nParams-A_Index)*16,"Ushort"), NumPut(SysAllocString(arg%A_Index%),varg,(nParams-A_Index)*16+8) Else NumPut(SubStr(arg%A_Index%,1,1)="+" ? 9 : 3,varg,(nParams-A_Index)*16,"Ushort"), NumPut(arg%A_Index%,varg,(nParams-A_Index)*16+8) If DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)=0 && DllCall(NumGet(NumGet(1*pdisp)+24), "Uint", pdisp, "int", dispID, "Uint", &IID_NULL, "Uint", LCID, "Ushort", nFlags, "Uint", &dispParams, "Uint", &varResult, "Uint", 0, "Uint", 0)=0 && nFlags = 3 Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(SysFreeString(bstr),1,0) : NumGet(varResult,8) Loop, % nParams NumGet(varg,(A_Index-1)*16,"Ushort")=8 ? SysFreeString(NumGet(varg,(A_Index-1)*16+8)) : "" Return Result } Invoke_(pdisp, sName, type1="",arg1="",type2="",arg2="",type3="",arg3="",type4="",arg4="",type5="",arg5="",type6="",arg6="",type7="",arg7="",type8="",arg8="",type9="",arg9="") { nParams:=0 Loop, 9 If (type%A_Index% = "") Break Else ++nParams VarSetCapacity(dispParams,16,0), VarSetCapacity(varResult,16,0), VarSetCapacity(IID_NULL,16,0), VarSetCapacity(varg,nParams*16,0) NumPut(&varg,dispParams,0), NumPut(nParams,dispParams,8) If (nFlags := SubStr(sName,0) <> "=" ? 1|2 : 4|8) & 12 NumPut(&varResult,dispParams,4), NumPut(1,dispParams,12), NumPut(-3,varResult), sName:=SubStr(sName,1,-1) Loop, % nParams NumPut(type%A_Index%,varg,(nParams-A_Index)*16,"Ushort"), type%A_Index%&0x4000=0 ? NumPut(type%A_Index%=8 ? SysAllocString(arg%A_Index%) : arg%A_Index%,varg,(nParams-A_Index)*16+8,type%A_Index%=5||type%A_Index%=7 ? "double" : type%A_Index%=4 ? "float" : "int64") : type%A_Index%=0x400C||type%A_Index%=0x400E ? NumPut(arg%A_Index%,varg,(nParams-A_Index)*16+8) : VarSetCapacity(ref%A_Index%,8,0) . NumPut(&ref%A_Index%,varg,(nParams-A_Index)*16+8) . NumPut(type%A_Index%=0x4008 ? SysAllocString(arg%A_Index%) : arg%A_Index%,ref%A_Index%,0,type%A_Index%=0x4005||type%A_Index%=0x4007 ? "double" : type%A_Index%=0x4004 ? "float" : "int64") If DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)=0 && DllCall(NumGet(NumGet(1*pdisp)+24), "Uint", pdisp, "int", dispID, "Uint", &IID_NULL, "Uint", LCID, "Ushort", nFlags, "Uint", &dispParams, "Uint", &varResult, "Uint", 0, "Uint", 0)=0 && nFlags = 3 Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(SysFreeString(bstr),1,0) : NumGet(varResult,8) Loop, % nParams type%A_Index%&0x4000=0 ? (type%A_Index%=8 ? SysFreeString(NumGet(varg,(nParams-A_Index)*16+8)) : "") : type%A_Index%=0x400C||type%A_Index%=0x400E ? "" : type%A_Index%=0x4008 ? (_TEMP_VT_BYREF_%A_Index%:=Ansi4Unicode(NumGet(ref%A_Index%))) . SysFreeString(NumGet(ref%A_Index%)) : (_TEMP_VT_BYREF_%A_Index%:=NumGet(ref%A_Index%,0,type%A_Index%=0x4005||type%A_Index%=0x4007 ? "double" : type%A_Index%=0x4004 ? "float" : "int64")) Return Result } DispInterface(this, prm1="", prm2="", prm3="", prm4="", prm5="", prm6="", prm7="", prm8="") { Critical If A_EventInfo = 6 DllCall(NumGet(NumGet(NumGet(this+8))+28),"Uint",NumGet(this+8),"Uint",prm1,"UintP",pname,"Uint",1,"UintP",0), VarSetCapacity(sfn,63), DllCall("user32\wsprintfA","str",sfn,"str","%s%S","Uint",this+40,"Uint",pname,"Cdecl"), SysFreeString(pname), (pfn:=RegisterCallback(sfn,"C F")) ? (hResult:=DllCall(pfn, "Uint", prm5, "Uint", this, "Cdecl")) . DllCall("kernel32\GlobalFree", "Uint", pfn) : (hResult:=0x80020003) Else If A_EventInfo = 5 hResult:=DllCall(NumGet(NumGet(NumGet(this+8))+40),"Uint",NumGet(this+8),"Uint",prm2,"Uint",prm3,"Uint",prm5) Else If A_EventInfo = 4 NumPut(0,prm3+0), hResult:=0x80004001 Else If A_EventInfo = 3 NumPut(0,prm1+0), hResult:=0 Else If A_EventInfo = 2 NumPut(hResult:=NumGet(this+4)-1,this+4), hResult ? "" : Unadvise(NumGet(this+16),NumGet(this+20)) . Release(NumGet(this+16)) . Release(NumGet(this+8)) . CoTaskMemFree(this) Else If A_EventInfo = 1 NumPut(hResult:=NumGet(this+4)+1,this+4) Else If A_EventInfo = 0 IsEqualGUID(this+24,prm1)||InStr("{00020400-0000-0000-C000-000000000046}{00000000-0000-0000-C000-000000000046}",String4GUID(prm1)) ? NumPut(this,prm2+0) . NumPut(NumGet(this+4)+1,this+4) . (hResult:=0) : NumPut(0,prm2+0) . (hResult:=0x80004002) Return hResult } DispGetParam(pDispParams, Position = 0, vtType = 8) { VarSetCapacity(varResult,16,0) DllCall("oleaut32\DispGetParam", "Uint", pDispParams, "Uint", Position, "Ushort", vtType, "Uint", &varResult, "UintP", nArgErr) Return NumGet(varResult,0,"Ushort")=8 ? Ansi4Unicode(NumGet(varResult,8)) . SubStr(SysFreeString(NumGet(varResult,8)),1,0) : NumGet(varResult,8) } CreateIDispatch() { Static IDispatch If Not VarSetCapacity(IDispatch) { VarSetCapacity(IDispatch,28,0), nParams=3112469 Loop, Parse, nParams NumPut(RegisterCallback("DispInterface","",A_LoopField,A_Index-1),IDispatch,4*(A_Index-1)) } Return &IDispatch } GetDefaultInterface(pdisp, LCID = 0) { DllCall(NumGet(NumGet(1*pdisp) +12), "Uint", pdisp , "UintP", ctinf) If ctinf { DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint" , 0, "Uint", LCID, "UintP", ptinf) DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr) DllCall(NumGet(NumGet(1*pdisp)+ 0), "Uint", pdisp, "Uint" , pattr, "UintP", ppv) DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr) DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf) If ppv DllCall(NumGet(NumGet(1*pdisp)+ 8), "Uint", pdisp), pdisp := ppv } Return pdisp } GetDefaultEvents(pdisp, LCID = 0) { DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint" , 0, "Uint", LCID, "UintP", ptinf) DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr) VarSetCapacity(IID,16), DllCall("RtlMoveMemory", "Uint", &IID, "Uint", pattr, "Uint", 16) DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr) DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx) DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf) Loop, % DllCall(NumGet(NumGet(1*ptlib)+12), "Uint", ptlib) { DllCall(NumGet(NumGet(1*ptlib)+20), "Uint", ptlib, "Uint", A_Index-1, "UintP", TKind) If TKind <> 5 Continue DllCall(NumGet(NumGet(1*ptlib)+16), "Uint", ptlib, "Uint", A_Index-1, "UintP", ptinf) DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr) nCount:=NumGet(pattr+48,0,"Ushort") DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr) Loop, % nCount { DllCall(NumGet(NumGet(1*ptinf)+36), "Uint", ptinf, "Uint", A_Index-1, "UintP", nFlags) If !(nFlags & 1) Continue DllCall(NumGet(NumGet(1*ptinf)+32), "Uint", ptinf, "Uint", A_Index-1, "UintP", hRefType) DllCall(NumGet(NumGet(1*ptinf)+56), "Uint", ptinf, "Uint", hRefType , "UintP", prinf) DllCall(NumGet(NumGet(1*prinf)+12), "Uint", prinf, "UintP", pattr) nFlags & 2 ? DIID:=String4GUID(pattr) : bFind:=IsEqualGUID(pattr,&IID) DllCall(NumGet(NumGet(1*prinf)+76), "Uint", prinf, "Uint" , pattr) DllCall(NumGet(NumGet(1*prinf)+ 8), "Uint", prinf) } DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf) If bFind Break } DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib) Return bFind ? DIID : "{00000000-0000-0000-0000-000000000000}" } GetGuidOfName(pdisp, Name, LCID = 0) { DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint", 0, "Uint", LCID, "UintP", ptinf) DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx) DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf), ptinf:=0 DllCall(NumGet(NumGet(1*ptlib)+44), "Uint", ptlib, "Uint", Unicode4Ansi(Name,Name), "Uint", 0, "UintP", ptinf, "UintP", memID, "UshortP", 1) DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib) DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr) GUID := String4GUID(pattr) DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr) DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf) Return GUID } GetTypeInfoOfGuid(pdisp, GUID, LCID = 0) { DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint", 0, "Uint", LCID, "UintP", ptinf) DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx) DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf), ptinf := 0 DllCall(NumGet(NumGet(1*ptlib)+24), "Uint", ptlib, "Uint", GUID4String(GUID,GUID), "UintP", ptinf) DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib) Return ptinf } ; A Function Name including Prefix is limited to 63 bytes! ConnectObject(psource, prefix = "", DIID = "{00020400-0000-0000-C000-000000000046}") { If (DIID = "{00020400-0000-0000-C000-000000000046}") 0+(pconn:=FindConnectionPoint(psource,DIID)) ? (DIID:=GetConnectionInterface(pconn))="{00020400-0000-0000-C000-000000000046}" ? DIID:=GetDefaultEvents(psource) : "" : pconn:=FindConnectionPoint(psource,DIID:=GetDefaultEvents(psource)) Else pconn:=FindConnectionPoint(psource,SubStr(DIID,1,1)="{" ? DIID : DIID:=GetGuidOfName(psource,DIID)) If !pconn || !(ptinf:=GetTypeInfoOfGuid(psource,DIID)) { MsgBox, No Event Interface Exists! Now exit the application. ExitApp } psink:=CoTaskMemAlloc(40+StrLen(prefix)+1), NumPut(1,NumPut(CreateIDispatch(),psink+0)), NumPut(psource,NumPut(ptinf,psink+8)) DllCall("RtlMoveMemory", "Uint", psink+24, "Uint", GUID4String(DIID,DIID), "Uint", 16) DllCall("RtlMoveMemory", "Uint", psink+40, "Uint", &prefix, "Uint", StrLen(prefix)+1) NumPut(Advise(pconn,psink),NumPut(pconn,psink+16)) Return psink } CreateObject(ByRef CLSID, ByRef IID, CLSCTX = 5) { If StrLen(CLSID)=38 GUID4String(CLSID,CLSID) If StrLen(IID)=38 GUID4String(IID,IID) DllCall("ole32\CoCreateInstance", "str", CLSID, "Uint", 0, "Uint", CLSCTX, "str", IID, "UintP", ppv) Return ppv } ActiveXObject(ProgID) { DllCall("ole32\CoCreateInstance", "Uint", SubStr(ProgID,1,1)="{" ? GUID4String(ProgID,ProgID) : CLSID4ProgID(ProgID,ProgID), "Uint", 0, "Uint", 5, "Uint", GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) Return GetDefaultInterface(pdisp) } GetObject(Moniker) { DllCall("ole32\CoGetObject", "Uint", Unicode4Ansi(Moniker,Moniker), "Uint", 0, "Uint", GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) Return GetDefaultInterface(pdisp) } GetActiveObject(ProgID) { DllCall("oleaut32\GetActiveObject", "Uint", SubStr(ProgID,1,1)="{" ? GUID4String(ProgID,ProgID) : CLSID4ProgID(ProgID,ProgID), "Uint", 0, "UintP", punk) DllCall(NumGet(NumGet(1*punk)+0), "Uint", punk, "Uint", GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) DllCall(NumGet(NumGet(1*punk)+8), "Uint", punk) Return GetDefaultInterface(pdisp) } CLSID4ProgID(ByRef CLSID, ProgID) { VarSetCapacity(CLSID, 16) DllCall("ole32\CLSIDFromProgID", "Uint", Unicode4Ansi(ProgID,ProgID), "Uint", &CLSID) Return &CLSID } GUID4String(ByRef CLSID, String) { VarSetCapacity(CLSID, 16) DllCall("ole32\CLSIDFromString", "Uint", Unicode4Ansi(String,String,38), "Uint", &CLSID) Return &CLSID } ProgID4CLSID(pCLSID) { DllCall("ole32\ProgIDFromCLSID", "Uint", pCLSID, "UintP", pProgID) Return Ansi4Unicode(pProgID) . SubStr(CoTaskMemFree(pProgID),1,0) } String4GUID(pGUID) { VarSetCapacity(String, 38 * 2 + 1) DllCall("ole32\StringFromGUID2", "Uint", pGUID, "Uint", &String, "int", 39) Return Ansi4Unicode(&String, 38) } IsEqualGUID(pGUID1, pGUID2) { Return DllCall("ole32\IsEqualGUID", "Uint", pGUID1, "Uint", pGUID2) } CoCreateGuid() { VarSetCapacity(GUID, 16, 0) DllCall("ole32\CoCreateGuid", "Uint", &GUID) Return String4GUID(&GUID) } CoTaskMemAlloc(cb) { Return DllCall("ole32\CoTaskMemAlloc", "Uint", cb) } CoTaskMemFree(pv) { Return DllCall("ole32\CoTaskMemFree", "Uint", pv) } CoInitialize() { Return DllCall("ole32\CoInitialize", "Uint", 0) } CoUninitialize() { Return DllCall("ole32\CoUninitialize") } OleInitialize() { Return DllCall("ole32\OleInitialize", "Uint", 0) } OleUninitialize() { Return DllCall("ole32\OleUninitialize") } SysAllocString(sString) { Return DllCall("oleaut32\SysAllocString", "Uint", Ansi2Unicode(sString,wString)) } SysFreeString(bstr) { Return DllCall("oleaut32\SysFreeString", "Uint", bstr) } SysStringLen(bstr) { Return DllCall("oleaut32\SysStringLen", "Uint", bstr) } SafeArrayDestroy(psa) { Return DllCall("oleaut32\SafeArrayDestroy", "Uint", psa) } VariantClear(pvarg) { Return DllCall("oleaut32\VariantClear", "Uint", pvarg) } AtlAxWinInit(Version = "") { CoInitialize() If !DllCall("GetModuleHandle", "str", "atl" . Version) DllCall("LoadLibrary" , "str", "atl" . Version) Return DllCall("atl" . Version . "\AtlAxWinInit") } AtlAxWinTerm(Version = "") { CoUninitialize() If hModule:=DllCall("GetModuleHandle", "str", "atl" . Version) Return DllCall("FreeLibrary" , "Uint", hModule) } AtlAxGetControl(hWnd, Version = "") { DllCall("atl" . Version . "\AtlAxGetControl", "Uint", hWnd, "UintP", punk) pdsp:=QueryInterface(punk,IID_IDispatch:="{00020400-0000-0000-C000-000000000046}") Release(punk) Return pdsp } AtlAxAttachControl(pdsp, hWnd, Version = "") { punk:=QueryInterface(pdsp,IID_IUnknown:="{00000000-0000-0000-C000-000000000046}") DllCall("atl" . Version . "\AtlAxAttachControl", "Uint", punk, "Uint", hWnd, "Uint", 0) Release(punk) } AtlAxCreateControl(hWnd, Name, Version = "") { VarSetCapacity(IID_NULL, 16, 0) DllCall("atl" . Version . "\AtlAxCreateControlEx", "Uint", Unicode4Ansi(Name,Name), "Uint", hWnd, "Uint", 0, "Uint", 0, "UintP", punk, "Uint", &IID_NULL, "Uint", 0) pdsp:=QueryInterface(punk,IID_IDispatch:="{00020400-0000-0000-C000-000000000046}") Release(punk) Return pdsp } AtlAxCreateContainer(hWnd, l, t, w, h, Name = "", Version = "") { Return DllCall("CreateWindowEx", "Uint",0x200, "str", "AtlAxWin" . Version, "Uint", Name ? &Name : 0, "Uint", 0x54000000, "int", l, "int", t, "int", w, "int", h, "Uint", hWnd, "Uint", 0, "Uint", 0, "Uint", 0) } AtlAxGetContainer(pdsp) { DllCall(NumGet(NumGet(1*pdsp)+ 0), "Uint", pdsp, "Uint", GUID4String(IID_IOleWindow,"{00000114-0000-0000-C000-000000000046}"), "UintP", pwin) DllCall(NumGet(NumGet(1*pwin)+12), "Uint", pwin, "UintP", hCtrl) DllCall(NumGet(NumGet(1*pwin)+ 8), "Uint", pwin) Return DllCall("GetParent", "Uint", hCtrl) } Ansi4Unicode(pString, nSize = "") { If (nSize = "") nSize:=DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0) VarSetCapacity(sString, nSize) DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize + 1, "Uint", 0, "Uint", 0) Return sString } Unicode4Ansi(ByRef wString, sString, nSize = "") { If (nSize = "") nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0) VarSetCapacity(wString, nSize * 2 + 1) DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize + 1) Return &wString } Ansi2Unicode(ByRef sString, ByRef wString, nSize = "") { If (nSize = "") nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0) VarSetCapacity(wString, nSize * 2 + 1) DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize + 1) Return &wString } Unicode2Ansi(ByRef wString, ByRef sString, nSize = "") { pString := wString + 0 > 65535 ? wString : &wString If (nSize = "") nSize:=DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0) VarSetCapacity(sString, nSize) DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize + 1, "Uint", 0, "Uint", 0) Return &sString } DecodeInteger(ref, nSize = 4) { DllCall("RtlMoveMemory", "int64P", val, "Uint", ref, "Uint", nSize) Return val } EncodeInteger(ref, val = 0, nSize = 4) { DllCall("RtlMoveMemory", "Uint", ref, "int64P", val, "Uint", nSize) } ScriptControl(sCode, sLang = "", bExec = False, sName = "", pdisp = 0, bGlobal = False) { CoInitialize() psc := ActiveXObject("MSScriptControl.ScriptControl") Invoke(psc, "Language=", sLang ? sLang : "VBScript") sName ? Invoke(psc, "AddObject", sName, "+" . pdisp, bGlobal) : "" ret := Invoke(psc, bExec ? "ExecuteStatement" : "Eval", sCode) Release(psc) CoUninitialize() Return ret }
|
|
|
|
|
6
|
DonationCoder.com Software / Post New Requests Here / Re: Vista Multiple Mouse Cursors
|
on: May 12, 2009, 06:12:19 PM
|
 Try Mice! Press F1 to switch between mouse locations. Edit mice= to add more mouse locations. Just a quick hack, feel free to add graphics or change hotkey. Skrommel [ copy or print] ;Mice.ahk ; Press F1 to switch between mouse positions ;Skrommel @ 2009 #NoEnv #SingleInstance,Force CoordMode,Mouse,Screen CoordMode,ToolTip,Screen mice=2 mouse=1 Return F1:: MouseGetPos,mx%mouse%,my%mouse% mx:=mx%mouse% my:=my%mouse% ToolTip,% mouse,% mx,% my,% mouse mouse+=1 If (mouse>mice) mouse=1 ToolTip,,,,% mouse mx:=mx%mouse% my:=my%mouse% MouseMove,% mx,% my,0 Return
|
|
|
|
|
9
|
DonationCoder.com Software / Finished Programs / Re: IDEA: Allow input commands to be sent to background windows.
|
on: May 11, 2009, 04:57:54 AM
|
 Try WriteThere! It redirects all keyboard input to one window. Click inside the target window and press F1 to redirect the input to it. Press F1 twice fast to disable WriteThere. Example: Open Internet Explorer and Notepad, and place them side by side. Click inside Notepad and press F1 to redirect the keyboard. Now you can navigate your browser using the mouse, but everyting your write will end up in Notepad! This is a beta if ever there was one! There's probably a lot of keys missing, it doesn't work with all programs, it disables global hotkeys, and so on. Skrommel [ copy or print] ;WriteThere.ahk ; Redirect all keyboard input to one window. ; Click the target window and press F1 to redirect. ; Press F1 twice fast to disable. ;Skrommel 2009 #NoEnv #Persistent,On #SingleInstance,Force SetWinDelay,0 SetControlDelay,0 SetBatchLines,-1 SendMode,Input ;SetKeyDelay,0 hotkeys=0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,æ,ø,å,LCtrl,RCtrl,LShift,RShift,LAlt,RAlt,LWin,RWin,Appskey,Left,Right,Up,Down,Tab,PgUp,PgDn,Home,End,Delete,Insert,Esc,Space,BackSpace,Enter,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,!,?,+,-,_,*,/,\,(,),{,[,],},<,>,|,&,§,@,$,£,#,¤,µ,^,~,¨,´,',.,:,`%,``,`",`; TOOLTIPON("WriteThere`n`nRedirect all keyboard input to one window.`nClick the target window and press F1 to redirect.`nPress F1 twice fast to disable.`n`nwww.1HourSoftware.com",10) Return TOGGLEHOTKEYS: If enabled<>On enabled=On Else enabled=Off TOOLTIPON("WriteThere " enabled) Loop,Parse,hotkeys,`, { Hotkey,$*%A_LoopField%,SEND,%enabled% Hotkey,$*%A_LoopField% Up,SEND,%enabled% } Hotkey,$*`,,SEND,%enabled% Hotkey,$*`, Up,SEND,%enabled% Return SEND: ;TOOLTIPON(A_ThisHotkey) StringTrimLeft,key,A_ThisHotkey,2 ControlSend,%ctrl%,{%key%},ahk_id %win% Return F1:: If enabled=On If A_PriorHotkey=F1 If A_TimeSincePriorHotkey<999 { Gosub,TOGGLEHOTKEYS Return } If enabled<>On Gosub,TOGGLEHOTKEYS win:=WinExist("A") Loop { parent:=DllCall("GetParent",UInt,win) If parent=0 Break win:=parent } ControlGetFocus,ctrl,ahk_id %win% winGetClass,class,ahk_id %win% TOOLTIPON("Keyboard redirected to `n" ctrl " in `n" class) Return TOOLTIPON(tip,delay=3) { ToolTip,%tip% SetTimer,TOOLTIPOFF,% delay*-1000 } TOOLTIPOFF: ToolTip, Return
|
|
|
|
|
10
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Replace Hourglass with Quote from text file
|
on: May 10, 2009, 08:59:49 AM
|
 Try HourglassQuotes! It displays a quote when the PC is busy, either from a file or from www.quotableonline.com. Place the quotes in a text file and edit the files= and timer= lines. To keep the quote from dissapearing, just click inside the window. It dissappears when it loses focus. Skrommel [ copy or print] ;HourglassQuotes.ahk ; Displays a quote when the PC is busy ;Skrommel @ 2009 delay=9 ;seconds to show the quote file= ;file with quotes. if empty, retrieve quote from internet internet=http://www.quotableonline.com/index.php ;url to page with random quote html1:="<div class=leftnavText><blockquote id=blockquote > " ;text to look for before the quote html2:="</blockquote>" ;text to look for after the quote filter:=" " ;string to remove from the quote #NoEnv #SingleInstance,Force applicationname=HourglassQuotes IniRead,counter,%applicationname%.ini,Settings,counter If (counter="Error" Or counter<1 Or counter>999999) counter=1 If file= Gosub,DOWNLOAD Else Gosub,READ Loop { Sleep,1000 ;Stolen from Sean at http://www.autohotkey.com/forum/topic32959.html VarSetCapacity(ci,20,0),NumPut(20,ci) DllCall("GetCursorInfo","Uint",&ci) hCursor:=NumGet(ci,8) If showing<>1 If hCursor In 65575,65557 ;65575=appstarting 65557=wait { Gui,Destroy Gui,+ToolWindow +AlwaysOntop Gui,Color,FFFFFF Gui,Add,Text,w200,%quote% Gui,Show,x0 y0 NoActivate,%applicationname% Gui,+LastFound guiid:=WinExist() SetTimer,QUOTEOFF,% delay*-1000 showing=1 If file= Gosub,DOWNLOAD Else Gosub,READ If quote= Continue } } ExitApp READ: FileReadLine,quote,%file%,%counter% If ErrorLevel=1 { counter=1 FileReadLine,quote,%file%,%counter% } Else counter+=1 IniWrite,%counter%,%applicationname%.ini,Settings,counter Return DOWNLOAD: UrlDownloadToFile,% internet,quote.htm FileRead,quote,quote.htm StringGetPos,pos,quote,% html1 StringTrimLeft,quote,quote,% pos+StrLen(html1) StringGetPos,pos,quote,% html2 StringLeft,quote,quote,% pos StringReplace,quote,quote,% filter,,All Return QUOTEOFF: active:=WinExist("A") If (active=guiid) { SetTimer,QUOTEOFF,-1000 Return } showing=0 Gui,Destroy Return
|
|
|
|
|
17
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Make your monitor corners look round
|
on: April 26, 2009, 03:49:22 PM
|
 Try RoundedCorners, a quick script that shows four images in the corners of the screen. Download the four images and save them as 1.gif, 2.gif, 3.gif and 4.gif in the same folder as the script. Skrommel [ copy or print] ;RoundedCorners.ahk ;Skrommel @ 2009 #NoEnv #SingleInstance,Force SetWorkingDir %A_ScriptDir% SetWinDelay,0 SetBatchLines,-1 Gui,Color,FFFFFF Gui,+AlwaysOnTop +TopMost -Caption +E0x20 +Border +ToolWindow x=0 y=0 Gui,Add,Picture,x%x% y%y%,1.gif x:=A_ScreenWidth-37 y=0 Gui,Add,Picture,x%x% y%y%,2.gif x:=A_ScreenWidth-37 y:=A_ScreenHeight-37 Gui,Add,Picture,x%x% y%y%,3.gif x=0 y:=A_ScreenHeight-37 Gui,Add,Picture,x%x% y%y%,4.gif Gui,+LastFound guiid:=WinExist() Gui,Show,x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% NoActivate WinSet,TransColor,FFFFFF,ahk_id %guiid% WinSet,AlwaysOnTop,On,ahk_id %guiid% SetTimer,TOP,1000 Return TOP: WinSet,Top,,ahk_id %guiid% Return
|
|
|
|
|
18
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Volume buttons (and others) pressed on keyboard are displayed on screen
|
on: April 15, 2009, 06:38:53 PM
|
 Prettier alpha blended version of GreenOSD! Skrommel [ copy or print] ;GreenOSD.ahk ; Shows changing volume and selected keys on screen ;Skrommel @2006 ;OSD texts, edit for other languages or special apps On=On Off=Off CapsLock=CapsLock NumLock=NumLock ScrollLock=ScrollLock Insert=Insert Browser_Back=Back Browser_Forward=Forward Browser_Refresh=Refresh Browser_Stop=Stop Browser_Search=Search Browser_Favorites=Favorites Browser_Home=Home Volume_Mute=Mute Volume_Down=Vol- Volume_Up=Vol+ Media_Next=Next Media_Prev=Prev Media_Stop=Stop Media_Play_Pause=Pause Launch_Mail=Mail Launch_Media=Media Launch_App1=App1 Launch_App2=App2 PrintScreen=PrintScreen ;OSD layout, edit for other color, size and other size=50 boldness=70 statefont=Arial actionfont=Arial font=Arial color=00FF00 delay=3 texttransparency=ff ; 00 to ff shadowtransparency=22 ; 00 to ff backtransparency=11 ; 00 to ff xposition=Center ; xposition=Center or any number yposition=800 ; yposition=Center or any number width=300 height=200 #SingleInstance,Force #Persistent,On SetWinDelay,0 SetBatchLines,-1 applicationname=GreenOSD showing=0 SoundGet,volume SoundGet,mute,,Mute SetTimer,CHECK,500 Return CHECK: SetTimer,CHECK,100 oldmute:=mute SoundGet,mute,,Mute oldvolume:=volume SoundGet,volume If (volume=oldvolume And mute=oldmute) { showing+=1 If (showing>=delay*10) { ;WinMove,%applicationname%1,,0,0,1,1 Gui, 1: Destroy showing=0 SetTimer,CHECK,500 } Return } showing=0 If mute=On { action1=%Volume_Mute% state1=%On% } Else If (volume<oldvolume) action1=%Volume_Down% Else If (volume>oldvolume) action1=%Volume_Up% Else { action1=%Volume_Mute% state1=%Off% } If (mute=oldmute) { state1= Loop,% Ceil(volume/5) state1=%state1%| } Gosub,SHOW1 Return SHOW1: text:=action1 If state1<> text.="`n" state1 Gosub,SHOW Return ~CapsLock:: ~NumLock:: ~ScrollLock:: ~Insert:: showing=0 StringTrimLeft,action,A_ThisHotkey,1 GetKeyState,state,%action%,T action1:=%action% If state=D state1:=%On% Else state1:=%Off% Gosub,SHOW1 Return ~PrintScreen:: ~Browser_Back:: ~Browser_Forward:: ~Browser_Refresh:: ~Browser_Stop:: ~Browser_Search:: ~Browser_Favorites:: ~Browser_Home:: ~Volume_Mute:: ~Media_Next:: ~Media_Prev:: ~Media_Stop:: ~Media_Play_Pause:: ~Launch_Mail:: ~Launch_Media:: ~Launch_App1:: ~Launch_App2:: showing=0 StringTrimLeft,action,A_ThisHotkey,1 action1:=%action% state1= Gosub,SHOW1 Return SHOW: ;Stolen from tic at http://www.autohotkey.com/forum/topic32238.html ; gdi+ ahk tutorial 8 written by tic (Tariq Porter) ; Requires Gdip.ahk either in your Lib folder as standard library or using #Include ; ; Tutorial to write text onto a gui ; Uncomment if Gdip.ahk is not in your standard library ;#Include, Gdip.ahk ; Start gdi+ If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } OnExit, Exit ; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap ;Width := 300, Height := 200 ; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption Gui, 1: Destroy Gui, 1: +E0x20 -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs ;Gui, 1: Add, Edit, w%Width% h20 y300, vMeEdit ; Show the window Gui, 1: Show,X%xposition% Y%yposition% AutoSize NoActivate, %applicationname%1 Gui, 1: +LastFound ; Get a handle to this window we have created in order to update it later hwnd1 := WinExist() ; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything hbm := CreateDIBSection(Width, Height) ; Get a device context compatible with the screen hdc := CreateCompatibleDC() ; Select the bitmap into the device context obm := SelectObject(hdc, hbm) ; Get a pointer to the graphics of the bitmap, for use with drawing functions G := Gdip_GraphicsFromHDC(hdc) ; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling) Gdip_SetSmoothingMode(G, 4) ; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with pBrush := Gdip_BrushCreateSolid("0x" backtransparency "000000") ; Fill the graphics of the bitmap with a rounded rectangle using the brush created ; Filling the entire graphics - from coordinates (0, 0) the entire width and height ; The last parameter (20) is the radius of the circles used for the rounded corners Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20) ; Delete the brush as it is no longer needed and wastes memory Gdip_DeleteBrush(pBrush) ; We can specify the font to use. Here we use Arial as most systems should have this installed ;Font = Arial ; Next we can check that the user actually has the font that we wish them to use ; If they do not then we can do something about it. I choose to give a wraning and exit! If !Gdip_FontFamilyCreate(Font) { MsgBox, 48, Font error!, The font you have specified does not exist on the system ExitApp } ; There are a lot of things to cover with the function Gdip_TextToGraphics ; The 1st parameter is the graphics we wish to use (our canvas) ; The 2nd parameter is the text we wish to write. It can include new lines `n ; The 3rd parameter, the options are where all the action takes place... ; You can write literal x and y coordinates such as x20 y50 which would place the text at that position in pixels ; or you can include the last 2 parameters (Width and Height of the Graphics we will use) and then you can use x10p ; which will place the text at 10% of the width and y30p which is 30% of the height ; The same percentage marker may be used for width and height also, so w80p makes the bounding box of the rectangle the text ; will be written to 80% of the width of the graphics. If either is missed (as I have missed height) then the height of the bounding ; box will be made to be the height of the graphics, so 100% ; Any of the following words may be used also: Regular,Bold,Italic,BoldItalic,Underline,Strikeout to perform their associated action ; To justify the text any of the following may be used: Near,Left,Centre,Center,Far,Right with different spelling of words for convenience ; The rendering hint (the quality of the antialiasing of the text) can be specified with r, whose values may be: ; SystemDefault = 0 ; SingleBitPerPixelGridFit = 1 ; SingleBitPerPixel = 2 ; AntiAliasGridFit = 3 ; AntiAlias = 4 ; The size can simply be specified with s ; The colour and opacity can be specified for the text also by specifying the ARGB as demonstrated with other functions such as the brush ; So cffff0000 would make a fully opaque red brush, so it is: cARGB (the literal letter c, follwed by the ARGB) ; The 4th parameter is the name of the font you wish to use ; As mentioned previously, you don not need to specify the last 2 parameters, the width and height, unless ; you are planning on using the p option with the x,y,w,h to use the percentage Options = x1p y21p w100p Centre c%shadowtransparency%000000 r4 s%size% Gdip_TextToGraphics(G, text, Options, Font, Width, Height) Options = x0p y20p w100p Centre c%texttransparency%%color% r4 s%size% Gdip_TextToGraphics(G, text, Options, Font, Width, Height) ; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen ; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height) ; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui ;OnMessage(0x201, "WM_LBUTTONDOWN") ; Select the object back into the hdc SelectObject(hdc, obm) ; Now the bitmap may be deleted DeleteObject(hbm) ; Also the device context related to the bitmap may be deleted DeleteDC(hdc) ; The graphics may now be deleted Gdip_DeleteGraphics(G) Return ;####################################################################### ; This function is called every time the user clicks on the gui ; The PostMessage will act on the last found window (this being the gui that launched the subroutine, hence the last parameter not being needed) ;WM_LBUTTONDOWN() ;{ ; PostMessage, 0xA1, 2 ;} ;####################################################################### Exit: ; gdi+ may now be shutdown on exiting the program Gdip_Shutdown(pToken) ExitApp Return ; Gdip standard library v1.26 by tic 23/12/08 ; ;##################################################################################### ;##################################################################################### ; STATUS ENUMERATION ; Return values for functions specified to have status enumerated return type ;##################################################################################### ; Ok = 0 ; GenericError = 1 ; InvalidParameter = 2 ; OutOfMemory = 3 ; ObjectBusy = 4 ; InsufficientBuffer = 5 ; NotImplemented = 6 ; Win32Error = 7 ; WrongState = 8 ; Aborted = 9 ; FileNotFound = 10 ; ValueOverflow = 11 ; AccessDenied = 12 ; UnknownImageFormat = 13 ; FontFamilyNotFound = 14 ; FontStyleNotFound = 15 ; NotTrueTypeFont = 16 ; UnsupportedGdiplusVersion = 17 ; GdiplusNotInitialized = 18 ; PropertyNotFound = 19 ; PropertyNotSupported = 20 ; ProfileNotFound = 21 ;##################################################################################### ;##################################################################################### ; GDI and structure functions ; ######################## ; UpdateLayeredWindow ; CreateRectF ; CreateSizeF ; CreateDIBSection ;##################################################################################### ;##################################################################################### ; ; GDI and structure functions ; ;##################################################################################### ;##################################################################################### ; Function: UpdateLayeredWindow ; Description: Updates a layered window with the handle to the DC of a gdi bitmap ; ; hwnd = Handle of the window to update ; hdc = Handle to the DC of the GDI bitmap to update the window with ; Layeredx = x position to place the window ; Layeredy = x position to place the window ; Layeredw = Width of the window ; Layeredh = Height of the window ; Alpha = Default = 255 : The transparency (0-255) to set the window transparency ; ; Return: If the function succeeds, the return value is nonzero. ; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255) { If ((x != "") && (y != "")) VarSetCapacity(pt, 8), NumPut(x, pt, 0), NumPut(y, pt, 4) If ((w = "") ||(h = "")) WinGetPos,,, w, h, ahk_id %hwnd% Return, DllCall("UpdateLayeredWindow" , "UInt", hwnd , "UInt", 0 , "UInt", ((x = "") && (y = "")) ? 0 : &pt , "Int64*", w|h<<32 , "UInt", hdc , "Int64*", 0 , "UInt", 0 , "UInt*", Alpha<<16|1<<24 , "UInt", 2) } ;##################################################################################### BitBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, Raster="") { Return, DllCall("gdi32\BitBlt" , "UInt", dDC ; handle to destination DC , "Int", dx ; x-coord of destination upper-left corner , "Int", dy ; y-coord of destination upper-left corner , "Int", dw ; width of destination rectangle , "Int", dh ; height of destination rectangle , "UInt", sDC ; handle to source DC , "Int", sx ; x-coordinate of source upper-left corner , "Int", sy ; y-coordinate of source upper-left corner , "UInt", Raster ? Raster : 0x00CC0020) ; raster operation code } ;##################################################################################### StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="") { Return, DllCall("gdi32\StretchBlt" , "UInt", dDC ; handle to destination DC , "Int", dx ; x-coord of destination upper-left corner , "Int", dy ; y-coord of destination upper-left corner , "Int", dw ; width of destination rectangle , "Int", dh ; height of destination rectangle , "UInt", sDC ; handle to source DC , "Int", sx ; x-coordinate of source upper-left corner , "Int", sy ; y-coordinate of source upper-left corner , "Int", sw ; width of source rectangle , "Int", sh ; height of source rectangle , "UInt", Raster ? Raster : 0x00CC0020) ; raster operation code } ;##################################################################################### SetImage(hwnd, hBitmap) { SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd% } ;##################################################################################### Gdip_BitmapFromScreen(Screen=0, Raster="") { If (Screen = 0) { Sysget, x, 76 Sysget, y, 77 Sysget, w, 78 Sysget, h, 79 } Else If (Screen&1 != "") { Sysget, M, Monitor, %Screen% x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop } Else { StringSplit, S, Screen, | x := S1, y := S2, w := S3, h := S4 } If (x = "") || (y = "") || (w = "") || (h = "") Return, -1 chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := GetDC() BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster) ReleaseDC(hhdc) pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm) SelectObject(hhdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc) Return, pBitmap } ;##################################################################################### Gdip_BitmapFromHWND(hwnd=0) { WinGetPos,,, Width, Height, ahk_id %hwnd% hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm) PrintWindow(hwnd, hdc) pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm) SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc) Return, pBitmap } ;##################################################################################### ; Function: CreateRectF ; Description: Creates a RectF object, containing a the coordinates and dimensions of a rectangle ; ; RectF = Name to call the RectF object ; x = x-coordinate of the upper left corner of the rectangle ; y = y-coordinate of the upper left corner of the rectangle ; w = Width of the rectangle ; h = Height of the rectangle ; ; Return: No return value ; CreateRectF(ByRef RectF, x, y, w, h) { VarSetCapacity(RectF, 16) NumPut(x, RectF, 0, "Float"), NumPut(y, RectF, 4, "Float"), NumPut(w, RectF, 8, "Float"), NumPut(h, RectF, 12, "Float") } ;##################################################################################### ; Function: CreateSizeF ; Description: Creates a SizeF object, containing an 2 values ; ; SizeF = Name to call the SizeF object ; w = w-value for the SizeF object ; h = h-value for the SizeF object ; ; Return: No Return value ; CreateSizeF(ByRef SizeF, w, h) { VarSetCapacity(SizeF, 8) NumPut(w, SizeF, 0, "Float"), NumPut(h, SizeF, 4, "Float") } ;##################################################################################### CreatePointF(ByRef PointF, x, y) { VarSetCapacity(PointF, 8) NumPut(x, PointF, 0, "Float"), NumPut(y, PointF, 4, "Float") } ;##################################################################################### CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0) { hdc2 := hdc ? hdc : GetDC() VarSetCapacity(bi, 40, 0) NumPut(w, bi, 4), NumPut(h, bi, 8), NumPut(40, bi, 0), NumPut(1, bi, 12, "UShort"), NumPut(0, bi, 16), NumPut(bpp, bi, 14, "UShort") hbm := DllCall("CreateDIBSection", "UInt" , hdc2, "UInt" , &bi, "UInt" , 0, "UInt*", ppvBits, "UInt" , 0, "UInt" , 0) If !hdc ReleaseDC(hdc2) Return, hbm } ;##################################################################################### PrintWindow(hwnd, hdc, Flags=0) { Return, DllCall("PrintWindow", "UInt", hwnd, "UInt", hdc, "UInt", Flags) } DestroyIcon(hIcon) { Return, DllCall("DestroyIcon", "UInt", hIcon) } CreateCompatibleDC(hdc=0) { Return, DllCall("CreateCompatibleDC", "UInt", hdc) } SelectObject(hdc, hgdiobj) { Return, DllCall("SelectObject", "UInt", hdc, "UInt", hgdiobj) } DeleteObject(hObject) { Return, DllCall("DeleteObject", "UInt", hObject) } GetDC(hwnd=0) { Return, DllCall("GetDC", "UInt", hwnd) } ReleaseDC(hdc, hwnd=0) { Return, DllCall("ReleaseDC", "UInt", hwnd, "UInt", hdc) } DeleteDC(hdc) { Return, DllCall("DeleteDC", "UInt", hdc) } ;##################################################################################### ;##################################################################################### ; ; Misc functions ; ;##################################################################################### Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File) { If (SubStr(File, 1, 4) = "File") && (SubStr(File, 5, StrLen(File)-4) & 1 != "") { RegExMatch(BRAFromMemIn, ":H:([0-9]+).*?:a:" SubStr(File, 5, StrLen(File)-4) ":b:(.*?):c:([0-9]+):d:([0-9]+)::", FileInfo) File := FileInfo2 } Else RegExMatch(BRAFromMemIn, ":H:([0-9]+).*?:a:([0-9]+):b:\Q" File "\E:c:([0-9]+):d:([0-9]+)::", FileInfo) If !FileInfo Return, 0 hData := DllCall("GlobalAlloc", "UInt", 2, "UInt", FileInfo3) pData := DllCall("GlobalLock", "UInt", hData) DllCall("RtlMoveMemory", "UInt", pData, "UInt", &BRAFromMemIn+FileInfo1+FileInfo4, "UInt", FileInfo3) DllCall("GlobalUnlock", "UInt", hData) DllCall("ole32\CreateStreamOnHGlobal", "UInt", hData, "Int", 1, "UInt*", pStream) DllCall("gdiplus\GdipCreateBitmapFromStream", "UInt", pStream, "UInt*", pBitmap) DllCall(NumGet(NumGet(1*pStream)+8), "UInt", pStream) Return, pBitmap } ;##################################################################################### ; ; GDI+ functions ; ;##################################################################################### ;##################################################################################### ;##################################################################################### ; Draw shape/line ;##################################################################################### Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h) { Return, DllCall("gdiplus\GdipDrawRectangle", "UInt", pGraphics, "UInt", pPen , "Float", x, "Float", y, "Float", w, "Float", h) } Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r) { Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4) E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h) Gdip_ResetClip(pGraphics) Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4) Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4) Gdip_DrawEllipse(pGraphics, pPen, x, y, 2*r, 2*r) Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y, 2*r, 2*r) Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r) Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r) Gdip_ResetClip(pGraphics) Return, E } Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h) { Return, DllCall("gdiplus\GdipDrawEllipse", "UInt", pGraphics, "UInt", pPen , "Float", x, "Float", y, "Float", w, "Float", h) } Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4) { Return, DllCall("gdiplus\GdipDrawBezier", "UInt", pgraphics, "UInt", pPen , "Float", x1, "Float", y1, "Float", x2, "Float", y2 , "Float", x3, "Float", y3, "Float", x4, "Float", y4) } Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) { Return, DllCall("gdiplus\GdipDrawArc", "UInt", pGraphics, "UInt", pPen , "Float", x, "Float", y, "Float", w, "Float", h, "Float", StartAngle, "Float", SweepAngle) } Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) { Return, DllCall("gdiplus\GdipDrawPie", "UInt", pGraphics, "UInt", pPen, "Float", x, "Float", y, "Float", w, "Float", h, "Float", StartAngle, "Float", SweepAngle) } Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2) { Return, DllCall("gdiplus\GdipDrawLine", "UInt", pGraphics, "UInt", pPen , "Float", x1, "Float", y1, "Float", x2, "Float", y2) } ; Points passed as x1,y1|x2,y2|x3,y3..... Gdip_DrawLines(pGraphics, pPen, Points) { StringSplit, Points, Points, | VarSetCapacity(PointF, 8*Points0) Loop, %Points0% { StringSplit, Coord, Points%A_Index%, `, NumPut(Coord1, PointF, 8*(A_Index-1), "Float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "Float") } Return, DllCall("gdiplus\GdipDrawLines", "UInt", pGraphics, "UInt", pPen, "UInt", &PointF, "Int", Points0) } ;##################################################################################### ; Fill shape ;##################################################################################### Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h) { Return, DllCall("gdiplus\GdipFillRectangle", "UInt", pGraphics, "Int", pBrush , "Float", x, "Float", y, "Float", w, "Float", h) } Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r) { Region := Gdip_GetClipRegion(pGraphics) Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4) E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h) Gdip_SetClipRegion(pGraphics, Region, 0) Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4) Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4) Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r) Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r) Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r) Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r) Gdip_SetClipRegion(pGraphics, Region, 0) Gdip_DeleteRegion(Region) Return, E } ; Points passed as x1,y1|x2,y2|x3,y3..... Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0) { StringSplit, Points, Points, | VarSetCapacity(PointF, 8*Points0) Loop, %Points0% { StringSplit, Coord, Points%A_Index%, `, NumPut(Coord1, PointF, 8*(A_Index-1), "Float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "Float") } Return, DllCall("gdiplus\GdipFillPolygon", "UInt", pGraphics, "UInt", pBrush, "UInt", &PointF, "Int", Points0, "Int", FillMode) } Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle) { Return, DllCall("gdiplus\GdipFillPie", "UInt", pGraphics, "UInt", pBrush , "Float", x, "Float", y, "Float", w, "Float", h, "Float", StartAngle, "Float", SweepAngle) } Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h) { Return, DllCall("gdiplus\GdipFillEllipse", "UInt", pGraphics, "UInt", pBrush , "Float", x, "Float", y, "Float", w, "Float", h, "Float") } Gdip_FillRegion(pGraphics, pBrush, Region) { Return, DllCall("gdiplus\GdipFillRegion", "UInt", pGraphics, "UInt", pBrush, "UInt", Region) } Gdip_FillPath(pGraphics, pBrush, Path) { Return, DllCall("gdiplus\GdipFillPath", "UInt", pGraphics, "UInt", pBrush, "UInt", Path) } ;##################################################################################### ; Graphics functions ;##################################################################################### ; Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", TransMatrix=1) { StringSplit, Points, Points, | VarSetCapacity(PointF, 8*Points0) Loop, %Points0% { StringSplit, Coord, Points%A_Index%, `, NumPut(Coord1, PointF, 8*(A_Index-1), "Float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "Float") } If (TransMatrix&1 = "") ImageAttr := Gdip_SetImageAttributesColorMatrix(TransMatrix) Else if (Matrix != 1) ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" TransMatrix "|0|0|0|0|0|1") E := DllCall("gdiplus\GdipDrawImagePointsRect", "UInt", pGraphics, "UInt", pBitmap , "UInt", &PointF, "Int", Points0, "Float", sx, "Float", sy, "Float", sw, "Float", sh , "Int", 2, "UInt", ImageAttr, "UInt", 0, "UInt", 0) If ImageAttr Gdip_DisposeImageAttributes(ImageAttr) Return, E } Gdip_DrawImage(pGraphics, pBitmap, dx, dy, dw, dh, sx="", sy="", sw="", sh="", Matrix=1) { If (Matrix&1 = "") ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix) Else if (Matrix != 1) ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1") If (sx = "") && (sy = "") && (sw = "") && (sh = "") sx := 0, sy := 0, sw := dw, sh := dh E := DllCall("gdiplus\GdipDrawImageRectRect", "UInt", pGraphics, "UInt", pBitmap , "Float", dx, "Float", dy, "Float", dw, "Float", dh , "Float", sx, "Float", sy, "Float", sw, "Float", sh , "Int", 2, "UInt", ImageAttr, "UInt", 0, "UInt", 0) If ImageAttr Gdip_DisposeImageAttributes(ImageAttr) Return, E } ;MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1 ;MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1 ;MatrixNegative = -1|0|0|0|0|0|1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1 Gdip_SetImageAttributesColorMatrix(Matrix) { VarSetCapacity(ColourMatrix, 100, 0) Matrix := RegExReplace(RegExReplace(Matrix, "^[^0-9-\.]+([0-9\.])", "$1", "", 1), "[^0-9-\.]+", "|") StringSplit, Matrix, Matrix, | Loop, 25 { Matrix := Matrix%A_Index% ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1 NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "Float") } DllCall("gdiplus\GdipCreateImageAttributes", "UInt*", ImageAttr) DllCall("gdiplus\GdipSetImageAttributesColorMatrix", "UInt", ImageAttr, "Int", 1, "Int", 1, "UInt", &ColourMatrix, "Int", 0, "Int", 0) VarSetCapacity(ColourMatrix, 0) Return, ImageAttr } Gdip_GraphicsFromImage(pBitmap) { DllCall("gdiplus\GdipGetImageGraphicsContext", "UInt", pBitmap, "UInt*", pGraphics) Return, pGraphics } Gdip_GraphicsFromHDC(hdc) { DllCall("gdiplus\GdipCreateFromHDC", "UInt", hdc, "UInt*", pGraphics) Return, pGraphics } ;##################################################################################### ; Bitmap functions ;##################################################################################### Gdip_BlurBitmap(pBitmap, Blur) { If ((Blur > 100) || (Blur < 1)) Return, -1 sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap) dWidth := sWidth//Blur, dHeight := sHeight//Blur pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight) G1 := Gdip_GraphicsFromImage(pBitmap1) Gdip_SetInterpolationMode(G1, 7) Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight) Gdip_DeleteGraphics(G1) Gdip_DisposeImage(pBitmap) pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight) G2 := Gdip_GraphicsFromImage(pBitmap2) Gdip_SetInterpolationMode(G2, 7) Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight) Gdip_DeleteGraphics(G2) Gdip_DisposeImage(pBitmap1) Return, pBitmap2 } ;##################################################################################### ; Function: Gdip_SaveBitmapToFile ; Description: Saves a gdi+ bitmap to a file in any supported format onto disk ; ; pBitmap = Pointer to the gdi+ bitmap object ; sOutput = The name of the file that the bitmap will eb saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG ; Quality = If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality ; ; Return: If the function succeeds, the return value is zero, otherwise: ; -1: Extension supplied is not a supported file format ; -2: Could not get a list of encoders on system ; -3: Could not find matching encoder for specified file format ; -4: Could not get WideChar name of output file ; -5: Could not save file to disk ; Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=100) { SplitPath, sOutput,,, Extension Extension := "." Extension If Extension not in .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG Return, -1 DllCall("gdiplus\GdipGetImageEncodersSize", "UInt*", nCount, "UInt*", nSize) VarSetCapacity(ci, nSize) DllCall("gdiplus\GdipGetImageEncoders", "UInt", nCount, "UInt", nSize, "UInt", &ci) If !(nCount && nSize) Return, -2 Loop, %nCount% { nSize := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76*(A_Index-1)+44), "Int", -1, "UInt", 0, "Int", 0, "UInt", 0, "UInt", 0) VarSetCapacity(sString, nSize) DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76*(A_Index-1)+44), "Int", -1, "Str", sString, "Int", nSize, "UInt", 0, "UInt", 0) If !InStr(sString, Extension) Continue pCodec := &ci+76*(A_Index-1) Break } If !pCodec Return, -3 If (Quality != 100) { If Extension in .JPG,.JPEG,.JPE,.JFIF { DllCall("gdiplus\GdipGetEncoderParameterListSize", "UInt", pBitmap, "UInt", pCodec, "UInt*", nSize) VarSetCapacity(EncoderParameters, nSize, 0) DllCall("gdiplus\GdipGetEncoderParameterList", "UInt", pBitmap, "UInt", pCodec, "UInt", nSize, "UInt", &EncoderParameters) Loop, % NumGet(EncoderParameters) ;% { If (NumGet(EncoderParameters, (28*(A_Index-1))+20) = 1) && (NumGet(EncoderParameters, (28*(A_Index-1))+24) = 6) { p := (28*(A_Index-1))+&EncoderParameters NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20))) Break } } } } nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sOutput, "Int", -1, "UInt", 0, "Int", 0) VarSetCapacity(wOutput, nSize*2) DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sOutput, "Int", -1, "UInt", &wOutput, "Int", nSize) VarSetCapacity(wOutput, -1) If !VarSetCapacity(wOutput) Return, -4 E := DllCall("gdiplus\GdipSaveImageToFile", "UInt", pBitmap, "UInt", &wOutput, "UInt", pCodec, "UInt", p ? p : 0) Return, E ? -5 : 0 } Gdip_GetPixel(pBitmap, x, y) { DllCall("gdiplus\GdipBitmapGetPixel", "UInt", pBitmap, "Int", x, "Int", y, "UInt*", ARGB) Return, ARGB } Gdip_SetPixel(pBitmap, x, y, ARGB) { Return, DllCall("gdiplus\GdipBitmapSetPixel", "UInt", pBitmap, "Int", x, "Int", y, "Int", ARGB) } Gdip_GetImageWidth(pBitmap) { DllCall("gdiplus\GdipGetImageWidth", "UInt", pBitmap, "UInt*", Width) Return, Width } Gdip_GetImageHeight(pBitmap) { DllCall("gdiplus\GdipGetImageHeight", "UInt", pBitmap, "UInt*", Height) Return, Height } Gdip_GetDpiX(pGraphics) { DllCall("gdiplus\GdipGetDpiX", "UInt", pGraphics, "Float*", DPIx) Return, DPIx } Gdip_GetDpiY(pGraphics) { DllCall("gdiplus\GdipGetDpiY", "UInt", pGraphics, "Float*", DPIy) Return, DPIy } Gdip_CreateBitmapFromFile(sFile) { VarSetCapacity(wFile, 1023) DllCall("kernel32\MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sFile, "Int", -1, "UInt", &wFile, "Int", 512) DllCall("gdiplus\GdipCreateBitmapFromFile", "UInt", &wFile, "UInt*", pBitmap) Return, pBitmap } Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0) { DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UInt", hBitmap, "UInt", Palette, "UInt*", pBitmap) Return, pBitmap } Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff) { DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "UInt", pBitmap, "UInt*", hbm, "Int", Background) Return, hbm } Gdip_CreateBitmapFromHICON(hIcon) { DllCall("gdiplus\GdipCreateBitmapFromHICON", "UInt", hIcon, "UInt*", pBitmap) Return, pBitmap } Gdip_CreateHICONFromBitmap(pBitmap) { DllCall("gdiplus\GdipCreateHICONFromBitmap", "UInt", pBitmap, "UInt*", hIcon) Return, hIcon } Gdip_CreateBitmap(Width, Height, Format=0x26200A) { DllCall("gdiplus\GdipCreateBitmapFromScan0", "Int", Width, "Int", Height, "Int", 0, "Int", Format, "UInt", 0, "UInt*", pBitmap) Return pBitmap } Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A) { DllCall("gdiplus\GdipCloneBitmapArea", "Float", x, "Float", y, "Float", w, "Float", h , "Int", Format, "UInt", pBitmap, "UInt*", pBitmapDest) Return, pBitmapDest } ;##################################################################################### ; Create resources ;##################################################################################### Gdip_CreatePen(ARGB, w) { DllCall("gdiplus\GdipCreatePen1", "Int", ARGB, "Float", w, "Int", 2, "UInt*", pPen) Return, pPen } Gdip_BrushCreateSolid(ARGB=0xff000000) { DllCall("gdiplus\GdipCreateSolidFill", "Int", ARGB, "UInt*", pBrush) Return, pBrush } ; HatchStyleHorizontal = 0 ; HatchStyleVertical = 1 ; HatchStyleForwardDiagonal = 2 ; HatchStyleBackwardDiagonal = 3 ; HatchStyleCross = 4 ; HatchStyleDiagonalCross = 5 ; HatchStyle05Percent = 6 ; HatchStyle10Percent = 7 ; HatchStyle20Percent = 8 ; HatchStyle25Percent = 9 ; HatchStyle30Percent = 10 ; HatchStyle40Percent = 11 ; HatchStyle50Percent = 12 ; HatchStyle60Percent = 13 ; HatchStyle70Percent = 14 ; HatchStyle75Percent = 15 ; HatchStyle80Percent = 16 ; HatchStyle90Percent = 17 ; HatchStyleLightDownwardDiagonal = 18 ; HatchStyleLightUpwardDiagonal = 19 ; HatchStyleDarkDownwardDiagonal = 20 ; HatchStyleDarkUpwardDiagonal = 21 ; HatchStyleWideDownwardDiagonal = 22 ; HatchStyleWideUpwardDiagonal = 23 ; HatchStyleLightVertical = 24 ; HatchStyleLightHorizontal = 25 ; HatchStyleNarrowVertical = 26 ; HatchStyleNarrowHorizontal = 27 ; HatchStyleDarkVertical = 28 ; HatchStyleDarkHorizontal = 29 ; HatchStyleDashedDownwardDiagonal = 30 ; HatchStyleDashedUpwardDiagonal = 31 ; HatchStyleDashedHorizontal = 32 ; HatchStyleDashedVertical = 33 ; HatchStyleSmallConfetti = 34 ; HatchStyleLargeConfetti = 35 ; HatchStyleZigZag = 36 ; HatchStyleWave = 37 ; HatchStyleDiagonalBrick = 38 ; HatchStyleHorizontalBrick = 39 ; HatchStyleWeave = 40 ; HatchStylePlaid = 41 ; HatchStyleDivot = 42 ; HatchStyleDottedGrid = 43 ; HatchStyleDottedDiamond = 44 ; HatchStyleShingle = 45 ; HatchStyleTrellis = 46 ; HatchStyleSphere = 47 ; HatchStyleSmallGrid = 48 ; HatchStyleSmallCheckerBoard = 49 ; HatchStyleLargeCheckerBoard = 50 ; HatchStyleOutlinedDiamond = 51 ; HatchStyleSolidDiamond = 52 ; HatchStyleTotal = 53 Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0) { DllCall("gdiplus\GdipCreateHatchBrush", "Int", HatchStyle, "Int", ARGBfront, "Int", ARGBback, "UInt*", pBrush) Return, pBrush } ; WrapModeTile = 0 ; WrapModeTileFlipX = 1 ; WrapModeTileFlipY = 2 ; WrapModeTileFlipXY = 3 ; WrapModeClamp = 4 Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1) { CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2) DllCall("gdiplus\GdipCreateLineBrush", "UInt", &PointF1, "UInt", &PointF2, "Int", ARGB1, "Int", ARGB2, "Int", WrapMode, "UInt*", LGpBrush) Return, LGpBrush } ; LinearGradientModeHorizontal = 0 ; LinearGradientModeVertical = 1 ; LinearGradientModeForwardDiagonal = 2 ; LinearGradientModeBackwardDiagonal = 3 Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1) { CreateRectF(RectF, x, y, w, h) DllCall("gdiplus\GdipCreateLineBrushFromRect", "UInt", &RectF, "Int", ARGB1, "Int", ARGB2, "Int", LinearGradientMode, "Int", WrapMode, "UInt*", LGpBrush) Return, LGpBrush } ;##################################################################################### ; Delete resources ;##################################################################################### Gdip_DeletePen(pPen) { Return, DllCall("gdiplus\GdipDeletePen", "UInt", pPen) } Gdip_DeleteBrush(pBrush) { Return, DllCall("gdiplus\GdipDeleteBrush", "UInt", pBrush) } Gdip_DisposeImage(pBitmap) { Return, DllCall("gdiplus\GdipDisposeImage", "UInt", pBitmap) } Gdip_DeleteGraphics(pGraphics) { Return, DllCall("gdiplus\GdipDeleteGraphics", "UInt", pGraphics) } Gdip_DisposeImageAttributes(ImageAttr) { Return, DllCall("gdiplus\GdipDisposeImageAttributes", "UInt", ImageAttr) } Gdip_DeleteFont(hFont) { Return, DllCall("gdiplus\GdipDeleteFont", "UInt", hFont) } Gdip_DeleteStringFormat(hFormat) { Return, DllCall("gdiplus\GdipDeleteStringFormat", "UInt", hFormat) } Gdip_DeleteFontFamily(hFamily) { Return, DllCall("gdiplus\GdipDeleteFontFamily", "UInt", hFamily) } Gdip_DeleteMatrix(Matrix) { Return, DllCall("gdiplus\GdipDeleteMatrix", "UInt", Matrix) } ;##################################################################################### ; Text functions ;##################################################################################### Gdip_TextToGraphics(pGraphics, Text, Options, Font="Arial", Width="", Height="") { IWidth := Width, IHeight:= Height RegExMatch(Options, "i)X([\-0-9]+)(p*)", xpos) RegExMatch(Options, "i)Y([\-0-9]+)(p*)", ypos) RegExMatch(Options, "i)W([0-9]+)(p*)", Width) RegExMatch(Options, "i)H([0-9]+)(p*)", Height) RegExMatch(Options, "i)C(?!(entre|enter))([a-f0-9]{8})", Colour) RegExMatch(Options, "i)Top|Up|Bottom|Down|vCentre|vCenter", vPos) RegExMatch(Options, "i)R([0-9])", Rendering) RegExMatch(Options, "i)S([0-9]+)(p*)", Size) If !(IWidth && IHeight) && (xpos2 || ypos2 || Width2 || Height2 || Size2) Return, -1 Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout" Loop, Parse, Styles, | { If RegExMatch(Options, "\b" A_loopField) Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8 } Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right" Loop, Parse, Alignments, | { If RegExMatch(Options, "\b" A_loopField) Align |= A_Index//2.1 ; 0|0|1|1|2|2 } xpos := (xpos1 != "") ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0 ypos := (ypos1 != "") ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0 Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight Colour := "0x" (Colour2 ? Colour2 : "ff000000") Rendering := ((Rendering1 >= 0) && (Rendering1 <= 4)) ? Rendering1 : 4 Size := (Size1 > 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12 hFamily := Gdip_FontFamilyCreate(Font) hFont := Gdip_FontCreate(hFamily, Size, Style) hFormat := Gdip_StringFormatCreate(0x4000) pBrush := Gdip_BrushCreateSolid(Colour) If !(hFamily && hFont && hFormat && pBrush && pGraphics) Return, !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0 CreateRectF(RC, xpos, ypos, Width, Height) Gdip_SetStringFormatAlign(hFormat, Align) Gdip_SetTextRenderingHint(pGraphics, Rendering) ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC) If vPos { StringSplit, ReturnRC, ReturnRC, | If (vPos = "vCentre") || (vPos = "vCenter") ypos := (Height-ReturnRC4)//2 Else If (vPos = "Top") || (vPos = "Up") ypos := 0 Else If (vPos = "Bottom") || (vPos = "Down") ypos := Height-ReturnRC4 CreateRectF(RC, xpos, ypos, Width, ReturnRC4) } E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC) Gdip_DeleteBrush(pBrush) Gdip_DeleteStringFormat(hFormat) Gdip_DeleteFont(hFont) Gdip_DeleteFontFamily(hFamily) Return, E ? E : ReturnRC } Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF) { nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0) VarSetCapacity(wString, nSize*2) DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize) Return, DllCall("gdiplus\GdipDrawString", "UInt", pGraphics, "UInt", &wString, "Int", -1, "UInt", hFont, "UInt", &RectF, "UInt", hFormat, "UInt", pBrush) } Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF) { nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0) VarSetCapacity(wString, nSize*2) DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize) VarSetCapacity(RC, 16) DllCall("gdiplus\GdipMeasureString", "UInt", pGraphics, "UInt", &wString, "Int", -1, "UInt", hFont, "UInt", &RectF, "UInt", hFormat, "UInt", &RC, "UInt*", Chars, "UInt*", Lines) Return, &RC ? NumGet(RC, 0, "Float") "|" NumGet(RC, 4, "Float") "|" NumGet(RC, 8, "Float") "|" NumGet(RC, 12, "Float") "|" Chars "|" Lines : 0 } ; Near = 0 ; Center = 1 ; Far = 2 Gdip_SetStringFormatAlign(hFormat, Align) { Return, DllCall("gdiplus\GdipSetStringFormatAlign", "UInt", hFormat, "Int", Align) } Gdip_StringFormatCreate(Format=0, Lang=0) { DllCall("gdiplus\GdipCreateStringFormat", "Int", Format, "Int", Lang, "UInt*", hFormat) Return, hFormat } ; Regular = 0 ; Bold = 1 ; Italic = 2 ; BoldItalic = 3 ; Underline = 4 ; Strikeout = 8 Gdip_FontCreate(hFamily, Size, Style=0) { DllCall("gdiplus\GdipCreateFont", "UInt", hFamily, "Float", Size, "Int", Style, "Int", 0, "UInt*", hFont) Return, hFont } Gdip_FontFamilyCreate(Font) { nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &Font, "Int", -1, "UInt", 0, "Int", 0) VarSetCapacity(wFont, nSize*2) DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &Font, "Int", -1, "UInt", &wFont, "Int", nSize) DllCall("gdiplus\GdipCreateFontFamilyFromName", "UInt", &wFont, "UInt", 0, "UInt*", hFamily) Return, hFamily } ;##################################################################################### ; Matrix functions ;##################################################################################### Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y) { DllCall("gdiplus\GdipCreateMatrix2", "Float", m11, "Float", m12, "Float", m21, "Float", m22, "Float", x, "Float", y, "UInt*", Matrix) Return, Matrix } Gdip_CreateMatrix() { DllCall("gdiplus\GdipCreateMatrix", "UInt*", Matrix) Return, Matrix } ;##################################################################################### ; GraphicsPath functions ;##################################################################################### ; Alternate = 0 ; Winding = 1 Gdip_CreatePath(BrushMode=0) { DllCall("gdiplus\GdipCreatePath", "Int", BrushMode, "UInt*", Path) Return, Path } Gdip_AddPathEllipse(Path, x, y, w, h) { Return, DllCall("gdiplus\GdipAddPathEllipse", "UInt", Path, "Float", x, "Float", y, "Float", w, "Float", h) } Gdip_DeletePath(Path) { Return, DllCall("gdiplus\GdipDeletePath", "UInt", Path) } ;##################################################################################### ; Quality functions ;##################################################################################### ; SystemDefault = 0 ; SingleBitPerPixelGridFit = 1 ; SingleBitPerPixel = 2 ; AntiAliasGridFit = 3 ; AntiAlias = 4 Gdip_SetTextRenderingHint(pGraphics, RenderingHint) { Return, DllCall("gdiplus\GdipSetTextRenderingHint", "UInt", pGraphics, "Int", RenderingHint) } ; Default = 0 ; LowQuality = 1 ; HighQuality = 2 ; Bilinear = 3 ; Bicubic = 4 ; NearestNeighbor = 5 ; HighQualityBilinear = 6 ; HighQualityBicubic = 7 Gdip_SetInterpolationMode(pGraphics, InterpolationMode) { Return, DllCall("gdiplus\GdipSetInterpolationMode", "UInt", pGraphics, "Int", InterpolationMode) } ; Default = 0 ; HighSpeed = 1 ; HighQuality = 2 ; None = 3 ; AntiAlias = 4 Gdip_SetSmoothingMode(pGraphics, SmoothingMode) { Return, DllCall("gdiplus\GdipSetSmoothingMode", "UInt", pGraphics, "Int", SmoothingMode) } ;GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics, CompositingMode compositingMode) ; CompositingModeSourceOver = 0 (blended) ; CompositingModeSourceCopy = 1 (overwrite) Gdip_SetCompositingMode(pGraphics, CompositingMode=0) { Return, DllCall("gdiplus\GdipSetCompositingMode", "UInt", pGraphics, "Int", CompositingMode) } ;##################################################################################### ; Extra functions ;##################################################################################### Gdip_Startup() { If !DllCall("GetModuleHandle", "Str", "gdiplus") DllCall("LoadLibrary", "Str", "gdiplus") VarSetCapacity(si, 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UInt*", pToken, "UInt", &si, "UInt", 0) Return, pToken } Gdip_Shutdown(pToken) { DllCall("gdiplus\GdiplusShutdown", "UInt", pToken) If hModule := DllCall("GetModuleHandle", "Str", "gdiplus") DllCall("FreeLibrary", "UInt", hModule) Return, 0 } ; Prepend = 0; The new operation is applied before the old operation. ; Append = 1; The new operation is applied after the old operation. Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0) { Return, DllCall("gdiplus\GdipRotateWorldTransform", "UInt", pGraphics, "Float", Angle, "Int", MatrixOrder) } Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0) { Return, DllCall("gdiplus\GdipScaleWorldTransform", "UInt", pGraphics, "Float", x, "Float", y, "Int", MatrixOrder) } Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0) { Return, DllCall("gdiplus\GdipTranslateWorldTransform", "UInt", pGraphics, "Float", x, "Float", y, "Int", MatrixOrder) } Gdip_ResetWorldTransform(pGraphics) { Return, DllCall("gdiplus\GdipResetWorldTransform", "UInt", pGraphics) } Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation) { pi := 4*ATan(1), TAngle := Angle*(pi/180) Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360) If ((Bound >= 0) && (Bound <= 90)) xTranslation := Height*Sin(TAngle), yTranslation := 0 Else If ((Bound > 90) && (Bound <= 180)) xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle) Else If ((Bound > 180) && (Bound <= 270)) xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle)) Else If ((Bound > 270) && (Bound <= 360)) xTranslation := 0, yTranslation := -Width*Sin(TAngle) } Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight) { pi := 4*ATan(1), TAngle := Angle*(pi/180) If !(Width && Height) Return, -1 RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle))) RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle))) } ; Replace = 0 ; Intersect = 1 ; Union = 2 ; Xor = 3 ; Exclude = 4 ; Complement = 5 Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0) { Return, DllCall("gdiplus\GdipSetClipRect", "UInt", pGraphics, "Float", x, "Float", y, "Float", w, "Float", h, "Int", CombineMode) } Gdip_SetClipPath(pGraphics, Path, CombineMode=0) { Return, DllCall("gdiplus\GdipSetClipPath", "UInt", pGraphics, "UInt", Path, "Int", CombineMode) } Gdip_ResetClip(pGraphics) { Return, DllCall("gdiplus\GdipResetClip", "UInt", pGraphics) } Gdip_GetClipRegion(pGraphics) { Region := Gdip_CreateRegion() DllCall("gdiplus\GdipGetClip", "UInt" pGraphics, "UInt*", Region) Return, Region } Gdip_SetClipRegion(pGraphics, Region, CombineMode=0) { Return, DllCall("gdiplus\GdipSetClipRegion", "UInt", pGraphics, "UInt", Region, "Int", CombineMode) } Gdip_CreateRegion() { DllCall("gdiplus\GdipCreateRegion", "UInt*", Region) Return, Region } Gdip_DeleteRegion(Region) { Return, DllCall("gdiplus\GdipDeleteRegion", "UInt", Region) }
|
|
|
|
|