Programmatically call special print driver functions - winapi

I want to programatically call the special functions in the Maintenance tab of my Canon Pixma's Printer Properties (in Windows):
I'm specifically after any .Net or Win32 methods that I should be looking to use, but I'm happy to hear alternative methods that might work.
Thanks.

I noticed the clean was sent to the printer via print spooler as a 'maintenance' job. Thanks to this SO answer here I was able to capture the data sent to the printer.
I then sent raw commands to the printer as per the instructions on this MS page.
(Unfortunately, I discovered this after doing hack with printui.dll,PrintUIEntry and various FindWindow() and SendMessage() calls to simulate the UI. * sigh *)

Related

How to change 3rd monitor programmatically

When I'm using my laptop, I use 3 displays:
The laptop display
A second monitor (connected through VGA)
A TV (connected through HDMI)
My videocard doesn't support 3 monitors, so I'm constantly switching from 2 to 3: when I'm on the computer, I use the 2nd monitor, and when I want to watch some movies, etc. I use the 3rd.
I currently have to go to Screen Resolution, select the monitor that is not in use, and choose Extend desktop to this display.
Is there a way I can automate it?
Is there any command-line tool, or any Windows API that allows doing it?
Edit:
Display Changer seems to do what I need, but the problem is that it only detects the working monitors. The 3rd monitor (which isn't currently in use) isn't detected, so I can't attach it.
A bit of RE on DisplaySwitch.exe shows that it calls
SetDisplayConfig(0, NULL, NULL, NULL, 0x888)
to set it to Extended on my computer.
From there, a little digging around got me to the SetDisplayConfig documentation obviously and also this SO page with some example code that queries your current display state and adds the actual flags to change them if you want to do so.
I answered a similar question with suggestion to try UltraMon or use their SDK, but you can also hit the Win32 API directly with ChangeDisplaySettingsEx. Another user, Sai, gave an reference to an example showing use of the function.

How to put monitor on standby and not let it wake up

I have 3 monitors, but I don't need them all turned on all the time. I can just shut them down with power button, but I want to use their standby mode, like Windows does when we let PC idle for a while - it shuts down monitors, HDD, etc.
But of course, I wanna keep using PC and let just that monitor on standby. Others must remain on and that one doesn't wake up even with me using PC.
Is it possible to do that? It would be great to have a shortcut like Winkey+1, 2, 3 etc to shut down and wake up each monitor.
An existing app with this feature is not likely to exist, but is there a Windows API function that can control monitor state, for each monitor in a MultiMonitor system?
The display control panel applet calls SetDisplayConfig to start or stop forced projection on a particular target
You can probably use MS Detours or some other API hooking tool to inspect the usage pattern of the API while using the applet to adjust display settings.
You'll want to try Display Fusion. You should be able to do what you're asking for using Monitor configurations.
I know I'm late on this but use DDC to control your display. You can easily create hotkeys that send a command via DDC to the display to turn-off. This would be equivalent to turning off the display using the button. Works like a charm for me. The only trick is that DDC command specs vary across monitor manufacturers but its not hard to find the right codes to send with the help of google.
Ready made tools also exist for this; search for anything that is related to DDC or EDID and you should find.
Be aware though that this does not remove the display from Windows which means that apps may find their way onto displays that are off and you will be looking for them.

Windows 7.1 SDK - Timing a call

I currently have a "dumbphone", but I'm trying to make an app that'll time and store the call duration of incoming calls for windows 7.1 ("7.5") phones, for the user scheduling purposes.
However, after extensive searching and googling, with topics like this one:
Windows Phone 7 - How to calculate call duration or termination
it seems that the Windows 7/7.1 SDK does not allow access to recognizing when a call is coming in. I've read about obscure and unobscure, but that this wouldn't be a good idea since it would start the timer anytime the UI hides the program, not just calls.
I've thought that maybe I could just pull the call duration or the start/end time from the call history, but windows 7 SDK doesn't support that either it seems.
So I decided to seek help. Is there a way to make this work? Is there some clever way to recognize when a call is incoming and stopped? Or some clever way to pull call times/durations? Or maybe a way to detect when the user presses that "accept incoming call" button? Or maybe a way to single out when a call is obscuring the UI?
Any help would be greatly appreciated. Thank you
Due to security reasons your application does not have any kind of accsess to call history ect. So you are in a sendbox and you don't know nothing about phone calls.
From the Windows Phone SDK, there is no way to achieve this!
The only thing I can think of is that when a call comes, the current app gets notified that is now Obscured because a new screen is now on top of it (the caller ID screen), and will get notified when it gets back to focus.
But the truth is that this happens even if a SMS message notification pops on the screen and the user taps to read it, or some app gets a notification pushed...

How to detect if a windows app is Tablet PC "Aware"

Does anyone know how I can determine if an application is able to accept Tablet PC input? i.e. some kind of hittest or windows message that I can send it?
thanks,
H
The Tablet PC Input Panel (which as of Vista is available even on non-tablets other than the basic editions) will send input using the Text Services Framework (TSF) to an application that supports it. Otherwise it will send normal input messages to the application which basically means a bunch of simulated keyboard events.
I suspect you are trying to determine whether or not an application supports TSF which provides a much more integrated experience such as bidirectional correction interface, information about the current selection, context hints, etc.
I don't know if this is reliable but if the control in question is a rich edit, you could try the EM_GETEDITSTYLE message which has a SES_USECTF flag in the return value that indicates whether or not TSF is turned on for that control. But for standard edit controls I'm not so sure. This article on MSDN goes into much more detail about using the text services framework and is probably more than you care to implement.

How does software like Spy++ get the information?

I'm working on a software for test automation. To get it working it need's to "have a look" on the desktop and all open windows. It needs to know which windows are open and what controls they consist of. So it has to do something similar to what Spy++ is doing (Spy++ from Visual Studio).
Does anyone know how Spy ++ get's all the information?
Are there any Windows Methods one can call to retrieve information about open windows?
You can use EnumWindows to get all top level windows. Within the lpEnumFunc you can call FindWindowEx to get child windows/controls of each top level window and then any other interesting function that gives you information you need, e.g. GetClassName, GetClassInfo, GetClientRect etc. etc. Take a look here for more
It's called a windows hook. Checkout the Win32 API SetWindowHookEx.
There are different types of hooks, they reside in a DLL and that DLL function is called by Windows for the type of windows messages of a specific thread or all threads in the same desktop.
Please also see my related answer on Windows hooks here.

Resources