Try
PrintSound!
It plays a sound and displays a traytip when something is printed.
I've set a delay of 10 seconds between prints to prevent multiple alarms for the same print.
Maybe larger jobs require a larger delay.
Skrommel
;PrintSound.ahk
; Plays a sound and displays a traytip when something is printed
;Skrommel @ 2008
delay=10
;Code stolen from SKAN at http://www.autohotkey.com/forum/topic22862.html
#SingleInstance,Force
#Persistent
SetBatchLines,-1
Process,Priority,,High
OnExit,ShutApp
WatchFolder := A_WinDir "\system32\spool\printers\"
WatchSubDirs := "0"
EventString := "New File,Deleted,Modified,Renamed From,Renamed To"
StringSplit, EventArray, EventString, `,
DllCall("shlwapi\PathAddBackslashA", UInt, &Watchfolder)
CBA_ReadDir := RegisterCallback("ReadDirectoryChanges")
SizeOf_FNI := ( 64KB := 1024 * 64 )
VarSetCapacity( FILE_NOTIFY_INFORMATION, SizeOf_FNI, 0 )
PointerFNI := &FILE_NOTIFY_INFORMATION
hDir := DllCall( "CreateFile", Str , WatchFolder, UInt, "1", UInt , "7", UInt, 0, UInt, "3", UInt, "1107296256", UInt , 0 )
Loop
{
nReadLen := 0
hThreadId := 0
hThread := DllCall( "CreateThread", UInt, 0, UInt, 0, UInt, CBA_ReadDir, UInt, 0, UInt,0, UIntP,hThreadId )
Loop
{
If nReadLen
{
PointerFNI := &FILE_NOTIFY_INFORMATION
Loop
{
NextEntry := NumGet( PointerFNI + 0 )
Action := NumGet( PointerFNI + 4 )
FileNameLen := NumGet( PointerFNI + 8 )
FileNamePtr := ( PointerFNI + 12 )
Event := EventArray%Action%
VarSetCapacity( FileNameANSI, FileNameLen )
DllCall( "WideCharToMultiByte", UInt,0, UInt,0, UInt,FileNamePtr, UInt, FileNameLen, Str, FileNameANSI, UInt,FileNameLen, UInt,0, UInt,0 )
File := WatchFolder . SubStr( FileNameANSI, 1, FileNameLen/2 )
If Event=New File
{
FileGetTime,created,%File%,C
If (created>prevcreated+delay)
{
SoundPlay,*64
TrayTip,PrintSound,Printing...
prevcreated:=created
}
}
If !NextEntry
Break
Else
PointerFNI += NextEntry
}
Break
}
Sleep 1000
}
DllCall( "TerminateThread", UInt,hThread, UInt,0 )
DllCall( "CloseHandle", UInt,hThread )
}
Return
ReadDirectoryChanges()
{
Global hDir,PointerFNI, Sizeof_FNI, WatchSubdirs, nReadlen
Return DllCall( "ReadDirectoryChangesW", UInt, hDir, UInt, PointerFNI, UInt, SizeOf_FNI, UInt, WatchSubDirs, UInt, "375", UIntP, nReadLen, UInt, 0, UInt, 0 )
}
ShutApp:
DllCall( "CloseHandle", UInt,hDir )
DllCall( "TerminateThread", UInt,hThread, UInt,0 )
DllCall( "CloseHandle", UInt,hThread )
ExitApp