message when: print job is send to a printer

Get help with using AutoHotkey and its commands and hotkeys
tijger
Posts: 4
Joined: 26 Jun 2015, 09:15

message when: print job is send to a printer

15 Dec 2017, 02:45

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.
BoBo
Posts: 1817
Joined: 13 May 2014, 17:15

Re: message when: print job is send to a printer

15 Dec 2017, 03:19

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 :)
tijger
Posts: 4
Joined: 26 Jun 2015, 09:15

Re: message when: print job is send to a printer

15 Dec 2017, 04:26

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....
User avatar
noname
Posts: 450
Joined: 19 Nov 2013, 09:15

Re: message when: print job is send to a printer

15 Dec 2017, 06:41

Creating a notification event when a printjob is send :
example:

Code: [Select all] [Expand] [Download] (notify.ahk)GeSHi © Codebox Plus

BoBo
Posts: 1817
Joined: 13 May 2014, 17:15

Re: message when: print job is send to a printer

15 Dec 2017, 08:16

noname wrote:Creating a notification event when a printjob is send :
example:

Code: [Select all] [Expand] [Download] (notify.ahk)GeSHi © Codebox Plus


@ noname
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
User avatar
noname
Posts: 450
Joined: 19 Nov 2013, 09:15

Re: message when: print job is send to a printer

15 Dec 2017, 12:07

Image

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] [Expand] [Download] (printer query.ahk)GeSHi © Codebox Plus

tijger
Posts: 4
Joined: 26 Jun 2015, 09:15

Re: message when: print job is send to a printer

16 Dec 2017, 15:01

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.
tijger
Posts: 4
Joined: 26 Jun 2015, 09:15

Re: message when: print job is send to a printer

18 Dec 2017, 07:49

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

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 61 guests