AutoHotkey Community

It is currently May 26th, 2012, 11:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: September 17th, 2007, 1:47 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I recently switched to the Wireless/HID keyboard/mouse devices. Then, the keyboard LED no longer worked with KeyboardClass0. But, I noticed a new one KeyboardClass1 and switched to it, then it was starting to work again. So, if having a problem with the original script, I suggest to try to change KeyboardClass0 to other ones.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2008, 10:46 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776

      Screen shot of TNA
      Image

      The first icon in the screen shot above is the indicator and the dots represent Read and Write
      • Red and Red - Idle
      • Green and Red - Read
      • Red and Green - Write
      • Green & Green - Read / Write
      Download HDD-Indicator@TNA - 4.5 KiB ( 65 lines )


:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2008, 11:25 am 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
SKAN wrote:
HDD-Indicator@TNA 4.5 KiB ( 65 lines )

omg
is it really an autohotkey code?
i completely don't understand the code :shock:
what's all about hex ? dynamic icon creating?
i feel being stupid :cry:

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2008, 3:18 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
heresy wrote:
what's all about hex ? dynamic icon creating?
i feel being stupid :cry:


I have replied in the IconEx topic : http://www.autohotkey.com/forum/viewtop ... 741#196741

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2008, 4:46 am 
SKAN wrote:
The first icon in the screen shot above is the indicator and the dots represent Read and Write

Thanks Skan.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2008, 3:56 pm 
Offline

Joined: December 29th, 2007, 9:40 pm
Posts: 142
SKAN,

Thanks for the beautiful script. I am making use of it on a virtual machine that I am now using for all of my dev work - wicked tight little tool.

Just a quick note of gratitude.

Happy holidays, all!

-t

_________________
When replying, please feel free to address me as Tod. My AHK.net site...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2008, 9:30 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Thanks for the nice words, friend :D


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 12th, 2009, 8:49 pm 
Offline

Joined: January 21st, 2009, 5:49 pm
Posts: 176
Sean wrote:
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.


This is really nice. The script was mentioned on donationcoder.com as a way to use Scroll Lock for HD LED flicker.

I noticed on my PCs that it discombobulated the Caps Lock LED. All I did was copy the DllCall where you get the keyboard LED state and paste it again just below the assignments to nReadCount and nWriteCount in the timer function. Seems to work great now on both my PCs.

Here's the StartLED with my line added

Code:
StartLED:
VarSetCapacity(dp, 88)
DllCall("DeviceIoControl", "Uint", hDrive, "Uint", 0x00070020, "Uint", 0, "Uint", 0, "Uint", &dp, "Uint", 88, "UintP", nReturn, "Uint", 0)   ; IOCTL_DISK_PERFORMANCE

nReadCount  := NumGet(dp, 40)
nWriteCount := NumGet(dp, 44)

;get keyboard status again
   DllCall("DeviceIoControl", "Uint", hKeybd, "Uint", 0x000B0040, "Uint", 0, "Uint", 0, "UintP", _nStatus_, "Uint", 4, "UintP", nReturn, "Uint", 0)   ; IOCTL_KEYBOARD_QUERY_INDICATORS
;to above comment is my mod - MilesAhead
   
If (nWriteCount <> _nWriteCount_) || (nReadCount <> _nReadCount_)
{
   _nReadCount_  := nReadCount
   _nWriteCount_ := nWriteCount
   nStatus := _nStatus_ | 1 << 16
}
Else   nStatus := _nStatus_ & ~(1 << 16)

DllCall("DeviceIoControl", "Uint", hKeybd, "Uint", 0x000B0008, "UintP", nStatus, "Uint", 4, "Uint", 0, "Uint", 0, "UintP", nReturn, "Uint", 0)
Return


Just one more tweak to save a bit of memory by calling EmptyWorkingSet

Code:
OnExit, ExitLED
;save a bit on memory if Windows 5 or newer - MilesAhead
result := DllCall("psapi.dll\EmptyWorkingSet", "Int", -1, "Int")
SetTimer, StartLED, On, 500


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2009, 3:55 pm 
Offline

Joined: March 22nd, 2006, 9:27 pm
Posts: 22
Please need help with this code.

I was very unsuccessful with creating a function out of the code to call it like:

Code:
DriveMonitor(driveLetter,xPos,yPos)


Can you please help me with this?


[ Moderator!: Please do not TOP-POST.. Redundant quoting of previous post edited out]


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Modified script
PostPosted: November 15th, 2009, 8:50 pm 
Offline

Joined: January 21st, 2009, 5:49 pm
Posts: 176
After looking at Sean's script I see he was using the initial call to get keyboard state as a save to be restored on program exit. Since the user may change the state of num lock or caps lock while the program is running, I thought it better to only save the Scroll Lock state, since that's what this program changes.

All my mods are commented. This script has them all incorporated along with code that saves and restores just the state of the scroll lock.

I named it HDDMonitorMAmod.ahk to avoid confusion.

http://www.autohotkey.net/~MilesAhead/Scripts/HDDMonitorMAmod.zip

Code:
;HDDMonitorMAmod.ahk

#Persistent
#SingleInstance, Force
SetBatchLines, -1

;Run, diskperf.exe -y   ; Execute it once to enable Disk Performance monitoring.
OnExit, ExitLED
;save a bit on memory if Windows 5 or newer - MilesAhead
result := DllCall("psapi.dll\EmptyWorkingSet", "Int", -1, "Int")
SetTimer, StartLED, On, 500

hDrive := DllCall("CreateFile", "str", "\\.\PhysicalDrive0", "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 0)
hKeybd := DllCall("CreateFile", "str", "\\.\GLOBALROOT\Device\KeyboardClass0", "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 0)

DllCall("DeviceIoControl", "Uint", hKeybd, "Uint", 0x000B0040, "Uint", 0, "Uint", 0, "UintP", _nStatus_, "Uint", 4, "UintP", nReturn, "Uint", 0)   ; IOCTL_KEYBOARD_QUERY_INDICATORS
;only save Scroll Lock status since caps lock or
;num lock may be changed by the user while this is running - MilesAhead
scrollOn := _nStatus_ & 1 << 16
Return

StartLED:
VarSetCapacity(dp, 88)
DllCall("DeviceIoControl", "Uint", hDrive, "Uint", 0x00070020, "Uint", 0, "Uint", 0, "Uint", &dp, "Uint", 88, "UintP", nReturn, "Uint", 0)   ; IOCTL_DISK_PERFORMANCE

nReadCount  := NumGet(dp, 40)
nWriteCount := NumGet(dp, 44)

;get keyboard status again
   DllCall("DeviceIoControl", "Uint", hKeybd, "Uint", 0x000B0040, "Uint", 0, "Uint", 0, "UintP", _nStatus_, "Uint", 4, "UintP", nReturn, "Uint", 0)   ; IOCTL_KEYBOARD_QUERY_INDICATORS
;to above comment is my mod - MilesAhead
   
If (nWriteCount <> _nWriteCount_) || (nReadCount <> _nReadCount_)
{
   _nReadCount_  := nReadCount
   _nWriteCount_ := nWriteCount
   nStatus := _nStatus_ | 1 << 16
}
Else   nStatus := _nStatus_ & ~(1 << 16)

DllCall("DeviceIoControl", "Uint", hKeybd, "Uint", 0x000B0008, "UintP", nStatus, "Uint", 4, "Uint", 0, "Uint", 0, "UintP", nReturn, "Uint", 0)
Return

ExitLED:
SetTimer, StartLED, Off
;restore original Scroll Lock state - MilesAhead
If scrollOn
   nStatus := _nStatus_ | 1 << 16
Else
   nStatus := _nStatus_ & ~(1 << 16)   
DllCall("DeviceIoControl", "Uint", hKeybd, "Uint", 0x000B0008, "UintP", nStatus, "Uint", 4, "Uint", 0, "Uint", 0, "UintP", nReturn, "Uint", 0)   ; IOCTL_KEYBOARD_SET_INDICATORS
DllCall("CloseHandle", "Uint", hKeybd)
DllCall("CloseHandle", "Uint", hDrive)
ExitApp



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 7:36 am 
Offline

Joined: March 22nd, 2006, 9:27 pm
Posts: 22
nobody can help me?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 7:58 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
klim wrote:
I was very unsuccessful with creating a function out of the code


Can you please explain why you want it as function. GUI and SetTimer does not fit well into a function.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 9:01 am 
Offline

Joined: March 22nd, 2006, 9:27 pm
Posts: 22
i'm creating a gui for a program (actually 30kb ahk source code) and drive activity can be very useful for it.

i messed around with the given code but then i'd to use dynamic variables and that was my problem.

here is a screenshot of my program:
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 11:53 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
klim wrote:
i messed around with the given code but then i'd to use dynamic variables and that was my problem.


It is hard to suggest anything without seeing a piece of code. :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 3:38 pm 
Offline

Joined: March 22nd, 2006, 9:27 pm
Posts: 22
here is the function with the call, but it only works with one call. problem is that i've to use unique (global) variables.


Code:
 
 ;this function call works
 DriveMonitor("C",1000,200)
 
 ;this function call doesn't work anymore
 DriveMonitor("J",1000,300)
 
 
 ;function
 DriveMonitor(DriveLetter,xPos,yPos)
 {
   Gui,Color,0x0
   Gui -Caption +Owner +AlwaysOnTop
   Gui,Font,s10 w700, Courier New

   global hDrv,  ReadingStatusDrive   ,WritingStatusDrive,
   CurDrv:= "\\.\" DriveLetter ":"
   hDrv := DllCall("CreateFile",Str,CurDrv,Uint,0,Uint,3,Uint,0,Uint,3,Uint,0,Uint,0)

   SetTimer,ScanDrv,50

   _= Build Quick+Dirty Gui to fit

   x=2
   Gui,Add,Text,x%x% y-5 w09 h12 c0x00FF00 vReadingStatusDrive,
   Gui,Add,Text,x%x% y6  w09 h12 c0x010101 ,%DriveLetter%
   Gui,Add,Text,x%x% y18 w09 h10 c0xFF8800 vWritingStatusDrive,
   x+=17

   x-=8
   ;x:= xPos
   ;y:= yPos
   ;Gui,Show, x1100 y200 w%x% h30 ,win
   Gui,Show, x%xPos% y%yPos% w%x% h30 ,win
   WinSet, TransColor,0x0 225 ,win
   Return


   ScanDrv:
   SetTimer,ScanDrv,Off
   VarSetCapacity(dp1,88)
   DllCall("DeviceIoControl",Uint,hDrv,Uint,0x00070020,Uint,0,Uint,0
                     ,Uint,&dp1,Uint,88,UintP,nReturn,Uint,0)

   nReadCount1  := DecodeInteger(&dp1 + 40)
   nWriteCount1 := DecodeInteger(&dp1 + 44)

   _= Case Writing @ WritingStatusDrive
    If (nWriteCount1 <> _nWriteCount_1)
    {
    _nWriteCount_1 := nWriteCount1
    GuiControl,,WritingStatusDrive, % Chr(149)
    }
    Else  guicontrol,,WritingStatusDrive,

   _= Case Reading @ ReadingStatusDrive
    If (nReadCount1 <> _nReadCount_1)
    {
    _nReadCount_1  := nReadCount1
    GuiControl,,ReadingStatusDrive,% Chr(149)
    }
    Else  guicontrol,,ReadingStatusDrive,


   SetTimer,ScanDrv,On
   Return
}

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



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 Previous  1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], Miguel and 13 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