AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Crazy Scripting : FolderSpy v0.96 [ Synchronous ]
Goto page Previous  1, 2, 3, 4, 5, 6, 7
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Wed Jun 10, 2009 11:35 pm    Post subject: Reply with quote

Thanks foir the quick response and it works perfectly!

I'm trying to understand the script better. I'm probably going to try a log file next and see how many lines I get from each file saved.


BTW the original froze up my comp just a couple of minutes ago, be careful running the original (non gui version).
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Back to top
View user's profile Send private message
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Thu Jun 11, 2009 12:24 am    Post subject: Reply with quote

Is it just me or does the non GUI version misfire? Also I added a log (shows on desktop when file is found). The only thing is it shows 20 instances of the same action. Heres the code:

Code:
;All props to Skan and tic
#Persistent
SetBatchLines, -1
Process, Priority,, High
OnExit, ShutApp

WatchFolder  := "C:\"
WatchSubDirs := "1"

EventString := "New File,Deleted,Modified,Renamed From,Renamed To"
StringSplit, EventArray, EventString, `,

DllCall("shlwapi\PathAddBackslashA", UInt, &Watchfolder)

CBA_ReadDir := RegisterCallback("ReadDirectoryChanges")

SizeOf_FNI := ( 64KB := 1024 * 64 )
VarSetCapacity( FILE_NOTIFY_INFORMATION, SizeOf_FNI, 0 )
PointerFNI := &FILE_NOTIFY_INFORMATION

hDir := DllCall( "CreateFile", Str  , WatchFolder, UInt, "1", UInt , "7", UInt, 0, UInt, "3", UInt, "1107296256", UInt , 0 )

Loop
{
   nReadLen  := 0
   hThreadId := 0

   hThread   := DllCall( "CreateThread", UInt, 0, UInt, 0, UInt, CBA_ReadDir, UInt, 0, UInt,0, UIntP,hThreadId )
                 
   Loop
   {
      If nReadLen
      {
         PointerFNI := &FILE_NOTIFY_INFORMATION

         Loop
         {
            NextEntry   := NumGet( PointerFNI + 0  )
            Action      := NumGet( PointerFNI + 4  )
            FileNameLen := NumGet( PointerFNI + 8  )
            FileNamePtr :=       ( PointerFNI + 12 )
   
            Event := EventArray%Action%     

            VarSetCapacity( FileNameANSI, FileNameLen )
            DllCall( "WideCharToMultiByte", UInt,0, UInt,0, UInt,FileNamePtr, UInt, FileNameLen,  Str, FileNameANSI, UInt,FileNameLen, UInt,0, UInt,0 )

            File := SubStr( FileNameANSI, 1, FileNameLen/2 )
            FullPath := WatchFolder . File
            FileGetAttrib, Attr, %FullPath%
            FormatTime, Time  , %A_Now%, HH:mm:ss
           
            CoordMode, ToolTip, Screen
            SplitPath,FullPath,,,Ext
            If !(Ext = "wav" or Ext = "mid")
              Sleep,-1
            else If !FileExist(FullPath) ; Man thanks to HotKeyIt
            Tooltip, %Time%`n%Event%`n%File%, 10, 10
            Else
            {
               Loop %FullPath%
               {
                  FormatTime, TStamp, %A_LoopFileTimeModified%, yyyy-MM-dd  HH:mm:ss
                  Tooltip, %Time%`n%Event%`n%File%`n%A_LoopFileSizeKB%`n%TStamp%`n%A_LoopFileAttrib%, 10, 10
    FileAppend, %Event% c:\%File%`n, %A_Desktop%\LastFileLog.txt
               }
            }   

            If !NextEntry
            Break
            Else
            PointerFNI += NextEntry
         }
         Break
      }           
   
      Sleep 100
   }

   DllCall( "TerminateThread", UInt,hThread, UInt,0 )
   DllCall( "CloseHandle", UInt,hThread )
}
Return

ReadDirectoryChanges()
{
   Global hDir,PointerFNI, Sizeof_FNI, WatchSubdirs, nReadlen
   Return DllCall( "ReadDirectoryChangesW", UInt, hDir, UInt, PointerFNI, UInt, SizeOf_FNI, UInt, WatchSubDirs, UInt, "375", UIntP, nReadLen, UInt, 0, UInt, 0 )
}

GuiClose:
ShutApp:
DllCall( "CloseHandle", UInt,hDir )
DllCall( "TerminateThread", UInt,hThread, UInt,0 )
DllCall( "CloseHandle", UInt,hThread )
ExitApp
Return

esc::ExitApp


Also added an a hk that esapes when esc is pressed.
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4653
Location: AHK Forum

PostPosted: Fri Jun 12, 2009 11:10 pm    Post subject: Reply with quote

Try WatchDirectory()
_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Mystiq



Joined: 08 Jan 2007
Posts: 83

PostPosted: Sat Jun 13, 2009 4:05 pm    Post subject: Reply with quote

HotKeyIt wrote:
Try WatchDirectory()


Cheers!

Just to want to point something i noticed on the code releated to the multi folder script.

Code:

               Dir%A_Index%         =
               Dir%A_Index%Path     =
               Dir%A_Index%Subdirs  =
               Dir%A_Index%FNI      =
               Dir%A_Index%Overlapped=
               DllCall( "CloseHandle", UInt,Dir%A_Index% )
               DllCall( "CloseHandle", UInt,NumGet(Dir%A_Index%Overlapped, 16) )


The "Dir%A_Index%Overlapped" variable is "emptied" and then used later on so i think thats wrong. Question
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4653
Location: AHK Forum

PostPosted: Sat Jun 13, 2009 11:27 pm    Post subject: Reply with quote

Mystiq wrote:
HotKeyIt wrote:
Try WatchDirectory()


Cheers!

Just to want to point something i noticed on the code releated to the multi folder script.

Code:

               Dir%A_Index%         =
               Dir%A_Index%Path     =
               Dir%A_Index%Subdirs  =
               Dir%A_Index%FNI      =
               Dir%A_Index%Overlapped=
               DllCall( "CloseHandle", UInt,Dir%A_Index% )
               DllCall( "CloseHandle", UInt,NumGet(Dir%A_Index%Overlapped, 16) )


The "Dir%A_Index%Overlapped" variable is "emptied" and then used later on so i think thats wrong. Question


Yeah, I noticed as well while writing WatchDirectory, this should be better:
Code:
StopWatchingDirectories:
      Loop % (DirIdx) {
         DllCall( "CloseHandle", UInt,Dir%A_Index% )
         DllCall( "CloseHandle", UInt,NumGet(Dir%A_Index%Overlapped, 16) )
         Dir%A_Index%=
         Dir%A_Index%Path=
         Dir%A_Index%Subdirs=
         Dir%A_Index%FNI=
         DllCall( "CloseHandle", UInt, NumGet(Dir%A_Index%Overlapped,16) )
         VarSetCapacity(Dir%A_Index%Overlapped,0)
      }
      DirIdx=
      VarSetCapacity(DirEvents,0)
   Return

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Mystiq



Joined: 08 Jan 2007
Posts: 83

PostPosted: Sun Jun 14, 2009 11:13 am    Post subject: Reply with quote

Anyone of you AHK gurus able to explain to me why the NumPut is offset by 16 in the below code? I just don't get it. Smile


Code:

    Dir%DirIdx%Subdirs  := WatchSubDirs
    VarSetCapacity( Dir%DirIdx%FNI, SizeOf_FNI )
    VarSetCapacity( Dir%DirIdx%Overlapped, 20, 0 )
    hEvent := DllCall( "CreateEvent", UInt,0, Int,true, Int,false, UInt,0 )
    NumPut( hEvent, Dir%DirIdx%Overlapped, 16 )      <---- this one


edit: Nevermind. If i got this right, its because of the overlapped structure.
Back to top
View user's profile Send private message
jackchen
Guest





PostPosted: Sun Jul 18, 2010 1:14 am    Post subject: Unicode Support Reply with quote

I tried both FolderSpy and WatchDirectory(),neither supprots file names or folder names in Chinese.This function reports only partial file name or folder name,the rest of the name are missed.I guess the script does not support Unicode characters.

I dont understand API at all,can someone point out the problem and give a solution?
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7
Page 7 of 7

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group