Topics - skrommel [ switch to compact view ]

Pages: [1] 2 3next
1
 :) The worlds fastest unindexed search?

InEverything - Search inside files using the Everything NTFS search engine.

I use Everything to search for files, but it doesn't search inside files, so I've thrown together a solution. Beta.

To run the script, you need to download Everything and ES from http://www.voidtools.com/download.php. Install Everything, turn on Tools - Options - ETP/FTP and check Start ETP/FTP server on startup. Plase ES.exe next to the script.

Skrommel


;InEverything.ahk
; Search fast inside files using the Everything NTFS search engine
;Skrommel @ 2009

find=*.ahk
needle=Skrommel

FileInstall,Everything.exe,Everything.exe
FileInstall,Everything.chm,Everything.chm
FileInstall,Everything.ini,Everything.ini
FileInstall,ES.exe,ES.exe

#NoEnv
#SingleInstance,Force
SetBatchLines,-1
SendMode,Input
SetWorkingDir,%A_ScriptDir%
SetTitleMatchMode=Slow

applicationname=InEverything

Gui,+Resize
Gui,Add,Text,xm w200,Files: (supports wildcards * and ?)
Gui,Add,Text,x+5 w300,Text: (case sensitive, no wildcards)
Gui,Add,Edit,xm w200 Vfind,%find%
Gui,Add,Edit,x+5 w300 Vneedle,%needle%
Gui,Add,Button,x+5 yp-1 Default Vstart GSTART,&Search
Gui,Add,Button,x+5 yp Vstop GSTOP,S&top
Gui,Add,ListView,xm Vlistview GLISTVIEW AltSubmit,File|Path|Ext|Modified|Size|Attrib|Position|%A_Space%
Gui,Show,,%applicationname%
Gui,+LastFound
guiid:=WinExist()
LV_ModifyCol(5,"Integer")
LV_ModifyCol(7,"Integer")
LV_ModifyCol(8,"Integer")

GuiControl,Disable,start
GuiControl,Disable,stop
WinSetTitle,ahk_id %guiid%,,%applicationname% - Waiting for Everything...
Loop
{
  IfWinNotExist,ahk_class EVERYTHING
    Run,Everything.exe,,Minimized
  Sleep,1000
  WinGetText,text,ahk_class EVERYTHING
  IfInString,text,objects
    Break
  IfInString,text,selected
    Break
  If A_Index=30
  {
    MsgBox,0,%applicationname%,Unable to start Everything!
    ExitApp
  }
}
WinSetTitle,ahk_id %guiid%,,%applicationname%
GuiControl,Enable,start
GuiControl,Enable,stop
Return


LISTVIEW:
If A_GuiEvent=RightClick
{
  LV_GetText(file,A_EventInfo,1)
  LV_GetText(path,A_EventInfo,2)
  sPath:=path "\" file
  ShellContextMenu(sPath<>"" ? sPath : 0x0011)
}

If A_GuiEvent=DoubleClick
{
  LV_GetText(file,A_EventInfo,1)
  LV_GetText(path,A_EventInfo,2)
  Run,%path%\%file%,,UseErrorLevel
  If ErrorLevel=1
    MsgBox,Could not open "%path%\%file%".
}
Return


START:
If stop<>1
  Gosub,STOP
LV_Delete()
Gui,Submit,NoHide
stop=0
total=0
searched=0
matching=0
SetTimer,FINISHED,-1000
Goto,SEARCH
Return


STOP:
stop=1
WinClose,ahk_pid %cmdretPID%
cmdretPID=0
Return


FINISHED:
If stop=1
{
  WinSetTitle,ahk_id %guiid%,,%applicationname% - Stopped searching through %searched% of %total% %find%-files for "%needle%". Found %matching% matching files.
  Return
}
Process,Exist,%cmdretPID%
running:=ErrorLevel
If (running=0 And searched=total)
  WinSetTitle,ahk_id %guiid%,,%applicationname% - Finished searching through %total% %find%-files for "%needle%". Found %matching% matching files.
Else
{
  WinSetTitle,ahk_id %guiid%,,%applicationname% - Searching through %searched% og %total% %find%-files for "%needle%". Found %matching% matching files...
  SetTimer,FINISHED,-1000
}
Loop,8
  LV_ModifyCol(A_Index,"AutoHdr")
Return


SEARCH:
CMDret_Stream("es.exe " find)
Return


GuiClose:
Gosub,STOP
;WinClose,ahk_class EVERYTHING
ExitApp


GuiSize:
If ErrorLevel=1  ;minimized
  Return
GuiControlGet,pos,Pos,listview
width:=A_GuiWidth-posx-10
height:=A_GuiHeight-posy-10
GuiControl,Move,listview,W%width% H%height%
Return


CMDret_Output(CMDout, CMDname="")
; CMDout - each line of output returned (1 line each time)
; CMDname - type of output to process (Optional)
{
  Global needle,stop,searched,matching

  If stop=1
    Return
  If CMDout<>
  {
    offset=0
    If needle<>
      offset:=FINDINFILE(CMDout,needle)
    If offset>-1
    {
      FileGetAttrib,attrib,% CMDout
      FileGetTime,modified,% CMDout,M
      FormatTime,modified,%modified%,yyyy-MM-dd HH:mm:ss
      FileGetSize,size,% CMDout,
      SplitPath,CMDout,name,dir,ext,name_no_ext,drive
      LV_Add("",name,dir,ext,modified,size,attrib,offset)
      matching+=1
    }
  }
  searched+=1
  Return  
}


FINDINFILE(file,needle)
{
  offset:=InFile(file,&needle,StrLen(needle),0)
  Return,% offset
}


FINDALLINFILE(file,needle)
{
  found=
  offset=-1
  Loop
  {
    offset:=InFile(file,&needle,StrLen(needle),offset+1)
    If offset=-1
      Break
    found.=offset ","
  }
  StringTrimRight,found,found,1
  Return,% found
}


;Stolen from wOxxOm at http://www.autohotkey.com/forum/topic25925.html
;InFile - InBuf based case-sensitive searching in file's contents of any* size
;*: even larger than 4GB, StartOffset may also be larger than 4GB.
;Usage:
;fileOffs:=InFile( "d:\filename", &needle, needleLen, StartOffset )

InFile( fileName, needleAddr, needleLen, StartOffset=0 )
{
   lRet=-1
   IfEqual,needleLen,0, return lRet
   IfEqual,needleAddr,0, return lRet
   hFile:=DllCall("CreateFile", "str", fileName,"uint",0x80000000 ;GENERIC_READ
            ,"uint", 1 ;FILE_SHARE_READ
            ,"uint", 0, "uint",3 ;OPEN_EXISTING
            ,"uint",0x2000000 ;FILE_FLAG_BACKUP_SEMANTICS
            ,"uint", 0)
   ifEqual,hFile,-1, return lRet

   VarSetCapacity( lBufLen, 8, 0 )
   NumPut( DllCall("GetFileSize","uint",hFile,"uint",&lBufLen+4), lBufLen )
   DllCall( "RtlMoveMemory", "int64 *",lBufLen64, "uint",&lBufLen, "uint",8 )
   lBufLen64 -= StartOffset
   If( lBufLen64>=0 )
   {   hMap:=DllCall("CreateFileMapping", "uint",hFile, "uint",0, "uint",2 ;PAGE_READONLY
               ,"uint",0,"uint",0,"uint",0)
      if( hMap )
      {   lMax32b=0xFFFFFFFF
         lMaxView=0x40000000 ;1GB
         VarSetCapacity( SI, 36, 0 )
         DllCall("GetSystemInfo","uint",&SI)
         memAllocGranularity:=NumGet( SI, 28 )
         loop
         {   FileOffs:=(StartOffset//memAllocGranularity)*memAllocGranularity
            delta:=StartOffset-FileOffs
            lBufLenLo:=(lBufLen64+delta > lMaxView) ? lMaxView : lBufLen64+delta
            hView:=DllCall("MapViewOfFile", "uint",hMap, "uint", 4 ;FILE_MAP_READ
                     ,"uint",FileOffs>>32,"uint",FileOffs & lMax32b,"uint",lBufLenLo)
            ifEqual,hView,0, break
            lRet:=InBuf( hView, needleAddr, lBufLenLo, needleLen, delta )
            DllCall("UnmapViewOfFile","uint",hView)
            if( lRet!=-1 )
            {   lRet += FileOffs
               break
            }
            StartOffset += lBufLenLo-needleLen
            lBufLen64 -= lBufLenLo-needleLen
            IfLessOrEqual,lBufLen64,0, break
         }
         DllCall("CloseHandle","uint",hMap)
      }
   }
   DllCall("CloseHandle","uint",hFile)
   return lRet
}


InBuf(haystackAddr, needleAddr, haystackSize, needleSize, StartOffset=0)
{   Static fun
   IfEqual,fun,
   {
      h=
      ( LTrim join
         5589E583EC0C53515256579C8B5D1483FB000F8EC20000008B4D108B451829C129D9410F8E
         B10000008B7D0801C78B750C31C0FCAC4B742A4B742D4B74364B74144B753F93AD93F2AE0F
         858B000000391F75F4EB754EADF2AE757F3947FF75F7EB68F2AE7574EB628A26F2AE756C38
         2775F8EB569366AD93F2AE755E66391F75F7EB474E43AD8975FC89DAC1EB02895DF483E203
         8955F887DF87D187FB87CAF2AE75373947FF75F789FB89CA83C7038B75FC8B4DF485C97404
         F3A775DE8B4DF885C97404F3A675D389DF4F89F82B45089D5F5E5A595BC9C2140031C0F7D0EBF0
      )
      VarSetCapacity(fun,StrLen(h)//2)
      Loop % StrLen(h)//2
         NumPut("0x" . SubStr(h,2*A_Index-1,2), fun, A_Index-1, "Char")
   }
   Return DllCall(&fun
      , "uint",haystackAddr, "uint",needleAddr
      , "uint",haystackSize, "uint",needleSize
      , "uint",StartOffset)
}


;Stolen from corrupt at http://www.autohotkey.com/forum/topic8606.html
; ******************************************************************
; CMDret-AHK functions by corrupt
;
; CMDret_Stream
; version 0.03 beta
; Updated: Feb 19, 2007
;
; CMDret code modifications and/or contributions have been made by:
; Laszlo, shimanov, toralf, Wdb
; ******************************************************************
; Usage:
; CMDin - command to execute
; CMDname - type of output to process (Optional)
; WorkingDir - full path to working directory (Optional)
; ******************************************************************
; Known Issues:
; - If using dir be sure to specify a path (example: cmd /c dir c:\)
; or specify a working directory
; - Running 16 bit console applications may not produce output. Use
; a 32 bit application to start the 16 bit process to receive output
; ******************************************************************
; Additional requirements:
; - Your script must also contain a CMDret_Output function
;
; CMDret_Output(CMDout, CMDname="")
; Usage:
; CMDout - each line of output returned (1 line each time)
; CMDname - type of output to process (Optional)
; ******************************************************************
; Code Start
; ******************************************************************

CMDret_Stream(CMDin, CMDname="", WorkingDir=0)
{
  Global cmdretPID,total

  tcWrk := WorkingDir=0 ? "Int" : "Str"
  idltm := A_TickCount + 20
  LivePos = 1
  VarSetCapacity(CMDout, 1, 32)
  VarSetCapacity(sui,68, 0)
  VarSetCapacity(pi, 16, 0)
  VarSetCapacity(pa, 12, 0)
  Loop, 4 {
    DllCall("RtlFillMemory", UInt,&pa+A_Index-1, UInt,1, UChar,12 >> 8*A_Index-8)
    DllCall("RtlFillMemory", UInt,&pa+8+A_Index-1, UInt,1, UChar,1 >> 8*A_Index-8)
  }
  IF (DllCall("CreatePipe", "UInt*",hRead, "UInt*",hWrite, "UInt",&pa, "Int",0) <> 0) {
    Loop, 4
      DllCall("RtlFillMemory", UInt,&sui+A_Index-1, UInt,1, UChar,68 >> 8*A_Index-8)
    DllCall("GetStartupInfo", "UInt", &sui)
    Loop, 4 {
      DllCall("RtlFillMemory", UInt,&sui+44+A_Index-1, UInt,1, UChar,257 >> 8*A_Index-8)
      DllCall("RtlFillMemory", UInt,&sui+60+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8)
      DllCall("RtlFillMemory", UInt,&sui+64+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8)
      DllCall("RtlFillMemory", UInt,&sui+48+A_Index-1, UInt,1, UChar,0 >> 8*A_Index-8)
    }
    IF (DllCall("CreateProcess", Int,0, Str,CMDin, Int,0, Int,0, Int,1, "UInt",0, Int,0, tcWrk, WorkingDir, UInt,&sui, UInt,&pi) <> 0) {
      Loop, 4
        cmdretPID += *(&pi+8+A_Index-1) << 8*A_Index-8
      Loop {
        idltm2 := A_TickCount - idltm
        If (idltm2 < 15) {
          DllCall("Sleep", Int, 15)
          Continue
        }
        IF (DllCall("PeekNamedPipe", "uint", hRead, "uint", 0, "uint", 0, "uint", 0, "uint*", bSize, "uint", 0 ) <> 0 ) {
          Process, Exist, %cmdretPID%
          IF (ErrorLevel OR bSize > 0) {
            IF (bSize > 0) {
              VarSetCapacity(lpBuffer, bSize+1, 0)
              IF (DllCall("ReadFile", "UInt",hRead, "Str", lpBuffer, "Int",bSize, "UInt*",bRead, "Int",0) > 0) {
                IF (bRead > 0) {
                  IF (StrLen(lpBuffer) < bRead) {
                    VarSetCapacity(CMcpy, bRead, 32)
                    bRead2 = %bRead%
                    Loop {
                      DllCall("RtlZeroMemory", "UInt", &CMcpy, Int, bRead)
                      NULLptr := StrLen(lpBuffer)
                      cpsize := bread - NULLptr
                      DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", (&lpBuffer + NULLptr + 2), "Int", (cpsize - 1))
                      DllCall("RtlZeroMemory", "UInt", (&lpBuffer + NULLptr), Int, cpsize)
                      DllCall("RtlMoveMemory", "UInt", (&lpBuffer + NULLptr), "UInt", &CMcpy, "Int", cpsize)
                      bRead2 --
                      IF (StrLen(lpBuffer) > bRead2)
                        break
                    }
                  }
              VarSetCapacity(lpBuffer, -1)
                  CMDout .= lpBuffer
                  bRead = 0
                }
              }
            }
          }
          ELSE
            break
        }
        ELSE
          break
        idltm := A_TickCount
        LiveFound := RegExMatch(CMDout, "m)^(.*)", LiveOut, LivePos)
        If (LiveFound)
          SetTimer, cmdretSTR, 5
      }
      cmdretPID=
      DllCall("CloseHandle", UInt, hWrite)
      DllCall("CloseHandle", UInt, hRead)
    }
  }
  StringTrimLeft, LiveRes, CMDout, %LivePos%
  If LiveRes <>
    Loop, Parse, LiveRes, `n
    {
      FileLine = %A_LoopField%
      StringTrimRight, FileLine, FileLine, 1
      total+=1
      CMDret_Output(FileLine, CMDname)
   }
  StringTrimLeft, CMDout, CMDout, 1
  cmdretPID = 0
  Return, CMDout
  
  cmdretSTR:
  SetTimer, cmdretSTR, Off
  If (LivePosLast <> LiveFound) {
    FileLine = %LiveOut1%
    LivePos := LiveFound + StrLen(FileLine) + 1
    LivePosLast := LivePos
    total+=1
    CMDret_Output(FileLine, CMDname)
 }
  Return
}


;Stolen from Sean at http://www.autohotkey.com/forum/topic22120.html
ShellContextMenu(sPath)
{
   CoInitialize()
   If   sPath Is Not Integer
      DllCall("shell32\SHParseDisplayName", "Uint", Unicode4Ansi(wPath,sPath), "Uint", 0, "UintP", pidl, "Uint", 0, "Uint", 0)
   Else   DllCall("shell32\SHGetFolderLocation", "Uint", 0, "int", sPath, "Uint", 0, "Uint", 0, "UintP", pidl)
   DllCall("shell32\SHBindToParent", "Uint", pidl, "Uint", GUID4String(IID_IShellFolder,"{000214E6-0000-0000-C000-000000000046}"), "UintP", psf, "UintP", pidlChild)
   DllCall(NumGet(NumGet(1*psf)+40), "Uint", psf, "Uint", 0, "Uint", 1, "UintP", pidlChild, "Uint", GUID4String(IID_IContextMenu,"{000214E4-0000-0000-C000-000000000046}"), "Uint", 0, "UintP", pcm)
   Release(psf)
   CoTaskMemFree(pidl)

   hMenu := DllCall("CreatePopupMenu")
   DllCall(NumGet(NumGet(1*pcm)+12), "Uint", pcm, "Uint", hMenu, "Uint", 0, "Uint", 3, "Uint", 0x7FFF, "Uint", 0)   ; QueryContextMenu
   DetectHiddenWindows, On
   Process, Exist
   WinGet, hAHK, ID, ahk_pid %ErrorLevel%
   WinActivate, ahk_id %hAHK%
   Global   pcm2 := QueryInterface(pcm,IID_IContextMenu2:="{000214F4-0000-0000-C000-000000000046}")
   Global   pcm3 := QueryInterface(pcm,IID_IContextMenu3:="{BCFCE0A0-EC17-11D0-8D10-00A0C90F2719}")
   Global   WPOld:= DllCall("SetWindowLong", "Uint", hAHK, "int",-4, "int",RegisterCallback("WindowProc"))
   DllCall("GetCursorPos", "int64P", pt)
   DllCall("InsertMenu", "Uint", hMenu, "Uint", 0, "Uint", 0x0400|0x800, "Uint", 2, "Uint", 0)
   DllCall("InsertMenu", "Uint", hMenu, "Uint", 0, "Uint", 0x0400|0x002, "Uint", 1, "Uint", &sPath)
   idn := DllCall("TrackPopupMenu", "Uint", hMenu, "Uint", 0x0100, "int", pt << 32 >> 32, "int", pt >> 32, "Uint", 0, "Uint", hAHK, "Uint", 0)
   NumPut(VarSetCapacity(ici,64,0),ici), NumPut(0x4000|0x20000000,ici,4), NumPut(1,NumPut(hAHK,ici,8),12), NumPut(idn-3,NumPut(idn-3,ici,12),24), NumPut(pt,ici,56,"int64")
   DllCall(NumGet(NumGet(1*pcm)+16), "Uint", pcm, "Uint", &ici)   ; InvokeCommand
;   VarSetCapacity(sName,259), DllCall(NumGet(NumGet(1*pcm)+20), "Uint", pcm, "Uint", idn-3, "Uint", 1, "Uint", 0, "str", sName, "Uint", 260)   ; GetCommandString
   DllCall("GlobalFree", "Uint", DllCall("SetWindowLong", "Uint", hAHK, "int", -4, "int", WPOld))
   DllCall("DestroyMenu", "Uint", hMenu)
   Release(pcm3)
   Release(pcm2)
   Release(pcm)
   CoUninitialize()
   pcm2:=pcm3:=WPOld:=0
}

WindowProc(hWnd, nMsg, wParam, lParam)
{
   Critical
   Global   pcm2, pcm3, WPOld
   If   pcm3
   {
      If   !DllCall(NumGet(NumGet(1*pcm3)+28), "Uint", pcm3, "Uint", nMsg, "Uint", wParam, "Uint", lParam, "UintP", lResult)
         Return   lResult
   }
   Else If   pcm2
   {
      If   !DllCall(NumGet(NumGet(1*pcm2)+24), "Uint", pcm2, "Uint", nMsg, "Uint", wParam, "Uint", lParam)
         Return   0
   }
   Return   DllCall("user32.dll\CallWindowProcA", "Uint", WPOld, "Uint", hWnd, "Uint", nMsg, "Uint", wParam, "Uint", lParam)
}

VTable(ppv, idx)
{
Return NumGet(NumGet(1*ppv)+4*idx)
}

QueryInterface(ppv, ByRef IID)
{
If StrLen(IID)=38
GUID4String(IID,IID)
DllCall(NumGet(NumGet(1*ppv)), "Uint", ppv, "str", IID, "UintP", ppv)
Return ppv
}

AddRef(ppv)
{
Return DllCall(NumGet(NumGet(1*ppv)+4), "Uint", ppv)
}

Release(ppv)
{
Return DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv)
}

QueryService(ppv, ByRef SID, ByRef IID)
{
If StrLen(SID)=38
GUID4String(SID,SID)
If StrLen(IID)=38
GUID4String(IID,IID)
GUID4String(IID_IServiceProvider,"{6D5140C1-7436-11CE-8034-00AA006009FA}")
DllCall(NumGet(NumGet(1*ppv)+4*0), "Uint", ppv, "str", IID_IServiceProvider, "UintP", psp)
DllCall(NumGet(NumGet(1*psp)+4*3), "Uint", psp, "str", SID, "str", IID, "UintP", ppv)
DllCall(NumGet(NumGet(1*psp)+4*2), "Uint", psp)
Return ppv
}

FindConnectionPoint(pdp, DIID)
{
DllCall(NumGet(NumGet(1*pdp)+ 0), "Uint", pdp, "Uint", GUID4String(IID_IConnectionPointContainer,"{B196B284-BAB4-101A-B69C-00AA00341D07}"), "UintP", pcc)
DllCall(NumGet(NumGet(1*pcc)+16), "Uint", pcc, "Uint", GUID4String(DIID,DIID), "UintP", pcp)
DllCall(NumGet(NumGet(1*pcc)+ 8), "Uint", pcc)
Return pcp
}

GetConnectionInterface(pcp)
{
VarSetCapacity(DIID, 16, 0)
DllCall(NumGet(NumGet(1*pcp)+12), "Uint", pcp, "str", DIID)
Return String4GUID(&DIID)
}

Advise(pcp, psink)
{
DllCall(NumGet(NumGet(1*pcp)+20), "Uint", pcp, "Uint", psink, "UintP", nCookie)
Return nCookie
}

Unadvise(pcp, nCookie)
{
Return DllCall(NumGet(NumGet(1*pcp)+24), "Uint", pcp, "Uint", nCookie)
}

/*
Enumerate(penum, ByRef Result)
{
VarSetCapacity(varResult,16,0)
If (0 = hResult:=DllCall(NumGet(NumGet(1*penum)+12), "Uint", penum, "Uint", 1, "Uint", &varResult, "UintP", 0))
Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(SysFreeString(bstr),1,0) : NumGet(varResult,8)
Return hResult
}
*/

Invoke(pdisp, sName, arg1="vT_NoNe",arg2="vT_NoNe",arg3="vT_NoNe",arg4="vT_NoNe",arg5="vT_NoNe",arg6="vT_NoNe",arg7="vT_NoNe",arg8="vT_NoNe",arg9="vT_NoNe")
{
nParams:=0
Loop, 9
If (arg%A_Index% == "vT_NoNe")
Break
Else ++nParams
VarSetCapacity(DispParams,16,0), VarSetCapacity(varResult,16,0), VarSetCapacity(IID_NULL,16,0), VarSetCapacity(varg,nParams*16,0)
NumPut(&varg,DispParams,0), NumPut(nParams,DispParams,8)
If (nFlags := SubStr(sName,0) <> "=" ? 3 : 12) = 12
NumPut(&varResult,DispParams,4), NumPut(1,DispParams,12), NumPut(-3,varResult), sName:=SubStr(sName,1,-1)
Loop, % nParams
If arg%A_Index% Is Not Integer
         NumPut(8,varg,(nParams-A_Index)*16,"Ushort"), NumPut(SysAllocString(arg%A_Index%),varg,(nParams-A_Index)*16+8)
Else NumPut(SubStr(arg%A_Index%,1,1)="+" ? 9 : 3,varg,(nParams-A_Index)*16,"Ushort"), NumPut(arg%A_Index%,varg,(nParams-A_Index)*16+8)
If DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)=0
&& DllCall(NumGet(NumGet(1*pdisp)+24), "Uint", pdisp, "int", dispID, "Uint", &IID_NULL, "Uint", LCID, "Ushort", nFlags, "Uint", &dispParams, "Uint", &varResult, "Uint", 0, "Uint", 0)=0
&& nFlags = 3
Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(SysFreeString(bstr),1,0) : NumGet(varResult,8)
Loop, % nParams
NumGet(varg,(A_Index-1)*16,"Ushort")=8 ? SysFreeString(NumGet(varg,(A_Index-1)*16+8)) : ""
Return Result
}

Invoke_(pdisp, sName, type1="",arg1="",type2="",arg2="",type3="",arg3="",type4="",arg4="",type5="",arg5="",type6="",arg6="",type7="",arg7="",type8="",arg8="",type9="",arg9="")
{
nParams:=0
Loop, 9
If (type%A_Index% = "")
Break
Else ++nParams
VarSetCapacity(dispParams,16,0), VarSetCapacity(varResult,16,0), VarSetCapacity(IID_NULL,16,0), VarSetCapacity(varg,nParams*16,0)
NumPut(&varg,dispParams,0), NumPut(nParams,dispParams,8)
If (nFlags := SubStr(sName,0) <> "=" ? 1|2 : 4|8) & 12
NumPut(&varResult,dispParams,4), NumPut(1,dispParams,12), NumPut(-3,varResult), sName:=SubStr(sName,1,-1)
Loop, % nParams
NumPut(type%A_Index%,varg,(nParams-A_Index)*16,"Ushort"), type%A_Index%&0x4000=0 ? NumPut(type%A_Index%=8 ? SysAllocString(arg%A_Index%) : arg%A_Index%,varg,(nParams-A_Index)*16+8,type%A_Index%=5||type%A_Index%=7 ? "double" : type%A_Index%=4 ? "float" : "int64") : type%A_Index%=0x400C||type%A_Index%=0x400E ? NumPut(arg%A_Index%,varg,(nParams-A_Index)*16+8) : VarSetCapacity(ref%A_Index%,8,0) . NumPut(&ref%A_Index%,varg,(nParams-A_Index)*16+8) . NumPut(type%A_Index%=0x4008 ? SysAllocString(arg%A_Index%) : arg%A_Index%,ref%A_Index%,0,type%A_Index%=0x4005||type%A_Index%=0x4007 ? "double" : type%A_Index%=0x4004 ? "float" : "int64")
If DllCall(NumGet(NumGet(1*pdisp)+20), "Uint", pdisp, "Uint", &IID_NULL, "UintP", Unicode4Ansi(wName, sName), "Uint", 1, "Uint", LCID, "intP", dispID)=0
&& DllCall(NumGet(NumGet(1*pdisp)+24), "Uint", pdisp, "int", dispID, "Uint", &IID_NULL, "Uint", LCID, "Ushort", nFlags, "Uint", &dispParams, "Uint", &varResult, "Uint", 0, "Uint", 0)=0
&& nFlags = 3
Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(SysFreeString(bstr),1,0) : NumGet(varResult,8)
Loop, % nParams
type%A_Index%&0x4000=0 ? (type%A_Index%=8 ? SysFreeString(NumGet(varg,(nParams-A_Index)*16+8)) : "") : type%A_Index%=0x400C||type%A_Index%=0x400E ? "" : type%A_Index%=0x4008 ? (_TEMP_VT_BYREF_%A_Index%:=Ansi4Unicode(NumGet(ref%A_Index%))) . SysFreeString(NumGet(ref%A_Index%)) : (_TEMP_VT_BYREF_%A_Index%:=NumGet(ref%A_Index%,0,type%A_Index%=0x4005||type%A_Index%=0x4007 ? "double" : type%A_Index%=0x4004 ? "float" : "int64"))
Return Result
}

DispInterface(this, prm1="", prm2="", prm3="", prm4="", prm5="", prm6="", prm7="", prm8="")
{
Critical
If A_EventInfo = 6
DllCall(NumGet(NumGet(NumGet(this+8))+28),"Uint",NumGet(this+8),"Uint",prm1,"UintP",pname,"Uint",1,"UintP",0), VarSetCapacity(sfn,63), DllCall("user32\wsprintfA","str",sfn,"str","%s%S","Uint",this+40,"Uint",pname,"Cdecl"), SysFreeString(pname), (pfn:=RegisterCallback(sfn,"C F")) ? (hResult:=DllCall(pfn, "Uint", prm5, "Uint", this, "Cdecl")) . DllCall("kernel32\GlobalFree", "Uint", pfn) : (hResult:=0x80020003)
Else If A_EventInfo = 5
hResult:=DllCall(NumGet(NumGet(NumGet(this+8))+40),"Uint",NumGet(this+8),"Uint",prm2,"Uint",prm3,"Uint",prm5)
Else If A_EventInfo = 4
NumPut(0,prm3+0), hResult:=0x80004001
Else If A_EventInfo = 3
NumPut(0,prm1+0), hResult:=0
Else If A_EventInfo = 2
NumPut(hResult:=NumGet(this+4)-1,this+4), hResult ? "" : Unadvise(NumGet(this+16),NumGet(this+20)) . Release(NumGet(this+16)) . Release(NumGet(this+8)) . CoTaskMemFree(this)
Else If A_EventInfo = 1
NumPut(hResult:=NumGet(this+4)+1,this+4)
Else If A_EventInfo = 0
IsEqualGUID(this+24,prm1)||InStr("{00020400-0000-0000-C000-000000000046}{00000000-0000-0000-C000-000000000046}",String4GUID(prm1)) ? NumPut(this,prm2+0) . NumPut(NumGet(this+4)+1,this+4) . (hResult:=0) : NumPut(0,prm2+0) . (hResult:=0x80004002)
Return hResult
}

DispGetParam(pDispParams, Position = 0, vtType = 8)
{
VarSetCapacity(varResult,16,0)
DllCall("oleaut32\DispGetParam", "Uint", pDispParams, "Uint", Position, "Ushort", vtType, "Uint", &varResult, "UintP", nArgErr)
Return NumGet(varResult,0,"Ushort")=8 ? Ansi4Unicode(NumGet(varResult,8)) . SubStr(SysFreeString(NumGet(varResult,8)),1,0) : NumGet(varResult,8)
}

CreateIDispatch()
{
Static IDispatch
If Not VarSetCapacity(IDispatch)
{
VarSetCapacity(IDispatch,28,0),   nParams=3112469
Loop,   Parse,   nParams
NumPut(RegisterCallback("DispInterface","",A_LoopField,A_Index-1),IDispatch,4*(A_Index-1))
}
Return &IDispatch
}

GetDefaultInterface(pdisp, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp) +12), "Uint", pdisp , "UintP", ctinf)
If ctinf
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint" , 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
DllCall(NumGet(NumGet(1*pdisp)+ 0), "Uint", pdisp, "Uint" , pattr, "UintP", ppv)
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
If ppv
DllCall(NumGet(NumGet(1*pdisp)+ 8), "Uint", pdisp), pdisp := ppv
}
Return pdisp
}

GetDefaultEvents(pdisp, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint" , 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
VarSetCapacity(IID,16), DllCall("RtlMoveMemory", "Uint", &IID, "Uint", pattr, "Uint", 16)
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
Loop, % DllCall(NumGet(NumGet(1*ptlib)+12), "Uint", ptlib)
{
DllCall(NumGet(NumGet(1*ptlib)+20), "Uint", ptlib, "Uint", A_Index-1, "UintP", TKind)
If TKind <> 5
Continue
DllCall(NumGet(NumGet(1*ptlib)+16), "Uint", ptlib, "Uint", A_Index-1, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
nCount:=NumGet(pattr+48,0,"Ushort")
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
Loop, % nCount
{
DllCall(NumGet(NumGet(1*ptinf)+36), "Uint", ptinf, "Uint", A_Index-1, "UintP", nFlags)
If !(nFlags & 1)
Continue
DllCall(NumGet(NumGet(1*ptinf)+32), "Uint", ptinf, "Uint", A_Index-1, "UintP", hRefType)
DllCall(NumGet(NumGet(1*ptinf)+56), "Uint", ptinf, "Uint", hRefType , "UintP", prinf)
DllCall(NumGet(NumGet(1*prinf)+12), "Uint", prinf, "UintP", pattr)
nFlags & 2 ? DIID:=String4GUID(pattr) : bFind:=IsEqualGUID(pattr,&IID)
DllCall(NumGet(NumGet(1*prinf)+76), "Uint", prinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*prinf)+ 8), "Uint", prinf)
}
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
If bFind
Break
}
DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib)
Return bFind ? DIID : "{00000000-0000-0000-0000-000000000000}"
}

GetGuidOfName(pdisp, Name, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint", 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf), ptinf:=0
DllCall(NumGet(NumGet(1*ptlib)+44), "Uint", ptlib, "Uint", Unicode4Ansi(Name,Name), "Uint", 0, "UintP", ptinf, "UintP", memID, "UshortP", 1)
DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
GUID := String4GUID(pattr)
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
Return GUID
}

GetTypeInfoOfGuid(pdisp, GUID, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint", 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf), ptinf := 0
DllCall(NumGet(NumGet(1*ptlib)+24), "Uint", ptlib, "Uint", GUID4String(GUID,GUID), "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib)
Return ptinf
}

; A Function Name including Prefix is limited to 63 bytes!
ConnectObject(psource, prefix = "", DIID = "{00020400-0000-0000-C000-000000000046}")
{
If (DIID = "{00020400-0000-0000-C000-000000000046}")
0+(pconn:=FindConnectionPoint(psource,DIID)) ? (DIID:=GetConnectionInterface(pconn))="{00020400-0000-0000-C000-000000000046}" ? DIID:=GetDefaultEvents(psource) : "" : pconn:=FindConnectionPoint(psource,DIID:=GetDefaultEvents(psource))
Else pconn:=FindConnectionPoint(psource,SubStr(DIID,1,1)="{" ? DIID : DIID:=GetGuidOfName(psource,DIID))
If !pconn || !(ptinf:=GetTypeInfoOfGuid(psource,DIID))
{
MsgBox, No Event Interface Exists! Now exit the application.
ExitApp
}
psink:=CoTaskMemAlloc(40+StrLen(prefix)+1), NumPut(1,NumPut(CreateIDispatch(),psink+0)), NumPut(psource,NumPut(ptinf,psink+8))
DllCall("RtlMoveMemory", "Uint", psink+24, "Uint", GUID4String(DIID,DIID), "Uint", 16)
DllCall("RtlMoveMemory", "Uint", psink+40, "Uint", &prefix, "Uint", StrLen(prefix)+1)
NumPut(Advise(pconn,psink),NumPut(pconn,psink+16))
Return psink
}

CreateObject(ByRef CLSID, ByRef IID, CLSCTX = 5)
{
If StrLen(CLSID)=38
GUID4String(CLSID,CLSID)
If StrLen(IID)=38
GUID4String(IID,IID)
DllCall("ole32\CoCreateInstance", "str", CLSID, "Uint", 0, "Uint", CLSCTX, "str", IID, "UintP", ppv)
Return ppv
}

ActiveXObject(ProgID)
{
DllCall("ole32\CoCreateInstance", "Uint", SubStr(ProgID,1,1)="{" ? GUID4String(ProgID,ProgID) : CLSID4ProgID(ProgID,ProgID), "Uint", 0, "Uint", 5, "Uint", GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp)
Return GetDefaultInterface(pdisp)
}

GetObject(Moniker)
{
DllCall("ole32\CoGetObject", "Uint", Unicode4Ansi(Moniker,Moniker), "Uint", 0, "Uint", GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp)
Return GetDefaultInterface(pdisp)
}

GetActiveObject(ProgID)
{
DllCall("oleaut32\GetActiveObject", "Uint", SubStr(ProgID,1,1)="{" ? GUID4String(ProgID,ProgID) : CLSID4ProgID(ProgID,ProgID), "Uint", 0, "UintP", punk)
DllCall(NumGet(NumGet(1*punk)+0), "Uint", punk, "Uint", GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp)
DllCall(NumGet(NumGet(1*punk)+8), "Uint", punk)
Return GetDefaultInterface(pdisp)
}

CLSID4ProgID(ByRef CLSID, ProgID)
{
VarSetCapacity(CLSID, 16)
DllCall("ole32\CLSIDFromProgID", "Uint", Unicode4Ansi(ProgID,ProgID), "Uint", &CLSID)
Return &CLSID
}

GUID4String(ByRef CLSID, String)
{
VarSetCapacity(CLSID, 16)
DllCall("ole32\CLSIDFromString", "Uint", Unicode4Ansi(String,String,38), "Uint", &CLSID)
Return &CLSID
}

ProgID4CLSID(pCLSID)
{
DllCall("ole32\ProgIDFromCLSID", "Uint", pCLSID, "UintP", pProgID)
Return Ansi4Unicode(pProgID) . SubStr(CoTaskMemFree(pProgID),1,0)
}

String4GUID(pGUID)
{
VarSetCapacity(String, 38 * 2 + 1)
DllCall("ole32\StringFromGUID2", "Uint", pGUID, "Uint", &String, "int", 39)
Return Ansi4Unicode(&String, 38)
}

IsEqualGUID(pGUID1, pGUID2)
{
Return DllCall("ole32\IsEqualGUID", "Uint", pGUID1, "Uint", pGUID2)
}

CoCreateGuid()
{
VarSetCapacity(GUID, 16, 0)
DllCall("ole32\CoCreateGuid", "Uint", &GUID)
Return String4GUID(&GUID)
}

CoTaskMemAlloc(cb)
{
Return DllCall("ole32\CoTaskMemAlloc", "Uint", cb)
}

CoTaskMemFree(pv)
{
Return DllCall("ole32\CoTaskMemFree", "Uint", pv)
}

CoInitialize()
{
Return DllCall("ole32\CoInitialize", "Uint", 0)
}

CoUninitialize()
{
Return DllCall("ole32\CoUninitialize")
}

OleInitialize()
{
Return DllCall("ole32\OleInitialize", "Uint", 0)
}

OleUninitialize()
{
Return DllCall("ole32\OleUninitialize")
}

SysAllocString(sString)
{
Return DllCall("oleaut32\SysAllocString", "Uint", Ansi2Unicode(sString,wString))
}

SysFreeString(bstr)
{
Return DllCall("oleaut32\SysFreeString", "Uint", bstr)
}

SysStringLen(bstr)
{
Return DllCall("oleaut32\SysStringLen", "Uint", bstr)
}

SafeArrayDestroy(psa)
{
Return DllCall("oleaut32\SafeArrayDestroy", "Uint", psa)
}

VariantClear(pvarg)
{
Return DllCall("oleaut32\VariantClear", "Uint", pvarg)
}

AtlAxWinInit(Version = "")
{
CoInitialize()
If !DllCall("GetModuleHandle", "str", "atl" . Version)
   DllCall("LoadLibrary"    , "str", "atl" . Version)
Return DllCall("atl" . Version . "\AtlAxWinInit")
}

AtlAxWinTerm(Version = "")
{
CoUninitialize()
If hModule:=DllCall("GetModuleHandle", "str", "atl" . Version)
Return DllCall("FreeLibrary"    , "Uint", hModule)
}

AtlAxGetControl(hWnd, Version = "")
{
DllCall("atl" . Version . "\AtlAxGetControl", "Uint", hWnd, "UintP", punk)
pdsp:=QueryInterface(punk,IID_IDispatch:="{00020400-0000-0000-C000-000000000046}")
Release(punk)
Return pdsp
}

AtlAxAttachControl(pdsp, hWnd, Version = "")
{
punk:=QueryInterface(pdsp,IID_IUnknown:="{00000000-0000-0000-C000-000000000046}")
DllCall("atl" . Version . "\AtlAxAttachControl", "Uint", punk, "Uint", hWnd, "Uint", 0)
Release(punk)
}

AtlAxCreateControl(hWnd, Name, Version = "")
{
VarSetCapacity(IID_NULL, 16, 0)
DllCall("atl" . Version . "\AtlAxCreateControlEx", "Uint", Unicode4Ansi(Name,Name), "Uint", hWnd, "Uint", 0, "Uint", 0, "UintP", punk, "Uint", &IID_NULL, "Uint", 0)
pdsp:=QueryInterface(punk,IID_IDispatch:="{00020400-0000-0000-C000-000000000046}")
Release(punk)
Return pdsp
}

AtlAxCreateContainer(hWnd, l, t, w, h, Name = "", Version = "")
{
Return DllCall("CreateWindowEx", "Uint",0x200, "str", "AtlAxWin" . Version, "Uint", Name ? &Name : 0, "Uint", 0x54000000, "int", l, "int", t, "int", w, "int", h, "Uint", hWnd, "Uint", 0, "Uint", 0, "Uint", 0)
}

AtlAxGetContainer(pdsp)
{
DllCall(NumGet(NumGet(1*pdsp)+ 0), "Uint", pdsp, "Uint", GUID4String(IID_IOleWindow,"{00000114-0000-0000-C000-000000000046}"), "UintP", pwin)
DllCall(NumGet(NumGet(1*pwin)+12), "Uint", pwin, "UintP", hCtrl)
DllCall(NumGet(NumGet(1*pwin)+ 8), "Uint", pwin)
Return DllCall("GetParent", "Uint", hCtrl)
}

Ansi4Unicode(pString, nSize = "")
{
If (nSize = "")
   nSize:=DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int",  0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString, nSize)
DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize + 1, "Uint", 0, "Uint", 0)
Return sString
}

Unicode4Ansi(ByRef wString, sString, nSize = "")
{
If (nSize = "")
   nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
VarSetCapacity(wString, nSize * 2 + 1)
DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize + 1)
Return &wString
}

Ansi2Unicode(ByRef sString, ByRef wString, nSize = "")
{
If (nSize = "")
   nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
VarSetCapacity(wString, nSize * 2 + 1)
DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize + 1)
Return &wString
}

Unicode2Ansi(ByRef wString, ByRef sString, nSize = "")
{
pString := wString + 0 > 65535 ? wString : &wString
If (nSize = "")
   nSize:=DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int",  0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString, nSize)
DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize + 1, "Uint", 0, "Uint", 0)
Return &sString
}

DecodeInteger(ref, nSize = 4)
{
DllCall("RtlMoveMemory", "int64P", val, "Uint", ref, "Uint", nSize)
Return val
}

EncodeInteger(ref, val = 0, nSize = 4)
{
DllCall("RtlMoveMemory", "Uint", ref, "int64P", val, "Uint", nSize)
}

ScriptControl(sCode, sLang = "", bExec = False, sName = "", pdisp = 0, bGlobal = False)
{
CoInitialize()
psc  := ActiveXObject("MSScriptControl.ScriptControl")
Invoke(psc, "Language=", sLang ? sLang : "VBScript")
sName ? Invoke(psc, "AddObject", sName, "+" . pdisp, bGlobal) : ""
ret  := Invoke(psc, bExec ? "ExecuteStatement" : "Eval", sCode)
Release(psc)
CoUninitialize()
Return ret
}

2
Post New Requests Here / WinFill - better than Aero Snap?
« on: January 11, 2009, 06:12 PM »
 :) Waiting for Windows 7?

WinFill - Drag a window to the edges of the screen to resize it.

Idea stolen from Windows 7's Aero Snap, but with more zones.

A  B  C  D  E

F             G

H             I

J   K      M N

A = top left corner = resize to fill top left quarter of the screen
B = top left           = resize to fill left half of the screen
C = top center      = maximize
...
F = left top          = resize to fill upper half of the screen
...

Try it!

Skrommel

;WinFill.ahk
; Drag a window to the edges of the screen to resize it
; A  B  C  D  E
;
; F           G
;
; H           I
;
; J  K    M   N
;Skrommel @ 2009

#SingleInstance,Force
SetWinDelay,0
CoordMode,Mouse,Screen
;CoordMode,ToolTip,Screen


~LButton::
MouseGetPos,mx0,my0,mwin1,mctrl1
WinGetPos,wx1,wy1,ww1,wh1,ahk_id %mwin1%
mx1:=mx0-wx1
my1:=my0-wy1
Return


~LButton Up::
MouseGetPos,mx2,my2,mwin2,mctrl2
SysGet,dragx,68
SysGet,dragy,69
If (mx2>=mx0-dragx And mx2<=mx0+dragx And my2>=my0-dragy And my2<=my0+dragy)
  Return

WinGet,progman,Id,Program Manager ahk_class Progman
If (progman=mwin1)
  Return
WinGetPos,wx2,wy2,ww2,wh2,ahk_id %mwin1%
mx3:=mx2-wx2
my3:=my2-wy2
SysGet,monitors,MonitorCount
Loop,% monitors
{
  current:=A_Index
  SysGet,monitor,Monitor,% current
  If (mx2>=monitorLeft And mx2<=MonitorRight And my2>=MonitorTop And my2<=MonitorBottom)
    Break
}
SysGet,monitor,MonitorWorkArea,% current
;ToolTip,%current%:%monitorLeft%-%monitorTop%-%mx2%-%my2%,100,100

If (mx3<>mx1 Or my3<>my1)
  Return
If (ww2<>ww1 Or wh2<>wh1)
  Return

If (mx2<=monitorLeft)
{
  If (my2=monitorTop)        ;topleft
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight/2,% monitorBottom/2 ;topleft
  Else
  If (my2>monitorTop And my2<monitorBottom/4)        ;topleft
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight,% monitorBottom/2 ;top
  Else
  If (my2>=monitorBottom/4 And my2<monitorBottom/4*3) ;middleleft
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight/2,% monitorBottom ;left
  Else
  If (my2>=monitorBottom/4*3 And my2<monitorBottom-1)  ;bottomleft
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorBottom/2,% monitorRight,% monitorBottom/2 ;bottom
  Else
  If (my2=monitorBottom-1)  ;bottomleft
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorBottom/2,% monitorRight/2,% monitorBottom/2 ;bottomleft
}
Else
If (mx2>=monitorRight)
{
  If (my2=monitorTop)        ;topright
    WinMove,ahk_id %mwin1%,,% monitorRight/2,% monitorTop,% monitorRight/2,% monitorBottom/2 ;topright
  Else
  If (my2>=monitorTop And my2<monitorBottom/4)        ;topright
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight,% monitorBottom/2 ;top
  Else
  If (my2>=monitorBottom/4 And my2<monitorBottom/4*3) ;middleright
    WinMove,ahk_id %mwin1%,,% monitorRight/2,% monitorTop,% monitorRight/2,% monitorBottom ;right
  Else
  If (my2>=monitorBottom/4*3 And my2<monitorBottom-1)  ;bottomright
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorBottom/2,% monitorRight,% monitorBottom/2 ;bottom
  Else
  If (my2=monitorBottom-1)  ;bottomright
    WinMove,ahk_id %mwin1%,,% monitorRight/2,% monitorBottom/2,% monitorRight/2,% monitorBottom/2 ;bottomright
}
Else
If (my2<=monitorTop)
{
  If (mx2>=monitorLeft And mx2<monitorRight/4)        ;topleft
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight/2,% monitorBottom ;left
  Else
  If (mx2>=monitorRight/4 And mx2<monitorRight/4*3)     ;topmiddle
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight,% monitorBottom ;full
  Else
  If (mx2>=monitorRight/4*3 And mx2<=monitorRight)     ;bottom
    WinMove,ahk_id %mwin1%,,% monitorRight/2,% monitorTop,% monitorRight/2,% monitorBottom ;right
;    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorBottom/2,% monitorRight,% monitorBottom/2 ;topright
}
Else
If (my2>=monitorBottom-1)
{
  If (mx2>=monitorLeft And mx2<monitorRight/4)        ;bottomleft
    WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight/2,% monitorBottom ;left
  Else
;  If (mx2>=monitorRight/4 And mx2<monitorRight/4*3)     ;bottommiddle
;    WinMinimize,ahk_id %mwin1% ;WinMove,ahk_id %mwin1%,,% monitorLeft,% monitorTop,% monitorRight,% monitorBottom ;full
;  Else
  If (mx2>=monitorRight/4*3 And mx2<=monitorRight)     ;bottom
    WinMove,ahk_id %mwin1%,,% monitorRight/2,% monitorTop,% monitorRight/2,% monitorBottom ;right
}
Return

3
N.A.N.Y. 2009 / NANY 2009 Release: DropCommand
« on: December 27, 2008, 06:38 PM »
Application NameDropCommand
Version 1.0
Short DescriptionEnables drag and drop of files to a command window in Vista
Supported OSesVista 32
Web Pagehttp://www.1HourSoftware.com
Download Linkhttps://www.donationcoder.com/Software/Skrommel/DropCommand/DropCommand.exe
Minimum RequirementsVista 32
Version historyFirst stable release
Authorskrommel



Why:
Requested on the forum: https://www.donationcoder.com/forum/index.php?topic=16154.0

Usage:
Open a command window, drag and drop a file on the window to place the file name on the command line.

Installing:
Run the exe-file. It creates a wav-file next to it.

Uninstalling:
Delete the exe-file and the wav-file.

Features:
Drop multiple files.

Planned features:
OLE drag and drop.

 :) Skrommel

 
 
 
 
 
 

4
Post New Requests Here / Vista style filename editing in XP
« on: September 24, 2008, 08:30 PM »
 :) One of the improvements in Vista is that it doesn't select the file type when you edit a filename.
Here's a quick hack to have this behaviour in XP, too!

It's called TheEnd!

TheEnd - Unselect the file type when renaming files in XP.

Features:

- Press F2 to rename a file.
- Or click a filename slowly two times.



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

Skrommel

5
 :) 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

Pages: [1] 2 3next
Go to full version