Hello,
I have a question.
Is there a way that i can see when a print job is send to a printer?
I have this now:
WaitQueueToBePrinted:
Sleep, 500
IfExist, c:\windows\system32\spool\printers\*.spl
{
MsgBox, A document is send to the printer!!
} else {
MsgBox, Still waiting...
Goto, WaitQueueToBePrinted
}
But it only works when i self place a .spl file in that folder.
message when: print job is send to a printer
Re: message when: print job is send to a printer
There are already several threads available about this/similar topic(s): https://www.google.de/search?q=site:aut ... ter+status
That one looks promising (needs probably a tweak): https://autohotkey.com/board/topic/8544 ... t-spooler/
Good luck
That one looks promising (needs probably a tweak): https://autohotkey.com/board/topic/8544 ... t-spooler/
Good luck
Re: message when: print job is send to a printer
Hello,
I found that tutorials, but they don''t give a solution (at the end of those topics the solution is not found)
When i press print in for example a .pdf file. I get a popup in desktop that the document is send to the printer. Thats not a window, with the result that i can''t use ifWindow exist....
I found that tutorials, but they don''t give a solution (at the end of those topics the solution is not found)
When i press print in for example a .pdf file. I get a popup in desktop that the document is send to the printer. Thats not a window, with the result that i can''t use ifWindow exist....
Re: message when: print job is send to a printer
Creating a notification event when a printjob is send :
example:
example:
Code: Select all
#Persistent
winmgmts := ComObjGet("winmgmts:")
ComObjConnect(createSink := ComObjCreate("WbemScripting.SWbemSink"), "PrintProcessCreate_")
interval := 10
winmgmts.ExecNotificationQueryAsync(createSink
, "Select * from __InstanceCreationEvent"
. " within " interval
. " Where TargetInstance ISA 'Win32_PrintJob'")
PrintProcessCreate_OnObjectReady(obj) {
SoundBeep,
msgbox,4,, printerjob started ,4
}
esc::
ObjRelease(winmgmts)
ObjRelease(createSink)
winmgmts := deleteSink := ""
exitapp
Re: message when: print job is send to a printer
@ nonamenoname wrote:Creating a notification event when a printjob is send :
example:Code: Select all
#Persistent winmgmts := ComObjGet("winmgmts:") ComObjConnect(createSink := ComObjCreate("WbemScripting.SWbemSink"), "PrintProcessCreate_") interval := 10 winmgmts.ExecNotificationQueryAsync(createSink , "Select * from __InstanceCreationEvent" . " within " interval . " Where TargetInstance ISA 'Win32_PrintJob'") PrintProcessCreate_OnObjectReady(obj) { SoundBeep, msgbox,4,, printerjob started ,4 } esc:: ObjRelease(winmgmts) ObjRelease(createSink) winmgmts := deleteSink := "" exitapp
Just out of curiosity, are those other details (> spoiler) also availabe using your approach? If yes, would you mind to provide them as well? Thx for your effort. Much appreciated
Spoiler
Re: message when: print job is send to a printer
I guess you can just run a query when a print command is detected.Some values are not found on my system/printer
Code: Select all
#Persistent
winmgmts := ComObjGet("winmgmts:")
ComObjConnect(createSink := ComObjCreate("WbemScripting.SWbemSink"), "PrintProcessCreate_")
interval := 10
winmgmts.ExecNotificationQueryAsync(createSink
, "Select * from __InstanceCreationEvent"
. " within " interval
. " Where TargetInstance ISA 'Win32_PrintJob'")
PrintProcessCreate_OnObjectReady(obj) {
SetTimer, info,-100
}
info:
strComputer := "."
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2")
colItems := objWMIService.ExecQuery("Select * from Win32_PrintJob")._NewEnum
while,colItems[item]
{
PrinterLocation := Item.Description
DocumentName := Item.Document
PrintStatus := Item.Status ; ( or JobStatus )
PrinterName := Item.Name
PagesPrinted := Item.PagesPrinted
PaperSize := Item.PaperSize
TotalPages := Item.TotalPages
PrintDate := Item.TimeSubmitted
}
MsgBox, % PrinterName " `n " PaperSize " `n " GetDate(PrintDate)
return
GetDate( tStamp ) { ; Returns Notepad date format.
Local Date:=0
FormatTime, Date, % RegExReplace( tStamp, "\..*" ), h:mm tt M/d/yyyy ; RegExRepl() is mostly cautionary.
Return Date
}
esc::
ObjRelease(winmgmts)
ObjRelease(createSink)
winmgmts := deleteSink := ""
exitapp
Re: message when: print job is send to a printer
Hello,
Thanks for your answers! I will try the code.
My goal is to:
- when a print job is send to the printer that a window (excel document) coming back on top.
I have made a excel file where people must fill in their names and when they push OK a ahk will run (with a macro in excel) and minimize the excel document and give the people 2 minutes the time to print a file.
after 2 minutes the excel document comes on top and stays on top (with a loop) till people will fill in their names and push OK.
But i wanna replace the 2 minutes with when the printjob is send. Because 2 minutes is sometimes to long or to short to print a file.
Thanks for your answers! I will try the code.
My goal is to:
- when a print job is send to the printer that a window (excel document) coming back on top.
I have made a excel file where people must fill in their names and when they push OK a ahk will run (with a macro in excel) and minimize the excel document and give the people 2 minutes the time to print a file.
after 2 minutes the excel document comes on top and stays on top (with a loop) till people will fill in their names and push OK.
But i wanna replace the 2 minutes with when the printjob is send. Because 2 minutes is sometimes to long or to short to print a file.
Re: message when: print job is send to a printer
It works now:
First i did a Goto, Process to outside the function but that give a error. It must stay in the function.
And i didn''t now the esc function to stop the ahk. Super:)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoTrayicon
IfWinExist, Print - Excel
{
WinMinimize
}
#Persistent
winmgmts := ComObjGet("winmgmts:")
ComObjConnect(createSink := ComObjCreate("WbemScripting.SWbemSink"), "PrintProcessCreate_")
interval := 10
winmgmts.ExecNotificationQueryAsync(createSink
, "Select * from __InstanceCreationEvent"
. " within " interval
. " Where TargetInstance ISA 'Win32_PrintJob'")
PrintProcessCreate_OnObjectReady(obj) {
Process:
IfWinExist, Print - Excel
{
WinActivate
WinSet, AlwaysOnTop, On
WinMaximize
Process, wait, Print - Excel , 3
}
Goto, Process
}
F8::
ObjRelease(winmgmts)
ObjRelease(createSink)
winmgmts := deleteSink := ""
exitapp
First i did a Goto, Process to outside the function but that give a error. It must stay in the function.
And i didn''t now the esc function to stop the ahk. Super:)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoTrayicon
IfWinExist, Print - Excel
{
WinMinimize
}
#Persistent
winmgmts := ComObjGet("winmgmts:")
ComObjConnect(createSink := ComObjCreate("WbemScripting.SWbemSink"), "PrintProcessCreate_")
interval := 10
winmgmts.ExecNotificationQueryAsync(createSink
, "Select * from __InstanceCreationEvent"
. " within " interval
. " Where TargetInstance ISA 'Win32_PrintJob'")
PrintProcessCreate_OnObjectReady(obj) {
Process:
IfWinExist, Print - Excel
{
WinActivate
WinSet, AlwaysOnTop, On
WinMaximize
Process, wait, Print - Excel , 3
}
Goto, Process
}
F8::
ObjRelease(winmgmts)
ObjRelease(createSink)
winmgmts := deleteSink := ""
exitapp
Who is online
Users browsing this forum: bobstoner289, Google [Bot], Ralf_Reddings200244 and 287 guests