misterspeed Danke für die Antwort
@m-obi Ich würde aber gerne das sich das script auf den kompletten PC bezieht.
Hier mein versuch, hat aber jedoch nicht funktioniert :o
[autoit]
#include <WinAPI.au3>
Opt("TrayAutoPause", 0)
[/autoit][autoit][/autoit][autoit]Global Const $SHCNE_RENAMEITEM = 0x0001
Global Const $SHCNE_CREATE = 0x0002
Global Const $SHCNE_DELETE = 0x0004
Global Const $SHCNE_MKDIR = 0x0008
Global Const $SHCNE_RMDIR = 0x0010
Global Const $SHCNE_UPDATEDIR = 0x1000
Global Const $SHCNE_UPDATEITEM = 0x2000
Global Const $SHCNE_UPDATEIMAGE = 0x8000
Global Const $SHCNE_RENAMEFOLDER = 0x20000
Global Const $SHCNE_ALLEVENTS = 0x7FFFFFFF
OnAutoItExitRegister("OnAutoItExit")
[/autoit][autoit][/autoit][autoit]$SHNOTIFY = _WinAPI_RegisterWindowMessage("shchangenotifymsg")
[/autoit][autoit][/autoit][autoit]$gui = GUICreate("")
GUIRegisterMsg($SHNOTIFY, "MY_SHNOTIFY")
;~ If Not FileExists("C:\test") Then DirCreate("C:\test")
;~ If Not FileExists("C:\test2") Then DirCreate("C:\test2")
$ppidl = DllCall("shell32.dll", "ptr", "ILCreateFromPathW", "wstr", "C:\")
ConsoleWrite($ppidl[0] & @CRLF)
$ppidl2 = DllCall("shell32.dll", "ptr", "ILCreateFromPathW", "wstr", "C:\")
ConsoleWrite($ppidl2[0] & @CRLF)
$shArray = DllStructCreate("double; double"); 16 bytes = two 8 byte shnotifystructs in an array
; == this could also be done as DllStructCreate("double[2]"), $pshArray = DllStructGetPtr($shArray)
; == then below would be
; == $shnotifystruct = DllStructCreate("ptr pidl; int fRecursive", $pshArray)
; == $shnotifystruct2 = DllStructCreate("ptr pidl; int fRecursive", $pshArray + -> ptr to array plus 8 bytes
; == for many folders, either method could be achieved by use of loops
$shnotifystruct = DllStructCreate("ptr pidl; int fRecursive", DllStructGetPtr($shArray, 1)); first struct, first element
ConsoleWrite("error1: " & @error & @CRLF)
DllStructSetData($shnotifystruct, "pidl", $ppidl[0])
DllStructSetData($shnotifystruct, "fRecursive", 0)
$shnotifystruct2 = DllStructCreate("ptr pidl; int fRecursive", DllStructGetPtr($shArray, 2)); second struct, second element
ConsoleWrite("error2: " & @error & @CRLF)
DllStructSetData($shnotifystruct2, "pidl", $ppidl2[0])
DllStructSetData($shnotifystruct2, "fRecursive", 0)
$register = DllCall("shell32.dll", "int", "SHChangeNotifyRegister", "hwnd", $gui, _
"int", 0x0003, _
"long", BitOR($SHCNE_CREATE, $SHCNE_DELETE, $SHCNE_MKDIR, $SHCNE_RMDIR), _
"uint", $SHNOTIFY, _
"int", 2, _; number of shnotifystructs in the array
"ptr", DllStructGetPtr($shArray)); ptr to the array
; free each created PIDL
DllCall("ole32.dll", "none", "CoTaskMemFree", "ptr", $ppidl[0])
DllCall("ole32.dll", "none", "CoTaskMemFree", "ptr", $ppidl2[0])
$shArray = 0
$shnotifystruct = 0
$shnotifystruct2 = 0
ConsoleWrite("register: " & $register[0] & @CRLF)
While 1
Sleep(1000)
WEnd
Func OnAutoItExit()
; deregister the window
$ret = DllCall("shell32.dll", "int", "SHChangeNotifyDeregister", "ulong", $register[0])
ConsoleWrite("deregister: " & $ret[0] & @CRLF)
EndFunc
Func MY_SHNOTIFY($hWnd, $Msg, $wParam, $lParam)
Local $path
ConsoleWrite("notify: " & $lParam & @CRLF)
$path = DllStructCreate("dword dwItem1; dword dwItem2", $wParam)
$ret = DllCall("shell32.dll", "int", "SHGetPathFromIDListW", "ptr", DllStructGetData($path, "dwItem1"), "wstr", "")
ConsoleWrite($ret[2] & @CRLF)
EndFunc