|
152
|
DonationCoder.com Software / Coding Snacks / Re: Window Tags
|
on: April 03, 2008, 10:21:36 AM
|
 I don't remember either, but here's KeySwitch - Use hotkeys to switch windows! 1: Press Ctrl-T to start assigning a hotkey. 2: Press Ctrl and 0 through 9 to assign that hotkey to the active window. 3: To swith to a window, press the assigned hotkey. To change modifiers and hotkeys, edit the modifier= and addkey= lines below. Skrommel [ copy or print] ;KeySwitch.ahk ; Use hotkeys to switch windows. ; 1: Press Ctrl-T to start assigning a hotkey. ; 2: Press Ctrl and 0 through 9 to assign that hotkey to the active window. ; 3: To swith to a window, press the assigned hotkey. ; To change modifiers and hotkeys, edit the modifier= and addkey= lines below. ;Skrommel @ 2008 modifier=^ ;^=Ctrl !=Alt +=Shift #=Win addkey=^T #SingleInstance,Force #NoEnv StringReplace,modifiertext,modifier,^,Ctrl- StringReplace,modifiertext,modifiertext,!,Alt- StringReplace,modifiertext,modifiertext,+,Shift- StringReplace,modifiertext,modifiertext,#,Win- StringReplace,addkeytext,addkey,^,Ctrl- StringReplace,addkeytext,addkeytext,!,Alt- StringReplace,addkeytext,addkeytext,+,Shift- StringReplace,addkeytext,addkeytext,#,Win- Loop,10 { key:=A_Index-1 Hotkey,%modifier%%key%,USE } Hotkey,%addkey%,ADD TOOLTIP("Press " addkeytext "`n to assign a hotkey to the active window`n`nwww.1HourSoftware.com",10) add=0 Return ADD: If add=0 { add=1 TOOLTIP("Press " modifiertext " and 0 through 9`n to assign the hotkey to the active window",0) } Else { add=0 ToolTip, } Return USE: StringRight,key,A_ThisHotkey,1 If add=1 { WinGet,winid%key%,Id,A add=0 WinGetTitle,title,A TOOLTIP(modifiertext . key " = " title) } Else { winid:=winid%key% WinActivate,Ahk_Id %winid% } Return TOOLTIP(message,timeout=4) { ToolTip,%message% If timeout<>0 SetTimer,TOOLTIPOFF,% timeout*1000 Return } TOOLTIPOFF: SetTimer,TOOLTIPOFF,Off ToolTip Return
|
|
|
|
|
154
|
DonationCoder.com Software / Post New Requests Here / Re: A folder when opened in "icon view" will run the application in it
|
on: March 31, 2008, 06:43:50 AM
|
 Try IconRun - doubleclick on a folder to launch the program inside! IconRun runs the program used to customize a folder's icon. To change what program to launch, rightclick on a folder, choose Properties, choose Customize, choose Change Icon and locate the program to run and use as a folder icon. When I find out how to identify an icon view, I'll add code to run the program that closest matches the folder name, or if it's only one program inside the folder, run it.  Also, it doesn't work with folders placed on the desktop. Skrommel [ copy or print] ;IconRun.ahk ; Doubleclick on a folder to launch the program inside. ; IconRun runs the program used to customize a folder's icon. ; To change what program to launch, rightclick on a folder, ; choose Properties, choose Customize, choose Change Icon ; and locate the program to run and use as a folder icon. ;Skrommel @ 2008 #NoEnv #SingleInstance,Force SendMode Input SetWorkingDir %A_ScriptDir% SetWinDelay,0 SetKeyDelay,0 SetBatchLines,-1 CoordMode,Mouse,Screen SysGet,doubleclickx,36 SysGet,doubleclicky,37 doubleclicktime:=DllCall("GetDoubleClickTime") Return #IfWinActive,ahk_class ExploreWClass $LButton:: Gosub,DOWN Return #IfWinActive,ahk_class CabinetWClass $LButton:: Gosub,DOWN Return #IfWinActive,ahk_class ExploreWClass $LButton Up:: Gosub,UP Return #IfWinActive,ahk_class CabinetWClass $LButton Up:: Gosub,UP Return DOWN: tick1:=tick2 tick2:=A_TickCount mx1:=mx2 my1:=my2 mwin1:=mwin2 mctrl1:=mctrl2 MouseGetPos,mx2,my2,mwin2,mctrl2 If (Abs(mx2-mx1)>doubleclickx Or Abs(my2-my1)>doubleclicky Or tick2-tick1>doubleclicktime Or mwin2<>mwin1 Or mctrl2<>mctrl1) { Click,Down counter=1 Return } counter+=1 Return UP: Sleep,% doubleclicktime/999 Click,Up Gosub,ACTION%counter% Return ACTION1: Return ACTION2: counter=0 MouseGetPos,,,mwin,mctrl If mctrl<>SysListView321 Goto,CLICK ControlGet,list,List,Focused,%mctrl%,ahk_id %mwin% If list= Goto,CLICK StringSplit,item,list,`n StringSplit,filename,item1,%A_Tab% Gosub,GETFOLDER path=%folder%\%filename1% FileGetAttrib,attrib,%path% IfNotInString,attrib,D Goto,CLICK IniRead,icon,%path%\desktop.ini,.ShellClassInfo,IconResource If icon=ERROR Goto,CLICK StringSplit,part,icon,`, SplitPath,part1,name,dir,ext,name_no_ext,drive If ext In ico,dll Goto,CLICK Run,%part1% Return CLICK: Click Return GETFOLDER: folder:=ShellFolder(hwndExplorer) StringRight,last,folder,1 If last=\ StringTrimRight,folder,folder,1 Return ;Stolen from Sean at http://www.autohotkey.com/forum/topic20701.html ShellFolder(hwnd=0) { If !(hWnd||(hWnd:=WinExist("ahk_class CabinetWClass"))||(hWnd:=WinExist("ahk_class ExploreWClass"))) Return COM_Init() psh:=COM_CreateObject("Shell.Application") psw:=COM_Invoke(psh,"Windows") Loop,% COM_Invoke(psw,"Count") { If COM_Invoke(pwb:=COM_Invoke(psw,"Item",A_Index-1),"hWnd")<>hWnd COM_Release(pwb) Else Break } sFolder:=COM_Invoke(pfi:=COM_Invoke(psf:=COM_Invoke(pfv:=COM_Invoke(pwb,"Document"),"Folder"),"Self"),"Path") COM_Release(psf) COM_Release(pfi) COM_Release(pfv) COM_Release(pwb) COM_Release(psw) COM_Release(psh) COM_Term() Return,sFolder } ;Com.ahk by Sean at http://www.autohotkey.net/~Sean/Lib/COM.zip COM_Init(bOLE = False) { Return bOLE ? COM_OleInitialize() : COM_CoInitialize() } COM_Term(bOLE = False) { Return bOLE ? COM_OleUninitialize() : COM_CoUninitialize() } COM_VTable(ppv, idx) { Return NumGet(NumGet(1*ppv)+4*idx) } COM_QueryInterface(ppv, IID = "") { If DllCall(NumGet(NumGet(1*ppv)+0), "Uint", ppv, "Uint", COM_GUID4String(IID,IID ? IID : IID=0 ? "{00000000-0000-0000-C000-000000000046}" : "{00020400-0000-0000-C000-000000000046}"), "UintP", ppv)=0 Return ppv } COM_AddRef(ppv) { Return DllCall(NumGet(NumGet(1*ppv)+4), "Uint", ppv) } COM_Release(ppv) { Return DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv) } COM_QueryService(ppv, SID, IID = "") { DllCall(NumGet(NumGet(1*ppv)+4*0), "Uint", ppv, "Uint", COM_GUID4String(IID_IServiceProvider,"{6D5140C1-7436-11CE-8034-00AA006009FA}"), "UintP", psp) DllCall(NumGet(NumGet(1*psp)+4*3), "Uint", psp, "Uint", COM_GUID4String(SID,SID), "Uint", IID ? COM_GUID4String(IID,IID) : &SID, "UintP", ppv:=0) DllCall(NumGet(NumGet(1*psp)+4*2), "Uint", psp) Return ppv } COM_FindConnectionPoint(pdp, DIID) { DllCall(NumGet(NumGet(1*pdp)+ 0), "Uint", pdp, "Uint", COM_GUID4String(IID_IConnectionPointContainer, "{B196B284-BAB4-101A-B69C-00AA00341D07}"), "UintP", pcc) DllCall(NumGet(NumGet(1*pcc)+16), "Uint", pcc, "Uint", COM_GUID4String(DIID,DIID), "UintP", pcp) DllCall(NumGet(NumGet(1*pcc)+ 8), "Uint", pcc) Return pcp } COM_GetConnectionInterface(pcp) { VarSetCapacity(DIID, 16, 0) DllCall(NumGet(NumGet(1*pcp)+12), "Uint", pcp, "Uint", &DIID) Return COM_String4GUID(&DIID) } COM_Advise(pcp, psink) { DllCall(NumGet(NumGet(1*pcp)+20), "Uint", pcp, "Uint", psink, "UintP", nCookie) Return nCookie } COM_Unadvise(pcp, nCookie) { Return DllCall(NumGet(NumGet(1*pcp)+24), "Uint", pcp, "Uint", nCookie) } COM_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 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(COM_SysFreeString(bstr),1,0) : NumGet(varResult,8) Return _hResult_ } COM_Invoke(pdisp, sName, arg0="vT_NoNe",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") { Global _hResult_ nParams := 10 sParams := 0123456789 Loop, Parse, sParams If (arg%A_LoopField% == "vT_NoNe") { nParams := A_Index - 1 Break } sParams := SubStr(sParams,1,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, Parse, sParams If arg%A_LoopField% Is Not Integer NumPut(8,varg,(nParams-A_Index)*16,"Ushort"), NumPut(COM_SysAllocString(arg%A_LoopField%),varg,(nParams-A_Index)*16+8) Else NumPut(SubStr(arg%A_LoopField%,1,1)="+" ? 9 : 3,varg,(nParams-A_Index)*16,"Ushort"), NumPut(arg%A_LoopField%,varg,(nParams-A_Index)*16+8) If (0 = _hResult_:=DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", COM_Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)) && (0 = _hResult_:=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)) && (3 = nFlags) Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(COM_SysFreeString(bstr),1,0) : NumGet(varResult,8) Loop, % nParams NumGet(varg,(A_Index-1)*16,"Ushort")=8 ? COM_SysFreeString(NumGet(varg,(A_Index-1)*16+8)) : "" Return Result } COM_Invoke_(pdisp, sName, type0="",arg0="",type1="",arg1="",type2="",arg2="",type3="",arg3="",type4="",arg4="",type5="",arg5="",type6="",arg6="",type7="",arg7="",type8="",arg8="",type9="",arg9="") { Global _hResult_ nParams := 10 sParams := 0123456789 Loop, Parse, sParams If (type%A_LoopField% = "") { nParams := A_Index - 1 Break } sParams := SubStr(sParams,1,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, Parse, sParams NumPut(type%A_LoopField%,varg,(nParams-A_Index)*16,"Ushort"), type%A_LoopField%&0x4000=0 ? NumPut(type%A_LoopField%=8 ? COM_SysAllocString(arg%A_LoopField%) : arg%A_LoopField%,varg,(nParams-A_Index)*16+8,type%A_LoopField%=5||type%A_LoopField%=7 ? "double" : type%A_LoopField%=4 ? "float" : "int64") : type%A_LoopField%=0x400C||type%A_LoopField%=0x400E ? NumPut(arg%A_LoopField%,varg,(nParams-A_Index)*16+8) : VarSetCapacity(_ref_%A_LoopField%,8,0) . NumPut(&_ref_%A_LoopField%,varg,(nParams-A_Index)*16+8) . NumPut(type%A_LoopField%=0x4008 ? COM_SysAllocString(arg%A_LoopField%) : arg%A_LoopField%,_ref_%A_LoopField%,0,type%A_LoopField%=0x4005||type%A_LoopField%=0x4007 ? "double" : type%A_LoopField%=0x4004 ? "float" : "int64") If (0 = _hResult_:=DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", COM_Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)) && (0 = _hResult_:=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)) && (3 = nFlags) Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(COM_SysFreeString(bstr),1,0) : NumGet(varResult,8) Loop, Parse, sParams type%A_LoopField%&0x4000=0 ? (type%A_LoopField%=8 ? COM_SysFreeString(NumGet(varg,(nParams-A_Index)*16+8)) : "") : type%A_LoopField%=0x400C||type%A_LoopField%=0x400E ? "" : type%A_LoopField%=0x4008 ? (_TEMP_VT_BYREF_%A_LoopField%:=COM_Ansi4Unicode(NumGet(_ref_%A_LoopField%))) . COM_SysFreeString(NumGet(_ref_%A_LoopField%)) : (_TEMP_VT_BYREF_%A_LoopField%:=NumGet(_ref_%A_LoopField%,0,type%A_LoopField%=0x4005||type%A_LoopField%=0x4007 ? "double" : type%A_LoopField%=0x4004 ? "float" : "int64")) Return Result } COM_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"), COM_SysFreeString(pname), (pfn:=RegisterCallback(sfn,"C F")) ? (hResult:=DllCall(pfn,"Uint",prm5,"Uint",prm6,"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 ? "" : COM_Unadvise(NumGet(this+16),NumGet(this+20)) . COM_Release(NumGet(this+16)) . COM_Release(NumGet(this+8)) . COM_CoTaskMemFree(this) Else If A_EventInfo = 1 NumPut(hResult:=NumGet(this+4)+1,this+4) Else If A_EventInfo = 0 COM_IsEqualGUID(this+24,prm1)||InStr("{00020400-0000-0000-C000-000000000046}{00000000-0000-0000-C000-000000000046}",COM_String4GUID(prm1)) ? NumPut(this,prm2+0) . NumPut(NumGet(this+4)+1,this+4) . (hResult:=0) : NumPut(0,prm2+0) . (hResult:=0x80004002) Return hResult } COM_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 ? COM_Ansi4Unicode(NumGet(varResult,8)) . SubStr(COM_SysFreeString(NumGet(varResult,8)),1,0) : NumGet(varResult,8) } COM_CreateIDispatch() { Static IDispatch If Not VarSetCapacity(IDispatch) { VarSetCapacity(IDispatch,28,0), nParams=3112469 Loop, Parse, nParams NumPut(RegisterCallback("COM_DispInterface","",A_LoopField,A_Index-1),IDispatch,4*(A_Index-1)) } Return &IDispatch } COM_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 } COM_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:=COM_String4GUID(pattr) : bFind:=COM_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}" } COM_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", COM_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 := COM_String4GUID(pattr) DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr) DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf) Return GUID } COM_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", COM_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! COM_ConnectObject(psource, prefix = "", DIID = "") { If Not DIID 0+(pconn:=COM_FindConnectionPoint(psource,"{00020400-0000-0000-C000-000000000046}")) ? (DIID:=COM_GetConnectionInterface(pconn))="{00020400-0000-0000-C000-000000000046}" ? DIID:=COM_GetDefaultEvents(psource) : "" : pconn:=COM_FindConnectionPoint(psource,DIID:=COM_GetDefaultEvents(psource)) Else pconn:=COM_FindConnectionPoint(psource,SubStr(DIID,1,1)="{" ? DIID : DIID:=COM_GetGuidOfName(psource,DIID)) If !pconn || !ptinf:=COM_GetTypeInfoOfGuid(psource,DIID) { MsgBox, No Event Interface Exists! Now exit the application. ExitApp } psink:=COM_CoTaskMemAlloc(40+StrLen(prefix)+1), NumPut(1,NumPut(COM_CreateIDispatch(),psink+0)), NumPut(psource,NumPut(ptinf,psink+8)) DllCall("RtlMoveMemory", "Uint", psink+24, "Uint", COM_GUID4String(DIID,DIID), "Uint", 16) DllCall("RtlMoveMemory", "Uint", psink+40, "Uint", &prefix, "Uint", StrLen(prefix)+1) NumPut(COM_Advise(pconn,psink),NumPut(pconn,psink+16)) Return psink } COM_CreateObject(CLSID, IID = "", CLSCTX = 5) { DllCall("ole32\CoCreateInstance", "Uint", SubStr(CLSID,1,1)="{" ? COM_GUID4String(CLSID,CLSID) : COM_CLSID4ProgID(CLSID,CLSID), "Uint", 0, "Uint", CLSCTX, "Uint", COM_GUID4String(IID,IID ? IID : IID=0 ? "{00000000-0000-0000-C000-000000000046}" : "{00020400-0000-0000-C000-000000000046}"), "UintP", ppv) Return ppv } COM_ActiveXObject(ProgID) { DllCall("ole32\CoCreateInstance", "Uint", SubStr(ProgID,1,1)="{" ? COM_GUID4String(ProgID,ProgID) : COM_CLSID4ProgID(ProgID,ProgID), "Uint", 0, "Uint", 5, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) Return COM_GetDefaultInterface(pdisp) } COM_GetObject(Moniker) { DllCall("ole32\CoGetObject", "Uint", COM_Unicode4Ansi(Moniker,Moniker), "Uint", 0, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) Return COM_GetDefaultInterface(pdisp) } COM_GetActiveObject(ProgID) { DllCall("oleaut32\GetActiveObject", "Uint", SubStr(ProgID,1,1)="{" ? COM_GUID4String(ProgID,ProgID) : COM_CLSID4ProgID(ProgID,ProgID), "Uint", 0, "UintP", punk) DllCall(NumGet(NumGet(1*punk)+0), "Uint", punk, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) DllCall(NumGet(NumGet(1*punk)+8), "Uint", punk) Return COM_GetDefaultInterface(pdisp) } COM_CLSID4ProgID(ByRef CLSID, ProgID) { VarSetCapacity(CLSID, 16) DllCall("ole32\CLSIDFromProgID", "Uint", COM_Unicode4Ansi(ProgID,ProgID), "Uint", &CLSID) Return &CLSID } COM_GUID4String(ByRef CLSID, String) { VarSetCapacity(CLSID, 16) DllCall("ole32\CLSIDFromString", "Uint", COM_Unicode4Ansi(String,String,38), "Uint", &CLSID) Return &CLSID } COM_ProgID4CLSID(pCLSID) { DllCall("ole32\ProgIDFromCLSID", "Uint", pCLSID, "UintP", pProgID) Return COM_Ansi4Unicode(pProgID) . SubStr(COM_CoTaskMemFree(pProgID),1,0) } COM_String4GUID(pGUID) { VarSetCapacity(String, 38 * 2 + 1) DllCall("ole32\StringFromGUID2", "Uint", pGUID, "Uint", &String, "int", 39) Return COM_Ansi4Unicode(&String, 38) } COM_IsEqualGUID(pGUID1, pGUID2) { Return DllCall("ole32\IsEqualGUID", "Uint", pGUID1, "Uint", pGUID2) } COM_CoCreateGuid() { VarSetCapacity(GUID, 16, 0) DllCall("ole32\CoCreateGuid", "Uint", &GUID) Return COM_String4GUID(&GUID) } COM_CoTaskMemAlloc(cb) { Return DllCall("ole32\CoTaskMemAlloc", "Uint", cb) } COM_CoTaskMemFree(pv) { Return DllCall("ole32\CoTaskMemFree", "Uint", pv) } COM_CoInitialize() { Return DllCall("ole32\CoInitialize", "Uint", 0) } COM_CoUninitialize() { Return DllCall("ole32\CoUninitialize") } COM_OleInitialize() { Return DllCall("ole32\OleInitialize", "Uint", 0) } COM_OleUninitialize() { Return DllCall("ole32\OleUninitialize") } COM_SysAllocString(sString) { Return DllCall("oleaut32\SysAllocString", "Uint", COM_Ansi2Unicode(sString,wString)) } COM_SysFreeString(bstr) { Return DllCall("oleaut32\SysFreeString", "Uint", bstr) } COM_SysStringLen(bstr) { Return DllCall("oleaut32\SysStringLen", "Uint", bstr) } COM_SafeArrayDestroy(psa) { Return DllCall("oleaut32\SafeArrayDestroy", "Uint", psa) } COM_VariantClear(pvarg) { Return DllCall("oleaut32\VariantClear", "Uint", pvarg) } COM_AtlAxWinInit(Version = "") { COM_CoInitialize() If Not DllCall("GetModuleHandle", "str", "atl" . Version) DllCall("LoadLibrary" , "str", "atl" . Version) Return DllCall("atl" . Version . "\AtlAxWinInit") } COM_AtlAxWinTerm(Version = "") { COM_CoUninitialize() If hModule := DllCall("GetModuleHandle", "str", "atl" . Version) Return DllCall("FreeLibrary" , "Uint", hModule) } COM_AtlAxAttachControl(pdsp, hWnd, Version = "") { Return DllCall("atl" . Version . "\AtlAxAttachControl", "Uint", punk:=COM_QueryInterface(pdsp,0), "Uint", hWnd, "Uint", 0), COM_Release(punk) } COM_AtlAxCreateControl(hWnd, Name, Version = "") { If DllCall("atl" . Version . "\AtlAxCreateControl", "Uint", COM_Unicode4Ansi(Name,Name), "Uint", hWnd, "Uint", 0, "Uint", 0)=0 Return COM_AtlAxGetControl(hWnd, Version) } COM_AtlAxGetControl(hWnd, Version = "") { If DllCall("atl" . Version . "\AtlAxGetControl", "Uint", hWnd, "UintP", punk)=0 pdsp:=COM_QueryInterface(punk), COM_Release(punk) Return pdsp } COM_AtlAxGetHost(hWnd, Version = "") { If DllCall("atl" . Version . "\AtlAxGetHost", "Uint", hWnd, "UintP", punk)=0 pdsp:=COM_QueryInterface(punk), COM_Release(punk) Return pdsp } COM_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) } COM_AtlAxGetContainer(pdsp) { DllCall(NumGet(NumGet(1*pdsp)+ 0), "Uint", pdsp, "Uint", COM_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) } COM_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 } COM_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 } COM_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 } COM_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 } COM_ScriptControl(sCode, sLang = "", bExec = False, sName = "", pdisp = 0, bGlobal = False) { COM_CoInitialize() psc := COM_CreateObject("MSScriptControl.ScriptControl") COM_Invoke(psc, "Language=", sLang ? sLang : "VBScript") sName ? COM_Invoke(psc, "AddObject", sName, "+" . pdisp, bGlobal) : "" ret := COM_Invoke(psc, bExec ? "ExecuteStatement" : "Eval", sCode) COM_Release(psc) COM_CoUninitialize() Return ret }
|
|
|
|
|
155
|
DonationCoder.com Software / Coding Snacks / Re: Context-menu bmp-to-jpg converter
|
on: March 30, 2008, 01:10:39 PM
|
 Here's the next best thing: ClipToJpg! Press a hotkey to save the clipboard to a jpg-file in the active folder. Edit the filename= and hotkey= lines to change filename and hotkey. I don't know how to add something to the context menu that pops up when clicking an empty space in a folder, so I had to use a hotkey instead. Also, it doesn't work with the desktop as the active folder. Skrommel [ copy or print] ;ClipToJpg.ahk ; Press a hotkey to save the clipboard to a jpg-file in the current folder ;Skrommel @ 2008 filename=folder.jpg hotkey=F1 #NoEnv #SingleInstance,Force applicationname:=ClipToJpg Hotkey,%hotkey%,SAVE Return SAVE: folder:=ShellFolder(WinExist("A")) StringRight,last,folder,1 If last=\ StringTrimRight,folder,folder,1 If folder<> { SaveClipBoardToJPG(folder "\" filename) TrayTip,%applicationname%,Clip saved to`n%folder%\%filename% } Else TrayTip,%applicationname%,No active folder found! Return ; Save any bitmaps on the clipboard to file ; isolated by impecco@gmail.com from Sean's script "ScreenCapture.ahk" posted on ; http://www.autohotkey.com/forum/topic18146.html ; needs GDI+ libaray "gdiplus.dll" which can be obtained from ; http://www.microsoft.com/downloads/details.aspx?FamilyID=6a63ab9c-df12-4d41-933c-be590feaa05a&displaylang=en SaveClipBoardToJPG(filepath) { Convert("", filepath) } Convert(sFileFr = "", sFileTo = "") { If sFileTo = sFileTo := A_ScriptDir . "\screen.bmp" SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo If Not hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll") Return sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : "" VarSetCapacity(si, 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0) If !sFileFr { DllCall("OpenClipboard", "Uint", 0) If DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2)) { DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage) } DllCall("CloseClipboard") } Else If (sFileFr Is Integer) { DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage) } Else { DllCall("gdiplus\GdipLoadImageFromFile", "Uint", Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage) } DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize) VarSetCapacity(ci, nSize) DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci) Loop, %nCount% { If !InStr(Ansi4Unicode(NumGet(ci, 76 * (A_Index - 1) + 44)), "." . sExtTo) Continue pCodec := &ci + 76 * (A_Index - 1) Break } If pImage pCodec ? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", 0) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage) DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken) DllCall("FreeLibrary", "Uint", hGdiPlus) } SaveHBITMAPToFile(hBitmap, sFile) { DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi) hFile:= DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0) DllCall("CloseHandle", "Uint", hFile) } Unicode4Ansi(ByRef wString, sString) { 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 &wString } Ansi4Unicode(pString) { nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0) VarSetCapacity(sString, nSize) DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0) Return sString } SetClipboardData(hBitmap) { DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi) hDIB := DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44)) pDIB := DllCall("GlobalLock", "Uint", hDIB) DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40) DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44)) DllCall("GlobalUnlock", "Uint", hDIB) DllCall("DeleteObject", "Uint", hBitmap) DllCall("OpenClipboard", "Uint", 0) DllCall("EmptyClipboard") DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB) DllCall("CloseClipboard") } ;Stolen from Sean at http://www.autohotkey.com/forum/topic20701.html ShellFolder(hwnd=0) { If !(hWnd||(hWnd:=WinExist("ahk_class CabinetWClass"))||(hWnd:=WinExist("ahk_class ExploreWClass"))) Return COM_Init() psh:=COM_CreateObject("Shell.Application") psw:=COM_Invoke(psh,"Windows") Loop,% COM_Invoke(psw,"Count") { If COM_Invoke(pwb:=COM_Invoke(psw,"Item",A_Index-1),"hWnd")<>hWnd COM_Release(pwb) Else Break } sFolder:=COM_Invoke(pfi:=COM_Invoke(psf:=COM_Invoke(pfv:=COM_Invoke(pwb,"Document"),"Folder"),"Self"),"Path") COM_Release(psf) COM_Release(pfi) COM_Release(pfv) COM_Release(pwb) COM_Release(psw) COM_Release(psh) COM_Term() Return,sFolder } ;Com.ahk by Sean at http://www.autohotkey.net/~Sean/Lib/COM.zip COM_Init(bOLE = False) { Return bOLE ? COM_OleInitialize() : COM_CoInitialize() } COM_Term(bOLE = False) { Return bOLE ? COM_OleUninitialize() : COM_CoUninitialize() } COM_VTable(ppv, idx) { Return NumGet(NumGet(1*ppv)+4*idx) } COM_QueryInterface(ppv, IID = "") { If DllCall(NumGet(NumGet(1*ppv)+0), "Uint", ppv, "Uint", COM_GUID4String(IID,IID ? IID : IID=0 ? "{00000000-0000-0000-C000-000000000046}" : "{00020400-0000-0000-C000-000000000046}"), "UintP", ppv)=0 Return ppv } COM_AddRef(ppv) { Return DllCall(NumGet(NumGet(1*ppv)+4), "Uint", ppv) } COM_Release(ppv) { Return DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv) } COM_QueryService(ppv, SID, IID = "") { DllCall(NumGet(NumGet(1*ppv)+4*0), "Uint", ppv, "Uint", COM_GUID4String(IID_IServiceProvider,"{6D5140C1-7436-11CE-8034-00AA006009FA}"), "UintP", psp) DllCall(NumGet(NumGet(1*psp)+4*3), "Uint", psp, "Uint", COM_GUID4String(SID,SID), "Uint", IID ? COM_GUID4String(IID,IID) : &SID, "UintP", ppv:=0) DllCall(NumGet(NumGet(1*psp)+4*2), "Uint", psp) Return ppv } COM_FindConnectionPoint(pdp, DIID) { DllCall(NumGet(NumGet(1*pdp)+ 0), "Uint", pdp, "Uint", COM_GUID4String(IID_IConnectionPointContainer, "{B196B284-BAB4-101A-B69C-00AA00341D07}"), "UintP", pcc) DllCall(NumGet(NumGet(1*pcc)+16), "Uint", pcc, "Uint", COM_GUID4String(DIID,DIID), "UintP", pcp) DllCall(NumGet(NumGet(1*pcc)+ 8), "Uint", pcc) Return pcp } COM_GetConnectionInterface(pcp) { VarSetCapacity(DIID, 16, 0) DllCall(NumGet(NumGet(1*pcp)+12), "Uint", pcp, "Uint", &DIID) Return COM_String4GUID(&DIID) } COM_Advise(pcp, psink) { DllCall(NumGet(NumGet(1*pcp)+20), "Uint", pcp, "Uint", psink, "UintP", nCookie) Return nCookie } COM_Unadvise(pcp, nCookie) { Return DllCall(NumGet(NumGet(1*pcp)+24), "Uint", pcp, "Uint", nCookie) } COM_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 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(COM_SysFreeString(bstr),1,0) : NumGet(varResult,8) Return _hResult_ } COM_Invoke(pdisp, sName, arg0="vT_NoNe",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") { Global _hResult_ nParams := 10 sParams := 0123456789 Loop, Parse, sParams If (arg%A_LoopField% == "vT_NoNe") { nParams := A_Index - 1 Break } sParams := SubStr(sParams,1,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, Parse, sParams If arg%A_LoopField% Is Not Integer NumPut(8,varg,(nParams-A_Index)*16,"Ushort"), NumPut(COM_SysAllocString(arg%A_LoopField%),varg,(nParams-A_Index)*16+8) Else NumPut(SubStr(arg%A_LoopField%,1,1)="+" ? 9 : 3,varg,(nParams-A_Index)*16,"Ushort"), NumPut(arg%A_LoopField%,varg,(nParams-A_Index)*16+8) If (0 = _hResult_:=DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", COM_Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)) && (0 = _hResult_:=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)) && (3 = nFlags) Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(COM_SysFreeString(bstr),1,0) : NumGet(varResult,8) Loop, % nParams NumGet(varg,(A_Index-1)*16,"Ushort")=8 ? COM_SysFreeString(NumGet(varg,(A_Index-1)*16+8)) : "" Return Result } COM_Invoke_(pdisp, sName, type0="",arg0="",type1="",arg1="",type2="",arg2="",type3="",arg3="",type4="",arg4="",type5="",arg5="",type6="",arg6="",type7="",arg7="",type8="",arg8="",type9="",arg9="") { Global _hResult_ nParams := 10 sParams := 0123456789 Loop, Parse, sParams If (type%A_LoopField% = "") { nParams := A_Index - 1 Break } sParams := SubStr(sParams,1,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, Parse, sParams NumPut(type%A_LoopField%,varg,(nParams-A_Index)*16,"Ushort"), type%A_LoopField%&0x4000=0 ? NumPut(type%A_LoopField%=8 ? COM_SysAllocString(arg%A_LoopField%) : arg%A_LoopField%,varg,(nParams-A_Index)*16+8,type%A_LoopField%=5||type%A_LoopField%=7 ? "double" : type%A_LoopField%=4 ? "float" : "int64") : type%A_LoopField%=0x400C||type%A_LoopField%=0x400E ? NumPut(arg%A_LoopField%,varg,(nParams-A_Index)*16+8) : VarSetCapacity(_ref_%A_LoopField%,8,0) . NumPut(&_ref_%A_LoopField%,varg,(nParams-A_Index)*16+8) . NumPut(type%A_LoopField%=0x4008 ? COM_SysAllocString(arg%A_LoopField%) : arg%A_LoopField%,_ref_%A_LoopField%,0,type%A_LoopField%=0x4005||type%A_LoopField%=0x4007 ? "double" : type%A_LoopField%=0x4004 ? "float" : "int64") If (0 = _hResult_:=DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", COM_Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)) && (0 = _hResult_:=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)) && (3 = nFlags) Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(COM_SysFreeString(bstr),1,0) : NumGet(varResult,8) Loop, Parse, sParams type%A_LoopField%&0x4000=0 ? (type%A_LoopField%=8 ? COM_SysFreeString(NumGet(varg,(nParams-A_Index)*16+8)) : "") : type%A_LoopField%=0x400C||type%A_LoopField%=0x400E ? "" : type%A_LoopField%=0x4008 ? (_TEMP_VT_BYREF_%A_LoopField%:=COM_Ansi4Unicode(NumGet(_ref_%A_LoopField%))) . COM_SysFreeString(NumGet(_ref_%A_LoopField%)) : (_TEMP_VT_BYREF_%A_LoopField%:=NumGet(_ref_%A_LoopField%,0,type%A_LoopField%=0x4005||type%A_LoopField%=0x4007 ? "double" : type%A_LoopField%=0x4004 ? "float" : "int64")) Return Result } COM_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"), COM_SysFreeString(pname), (pfn:=RegisterCallback(sfn,"C F")) ? (hResult:=DllCall(pfn,"Uint",prm5,"Uint",prm6,"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 ? "" : COM_Unadvise(NumGet(this+16),NumGet(this+20)) . COM_Release(NumGet(this+16)) . COM_Release(NumGet(this+8)) . COM_CoTaskMemFree(this) Else If A_EventInfo = 1 NumPut(hResult:=NumGet(this+4)+1,this+4) Else If A_EventInfo = 0 COM_IsEqualGUID(this+24,prm1)||InStr("{00020400-0000-0000-C000-000000000046}{00000000-0000-0000-C000-000000000046}",COM_String4GUID(prm1)) ? NumPut(this,prm2+0) . NumPut(NumGet(this+4)+1,this+4) . (hResult:=0) : NumPut(0,prm2+0) . (hResult:=0x80004002) Return hResult } COM_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 ? COM_Ansi4Unicode(NumGet(varResult,8)) . SubStr(COM_SysFreeString(NumGet(varResult,8)),1,0) : NumGet(varResult,8) } COM_CreateIDispatch() { Static IDispatch If Not VarSetCapacity(IDispatch) { VarSetCapacity(IDispatch,28,0), nParams=3112469 Loop, Parse, nParams NumPut(RegisterCallback("COM_DispInterface","",A_LoopField,A_Index-1),IDispatch,4*(A_Index-1)) } Return &IDispatch } COM_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 } COM_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:=COM_String4GUID(pattr) : bFind:=COM_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}" } COM_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", COM_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 := COM_String4GUID(pattr) DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr) DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf) Return GUID } COM_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", COM_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! COM_ConnectObject(psource, prefix = "", DIID = "") { If Not DIID 0+(pconn:=COM_FindConnectionPoint(psource,"{00020400-0000-0000-C000-000000000046}")) ? (DIID:=COM_GetConnectionInterface(pconn))="{00020400-0000-0000-C000-000000000046}" ? DIID:=COM_GetDefaultEvents(psource) : "" : pconn:=COM_FindConnectionPoint(psource,DIID:=COM_GetDefaultEvents(psource)) Else pconn:=COM_FindConnectionPoint(psource,SubStr(DIID,1,1)="{" ? DIID : DIID:=COM_GetGuidOfName(psource,DIID)) If !pconn || !ptinf:=COM_GetTypeInfoOfGuid(psource,DIID) { MsgBox, No Event Interface Exists! Now exit the application. ExitApp } psink:=COM_CoTaskMemAlloc(40+StrLen(prefix)+1), NumPut(1,NumPut(COM_CreateIDispatch(),psink+0)), NumPut(psource,NumPut(ptinf,psink+8)) DllCall("RtlMoveMemory", "Uint", psink+24, "Uint", COM_GUID4String(DIID,DIID), "Uint", 16) DllCall("RtlMoveMemory", "Uint", psink+40, "Uint", &prefix, "Uint", StrLen(prefix)+1) NumPut(COM_Advise(pconn,psink),NumPut(pconn,psink+16)) Return psink } COM_CreateObject(CLSID, IID = "", CLSCTX = 5) { DllCall("ole32\CoCreateInstance", "Uint", SubStr(CLSID,1,1)="{" ? COM_GUID4String(CLSID,CLSID) : COM_CLSID4ProgID(CLSID,CLSID), "Uint", 0, "Uint", CLSCTX, "Uint", COM_GUID4String(IID,IID ? IID : IID=0 ? "{00000000-0000-0000-C000-000000000046}" : "{00020400-0000-0000-C000-000000000046}"), "UintP", ppv) Return ppv } COM_ActiveXObject(ProgID) { DllCall("ole32\CoCreateInstance", "Uint", SubStr(ProgID,1,1)="{" ? COM_GUID4String(ProgID,ProgID) : COM_CLSID4ProgID(ProgID,ProgID), "Uint", 0, "Uint", 5, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) Return COM_GetDefaultInterface(pdisp) } COM_GetObject(Moniker) { DllCall("ole32\CoGetObject", "Uint", COM_Unicode4Ansi(Moniker,Moniker), "Uint", 0, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) Return COM_GetDefaultInterface(pdisp) } COM_GetActiveObject(ProgID) { DllCall("oleaut32\GetActiveObject", "Uint", SubStr(ProgID,1,1)="{" ? COM_GUID4String(ProgID,ProgID) : COM_CLSID4ProgID(ProgID,ProgID), "Uint", 0, "UintP", punk) DllCall(NumGet(NumGet(1*punk)+0), "Uint", punk, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp) DllCall(NumGet(NumGet(1*punk)+8), "Uint", punk) Return COM_GetDefaultInterface(pdisp) } COM_CLSID4ProgID(ByRef CLSID, ProgID) { VarSetCapacity(CLSID, 16) DllCall("ole32\CLSIDFromProgID", "Uint", COM_Unicode4Ansi(ProgID,ProgID), "Uint", &CLSID) Return &CLSID } COM_GUID4String(ByRef CLSID, String) { VarSetCapacity(CLSID, 16) DllCall("ole32\CLSIDFromString", "Uint", COM_Unicode4Ansi(String,String,38), "Uint", &CLSID) Return &CLSID } COM_ProgID4CLSID(pCLSID) { DllCall("ole32\ProgIDFromCLSID", "Uint", pCLSID, "UintP", pProgID) Return COM_Ansi4Unicode(pProgID) . SubStr(COM_CoTaskMemFree(pProgID),1,0) } COM_String4GUID(pGUID) { VarSetCapacity(String, 38 * 2 + 1) DllCall("ole32\StringFromGUID2", "Uint", pGUID, "Uint", &String, "int", 39) Return COM_Ansi4Unicode(&String, 38) } COM_IsEqualGUID(pGUID1, pGUID2) { Return DllCall("ole32\IsEqualGUID", "Uint", pGUID1, "Uint", pGUID2) } COM_CoCreateGuid() { VarSetCapacity(GUID, 16, 0) DllCall("ole32\CoCreateGuid", "Uint", &GUID) Return COM_String4GUID(&GUID) } COM_CoTaskMemAlloc(cb) { Return DllCall("ole32\CoTaskMemAlloc", "Uint", cb) } COM_CoTaskMemFree(pv) { Return DllCall("ole32\CoTaskMemFree", "Uint", pv) } COM_CoInitialize() { Return DllCall("ole32\CoInitialize", "Uint", 0) } COM_CoUninitialize() { Return DllCall("ole32\CoUninitialize") } COM_OleInitialize() { Return DllCall("ole32\OleInitialize", "Uint", 0) } COM_OleUninitialize() { Return DllCall("ole32\OleUninitialize") } COM_SysAllocString(sString) { Return DllCall("oleaut32\SysAllocString", "Uint", COM_Ansi2Unicode(sString,wString)) } COM_SysFreeString(bstr) { Return DllCall("oleaut32\SysFreeString", "Uint", bstr) } COM_SysStringLen(bstr) { Return DllCall("oleaut32\SysStringLen", "Uint", bstr) } COM_SafeArrayDestroy(psa) { Return DllCall("oleaut32\SafeArrayDestroy", "Uint", psa) } COM_VariantClear(pvarg) { Return DllCall("oleaut32\VariantClear", "Uint", pvarg) } COM_AtlAxWinInit(Version = "") { COM_CoInitialize() If Not DllCall("GetModuleHandle", "str", "atl" . Version) DllCall("LoadLibrary" , "str", "atl" . Version) Return DllCall("atl" . Version . "\AtlAxWinInit") } COM_AtlAxWinTerm(Version = "") { COM_CoUninitialize() If hModule := DllCall("GetModuleHandle", "str", "atl" . Version) Return DllCall("FreeLibrary" , "Uint", hModule) } COM_AtlAxAttachControl(pdsp, hWnd, Version = "") { Return DllCall("atl" . Version . "\AtlAxAttachControl", "Uint", punk:=COM_QueryInterface(pdsp,0), "Uint", hWnd, "Uint", 0), COM_Release(punk) } COM_AtlAxCreateControl(hWnd, Name, Version = "") { If DllCall("atl" . Version . "\AtlAxCreateControl", "Uint", COM_Unicode4Ansi(Name,Name), "Uint", hWnd, "Uint", 0, "Uint", 0)=0 Return COM_AtlAxGetControl(hWnd, Version) } COM_AtlAxGetControl(hWnd, Version = "") { If DllCall("atl" . Version . "\AtlAxGetControl", "Uint", hWnd, "UintP", punk)=0 pdsp:=COM_QueryInterface(punk), COM_Release(punk) Return pdsp } COM_AtlAxGetHost(hWnd, Version = "") { If DllCall("atl" . Version . "\AtlAxGetHost", "Uint", hWnd, "UintP", punk)=0 pdsp:=COM_QueryInterface(punk), COM_Release(punk) Return pdsp } COM_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) } COM_AtlAxGetContainer(pdsp) { DllCall(NumGet(NumGet(1*pdsp)+ 0), "Uint", pdsp, "Uint", COM_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) } COM_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 } COM_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 } COM_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 } COM_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 } COM_ScriptControl(sCode, sLang = "", bExec = False, sName = "", pdisp = 0, bGlobal = False) { COM_CoInitialize() psc := COM_CreateObject("MSScriptControl.ScriptControl") COM_Invoke(psc, "Language=", sLang ? sLang : "VBScript") sName ? COM_Invoke(psc, "AddObject", sName, "+" . pdisp, bGlobal) : "" ret := COM_Invoke(psc, bExec ? "ExecuteStatement" : "Eval", sCode) COM_Release(psc) COM_CoUninitialize() Return ret }
|
|
|
|
|
157
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Vista integrity levels shell extension
|
on: March 28, 2008, 09:16:26 PM
|
 Try IntegrityLevel! You must compile it and run it once to register the shell extension. Then you can rightclick a file and change the integrity level by choosing IntegrityLevel in the context menu. Download chml from http://www.minasi.com/vista/chml.htm and place it in the script's folder. 2008.03.29: Added shell extension for folders, automatically downloads chml.exe, fixed a typo in the command line for chml.exe. Skrommel [ copy or print] ;IntegrityLevel.ahk ; RightClick a file and choose IntegrityLevel ; to change it's integrity level in Vista. ;Skrommel @ 2008 #NoEnv #SingleInstance,Force applicationname=IntegrityLevel IfNotExist,%A_ScriptDir%\chml.exe { TrayTip,%applicationname%,Downloading chml.exe from`nhttp://www.minasi.com/vista/chml.htm... UrlDownloadToFile,http://www.minasi.com/vista/chml.exe,%A_ScriptDir%\chml.exe If ErrorLevel=1 { MsgBox,0,%applicationname%,Please download chml.exe from`nhttp://www.minasi.com/vista/chml.htm! ExitApp } } If 0=0 { RegWrite,REG_SZ,HKEY_CLASSES_ROOT,*\shell\%applicationname%\command,,%A_ScriptDir%\%applicationname%.exe "`%1" RegWrite,REG_SZ,HKEY_CLASSES_ROOT,Folder\shell\%applicationname%\command,,%A_ScriptDir%\%applicationname%.exe "`%1" MsgBox,0,%applicationname%,Rightclick a file and choose %applicationname% `nto change the file's integrity level.`n`nUses chml.exe from http://www.minasi.com/vista/chml.htm`n`nwww.1HourSoftware.com ExitApp } filename=%1% command=%A_ScriptDir%\chml.exe "%filename%" -d output:=CMDret_RunReturn(command) StringSplit,part,output,= StringTrimRight,integrity,part2,2 Gui,Add,Text,w200,%filename% Gui,Add,GroupBox,Vgroupbox w230 h135,Integrity Level: GUi,Add,Radio,xp+10 yp+20 Vhigh,High (administrators) GUi,Add,Radio,Vmedium,Medium (non-administrators) GUi,Add,Radio,Vlow,Low (temporary Internet files) GUi,Add,Radio,Vuntrusted,Untrusted FileGetAttrib,attrib,%filename% IfInString,attrib,D Gui,Add,CheckBox,Vinherit y+20 Checked,Subfolders and -files inherit integrity level Else Gui,Add,CheckBox,Vinherit y+20 Disabled,Subfolders and -files inherit integrity level Gui,Add,Button,W75 xm+30 y+20 Default GOK,&OK Gui,Add,Button,W75 x+5 GCANCEL,&Cancel Gui,Add,StatusBar,,www.1HourSoftware.com IfInString,integrity,High integrity=high IfInString,integrity,Medium integrity=medium IfInString,integrity,Low integrity=low IfInString,integrity,Untrusted integrity=untrusted GuiControl,,%integrity%,1 Gui,Show Return OK: Gui,Submit If high=1 integrity=h If medium=1 integrity=m If low=1 integrity=l If untrusted=1 integrity=u If inherit=0 inherit=-noinherit Else inherit= command=%A_ScriptDir%\chml.exe "%filename%" -i:%integrity% %inherit% output:=CMDret_RunReturn(command) CANCEL: GuiClose: ExitApp ; ****************************************************************** ; CMDret-AHK functions ; version 1.10 beta ; ; Updated: Dec 5, 2006 ; by: corrupt ; Code modifications and/or contributions made by: ; Laszlo, shimanov, toralf, Wdb ; ****************************************************************** ; Usage: ; CMDin - command to execute ; 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: ; - none ; ****************************************************************** ; Code Start ; ****************************************************************** CMDret_RunReturn(CMDin, WorkingDir=0) { Global cmdretPID tcWrk := WorkingDir=0 ? "Int" : "Str" idltm := A_TickCount + 20 CMsize = 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 < 10) { DllCall("Sleep", Int, 10) 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) IF (DllCall("ReadFile", "UInt",hRead, "Str", lpBuffer, "Int",bSize, "UInt*",bRead, "Int",0) > 0) { IF (bRead > 0) { TRead += bRead VarSetCapacity(CMcpy, (bRead+CMsize+1), 0) CMcpy = a DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", &CMDout, "Int", CMsize) DllCall("RtlMoveMemory", "UInt", &CMcpy+CMsize, "UInt", &lpBuffer, "Int", bRead) CMsize += bRead VarSetCapacity(CMDout, (CMsize + 1), 0) CMDout=a DllCall("RtlMoveMemory", "UInt", &CMDout, "UInt", &CMcpy, "Int", CMsize) VarSetCapacity(CMDout, -1) ; fix required by change in autohotkey v1.0.44.14 } } } } ELSE break } ELSE break idltm := A_TickCount } cmdretPID= DllCall("CloseHandle", UInt, hWrite) DllCall("CloseHandle", UInt, hRead) } } IF (StrLen(CMDout) < TRead) { VarSetCapacity(CMcpy, TRead, 32) TRead2 = %TRead% Loop { DllCall("RtlZeroMemory", "UInt", &CMcpy, Int, TRead) NULLptr := StrLen(CMDout) cpsize := Tread - NULLptr DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", (&CMDout + NULLptr + 2), "Int", (cpsize - 1)) DllCall("RtlZeroMemory", "UInt", (&CMDout + NULLptr), Int, cpsize) DllCall("RtlMoveMemory", "UInt", (&CMDout + NULLptr), "UInt", &CMcpy, "Int", cpsize) TRead2 -- IF (StrLen(CMDout) > TRead2) break } } StringTrimLeft, CMDout, CMDout, 1 Return, CMDout }
|
|
|
|
|
158
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Global hotkeys in VLC
|
on: March 26, 2008, 09:05:56 PM
|
 Here's GlobalVLC! It makes VLC hotkeys work even when VLC is inactive. Edit your VLC config file by removing the # in front of the hotkey you want to make global, and add an unoccupied hotkey. Also change the script below: vlcrc= must point to your VLC config file, and vlc= must match the title of VLC. Skrommel [ copy or print] ;GlobalVLC.ahk ; Make VLC hotkeys work even when VLC is inactive. ; Edit your VLC config file by removing the # in front of ; the hotkey you want to make global, and add a unoccupied hotkey. ; Change the vlcrc= line below to match the location of your VLC config file ; and vlc= must match the titlebar of VLC. ;Skrommel @ 2008 vlcrc=C:\Users\%A_UserName%\AppData\Roaming\vlc\vlcrc vlc=VLC media player #SingleInstance,Force #NoEnv SendMode,Input applicationname=GlobalVLC IfNotExist,%vlcrc% MsgBox,0,%applicationname%,VLC config file not found!`n`n%vlcrc% hotkeys= count=0 found=0 Loop,Read,%vlcrc% { IfInString,A_LoopReadLine,[main] found=1 If found=0 Continue StringSplit,part,A_LoopReadLine,= StringReplace,part1,part1,%A_Space%,,All If (SubStr(part1,1,4)<>"key-") Continue If part2= Continue If part2=Unset Continue StringReplace,part2,part2,Right,Right StringReplace,part2,part2,Left,Left StringReplace,part2,part2,Up,Up StringReplace,part2,part2,Down,Down StringReplace,part2,part2,Enter,Enter StringReplace,part2,part2,Space,Space StringReplace,part2,part2,Tab,Tab StringReplace,part2,part2,BackSpace,BackSpace StringReplace,part2,part2,Space,Space StringReplace,part2,part2,F12,F12 StringReplace,part2,part2,F11,F11 StringReplace,part2,part2,F10,F10 StringReplace,part2,part2,F9,F9 StringReplace,part2,part2,F8,F8 StringReplace,part2,part2,F7,F7 StringReplace,part2,part2,F6,F6 StringReplace,part2,part2,F5,F5 StringReplace,part2,part2,F4,F4 StringReplace,part2,part2,F3,F3 StringReplace,part2,part2,F2,F2 StringReplace,part2,part2,F1,F1 StringReplace,part2,part2,Shift-,+ StringReplace,part2,part2,Ctrl-,^ StringReplace,part2,part2,Alt-,! Hotkey,%part2%,SEND count+=1 hotkeys=%hotkeys%%part1%`=%part2%`n } If count=0 MsgBox,0,%applicationname%,No hotkeys found! Else MsgBOx,0,%applicationname%,Made the following hotkeys global:`n`n%hotkeys% Return SEND: ; ToolTip,%A_ThisHotkey% ControlSend,,%A_ThisHotkey%,%vlc% Return
|
|
|
|
|
159
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Global hotkeys in VLC
|
on: March 26, 2008, 01:01:04 PM
|
 Josh, please elaborate! read the vlc config file and allow me to assign global hotkeys based on it Do you want to read the vlcrc and if some setting has a certain value, a hotkey should be available? Or do you want to press a hotkey and cange a value in the vlcrc? Or, as I would have done it, have the hotkeys run menu commands? Skrommel
|
|
|
|
|
160
|
DonationCoder.com Software / Post New Requests Here / Re: [request] Taskbar Displayed Only On <Win> Keypress
|
on: March 23, 2008, 07:47:49 PM
|
 kartal: I've made a version that shows the taskbar when the windows key is released, it will work better with Win+E and other hotkeys. nogojoe: I could add a proper pause action. When you pause now, the taskbar is still set to autohide and so it hides completely. Armando: Try downloading TweakUi from microsoft, I think it has an option to disable button flashing. Skrommel
|
|
|
|
|
161
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Popup box to automate command prompt daily file copy task
|
on: March 23, 2008, 04:27:13 PM
|
 Only love, tinjaw, but here's a more elaborate AutoHotkey version. Skrommel [ copy or print] ;Press a hotkey to show a file copy dialog ;Skrommel @ 2008 file=1234567 source=X:\ target=C:\Share hotkey=#c #NoEnv #SingleInstance,Force If hotkey<> { Hotkey,%hotkey%,DIALOG Return } DIALOG: Gui,Destroy Gui,Add,Text,,Filename: Gui,Add,Edit,w200 vfile,%file% Gui,Add,Text,,Source: Gui,Add,Edit,w200 vsource,%source% Gui,Add,Text,,Target: Gui,Add,Edit,w200 vtarget,%target% Gui,Add,Button,x+5 w75 GCOPY Default,&Copy Gui,Add,StatusBar,,www.1HourSoftware.com Gui,Show,,Copy Return COPY: Gui,Submit,NoHide SB_SetText("Copying " source . file " to " target "...") StringRight,char,source,1 If (char<>"\") source.="\" StringRight,char,target,1 If (char<>"\") target.="\" IfNotExist %source%%file% { SB_SetText("Unable to find source " source . file) Return } FileCreateDir,%target% IfNotExist %target% { SB_SetText("Unable to find target " target) Return } FileCopy,%source%%file%,%target%,1 If ErrorLevel=0 SB_SetText("Finished copying " source . file " to " target) Else SB_SetText("Unable to copy " source . file " to " target) Return
|
|
|
|
|
162
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Stand alone bookmarks toolbar
|
on: March 23, 2008, 02:25:54 PM
|
 But won't a regular toolbar get in the way? Anyway, here's a very early version of BookmarkBar so you can test if it's a practical approach. Resize by editing the width:= line, no sortinging or reordering The first time you run it, it has to fetch the favicons, so just hang in there! Skrommel @ 2008 [ copy or print] ;BookmarkBar.ahk ; A standalone toolbar for your bookmarks ;Skrommel @ 2008 favorites= width:=A_ScreenWidth maxlines=33 wrap:=100 columnwidth=200 #NoEnv #SingleInstance,Force SetBatchLines,-1 SetWinDelay,0 CoordMode,Mouse,Screen applicationname=BookmarkBar FileCreateDir,FavIcons Gui,1:Color,FFFFFF Gui,1:Margin,0,0 Gui,1:+ToolWindow +Border +AlwaysOnTop +OwnDialogs x=0 counter=0 If favorites= RegRead,favorites,HKEY_CURRENT_USER,Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,Favorites SplitPath,favorites,,,,name_no_ext, counter+=1 Gui,1:Add,Picture,V1%counter% GMENU x+%x% w16 h-1 Icon14,%A_WinDir%\Explorer.exe Gui,1:Add,Text,V2%counter% GMENU x+0,%name_no_ext% Loop,%favorites%\*.url,0,0 { list%counter%:=list%counter% . A_LoopFileLongPath "`n" IniRead,iconfile,%A_LoopFileLongPath%,InternetShortcut,IconFile SplitPath,A_LoopFileLongPath,,,,name_no_ext icon:=name_no_ext IfNotExist,FavIcons\%icon%.ico UrlDownloadToFile,*0 %iconfile%,FavIcons\%icon%.ico } x=10 Loop,%favorites%\*.*,1,1 { IfInString,A_LoopFileAttrib,D { GuiControlGet,pos,Pos,2%counter% If (posX+posW>width-wrap) { Gui,1:Add,Text,xm yp+17 w0 x=0 } counter+=1 Gui,1:Add,Picture,V1%counter% GMENU x+%x% w16 h-1 Icon14,%A_WinDir%\Explorer.exe Gui,1:Add,Text,V2%counter% GMENU x+0, %A_LoopFileName% If x=0 x=10 list%counter%= Loop,%A_LoopFileLongPath%\*.*,0,0 { list%counter%:=list%counter% . A_LoopFileLongPath "`n" IniRead,iconfile,%A_LoopFileLongPath%,InternetShortcut,IconFile SplitPath,A_LoopFileLongPath,,,,name_no_ext icon:=name_no_ext IfNotExist,FavIcons\%icon%.ico UrlDownloadToFile,*0 %iconfile%,FavIcons\%icon%.ico } } } Gui,1:Show,W%width%,%applicationname% Return MENU: MouseGetPos,mx,my mx+=10 my+=10 Gui,2:Destroy Gui,2:Color,FFFFFF Gui,2:Margin,1,1 Gui,2:+ToolWindow +AlwaysOnTop -Caption +Border +Owner1 StringTrimLeft,control,A_GuiControl,1 x=1 y=1 lines=0 Loop,parse,list%control%,`n { If (lines>maxlines) { x:=x+columnwidth+27 y=1 lines=0 Gui,2:Add,Text,x%x% ym w0 } lines+=1 SplitPath,A_LoopField,name,,,name_no_ext, IniRead,url%A_Index%,%A_LoopField%,InternetShortcut,URL IniRead,iconfile,%A_LoopField%,InternetShortcut,IconFile IniRead,iconindex,%A_LoopField%,InternetShortcut,IconIndex IfExist,%iconfile% Gui,2:Add,Picture,V3%lines% GURL x%x% yp+%y% w16 h-1 Icon%iconindex%,%iconfile% Else { icon:=name_no_ext IfExist,FavIcons\%icon%.ico Gui,2:Add,Picture,V3%A_Index% GURL x%x% yp+%y% w16 h-1 Icon%iconindex%,FavIcons\%icon%.ico Else Gui,2:Add,Picture,V3%A_Index% GURL x%x% yp+%y% w16 h-1 Icon15,%A_WinDir%\Explorer.exe } If y=1 y=17 If name_no_ext<> Gui,2:Add,Text,V4%A_Index% GURL x+0 w%columnwidth% -Wrap,%name_no_ext% Else { url:=url%A_Index% Gui,2:Add,Text,V4%A_Index% GURL x+0 w%columnwidth% -Wrap,%url% } } Gui,2:Show,X%mx% Y%my%,%applicationname% Return URL: StringTrimLeft,control,A_GuiControl,1 url:=url%control% Run,%url% Return 1GuiClose: ExitApp
|
|
|
|
|
164
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: Stand alone bookmarks toolbar
|
on: March 23, 2008, 03:40:35 AM
|
 I started coding this tool last night, but then I remembered that Explorer can do this too! Just create a shortcut to your favorites folder on the desktop, and drag the icon to one of the screen's edges. When you drop it, it creates a toolbar! Now rightclick it's handle, and select Always on top. To make it more usable, detach it from the edge by dragging it's handle and dropping it somewhere in the middle of the screen. Then resize it to make it as small as possible to make the folders in your favorites work properly. Now you have a tiny, floating, always on top favorites toolbar that you can move where you like, edit and update at will. Skrommel
|
|
|
|
|
166
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA? simple startup manager with timer
|
on: March 22, 2008, 03:32:36 PM
|
 Try AskToRun! It shows a timed confirmation dialog before running programs. Edit the apps= line to add programs, separate them by commas. You can also change the timer= to change the countdown time. To change the default action, just change the defaulttext, othertext, defaultaction and otheraction lines. Edited 2008.03.23Skrommel [ copy or print] ;AskToRun.ahk ; Shows a timed confirmation dialog before running programs. ; Edit the apps= line to add programs, separate them by commas. ; Edit the timer= line to change the countdown time. ; To change the default action, edit the lines ; defaulttext and othertext and defaultaction and otheraction. ;Skrommel @ 2008 apps=Notepad.exe,Calc.exe ; Programs to run, separated by commas timer=10 ; Seconds to wait before default action defaulttext=No ; Text displayed on the default button othertext=Yes ; Text displayed on the other button defaultaction=DONT ; DO or DONT otheraction=DO ; DO or DONT prompt=Run these apps? ; Text displayed in the dialog seconds=sec ; Text displayed after the counter #NoEnv #SingleInstance,Force applicationname=AskToRun StringReplace,apps,apps,`,,`n,All Gui,+ToolWindow +AlwaysOnTop Gui,Add,Text,,`n%prompt%`n`n%apps%`n Gui,Add,Button,w75 Default Vcounter G%defaultaction%,&%defaulttext% (%timer% %seconds%) Gui,Add,Button,w75 x+5 G%otheraction%,&%othertext% Gui,Show,,%applicationname% SetTimer,COUNTDOWN,1000 Return COUNTDOWN: timer-=1 GuiControl,,counter,&%defaulttext% (%timer% %seconds%) If timer=0 Goto,DONT Return DO: SetTimer,COUNTDOWN,Off Loop,Parse,Apps,`n Run,%A_LoopField%,,UseErrorLevel ExitApp GuiClose: DONT: SetTimer,COUNTDOWN,Off ExitApp
|
|
|
|
|
169
|
DonationCoder.com Software / Finished Programs / Re: IDEA: Gracefully close Firefox on PC exit
|
on: March 15, 2008, 01:30:49 PM
|
 Try CloseToQuit - Close programs before the system shuts down! Usage: Add the process name, class or a part of the caption of the programs you want to close to the apps= line. Separate them by commas. Any spaces or tabs around the delimiting commas are significant, meaning that they are part of the match string! Syntax: apps=[<process name>,<class>,<part of a caption>] Example: apps=calc.exe,MozillaWindowClass,- Notepad Skrommel [ copy or print] ;CloseToQuit.ahk ; Close programs before the system shuts down ; Usage: Add the process name, class or a part of the caption of the programs ; you want to close to the apps= line. Separate them by commas. ; Any spaces or tabs around the delimiting commas are significant, ; meaning that they are part of the match string! ; Syntax: apps=[<process name>,<class>,<part of a caption>] ; Example: apps=calc.exe,MozillaWindowClass,- Notepad ;Skrommel @ 2008 #NoEnv #SingleInstance,Force DetectHiddenWindows,On SetWinDelay,0 SetBatchLines,-1 apps=calc.exe,MozillaWindowClass,- Notepad DllCall("kernel32.dll\SetProcessShutdownParameters",UInt,0x4FF,UInt,0) OnMessage(0x11,"WM_QUERYENDSESSION") Return WM_QUERYENDSESSION(wParam,lParam) { Global apps Gui,+LastFound self:=WinExist() WinGet,ids,List,,,Program Manager Loop,%ids% { id:=ids%A_Index% If id=%self% Continue WinGet,process,ProcessName,ahk_id %id% WinGetClass,class,ahk_id %id% WinGetTitle,title,ahk_id %id% If process In %apps% WinClose,ahk_id %id% Else If class In %apps% WinClose,ahk_id %id% Else If title Contains %apps% WinClose,ahk_id %id% } ExitApp }
|
|
|
|
|
170
|
DonationCoder.com Software / Post New Requests Here / Re: AutoStart Program(s), if key is pressed or CapsLock On/Off with Parameter
|
on: March 13, 2008, 07:32:08 PM
|
ToggleRun runs programs on startup when Capslock,Numlock, Scrolllock or Insert is down, or up. You can also use RunWait instead of Run to wait for a program to end before running the next in the group. Edit the script and place it in your startup folder. It is written in AutoHotkey from www.autohotkey.com. Skrommel [ copy or print] ;ToogleRun.ahk ; Run programs on startup when Capslock, Numlock, Scrolllock or Insert is down ; Usage: Place the script in your startup folder ; Format: Run, Target [, WorkingDir, Max|Min|Hide ] ;Skrommel @ 2008 If (GetKeyState("Capslock","T")=1) { Run,Notepad.exe C:\Test1.txt Run,Paint.exe C:\Test2.bmp Run,Write.exe C:\Test3.wri } Else { Run,Calc.exe,,Min Run,IExplore.exe,,Max } If (GetKeyState("Numlock","T")=1) Run,Calc.exe,,Min If (GetKeyState("Scrolllock","T")=1) Run,Pbrush.exe C:\Windows\Bubbles.bmp,,Max If (GetKeyState("Insert","T")=1) Run,Write.exe
|
|
|
|
|
172
|
DonationCoder.com Software / Coding Snacks / DetachVideo - Give embedded videos their own window!
|
on: March 09, 2008, 07:24:00 AM
|
 Try this one! DetachVideo - Detach embedded videos from your tabbed browser and show them in a window of their own. Usage: Hold your mouse over a video and press F12.  This is a lifesaver when browsing YouTube or any other video site. Just place your mouse over a video and press F12, and the video is moved to a floating, always on top window that you can move anywhere you like, and keep on browsing. Just make shure you don't close the brower tab or scroll too far, or the video will dissapear. And it can of course show multiple detached videos! You'll find the downloads and more info at 1 Hour Software by Skrommel. Skrommel
|
|
|
|
|
173
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: port-apps launcher (auto-create shortcuts to exe's within a directory)
|
on: February 22, 2008, 05:38:49 PM
|
 Here's version 1.1 of ShortCutter! 20080223: Added browse functionality, changed the text of the settings dialog. Skrommel [ copy or print] ;ShortCutter.ahk ; Make autoupdating collections of shortcuts to certain filetypes ;Skrommel @ 2006 #Persistent #SingleInstance,Force applicationname=ShortCutter open=0 Gosub,INIREAD Gosub,TRAYMENU If enabled=1 enabled=0 Else enabled=1 Gosub,TOGGLE Process,Priority,,Low Gosub,TIMER Return TIMER: If enabled=0 Return SetTimer,TIMER,%timer%,Off Loop,%rules% { active:=%A_Index%active If active=0 Continue source:=%A_Index%source target:=%A_Index%target files:=%A_Index%files ignore:=%A_Index%ignore recurse:=%A_Index%recurse If (source="" Or target="") Continue Menu,Tray,Tip,%applicationname% - %files% FileCreateDir,%target% FileSetAttrib,-A,%target%\*.lnk,0,0 Gosub,FIND Loop,%target%\*.lnk,0,0 { Sleep,%delay% FileGetAttrib,attrib,%A_LoopFileLongPath% IfNotInString,attrib,A { FileGetShortcut,%A_LoopFileLongPath%,linktarget IfNotExist,%linktarget% FileDelete,%A_LoopFileLongPath% } } } SetTimer,TIMER,%timer%,On Return FIND: Loop,%source%\*.*,2,% (recurse="Yes") { Sleep,%delay% If enabled=0 Return folderpath:=A_LoopFileLongPath If status=1 TrayTip,%applicationname%,%folderpath% Loop,Parse,files,`, { type:=A_LoopField Loop,%folderpath%\%type%,0,0 { path:=A_LoopFileLongPath name:=A_LoopFileName If path Contains %ignore% Continue exist=0 counter=0 version= Loop { Sleep,%delay% If counter>0 version=-%counter% IfExist,%target%\%A_LoopFileName%%version%.lnk { FileGetShortcut,%target%\%A_LoopFileName%%version%.lnk,linktarget If (linktarget=path) { exist=1 Break } counter+=1 } Else Break } If exist=0 { FileCreateShortcut,%path%,%target%\%A_LoopFileName%%version%.lnk,%folderpath%,,%path% FileGetTime,date,%path%,M FileSetTime,%date%,%target%\%A_LoopFileName%%version%.lnk } Else { FileSetAttrib,+A,%target%\%A_LoopFileName%%version%.lnk FileGetTime,date,%path%,M FileSetTime,%date%,%target%\%A_LoopFileName%%version%.lnk } } } } Return INIREAD: IfNotExist,%applicationname%.ini { start=1 delay=5 timer=60000 status=0 1active=1 1source=C:\ 1target=%A_Desktop%\Images 1files=*.jpg,*.jpeg 1ignore=Recycled,Temporary 1recurse=Yes 2active=1 2source=C:\ 2target=%A_Desktop%\Music 2files=*.mp3 2ignore=Recycled,Temporary 2recurse=Yes rules=2 Gosub,INIWRITE } Else { IniRead,start,%applicationname%.ini,Settings,start If start=1 enabled=1 Else enabled=0 IniRead,delay,%applicationname%.ini,Settings,delay IniRead,timer,%applicationname%.ini,Settings,timer IniRead,status,%applicationname%.ini,Settings,status rules=1 Loop { IniRead,active,%applicationname%.ini,%A_Index%,active IniRead,source,%applicationname%.ini,%A_Index%,source IniRead,target,%applicationname%.ini,%A_Index%,target IniRead,files,%applicationname%.ini,%A_Index%,files IniRead,ignore,%applicationname%.ini,%A_Index%,ignore IniRead,recurse,%applicationname%.ini,%A_Index%,recurse If (source="ERROR" And target="ERROR" And files="ERROR") Break If (source="" And target="" And files="") Break %rules%active:=active %rules%source:=source %rules%target:=target %rules%files:=files %rules%ignore:=ignore %rules%recurse:=recurse rules+=1 } rules-=1 } Return INIWRITE: Iniwrite,%start%,%applicationname%.ini,Settings,start Iniwrite,%delay%,%applicationname%.ini,Settings,delay Iniwrite,%timer%,%applicationname%.ini,Settings,timer Iniwrite,%status%,%applicationname%.ini,Settings,status count=1 Loop,%rules% { If (%A_Index%source="" And %A_Index%target="" And %A_Index%files="" And %A_Index%ignore="" And %A_Index%recurse="") { IniDelete,%applicationname%.ini,%A_Index%, Continue } active:=%A_Index%active source:=%A_Index%source target:=%A_Index%target files:=%A_Index%files ignore:=%A_Index%ignore recurse:=%A_Index%recurse Iniwrite,%active%,%applicationname%.ini,%count%,active Iniwrite,%source%,%applicationname%.ini,%count%,source Iniwrite,%target%,%applicationname%.ini,%count%,target Iniwrite,%files%,%applicationname%.ini,%count%,files Iniwrite,%ignore%,%applicationname%.ini,%count%,ignore Iniwrite,%recurse%,%applicationname%.ini,%count%,recurse count+=1 } count-=1 rules:=count Gosub,INIREAD Return SETTINGS: oldenabled:=enabled enabled=0 insert=0 Gui,99:Destroy Gui,99:Add,Tab,w580 h370,Rules|Options Gui,99:Tab,1 Gui,99:Add,ListView,w560 h300 GLISTVIEW NoSort -Multi Checked,Active|Source|Target|Files|Ignore|Recurse? Gui,99:Default Loop,%rules% { If (%A_Index%source="" And %A_Index%target="" And %A_Index%files="" And %A_Index%ignore="" And %A_Index%recurse="") Continue LV_ADD("","",%A_Index%source,%A_Index%target,%A_Index%files,%A_Index%ignore,%A_Index%recurse) If %A_Index%active=1 LV_Modify(LV_GetCount(),"Check") } LV_ADD("","","","","","","") Gui,99:Tab,1 Gui,99:Add,Button,w75 x20 y340 GSETTINGSEDIT,&Edit Gui,99:Add,Button,w75 x+5 GSETTINGSINSERT,&Insert Gui,99:Add,Button,w75 x+5 GSETTINGSDELETE,&Delete Gui,99:Add,Button,w75 x+5 GSETTINGSMOVEUP,Move &Up Gui,99:Add,Button,w75 x+5 GSETTINGSMOVEDOWN,Move &Down Gui,99:Tab,2 Gui,99:Add,GroupBox,x20 y50 w300,Timer - How often to check for new files? Gui,99:Add,Edit,x30 yp+20 w75 votimer,% Floor(timer/1000) Gui,99:Add,Text,x+5 yp+5,seconds Gui,99:Add,GroupBox,x20 y+30 w300,Delay - How long to wait between file operations (0-100)? Gui,99:Add,Edit,x30 yp+20 w75 vodelay,%delay% Gui,99:Add,Text,x+5 yp+5,ms Gui,99:Add,GroupBox,x20 y+30 w300,Status If status=1 Gui,99:Add,CheckBox,xp+10 yp+20 vostatus Checked,Show status in the tray Else Gui,99:Add,CheckBox,xp+10 yp+20 vostatus,Show status in the tray Gui,99:Add,GroupBox,x20 y+30 w300,Startup If start=1 Gui,99:Add,CheckBox,xp+10 yp+20 vostart Checked,Start enabled Else Gui,99:Add,CheckBox,xp+10 yp+20 vostart,Start enabled Gui,99:Tab Gui,99:Add,Button,x425 y340 w75 Default GSETTINGSOK,&OK Gui,99:Add,Button,x+5 w75 GSETTINGSCANCEL,&Cancel Gui,99:Show,w600 h390,%Applicationname% Settings Return LISTVIEW: If A_GuiEvent=DoubleClick Gosub,SETTINGSEDIT Return SETTINGSINSERT: row:=LV_GetNext(0,"Focused") insert=1 Gosub,SETTINGSEDIT Return SETTINGSDELETE: row:=LV_GetNext(0,"Focused") If (row=LV_GetCount()) Return LV_Delete(row) LV_Modify(row,"Select") LV_Modify(row,"Focus") Return SETTINGSEDIT: row:=LV_GetNext(0,"Focused") If row=0 Return LV_GetText(source,row,2) LV_GetText(target,row,3) LV_GetText(files,row,4) LV_GetText(ignore,row,5) LV_GetText(recurse,row,6) Gui,98:Destroy Gui,98:+ToolWindow Gui,98:Add,GroupBox,x10 w560 h50,&Source - Where to look for files Gui,98:Add,Edit,xp+10 yp+20 w460 vosource,%source% Gui,98:Add,Button,x+5 yp w75 GBROWSESOURCE,&Browse... Gui,98:Add,GroupBox,x10 y+20 w560 h50,&Target - Where to store the shortcuts Gui,98:Add,Edit,xp+10 yp+20 w460 votarget,%target% Gui,98:Add,Button,x+5 yp w75 GBROWSETARGET,B&rowse... Gui,98:Add,GroupBox,x10 y+20 w480 h70,&Files - What files to create shortcuts to Gui,98:Add,Edit,xp+10 yp+20 w460 vofiles,%files% Gui,98:Add,Text,y+5 300,Supports wildcards * ?. Example: *.jp*g Gui,98:Add,GroupBox,x10 y+20 w480 h70,&Ignore - What (parts of) filenames to ignore Gui,98:Add,Edit,xp+10 yp+20 w460 voignore,%ignore% Gui,98:Add,Text,y+5 300,No wildcards. Example: jpg,jpeg,C:\Boot.ini options=No|Yes| StringReplace,options,options,%recurse%,%recurse%| Gui,98:Add,GroupBox,x10 y+20 w300 h70,&Recurse - Search subfolders? Gui,98:Add,DropDownList,xp+10 yp+20 w150 vorecurse,%options% Gui,98:Add,Text,y+5 300,No, Yes Gui,98:Add,Button,x420 y340 w75 Default GEDITOK,&OK Gui,98:Add,Button,x+5 w75 GEDITCANCEL,&Cancel Gui,98:Show,w580 h370,%applicationname% Edit Return BROWSESOURCE: Gui,98:+LastFound guiid:=WinExist("A") ControlGetText,sourcefolder,Edit1,ahk_id %guiid% FileSelectFolder,chosenfolder,*%sourcefolder%,3,Select a source folder If chosenfolder= chosenfolder:=sourcefolder ControlSetText,Edit1,%chosenfolder%,ahk_id %guiid% Return BROWSETARGET: Gui,98:+LastFound guiid:=WinExist("A") ControlGetText,targetfolder,Edit2,ahk_id %guiid% FileSelectFolder,chosenfolder,*%targetfolder%,3,Select a target folder If chosenfolder= chosenfolder:=targetfolder ControlSetText,Edit2,%targetfolder%,ahk_id %guiid% Return EDITOK: Gui,98:Submit,NoHide If (osource="" Or otarget="" Or ofiles="") MsgBox,0,%applicationname% - Error,Please fill inn Source, Target and Files Else { Gui,99:Default If insert=1 LV_Insert(row,"Focus","",osource,otarget,ofiles,oignore,orecurse) Else { LV_Modify(row,"Focus","",osource,otarget,ofiles,oignore,orecurse) If (row=LV_GetCount()) LV_ADD("","","","","","","") } Gosub,EDITCANCEL } Return EDITCANCEL: Gui,98:Destroy insert=0 Return SETTINGSMOVEUP: row:=LV_GetNext(0,"Focused") If row=1 Return If (row=LV_GetCount()) Return LV_GetText(source2,row,2) LV_GetText(target2,row,3) LV_GetText(files2,row,4) LV_GetText(ignore2,row,5) LV_GetText(recurse2,row,6) row-=1 LV_GetText(source1,row,2) LV_GetText(target1,row,3) LV_GetText(files1,row,4) LV_GetText(ignore1,row,5) LV_GetText(recurse1,row,6) LV_Modify(row,"Select","",source2,target2,files2,ignore2,recurse2) LV_Modify(row,"Focus") row+=1 LV_Modify(row,"","",source1,target1,files1,ignore1,recurse1) Return SETTINGSMOVEDOWN: row:=LV_GetNext(0,"Focused") If (row>=LV_GetCount()-1) Return LV_GetText(source2,row,2) LV_GetText(target2,row,3) LV_GetText(files2,row,4) LV_GetText(ignore2,row,5) LV_GetText(recurse2,row,6) row+=1 LV_GetText(source1,row,2) LV_GetText(target1,row,3) LV_GetText(files1,row,4) LV_GetText(ignore1,row,5) LV_GetText(recurse1,row,6) LV_Modify(row,"Select","",source2,target2,files2,ignore2,recurse2) LV_Modify(row,"Focus") row-=1 LV_Modify(row,"","",source1,target1,files1,ignore1,recurse1) Return SETTINGSOK: Gui,99:Submit,NoHide If otimer>0 timer:=otimer*1000 If odelay>0 delay:=odelay status:=ostatus start:=ostart count=1 Loop % LV_GetCount() { checked:=LV_GetNext(count-1,"Checked") If (checked=count) %count%active=1 Else %count%active=0 LV_GetText(%count%source,A_Index,2) LV_GetText(%count%target,A_Index,3) LV_GetText(%count%files,A_Index,4) LV_GetText(%count%ignore,A_Index,5) LV_GetText(%count%recurse,A_Index,6) If (%count%source="" And %count%target="" And %count%files="" And %count%ignore="" And %count%recurse="") Continue count+=1 } rules:=count Gosub,INIWRITE Gosub,SETTINGSCANCEL Return SETTINGSCANCEL: Gui,98:Destroy Gui,99:Destroy enabled:=oldenabled Gosub,TIMER Return TRAYMENU: Menu,Tray,NoStandard Menu,Tray,DeleteAll Menu,Tray,Add,%applicationname%,SETTINGS Menu,Tray,Add Menu,Tray,Add,&Settings,SETTINGS Menu,Tray,Add,&Enabled,TOGGLE Menu,Tray,Add Menu,Tray,Add,&About,ABOUT Menu,Tray,Add,E&xit,EXIT Menu,Tray,Default,%applicationname% Menu,Tray,Tip,%applicationname% Return TOGGLE: If enabled=1 { enabled=0 Menu,Tray,UnCheck,&Enabled ;Menu,Tray,Icon,%applicationname%.exe,3 } Else { enabled=1 Menu,Tray,Check,&Enabled ;Menu,Tray,Icon,%applicationname%.exe,1 } Return ABOUT: Gui,97:Destroy Gui,97:Add,Picture,Icon1,%applicationname%.exe Gui,97:Font,Bold Gui,97:Add,Text,x+10 yp+10,%applicationname% v1.1 Gui,97:Font Gui,97:Add,Text,xm,Make autoupdating collections of shortcuts to certain filetypes. Gui,97:Add,Text,xm,- Rightclick the tray icon to configure Gui,97:Add,Text,xm,- Choose Settings to change rules and options Gui,97:Add,Text,xm,- Choose Enable to Start or Stop all the rules Gui,97:Add,Text,y+0,`t Gui,97:Add,Picture,xm Icon2,%applicationname%.exe Gui,97:Font,Bold Gui,97:Add,Text,x+10 yp+10,1 Hour Software by Skrommel Gui,97:Font Gui,97:Add,Text,xm,For more tools, information and donations, visit Gui,97:Font,CBlue Underline Gui,97:Add,Text,xm G1HOURSOFTWARE,www.1HourSoftware.com Gui,97:Font Gui,97:Add,Text,y+0,`t Gui,97:Add,Picture,xm Icon5,%applicationname%.exe Gui,97:Font,Bold Gui,97:Add,Text,x+10 yp+10,DonationCoder Gui,97:Font Gui,97:Add,Text,xm,Please support the DonationCoder community Gui,97:Font,CBlue Underline Gui,97:Add,Text,xm GDONATIONCODER,www.DonationCoder.com Gui,97:Font Gui,97:Add,Text,y+0,`t Gui,97:Add,Picture,xm Icon6,%applicationname%.exe Gui,97:Font,Bold Gui,97:Add,Text,x+10 yp+10,AutoHotkey Gui,97:Font Gui,97:Add,Text,xm,This program was made using AutoHotkey Gui,97:Font,CBlue Underline Gui,97:Add,Text,xm GAUTOHOTKEY,www.AutoHotkey.com Gui,97:Font Gui,97:Add,Text,y+0,`t Gui,97:Add,Button,GABOUTOK Default w75,&OK Gui,97:Show,,%applicationname% About hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND OnMessage(0x200,"WM_MOUSEMOVE") Return 1HOURSOFTWARE: Run,http://www.1hoursoftware.com,,UseErrorLevel Return DONATIONCODER: Run,http://www.donationcoder.com,,UseErrorLevel Return AUTOHOTKEY: Run,http://www.autohotkey.com,,UseErrorLevel Return ABOUTOK: Gui,97:Destroy OnMessage(0x200,"") DllCall("DestroyCursor","Uint",hCurs) Return WM_MOUSEMOVE(wParam,lParam) { Global hCurs MouseGetPos,,,winid,ctrl If ctrl in Static12,Static17,Static22 DllCall("SetCursor","UInt",hCurs) } EXIT: ExitApp
|
|
|
|
|