AutoHotkey Community

It is currently May 24th, 2012, 9:34 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 50 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: March 31st, 2007, 3:38 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
This script monitors the (first) hard disk drive activity and shows it using ScrollLock LED.

PS. Don't forget to run "diskperf.exe -y" once to enable the HDD monitoring.

DOWNLOAD HDDMonitor.ahk.


Last edited by Sean on August 22nd, 2007, 7:09 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 4:44 am 
Offline

Joined: December 12th, 2006, 7:30 pm
Posts: 10
Location: Florida
Nicely done.

I'm for anything that makes blinky lights.

Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 10:06 am 
Offline

Joined: March 21st, 2007, 1:48 pm
Posts: 20
Location: Lithuania
Real nice 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 12:26 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
it doesn't work here.. mayb microsoft natural keyboard...

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 1:08 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
it doesn't work here.. mayb microsoft natural keyboard...

Yes, someone once told me that the keyboard indicator function didn't work with MS natural keyboard. I found it rather ironic, the one which broke their provided functionality was thier own product... but I'm afraid it's not unusual with MS.

My original version was using GUI, a small box sitting at the top left corner and changing the background color accordingly. Apparently, however, it seemed not possible to change in real time the background color of AHK's GUI, unless using controls. Instead of digging into it, as I'm usually impatient with GUI stuffs, I chose to use the keyboard indicators. Maybe later, unless someone else does the GUI thing before.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 3:01 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
Apparently, however, it seemed not possible to change in real time the background color of AHK's GUI, unless using controls.

You can always text the text color of statics.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 8:53 pm 
My laptop doesn't have a scroll lock LED. How do you change it so it uses the caps lock or num lock LED instead?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 11:46 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Timothy wrote:
My laptop doesn't have a scroll lock LED. How do you change it so it uses the caps lock or num lock LED instead?

Oh, I forgot to say about it. There are two '1 << 16' in the script. Just replace 1 with 2 or 4 (or, equivalently, 16 to 17 or 18 leaving 1 as it is).

Code:
ScrollLock: 1,  NumLock: 2,  CapsLock: 4

You may also combine them like 2+4 etc.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2007, 1:29 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
And, I forgot another one to mention. Currently, it sets the indicators constantly every 500ms, no matter what the situations are. For example, even when HDD remains with no activity a while, the script tries to constantly set the indicators, although there appear no change at all to the user. So, if worried about it, may introduce a flag like bScroll to tell the previous state and so decide to set new status or not.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2007, 6:29 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Dear Sean, :)

Your script is Nice & Useful.

Sean wrote:
My original version was using GUI, a small box sitting at the top left corner and changing the background color accordingly. Apparently, however, it seemed not possible to change in real time the background color of AHK's GUI, unless using controls. Instead of digging into it, as I'm usually impatient with GUI stuffs, I chose to use the keyboard indicators. Maybe later, unless someone else does the GUI thing before.


Here is my attempt, just a starter, < 45 lines.

Code:
; Posted at http://www.autohotkey.com/forum/viewtopic.php?p=113890#113890

#SingleInstance, Force
Process, Priority,, High
OnExit, Quit
oRC := 0, oWC := 0

; Run, diskperf.exe -y   ; Execute it once to enable Disk Performance monitoring.

SetTimer, HDD_Monitor, ;500

hDrv := DllCall( "CreateFile", Str,"\\.\PhysicalDrive0", Uint,0 ,Uint,3, Uint,0, Uint,3
                , Uint,0, Uint,0 )

Gui, -Caption +Border +AlwaysOnTop +ToolWindow
Gui, Color, EEAA99 
Gui, +LastFound 
WinSet, TransColor, EEAA99 
Gui, Add, Progress,     w60 h9 cGreen -0x1 vRead
Gui, Add, Progress, x+5 w60 h9 cRed   -0x1 vWrite
Gui, Show, x780 y3 , HDD Monitor                 ; Adjust X & Y to suit your screen res
Return

HDD_Monitor:
  VarSetCapacity(dp, 88)
  DllCall( "DeviceIoControl", Uint,hDrv, Uint,0x00070020, Uint,0, Uint,0, Uint, &dp
          , Uint,88, UintP,nReturn, Uint,0 )

  nRC := *(&dp+40) | *(&dp+41) << 8 | *(&dp+42) << 16 | *(&dp+43) << 24
  nWC := *(&dp+44) | *(&dp+45) << 8 | *(&dp+46) << 16 | *(&dp+47) << 24

  RC := Round(100-(100*(1/(1+(nRC-oRC)))))  ,  WC := Round(100-(100*(1/(1+(nWC-oWC)))))

  GuiControl,, Read , %RC%
  GuiControl,, Write, %WC%
  oRC := nRC ,  oWC := nWC
Return

Quit:
  DllCall("CloseHandle", "Uint", hDrv)
  ExitApp
Return


I find your posts more & more useful. Keep up the good work.

Thanks. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2007, 7:26 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
Here is my attempt, just a starter, < 45 lines.

Ah, you still didn't learn, Skan..... :D

BTW, very nice gui.

BTW2, I see that you are interested in algorythm performance. DOn't number of lines misslead you, it has not 1 single thing to do with the speed, and its usualy contrary, that longer code is quicker then shorter.

If you are interested in theory, you will have to know differential equations pretty much, (in)finite sums and logarithms. The speed of algorythm can be proved mathematicaly. I have my books about this on Serbian only, but if you want to know more I can find you relevant articles and your guru most definitely can provide some help about the topic 8)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2007, 1:05 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Skan wrote:
Here is my attempt, just a starter, < 45 lines.

Thanks for this excellent GUI. I knew that you could do it better than me. :)
BTW, you separated the read/write counter. I almost thought that you had a psychic power. ;)

Quote:
I find your posts more & more useful. Keep up the good work.

Thanks for the good words.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2007, 4:00 pm 
Offline

Joined: July 6th, 2004, 10:07 am
Posts: 171
Location: Manchester, England.
@All

Here's another take based on FloatLed

http://www.softpedia.com/get/System/Har ... tLED.shtml

Code:
 _= 2007 04 03 Ver 1.0.46.10
 _= ESC to exit program !
 ; add ini to remember last screen pos
 #NoEnv
 #Persistent
 #SingleInstance, Force
 SetBatchLines, -1

 Gui,Color,0x0
 Gui -Caption +Owner +AlwaysOnTop
 Gui,Font,s10 w700, Courier New

 OnMessage(0x219, "NotifyChange")
 ;; include code to re-evaluate when
 ;; hidden drive is activated during
 ;; Pseudo raid !

/*
 Run, diskperf.exe -y   ; Execute it once to enable Disk Performance monitoring.
 Not required for Xp +
 In Windows 2000 this IOCTL is handled by the filter driver diskperf.
 In Windows XP and later operating systems,
 the partition manager handles this request for disks and
 ftdisk.sys and dmio.sys handle this request for volumes.
*/

 SetTimer,ScanDrv,50

 _= Enumerate Available Drives (Fixed)

 DriveGet,aDrives,List,FIXED
   Loop,Parse,aDrives
   {
   DrvCount ++
   Drv%A_Index% := a_Loopfield
   CurDrv:= "\\.\" Drv%A_Index% ":"
   hDrv%A_Index% := DllCall("CreateFile",Str,CurDrv,Uint,0,Uint,3,Uint,0,Uint,3,Uint,0,Uint,0)
   }

 _= Build Quick+Dirty Gui to fit

 x=2
   Loop,% DrvCount
   {
   Gui,Add,Text,x%x% y-5 w09 h12 c0x00FF00 vx%A_Index%,
   Gui,Add,Text,x%x% y6  w09 h12 c0xFFFFFF ,% Drv%A_Index%
   Gui,Add,Text,x%x% y18 w09 h10 c0xFF8800 vy%A_Index%,
   x+=17
   }

 x-=8
 Gui,Show, x100 y100 w%x% h30 ,win
 ; WinSet, TransColor,0x0 225 ,win
 Return

 GuiEscape:
 GuiClose:
 ExitApp

 Return

 ScanDrv:
 SetTimer,ScanDrv,Off
   Loop,% DrvCount
   {
   VarSetCapacity(dp%A_Index%,88)
   DllCall("DeviceIoControl",Uint,hDrv%A_Index%,Uint,0x00070020,Uint,0,Uint,0
                            ,Uint,&dp%A_Index%,Uint,88,UintP,nReturn,Uint,0)

   nReadCount%A_Index%  := DecodeInteger(&dp%A_Index% + 40)
   nWriteCount%A_Index% := DecodeInteger(&dp%A_Index% + 44)

 _= Case Writing @ y%A_Index%
     If (nWriteCount%A_Index% <> _nWriteCount_%A_Index%)
     {
     _nWriteCount_%A_Index% := nWriteCount%A_Index%
     GuiControl,,y%A_Index%,=
     }
     Else  guicontrol,,y%A_Index%,

 _= Case Reading @ x%A_Index%
     If (nReadCount%A_Index% <> _nReadCount_%A_Index%)
     {
     _nReadCount_%A_Index%  := nReadCount%A_Index%
     GuiControl,,x%A_Index%,=     
     }
     Else  guicontrol,,x%A_Index%,
   }

 SetTimer,ScanDrv,On
 Return

 DecodeInteger(ptr)
 {
   Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
 }

 ~LButton::DragGui("win")

 _=========================================================================
 _== FUNCTION :     DragGui(WinTitle)                                    ==
 _== Author   :     Chris Mallett                                        ==
 _== Updated  :     Converted to FUNCTION By Dave Perrée Jun 2006        ==
 _== Usage    :     ~LButton::DragScreen("WinTitle")                     ==
 _=========================================================================

 DragGui(_WinTitlePart)
 {
 STATIC _GuiID,_MouseStartX,_MouseStartY
 WinGet,_GuiID, ID,% _WinTitlePart
 CoordMode,Mouse
 MouseGetPos,_MouseStartX,_MouseStartY,_MouseWin
    If _MouseWin <> %_GuiID%
    Return
 SetTimer,_WatchMouse,5
 Return
 _WatchMouse:
 GetKeyState,_LButtonState,LButton,P
    If _LButtonState=U
    {
    SetTimer,_WatchMouse,Off
    Return
    }
 CoordMode,Mouse
 MouseGetPos,_MouseX,_MouseY
 _DeltaX:=_MouseX
 _DeltaX-=%_MouseStartX%
 _DeltaY:=_MouseY
 _DeltaY-=%_MouseStartY%
 _MouseStartX:=_MouseX
 _MouseStartY:=_MouseY
 WinGetPos,_GuiX,_GuiY,,,ahk_id%_GuiID%
 _GuiX+=%_DeltaX%
 _GuiY+=%_DeltaY%
 SetWinDelay,-1
 WinMove,ahk_id %_GuiID%,,%_GuiX%,%_GuiY%
 RETURN
 }

 NotifyChange()
 {
 ; do nothing yet
 Return
 }



Have Fun

_________________
Simple ideas lie within reach, only of complex minds


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2007, 5:03 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Dippy46 wrote:
Here's another take based on FloatLed

Nice. BTW, there seems to be a confusion in the comment. I don't think diskperf.exe has anything to do with diskperf.sys which is indeed missing in XP. diskperf.exe controls the enableness of the corresponding counter. To see this, execute diskperf -n. So, it's still needed in XP.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2007, 6:02 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
@majkinetor

Quote:
Ah, you still didn't learn, Skan..... :D


IMHO, the beauty of AHK is lies in the fact that one can write really short ( ( I refer to the lines ) & yet powerful scripts. Ofcourse, techies like you and others have pointed out the various limitations of the language. Still, I admire AHK very much mainly for its simple syntax and the powerful GUI capabilities. I am glad that I do not have to be a powerful programmer to use AHK. :D

Quote:
BTW, very nice gui.


Thanks :)





@Sean

Quote:
Thanks for this excellent GUI. I knew that you could do it better than me. :)
BTW, you separated the read/write counter. I almost thought that you had a psychic power. ;)


Thanks :)





@Dippy46 : Re. DragGui()

Nice script Sir :). BTW, The drag can be enabled for a captionless GUI with a simple postmessage. Example:

Code:
Gui, -Caption +ToolWindow +0x400000
Gui, Font, S14 Bold, Verdana
Gui, Add, Text, w200 h27 Border Center GuiMove, Click Here `&& Drag
Gui, Show, AutoSize
Return

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
Exitapp


Example taken from: How to enable Drag for a GUI without a Titlebar ?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 50 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group