Latest posts of: skrommel - DonationCoder.com
Welcome Guest.   Make a donation to an author on the site May 26, 2015, 08:53:50 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
  Forum Home Thread Marks Chat! Downloads Search Login Register  
  Show Posts
      View this member's profile 
      donate to someone Donate to this member 
Pages: Prev 1 2 3 4 5 6 [7] 8 9 10 11 12 ... 36 Next
151  DonationCoder.com Software / Post New Requests Here / Re: IDEA: screensaver / monitor timeouts to IGNORE small mouse jitters on: June 14, 2008, 09:16:13 AM
 tellme If works very well on Vista... Try the script again, I've corrected the line split, commented the script and decreased the sensitivity.

Skrommel
152  DonationCoder.com Software / Post New Requests Here / Re: IDEA: Insert date and time into internet explorer - or other text field on: June 14, 2008, 08:08:57 AM
 smiley Here's TimeStamp 2.1!

Use the tray menu or hotkeys to send user defined times and dates to the active window.
Doubleclick the tray icon to send the last used timestamp.
Use the Settings menu in the tray to change the timestamps and hotkeys.
Default hotkeys are F1 and F2.

Skrommel


[copy or print]
;TimeStamp.ahk
; Use the tray menu or hotkeys to send user defined times and dates to the active window.
; Doubleclick the tray icon to send the last used timestamp.
; Use the Settings menu in the tray to change the timestamps and hotkeys.
;Skrommel @ 2008


#SingleInstance,Force
#Persistent,On
#NoEnv
SendMode,Input
SetWorkingDir,%A_ScriptDir%
SetBatchLines,-1
SetWinDelay,0
SetKeyDelay,0
AutoTrim,Off

applicationname=TimeStamp
Gosub,INIFILE
Gosub,MENU

string:=stamp1

Gui,+LastFound
guiid:=WinExist()
DllCall("RegisterShellHookWindow",UInt,guiid)
msgnum:=DllCall("RegisterWindowMessage",Str,"SHELLHOOK")
OnMessage(msgnum,"SHELLMESSAGE" )
OnMessage(0x404,"TRAYMESSAGE")
OnMessage(0x200,"WM_MOUSEMOVE")
OnExit,EXIT
Return


MENU:
Menu,Tray,NoStandard
Menu,Tray,DeleteAll
Menu,Tray,Add,%applicationname%,SEND
Menu,Tray,Default,%applicationname%

Menu,Tray,Add
stamps=0
Loop,99
{
  IniRead,stamp,%applicationname%.ini,Settings,stamp%A_Index%
  If stamp=ERROR
    Continue
  stamps+=1
  stamp%stamps%:=stamp
  string:=stamp
  Gosub,EXPAND

  IniRead,hotkey,%applicationname%.ini,Settings,hotkey%A_Index%
  If hotkey=ERROR
    hotkey=
  Else
  {
    hotkey%stamps%:=hotkey
    Hotkey,%hotkey%,SEND,On
  }
  Menu,Tray,Add,&%stamps% - %hotkey% - %timestring%,SEND
}

Menu,Tray,Add
WinGetTitle,title,ahk_id %lastactiveid%
If title=
  WinGet,title,ProcessName,ahk_id %lastactiveid%
StringLeft,shorttitle,title,50
If (shorttitle<>title)
 shorttitle.="..."
Menu,Tray,Add,Active window: %shorttitle%,ACTIVATE

Menu,Tray,Add
Menu,Tray,Add,&Settings...,SETTINGS
Menu,Tray,Add,&About...,ABOUT
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Tip,%applicationname%
Return


ACTIVATE:
WinActivate,ahk_id %lastactiveid%
Return


SEND:
If (A_TimeSinceThisHotkey<100 And A_TimeSinceThisHotkey<>-1)
{
  Loop,%stamps%
  {
    If (hotkey%A_Index%<>A_ThisHotkey)
      Continue
    string:=stamp%A_Index%
    Gosub,EXPAND
    Send,%timestring%
    Break
  }
}
Else
{
  If A_ThisMenuItemPos=1
    Gosub,EXPAND
  Else
  If A_ThisMenuItemPos>2
  {
    menu:=A_ThisMenuItemPos-2
    string:=stamp%menu%
    Gosub,EXPAND
  }
  WinActivate,ahk_id %lastactiveid%
  WinWaitActive,ahk_id %lastactiveid%,,5
  If ErrorLevel=0
  {
    Send,%timestring%
  }
}
Return


SHELLMESSAGE(wParam,lParam)
{
  Global lastactiveid

  If wParam<>4
    Return
  IfWinNotExist,ahk_id %lParam%
    Return
  WinGetClass,class,ahk_id %lParam%
  If class in Shell_TrayWnd
  {
    Gosub,MENU
    Return
  }
  lastactiveid:=lParam
}


TRAYMESSAGE(wParam,lParam)
{
  If lParam In 517
    Gosub,MENU
  Return
}


EXPAND:
StringGetPos,pos,string,"
If pos=0
  timepos=3
else
  timepos=1
StringSplit,timearray,string,"
LOOP1:
  FormatTime,week,,YWeek
  StringRight,week,week,2
  week+=0
  FormatTime,day,,YDay
  FormatTime,longday,,dddd
  StringLower,dllower,longday
  StringLower,dltitle,longday,T
  StringUpper,dlupper,longday 
  FormatTime,shortday,,ddd
  StringLower,dslower,shortday
  StringLower,dstitle,shortday,T
  StringUpper,dsupper,shortday
  FormatTime,longmonth,,MMMM
  StringLower,mllower,longmonth
  StringLower,mltitle,longmonth,T
  StringUpper,mlupper,longmonth 
  FormatTime,shortmonth,,MMM
  StringLower,mslower,shortmonth
  StringLower,mstitle,shortmonth,T
  StringUpper,msupper,shortmonth
  time=timearray%timepos%
  time:=%time%
  If time=
    Goto,NEXT1
  StringReplace,time,time,nl,&&&,All
  StringReplace,time,time,tab,|||,All
  StringReplace,time,time,week,@@@@,All
  StringReplace,time,time,day,@@@,All
  StringReplace,time,time,dddd,!!!!,All
  StringReplace,time,time,Dddd,$!!!,All
  StringReplace,time,time,DDDD,$$$$,All
  StringReplace,time,time,ddd,!!!,All
  StringReplace,time,time,Ddd,$!!,All
  StringReplace,time,time,DDD,$$$,All
  StringReplace,time,time,mmmm,££££,All
  StringReplace,time,time,Mmmm,§£££,All
  StringReplace,time,time,MMMM,§§§§,All
  StringReplace,time,time,mmm,£££,All
  StringReplace,time,time,Mmm,§££,All
  StringReplace,time,time,MMM,§§§,All
  FormatTime,time,,%time%
  StringReplace,time,time,&&&,`n,All
  StringReplace,time,time,|||,%A_Tab%,All
  StringReplace,time,time,@@@@,%week%,All
  StringReplace,time,time,@@@,%day%,All
  StringReplace,time,time,!!!!,%dllower%,All
  StringReplace,time,time,$!!!,%dltitle%,All
  StringReplace,time,time,$$$$,%dlupper%,All
  StringReplace,time,time,!!!,%dslower%,All
  StringReplace,time,time,$!!,%dstitle%,All
  StringReplace,time,time,$$$,%dsupper%,All
  StringReplace,time,time,££££,%mllower%,All
  StringReplace,time,time,§£££,%mltitle%,All
  StringReplace,time,time,§§§§,%mlupper%,All
  StringReplace,time,time,£££,%mslower%,All
  StringReplace,time,time,§££,%mstitle%,All
  StringReplace,time,time,§§§,%msupper%,All
  timearray%timepos%=%time%
NEXT1:
  timepos+=2
If timepos<=%timearray0%
  Goto,LOOP1
timestring=
timepos=1
LOOP2:
  time=timearray%timepos%
  time:=%time%
  timestring=%timestring%%time%
  timepos+=1
If timepos<=%timearray0%
  Goto,LOOP2
Return


SETTINGS:
Run,TimeStamp.ini
Return


ABOUT:
Gui,99:Destroy
Gui,99:Margin,20,20
Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
Gui,99:Font,W700
Gui,99:Add,Text,x+10 yp+10 Bold,%applicationname% v2.1
Gui,99:Font,W400
Gui,99:Add,Text,y+10,Sends user defined times and dates to the active window.
Gui,99:Add,Text,xp y+5,Doubleclick the tray icon to send the last used date and time.
Gui,99:Add,Text,y+10,Use the Settings menu to change the timestamps and hotkeys.

Gui,99:Add,Picture,xm y+20 G1HOURSOFTWARE Icon2,%applicationname%.exe
Gui,99:Add,Text,x+10 yp,For more tools, information and donations, please visit
Gui,99:Font,W700 CBlue
Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
Gui,99:Font,W400 CBlack

Gui,99:Add,Picture,xm y+20 GDONATIONCODER Icon7,%applicationname%.exe
Gui,99:Add,Text,x+10 yp,Please support the contributors at
Gui,99:Font,W700 CBlue
Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
Gui,99:Font,W400 CBlack

Gui,99:Add,Picture,xm y+20 GAUTOHOTKEY Icon6,%applicationname%.exe
Gui,99:Add,Text,x+10 yp,This tool was made using the powerful
Gui,99:Font,W700 CBlue
Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
Gui,99:Font,W400 CBlack

Gui,99:Show,,%applicationname% - About
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
Gui,99:+LastFound
aboutid:=WinExist()
Return

1HOURSOFTWARE:
Run,www.1HourSoftware.com
Return

DONATIONCODER:
Run,www.DonationCoder.com
Return

AUTOHOTKEY:
Run,www.AutoHotkey.com
Return


WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  Global aboutid
  MouseGetPos,,,mwin,mctrl
  If mwin in %aboutid%
  If mctrl in Static8,Static11,Static14
    DllCall("SetCursor","UInt",hCurs)
  Return
}

99GuiEscape:
99GuiClose:
  Gui,99:Destroy
  OnMessage(0x200,"")
  DllCall("DestroyCursor","Uint",hCurs)
Return


EXIT:
  DllCall("DeregisterShellHookWindow",UInt,guiid)
  ExitApp


INIFILE:
IfNotExist,%applicationname%.ini
  FileAppend,
(
[Settings]
stamp1=H:mm:ss" - "dddd" "d.MM.yyy" - d"day" w"weeknl
hotkey1=F1
stamp2=yyy.MM.d" "tabH:mm:ss
hotkey2=F2

;TimeStamp.ini
;
;Hotkeys
;^=Ctrl !=Alt +=Shift #=Window
;
;Examples:
;
;^F1=Ctrl-F1
;+!j=Shift-Alt-j
;
;
;Formatting (case sensitive)
;
;nl   NewLine
;tab  Tab
;     Surround regular text with ""
;
;Date Formats (case sensitive)
;
;d    Day of the month without leading zero (1 - 31)
;dd   Day of the month with leading zero (01 – 31)
;ddd  Lowercase abbreviated name for the day of the week (e.g. mon)
;Ddd  Like ddd, but Titlecase
;DDD  Like ddd, but UPPERCASE
;dddd Lowercase full name for the day of the week (e.g. monday)
;Dddd Like ddd, but Titlecase
;DDDD Like ddd, but UPPERCASE
;M    Month without leading zero (1 – 12)
;MM   Month with leading zero (01 – 12)
;mmm  Lowercase abbreviated month name (e.g. jan)
;Mmm  Like mmm, but Titlecase
;MMM  Like mmm, but UPPERCASE
;mmmm Full month name (e.g. january)
;Mmmm Like mmmm, but Titlecase
;MMMM Like mmmm, but UPPERCASE
;y    Year without century, without leading zero (0 – 99)
;yy   Year without century, with leading zero (00 - 99)
;yyyy Year with century. Example: 2005
;gg   Period/era string for the current user's locale (blank if none)
;Day  Day of the year
;Week Week of the year
;
;Time Formats (case sensitive)
;
;h    Hours without leading zero; 12-hour format (1 - 12)
;hh   Hours with leading zero; 12-hour format (01 – 12)
;H    Hours without leading zero; 24-hour format (0 - 23)
;HH   Hours with leading zero; 24-hour format (00– 23)
;m    Minutes without leading zero (0 – 59)
;mm   Minutes with leading zero (00 – 59)
;s    Seconds without leading zero (0 – 59)
;ss   Seconds with leading zero (00 – 59)
;t    Single character time marker, such as A or P (depends on locale)
;tt   Multi-character time marker, such as AM or PM (depends on locale)
;
;Examples:
;
;H:mm:ss" - "dddd" "d.MM.yyy" - d"day" w"week = 10:49:05 - saturday 14.06.2008 - d166 w24
;yyy.MM.d" "nlH:mm:ss                         = 2008.06.14
;                                               10:49:36
)
,%applicationname%.ini
Return
153  DonationCoder.com Software / Post New Requests Here / Re: Screamer Radio frontend - ScreamerMenu on: June 13, 2008, 09:27:28 PM
 Sad It looks like mr Zidar has dropped standard menus in Screamer beta4, so I don't know if I can make ScreamerMenu work.

Skrommel
154  DonationCoder.com Software / Post New Requests Here / Re: IDEA: screensaver / monitor timeouts to IGNORE small mouse jitters on: June 13, 2008, 09:19:02 PM
 smiley Here's Jiggle!

It prevents small mouse movements from stopping the screensaver.

Skrommel

[copy or print]
;Jiggle.ahk
; Prevents small mouse movements from stopping the screensaver
;Skrommel @ 2008

#SingleInstance,Force
#Persistent,On
SetBatchLines,-1

SetTimer,CHECKSCREENSAVER,1000
Return


CHECKSCREENSAVER:                     ;is the screensaver running
  oldactive:=active
  VarSetCapacity(active,4,0)
  DllCall("user32.dll\SystemParametersInfo","uint",0x0072,"uint",0,"uint*",active,"uint",0) ; SPI_GETSCREENSAVERRUNNING = 0x0072 
  If active>0                         ;yes, lock the mouse
    hHookKeybd:=DllCall("SetWindowsHookEx",Int,14,Uint,RegisterCallback("CHECKMOUSEMOVE","F"),UInt
               ,DllCall("GetModuleHandle",UInt,0),UInt,0)  ; WH_MOUSE_LL = 14
  Else
  If oldactive=1                      ;no, check if it has run, if so, stop watching the mouse
    Reload
Return


CHECKMOUSEMOVE(nCode,wParam,lParam)
{
   Global blockMouse
   Global counter
   
   If A_TimeIdlePhysical<1000          ;has the system not been idle
   {
     counter+=1
     If counter>100                     ;has it not been idle repeatedly
     {
       blockMouse=0                    ;start forwarding the mouse messages
       counter=0
     }
   }
   Else
   {
     blockMouse=1                      ;stop forwarding the mouse messages
     counter=0
   }
   ToolTip,%A_TimeIdlePhysical%-%counter%-%blockmouse%
   Return blockMouse ? 1 : DllCall("CallNextHookEx",UInt,0,Int,nCode,UInt,wParam,UInt,lParam)
}
155  DonationCoder.com Software / Post New Requests Here / Re: IDEA : Right-Click Menu gives an [ENTER] choice and when LEFT-Clicked [ENTER]s on: April 18, 2008, 12:40:20 PM
 smiley Or Maxthon! It's Internet Explorer based, and incredible!

I've also developed a SuperDuperDragAndDrop with customizable actions depending on what app you're in and the direction you drag and drop, but I'm having trouble with DDE and HTML, so it crashes in Internet Explorer. Sad

Skrommel
156  DonationCoder.com Software / Coding Snacks / Re: Window Tags on: April 03, 2008, 10:21:36 AM
 smiley 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
157  DonationCoder.com Software / Post New Requests Here / Re: IDEA : Right-Click Menu gives an [ENTER] choice and when LEFT-Clicked [ENTER]s on: April 02, 2008, 07:04:01 PM
 tellme Where? And what for?

Skrommel
158  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
 smiley 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.

Angry 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
}
159  DonationCoder.com Software / Coding Snacks / Re: Context-menu bmp-to-jpg converter on: March 30, 2008, 01:10:39 PM
 smiley 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
}
160  DonationCoder.com Software / Post New Requests Here / Re: IDEA: Vista integrity levels shell extension on: March 29, 2008, 11:19:41 AM
 smiley Just uploaded a new version above!

Added shell extension for folders, and it now automatically downloads chml.exe. I also corrected a typo in the command line for chml.exe, so it should work better now!

Skrommel
161  DonationCoder.com Software / Post New Requests Here / Re: IDEA: Vista integrity levels shell extension on: March 28, 2008, 09:16:26 PM
 smiley 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
}
162  DonationCoder.com Software / Post New Requests Here / Re: IDEA: Global hotkeys in VLC on: March 26, 2008, 09:05:56 PM
 smiley 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
163  DonationCoder.com Software / Post New Requests Here / Re: IDEA: Global hotkeys in VLC on: March 26, 2008, 01:01:04 PM
 tellme Josh, please elaborate!

Quote
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
164  DonationCoder.com Software / Post New Requests Here / Re: [request] Taskbar Displayed Only On <Win> Keypress on: March 23, 2008, 07:47:49 PM
 smiley 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
165  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
 smiley 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
166  DonationCoder.com Software / Post New Requests Here / Re: IDEA: Stand alone bookmarks toolbar on: March 23, 2008, 02:25:54 PM
 smiley 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
167  DonationCoder.com Software / Post New Requests Here / Re: [idea] Text to Unicode Conversion on: March 23, 2008, 04:05:16 AM
 smiley Here's an AutoHotkey version!

Skrommel

[copy or print]
input=http://www.example.com
output=
Loop,Parse,input,
  output:=output "&" Asc(A_LoopField) ";"
MsgBox,%output%
168  DonationCoder.com Software / Post New Requests Here / Re: IDEA: Stand alone bookmarks toolbar on: March 23, 2008, 03:40:35 AM
 smiley 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
169  DonationCoder.com Software / Post New Requests Here / Re: IDEA? simple startup manager with timer on: March 22, 2008, 08:35:16 PM
 smiley Try the updated script above!

Skrommel
170  DonationCoder.com Software / Post New Requests Here / Re: IDEA? simple startup manager with timer on: March 22, 2008, 03:32:36 PM
 smiley 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.23

Skrommel

[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
171  DonationCoder.com Software / Post New Requests Here / Re: [request] Taskbar Displayed Only On <Win> Keypress on: March 17, 2008, 09:16:47 PM
 smiley Try PushToShow!

PushToShow - Completely hides the taskbar until the Windows key is pushed.

You'll find the downloads and more info at 1 Hour Software by Skrommel.

Skrommel
172  DonationCoder.com Software / Finished Programs / Re: IDEA: Gracefully close Firefox on PC exit on: March 15, 2008, 05:24:03 PM
 smiley You can use CloseToQuit to close a list of apps, with options to close by using the process name, the class name or a part of a window caption.

To close FireFox just use apps=firefox.exe or apps=MozillaWindowClass.

Skrommel
173  DonationCoder.com Software / Finished Programs / Re: IDEA: Gracefully close Firefox on PC exit on: March 15, 2008, 01:30:49 PM
 smiley 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
}
174  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
 smiley 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
175  DonationCoder.com Software / Coding Snacks / Re: DetachVideo - Give embedded videos their own window! on: March 10, 2008, 11:49:55 AM
 Sad Sorry, DetachVideo only steals the control from a window, it can't resize the video. But it may be possible to change the <embed> tag of the browser to resize the video before stealing it...

Skrommel
Pages: Prev 1 2 3 4 5 6 [7] 8 9 10 11 12 ... 36 Next
DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.086s | Server load: 0.02 ]


Share on Facebook
submit to reddit