delray
Active Members-
Posts
31 -
Joined
-
Last visited
delray's Achievements
Seeker (1/7)
0
Reputation
-
Still not working: $path = "C:\Users\username\Cookies\" While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) = ".txt" then $hFile = FileOpen($path & $file) ; Get file handle. MsgBox(0, 0, "File handle: " & $file & " : " & $hFile) $aTime = _Date_Time_GetFileTime($hFile) $aDate = _Date_Time_FileTimeToStr($aTime[2]) If $aTime <> "" Then MsgBox(4096, "File:", $file & ": " & $aDate) Else MsgBox(4096, "File:", "No more files") EndIf FileClose($hFile) EndIf WEnd
-
ok, understand, but a second issue has occurred, the _Date_Time_GetFileTime($hFile) function is failing and returns null in $aDate = _Date_Time_FileTimeToStr($aTime[2]). Should not the file handle be more than 1 digit normally? Matter of fact, it is returning 2 for every file.
-
2 things, I messed up when I copied and pasted your code the first time and second it is now return 2. thanks BrewManNH. A question now: If the file name is being rerturned, why is the full path required to get the handle?
-
Still getting -1: If StringRight($file, 4) = ".txt" then $hFile = FileOpen("C:Usersrdwray" & $file) ; Get file handle. FileClose($hFile) MsgBox(0, 0, "File handle: " & $file & " : " & $hFile) $aTime = _Date_Time_GetFileTime($hFile) $aDate = _Date_Time_FileTimeToStr($aTime[2]) If $aTime <> "" Then MsgBox(4096, "File:", $file & ": " & $aDate) Else MsgBox(4096, "File:", "No more files") EndIf EndIf
-
File names, dates and times are returned but $hFile (file handle) always returns -1; why? #include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> ; Shows the filenames of all files with .txt extention. $search = FileFindFirstFile("C:UsersrdwrayCookies*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf ; Get current system time: $tSys = _Date_Time_GetLocalTime() $sTime = _Date_Time_SystemTimeToDateTimeStr($tSys) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight($file, 4) = ".txt" then $hFile = FileOpen($file) ; Get file handle. FileClose($hFile) MsgBox(0, 0, "File handle: " & $file & " : " & $hFile) $aTime = _Date_Time_GetFileTime($hFile) $aDate = _Date_Time_FileTimeToStr($aTime[2]) If $aTime <> "" Then MsgBox(4096, "File:", $file & ": " & $aDate) Else MsgBox(4096, "File:", "No more files") EndIf EndIf WEnd
-
I switched the "Send"s around to make sure I wasn't messing up and changed "Sleep" many times. I am going to show the code for the original program from AHK that works great. The icons are embeded in the script as you will see and this is what I am trying to get rid of and use AU3 icon handling. ; HDD Indicator @ TNA by SKAN ( arian.suresh@gmail.com ) ; Created: 15-May-2008 / Last Modified: 04-Oct-2010 ; ; Credit : Adapted from "HDD Activity Monitoring LED" by Sean ; Topic : www.autohotkey.com/forum/viewtopic.php?t=18033 ; This file : www.autohotkey.net/~Skan/ShortCode/HDD-Indicator_TNA.ahk #Persistent Process, Priority,, High SetBatchLines -1 ; Creating NOTIFYICONDATA : http://msdn.microsoft.com/en-us/library/aa930660.aspx ; Thanks Lexikos : http://www.autohotkey.com/forum/viewtopic.php?p=162175#162175 PID := DllCall("GetCurrentProcessId"), VarSetCapacity( NID,444,0 ), NumPut( 444,NID ) DetectHiddenWindows, On NumPut( WinExist( A_ScriptFullPath " ahk_class AutoHotkey ahk_pid " PID),NID,4 ) DetectHiddenWindows, Off NumPut( 1028,NID,8 ), NumPut( hIcon1,NID,20), NumPut( 2,NID,12 ), IconDataHex:="" GoSub, IconData ; Create IconData buffer Loop 4 ; Obtain 4 Icon handles from IconData buffer hICon%A_Index% := DllCall( "CreateIconFromResourceEx", UInt,&IconData+( 296*(A_Index-1)) , UInt,296, Int,1, UInt,0x30000, Int,16, Int,16, UInt,0 ) ; Run, diskperf.exe -y ; Execute it once to enable Disk Performance monitoring. ORC:=0, OWC:=0, VarSetCapacity( DP,88,0 ) ; DISK_PERFORMANCE hDrv := DllCall( "CreateFile", Str,"\\.\PhysicalDrive0", UInt,0 ,UInt,3, UInt,0, UInt,3 , UInt,0, UInt,0 ) OnExit, QuitScript SetTimer, HDD_Monitor HDD_Monitor: DllCall( "DeviceIoControl", UInt,hDrv, UInt,0x70020, UInt,0, UInt,0, UInt,&DP, UInt,88 , UintP,nReturn, Uint,0 ) NRC:=NumGet(DP,40), NWC:=NumGet(DP,44), RC:=NRC-ORC, WC:=NWC-OWC, ORC:=NRC,OWC:=NWC IC := RC=0&&WC=0 ? 1 : RC!=0&&WC=0 ? 2 : RC=0&&WC!=0 ? 3 : RC!=0&&WC!=0 ? 4 : NumPut( hIcon%IC%,NID,20 ), DllCall( "shell32\Shell_NotifyIcon",UInt,0x1,UInt,&NID ) Return ; // end of auto-execute section // ; Icons are actually 512 bytes in length IconData: IconDataHex = ( join 280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000 0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00 0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000 000000000000000000001910001910080000999000999008800019100019100880000000000000088087777777 777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000 00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000 000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000 280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000 0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00 0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000 000000000000000000002A20001910080000AAA00099900880002A200019100880000000000000088087777777 777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000 00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000 000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000 280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000 0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00 0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000 000000000000000000001910002A20080000999000AAA00880001910002A200880000000000000088087777777 777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000 00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000 000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000 280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000 0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00 0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000 000000000000000000002A20002A20080000AAA000AAA00880002A20002A200880000000000000088087777777 777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000 00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000 000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000 ) VarSetCapacity( IconData,( nSize:=StrLen(IconDataHex)//2) ) Loop %nSize% ; MCode by Laszlo Hars: http://www.autohotkey.com/forum/viewtopic.php?t=21172 NumPut( "0x" . SubStr(IconDataHex,2*A_Index-1,2), IconData, A_Index-1, "Char" ) Return QuitScript: DllCall("CloseHandle", "Uint", hDrv) ExitApp Return
-
I sent the output to num and caps lock and they are fluctuating as they should be, but the icons are not activating other than the first one (Drive.ico). #include <Process.au3> #include <array.au3> #include <WinAPIEx.au3> Global $NID[444], $Ret, $nReturn, $hDrv Global $ORC=0, $OWC=0 Global $DP = DllStructCreate("byte[88]") Global $hDrv = _WinAPI_CreateFile( "\\.\PhysicalDrive0", 2, 3, 0, 3, 0) While 1 Local $ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', _ 'ptr', $hDrv, _ 'dword', 0x70020, _ 'ptr', 0, _ 'dword', 0, _ 'ptr', DllStructGetPtr($DP), _ 'dword', 88, _ 'dword*', 0, _ 'ptr', 0) ;ToolTip($hDrv & " : " & $ret[0]) $NRC = DllStructGetData ($DP, 1, 40) ;NRC:=NumGet(DP,40), $NWC = DllStructGetData ($DP, 1, 44) ;NWC:=NumGet(DP,44), $RC = $NRC - $ORC ;RC:=NRC-ORC, $WC = $NWC - $OWC ;WC:=NWC-OWC, $ORC = $NRC ; $OWC = $NWC ;OWC:=NWC ToolTip($RC & " : " & $WC) If $RC=0 And $WC=0 Then Send ("{NUMLOCK}") ; $IC=_ TraySetIcon("Drive.ico") ElseIf $RC<>0 And $WC=0 Then Send ("{CAPSLOCK}") ; $IC=2 TraySetIcon("Read.ico") ElseIf $RC=0 And $WC<>0 Then Send ("{CAPSLOCK}") ; $IC=3 TraySetIcon("Write.ico") ElseIf $RC<>0 and $WC<>0 Then Send ("{CAPSLOCK}") ; $IC=4 TraySetIcon("Read_Write.ico") EndIf ; Sleep(1000) WEnd
-
Here is the entire code and I am not getting any data in $NRC and $NWC: #include <Process.au3> #include <array.au3> #include <WinAPIEx.au3> Global $NID[444], $Ret, $nReturn, $hDrv Global $ORC=0, $OWC=0 main() Func main() Global $DP = DllStructCreate("byte[88]") Global $hDrv = _WinAPI_CreateFile( "\\.\PhysicalDrive0", 2, 3, 0, 3, 0) While 1 Local $ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', _ 'ptr', $hDrv, _ 'dword', 0x70020, _ 'ptr', 0, _ 'dword', 0, _ 'ptr', DllStructGetPtr($DP), _ 'dword', 88, _ 'dword*', 0, _ 'ptr', 0) ;ToolTip($hDrv & " : " & $ret[0]) $NRC = DllStructGetData ($DP, 40) ;NRC:=NumGet(DP,40), $NWC = DllStructGetData ($DP, 44) ;NWC:=NumGet(DP,44), $RC = $NRC - $ORC ;RC:=NRC-ORC, $WC = $NWC - $OWC ;WC:=NWC-OWC, $ORC = $NRC ; $ORC = $NRC ;ORC:=NRC, $OWC = $NWC ;OWC:=NWC ToolTip($NRC & " : " & $NWC) ; 0 : 0 at this point Sleep(500) If $RC=0 And $WC=0 Then ; $IC=_ TraySetIcon("Drive.ico") ElseIf $RC<>0 And $WC=0 Then ; $IC=2 TraySetIcon("Read.ico") ElseIf $RC=0 And $WC<>0 Then ; $IC=3 TraySetIcon("Write.ico") ElseIf $RC<>0 and $WC<>0 Then ; $IC=4 TraySetIcon("Read_Write.ico") EndIf WEnd EndFunc
-
That made the difference. No error and $ret[0] = 1 Now I will try and move to the next step which will take a few minutes. Thanks again Mass Spammer...
-
WinApi Error: The data area passed to a system call is too small. $hDrv = 0x00000170 Don't be sorry, I am grateful.
-
$ret[0] = 0 _WinAPI_GetLastError()) = 122 System buffer too small... What ever that means.
-
This is what I currently have:#include <WinAPI.au3> #include <WinAPIEx.au3> Local $tDGEX[444] Local $hDrv = _WinAPI_CreateFile( "\\.\PhysicalDrive0", 2, 3, 0, 3, 0) MsgBox(0, 0, $hDrv) ; Returns handle Local $ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', _ 'ptr', $hDrv, _ 'dword', 0x70020, _ 'ptr', 0, _ 'dword', 0, _ 'ptr', ptr($tDGEX), _ 'dword', 88, _ 'dword*', 0, _ 'ptr', 0) MsgBox(0, 0, $ret) ; Returns null
-
If $RC=0 And $WC=0 Then ; $IC=_ TraySetIcon("Drive.ico") ElseIf $RC<>0 And $WC=0 Then ; $IC=2 TraySetIcon("Read.ico") ElseIf $RC=0 And $WC<>0 Then ; $IC=3 TraySetIcon("Write.ico") ElseIf $RC<>0 and $WC<>0 Then ; $IC=4 TraySetIcon("Read_Write.ico") EndIf Found part of the problem, but need an answer:
-
Trying to get the handle to drive 0 and this isn't working; why? thanks... (this one returns 0) $hDrv = _WinAPI_CreateFileEx( "\\.\PhysicalDrive0", 0, 3, 0, 3, 0, 0) ; Returns 0 (this one returns null) $hDrv = DllCall('kernel32.dll', 'ptr', 'CreateFile', 'str', "\\.\PhysicalDrive0", 'dword', 0, 'dword', 3, 'ptr', 0, 'dword', 3, 'dword', 0, 'ptr', 0) ; Returns null (from WinAPIEx.au3) Func _WinAPI_CreateFileEx($sFile, $iCreation, $iAccess = 0, $iShare = 0, $iFlagsAndAttributes = 0, $tSecurity = 0, $hTemplate = 0) Local $Ret = DllCall('kernel32.dll', 'ptr', 'CreateFileW', 'wstr', $sFile, 'dword', $iAccess, 'dword', $iShare, 'ptr', DllStructGetPtr($tSecurity), 'dword', $iCreation, 'dword', $iFlagsAndAttributes, 'ptr', $hTemplate) If (@error) Or ($Ret[0] = Ptr(-1)) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_CreateFileEx
-
Here is the code I have come up with. The idea is to set an icon into the tray depending on its current status idle/read/write/read+write. The only problem is that it fails. Any and all help appreciated. #include <Process.au3> ;#Include <Timers.au3> Global $NID[444], $Ret, $nReturn Global $ORC=0, $OWC=0, $DP[88] main() Func main() ProcessSetPriority("HHD_Monitor.au3", 4) $PID = DllCall("kernel32.dll", "handle", "GetCurrentProcessId") ; Run, diskperf.exe -y ; Execute it once to enable Disk Performance monitoring. ; DISK_PERFORMANCE $hDrv = DllCall("kernel32.dll", "ptr", "CreateFile", "Str", "\\.\PhysicalDrive0", "uint", 0, "uint", 3, "uint", 0, "uint", 3, "uint", 0, "uint", 0) While 1 ;_Timer_SetTimer(HDD_Monitor) ;HDD_Monitor: $Ret = DllCall("kernel32.dll", "int", "DeviceIoControl", "uint", 0x70020, "uint", DllStructGetPtr($DP), "uint", 88, "uint_ptr", $nReturn, "uint", 0) $NRC = $DP[40] ;NRC:=NumGet(DP,40), $NWC = $DP[44] ;NWC:=NumGet(DP,44), $RC = $NRC - $ORC ;RC:=NRC-ORC, $WC = $NWC - $OWC ;WC:=NWC-OWC, $ORC = $NRC ; $ORC = $NRC ;ORC:=NRC, $OWC = $NWC ;OWC:=NWC If $RC=0 And $WC=0 Then ; $IC=1 TraySetIcon("0.icon") ElseIf $RC<>0 And $WC=0 Then ; $IC=2 TraySetIcon("1.icon") ElseIf $RC=0 And $WC<>0 Then ; $IC=3 TraySetIcon("2.icon") ElseIf $RC<>0 and $WC<>0 Then ; $IC=4 TraySetIcon("3.icon") EndIf WEnd EndFunc