Default Printer Viewer/Changer -- Feedback welcome

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
kunkel321
Posts: 1149
Joined: 30 Nov 2015, 21:19

Default Printer Viewer/Changer -- Feedback welcome

17 Jun 2023, 09:52

A simple tool I made from combining different commands that I found here on the forums.

Last version before adding context menu:
Spoiler


6-19-2023 Version with right-click-on-item context menu
Spoiler

/=====================
5-14-2024 Update: A version for AHKv2 is here:
viewtopic.php?f=83&p=571743#p571743
Last edited by kunkel321 on 14 May 2024, 17:44, edited 13 times in total.
ste(phen|ve) kunkel
garry
Posts: 3788
Joined: 22 Dec 2013, 12:50

Re: Default Printer Viewer/Changer -- Feedback welcome

17 Jun 2023, 16:59

works fine , just added these commands after buttonset to see what happened :

Code: Select all

run,shell:PrintersFolder   ;- show printers and with rightclick change as default printer
run,control printers       ;- maybe rightclick for problem solution
EDIT : some other commands :

Code: Select all

F1:=a_scriptdir . "\test.txt"
printerA:="Pantum M6600NW Series"
;---------------
runwait,RUNDLL32 PRINTUI.DLL`,PrintUIEntry /f "%f1%" /Xg /n "%printerA%"      ;- show printers specification in file F1
runwait,rundll32 printui.dll`,PrintUIEntry /?                                 ;- Help
runwait,rundll32 printui.dll`,PrintUIEntry /o /n "%printerA%"                 ;- display printer queue view
runwait,rundll32 printui.dll`,PrintUIEntry /p /n "%printerA%"                 ;-  printer properties
try,
  run,%f1%    ;- show printers specification
;run,shell:PrintersFolder 
;run,control printers  
return
Last edited by garry on 18 Jun 2023, 13:12, edited 1 time in total.
User avatar
kunkel321
Posts: 1149
Joined: 30 Nov 2015, 21:19

Re: Default Printer Viewer/Changer -- Feedback welcome

17 Jun 2023, 17:58

Yeah, accessing the already-existing system tools probably makes more sense.
But it's not as much fun. :geek:
garry wrote:
17 Jun 2023, 16:59

Code: Select all

run,control printers       ;- maybe rightclick for problem solution
This gets its own button. LOL.
ste(phen|ve) kunkel
garry
Posts: 3788
Joined: 22 Dec 2013, 12:50

Re: Default Printer Viewer/Changer -- Feedback welcome

18 Jun 2023, 05:31

@kunkel321 your script is optimal, easy see or set the default printer . Button 'control panel' is fine , maybe solve printer problems or other things with rightclick .
User avatar
kunkel321
Posts: 1149
Joined: 30 Nov 2015, 21:19

Re: Default Printer Viewer/Changer -- Feedback welcome

18 Jun 2023, 09:04

garry wrote:
18 Jun 2023, 05:31
@kunkel321 your script is optimal, easy see or set the default printer . Button 'control panel' is fine , maybe solve printer problems or other things with rightclick .
Do you mean a popup menu upon right-clicking the radio items? I hand't thought of that. I'll see if I can figure out how to do it. :D
ste(phen|ve) kunkel
garry
Posts: 3788
Joined: 22 Dec 2013, 12:50

Re: Default Printer Viewer/Changer -- Feedback welcome

18 Jun 2023, 09:30

sorry , nothing to change in your script . You have already the button > run,control printers , which I often used if I have a problem with the printer .
User avatar
kunkel321
Posts: 1149
Joined: 30 Nov 2015, 21:19

Re: Default Printer Viewer/Changer -- Feedback welcome

18 Jun 2023, 10:25

I see what you mean. Yes, just using the Control Panel for that probably makes more sense. Especially for troubleshooting. If you need to troubleshoot a printer, you'd likely go to the CP anyway... Though a fourth button to "open print que" might be nice...

On a related note: It doesn't appear that you can detect right-clicks on a radio item anyway... The docs for A_GuiControl indicate:
RightClick: Occurs only for GuiContextMenu, ListViews, and TreeViews.
EDIT: Upon experimentation... It looks like you can use an if GetKeyState("RButton") in the gLabel Label. That still doesn't detect a right-click though.... It only detects if the right button is being held down when you left click a radio item.
ste(phen|ve) kunkel
garry
Posts: 3788
Joined: 22 Dec 2013, 12:50

Re: Default Printer Viewer/Changer -- Feedback welcome

18 Jun 2023, 14:28

example , rightclick on button ( if you don't want too many buttons ) or a GUI-menu
viewtopic.php?p=321750#p321750
User avatar
kunkel321
Posts: 1149
Joined: 30 Nov 2015, 21:19

Re: Default Printer Viewer/Changer -- Feedback welcome

18 Jun 2023, 17:46

Very cool. Thanks for all the info Garry!

Your right-click-on-button solution is very clever. It's always fun to see the different ways to solve different things. Alas, I think the technique might not be compatible with radio buttons... It requires that each command (button) have a unique vName and gName. With radio buttons though, the group members all share a vName.
Actually, the previous statement can't be accurate... I have experimented with a simple set of radio buttons and it only worked with a single variable. The above code makes multiple variables with vRadio%A_Index% though... [new edit at bottom of this post]


I suppose the above tool could be remade with dynamically-created buttons, rather than radio items.
I think I like the idea of a fourth button at the bottom, for "Show print queue," though. :ugeek: I'll use your above command line printer code for that.

EDIT: Wow... There certainly is a lot of information available via the /? one you posted....
Spoiler
Just got an idea.... Rather than a "print queue" button, we can have a drop list that offers all of the above command line entries... The user selects one, then presses a button to do whatever command is selected. EDIT: Meh... Actually most of the commands are administrative things that I would never want to do.

EDIT 6-19-2023 It took a while to the the syntax right, but it turned out that I didn't even need to change the existing code to add r-click functionality... I just needed to add this subroutine:

Code: Select all

dfGuiContextMenu:
MouseGetPos,,,,Control1
Loop, parse, printerlist, `n
{
	If (A_GuiControl = "Radio" A_Index) {
		MsgBox % A_LoopField
	}
}
return
:bravo:

EDIT 6-19-2023: New version of code in first post.
ste(phen|ve) kunkel
User avatar
kunkel321
Posts: 1149
Joined: 30 Nov 2015, 21:19

Re: Default Printer Viewer/Changer -- Feedback welcome

14 May 2024, 17:45

A version of this printer tool, for AHKv2, is here:
viewtopic.php?f=83&p=571743#p571743
ste(phen|ve) kunkel

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 83 guests