linbin Posted October 19, 2014 Share Posted October 19, 2014 (edited) expandcollapse popup#include <APIShellExConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WinAPIShellEx.au3> Opt('TrayAutoPause', 0) Global Const $g_sPath = @ScriptDir & '\~TEST~' DirCreate($g_sPath) If Not FileExists($g_sPath) Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.') Exit EndIf OnAutoItExitRegister('OnAutoItExit') Local $hWnd = GUICreate('') Local $iMsg = _WinAPI_RegisterWindowMessage('SHELLCHANGENOTIFY') GUIRegisterMsg($iMsg, 'WM_SHELLCHANGENOTIFY') Global $g_iID = _WinAPI_ShellChangeNotifyRegister($hWnd, $iMsg, $SHCNE_ALLEVENTS, BitOR($SHCNRF_INTERRUPTLEVEL, $SHCNRF_SHELLLEVEL, $SHCNRF_RECURSIVEINTERRUPT), $g_sPath, 1) If @error Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Window does not registered.') Exit EndIf While 1 Sleep(1000) WEnd Func WM_SHELLCHANGENOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $sPath = _WinAPI_ShellGetPathFromIDList(DllStructGetData(DllStructCreate('dword Item1; dword Item2', $wParam), 'Item1')) If $sPath Then ConsoleWrite('Event: 0x' & Hex($lParam) & ' | Path: ' & $sPath & @CRLF) Else ConsoleWrite('Event: 0x' & Hex($lParam) & @CRLF) EndIf EndFunc ;==>WM_SHELLCHANGENOTIFY Func OnAutoItExit() If $g_iID Then _WinAPI_ShellChangeNotifyDeregister($g_iID) EndIf DirRemove($g_sPath) EndFunc ;==>OnAutoItExit It is the Example script from Help file. My OS is WindowsXP. When I copy a file into the '~TEST~' folder,console output is OK as below: Event: 0x00000002 | Path: E:~TEST~1.au3 But when I download a file via FireFox into the folder, console output is as below: Event: 0x00001000 | Path: E:~TEST~ A file named [filename].part is created in the folder, why the file name is missing? Edited October 20, 2014 by linbin Link to comment Share on other sites More sharing options...
Spider001 Posted October 19, 2014 Share Posted October 19, 2014 on firefox the .part file = the temp file while downloading before creating the real file. after creating the realfile this .part file is deleted http://forums.mozillazine.org/viewtopic.php?f=38&t=1410275 Link to comment Share on other sites More sharing options...
linbin Posted October 19, 2014 Author Share Posted October 19, 2014 on firefox the .part file = the temp file while downloading before creating the real file. after creating the realfile this .part file is deleted http://forums.mozillazine.org/viewtopic.php?f=38&t=1410275 but why the script can't output the part file name on console? Also after the real file is created, the console output is Event: 0x00001000 | Path: E:~TEST~ AGAIN. How can I get the file name? Link to comment Share on other sites More sharing options...
linbin Posted October 20, 2014 Author Share Posted October 20, 2014 I test it on Win7 and it works. The console output is as below when I download QQ6.4.exe via Firefox : Event: 0x00000002 | Path: D:QQ6.4.exe Event: 0x00000002 | Path: D:QQ6.4.exe.part Event: 0x00002000 | Path: D:QQ6.4.exe.part Event: 0x00002000 | Path: D:QQ6.4.exe.part Event: 0x00000004 | Path: D:QQ6.4.exe Event: 0x00000001 | Path: D:QQ6.4.exe.part Event: 0x00002000 | Path: D:QQ6.4.exe Event: 0x00002000 | Path: D:QQ6.4.exe Why it doesn't work in WinXP? Is it a bug? Link to comment Share on other sites More sharing options...
Spider001 Posted October 20, 2014 Share Posted October 20, 2014 it can be a bug. 32bit/64bit ? Link to comment Share on other sites More sharing options...
linbin Posted October 21, 2014 Author Share Posted October 21, 2014 it works on Win7 x32. I've created a bug Ticket. Link to comment Share on other sites More sharing options...
Solution LarsJ Posted October 21, 2014 Solution Share Posted October 21, 2014 I don't think this is a bug. This is a limitation of Windows XP.In the bottom of the remarks for SHChangeNotifyRegister you can read:"For performance reasons, multiple notifications can be combined into a single notification. For example, if a large number of SHCNE_UPDATEITEM notifications are generated for files in the same folder, they can be joined into a single SHCNE_UPDATEDIR notification."The event you are receiving in post 1 (0x00001000) is exactly SHCNE_UPDATEDIR. Post 4 confirms that downloading a file generates a lot of events.On XP all these events are joined into a single SHCNE_UPDATEDIR notification.On Win 7 which is newer and faster there are no performance issues, and you are receiving all the events. linbin 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now