ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Idea : Print Notification

(1/1)

thankusan:
Discription : A program which make a beep or chime sound when a print command is given on a local printer-shared.  (ie; when a print arrives in the PC to which the printer is connected. Wonder why XP does not have such an option.

thankusan:
To make it simple, program for a sound generation when print command arrives to the pc. Could be an addon in the 'sounds and audio devices' shown on control panel

skrommel:
 :) 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

Navigation

[0] Message Index

Go to full version