Can Autohotkey change Printer settings? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mrdigitalis
Posts: 67
Joined: 23 May 2022, 01:17

Can Autohotkey change Printer settings?

Post by mrdigitalis » 02 Aug 2022, 12:27

Dear Form-Members,

I have a question. I have a little VBA script:

Code: Select all

Sub PrintMer()
   'Deze functie print de MER-planning in kleur en passend voor 1 pagina
    'ActiveSheet.PageSetup.BlackAndWhite = False 'This line does not work, it still prints black and white.
    ActiveSheet.PageSetup.Orientation = xlLandscape
    ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, ActivePrinter:="Xerox_Secure on PRN-MNG01"
    ActiveSheet.PageSetup.Zoom = 80
    MsgBox "De opdracht Mer printen is voltooid!"
End Sub
The problem is that it must be printed in color, and it is printed now in Black and White.
I have heard that VBA can not change the settings from the printer, see picture below:
image.png
image.png (65.95 KiB) Viewed 1219 times
The question is, can AHK change the settting XEROX Black and White form On to OFF, and should this be done?
Tips and tricks are very welcome!

Thanks in Advance!


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

Re: Can Autohotkey change Printer settings?

Post by BoBo » 03 Aug 2022, 00:29

@mrdigitalis - what's the printer model/type (generic drivers are used for several types!)?? There's a good chance that you could trigger the printers properties from the command line (IMHO, preferable).

mrdigitalis
Posts: 67
Joined: 23 May 2022, 01:17

Re: Can Autohotkey change Printer settings?

Post by mrdigitalis » 03 Aug 2022, 14:53

@mikeyww sounds interesting, but how does it work? I have a little try, but it does not work.

Code: Select all

; De functie zet de default printerinstelling Zwart/Wit om in kleur.
Set_Color_ON()
{
   ;Control, ChooseString, String [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
   
   Control, ChooseString, "Xerox Black and White" ,"\\PRN-MNG01\Xerox_Secure Properties", ComboBox3, "Off (Use Document Color)"
}
[attachment=0]image.png[/attachment]
         
Set_Color_ON()
Attachments
image.png
image.png (65.71 KiB) Viewed 900 times

mrdigitalis
Posts: 67
Joined: 23 May 2022, 01:17

Re: Can Autohotkey change Printer settings?

Post by mrdigitalis » 03 Aug 2022, 14:59

@BoBo It is a: Xerox Versalink C7030
And this is the driver:
image.png
image.png (96.13 KiB) Viewed 894 times
It is on the companies Computer, and I cannot run a CMD command, but batches are possible.

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Can Autohotkey change Printer settings?  Topic is solved

Post by mikeyww » 03 Aug 2022, 19:11

By default, AHK commands use literal strings rather than expressions. An example is below.

Code: Select all

Gui, Font, s10
Gui, Add, Text    , w230, ABC
Gui, Add, ComboBox, wp  , A||B|C
Gui, Add, Text    , wp  , DEF
Gui, Add, ComboBox, wp  , D||E|F
Gui, Add, Text    , wp  , Xerox Black and White
Gui, Add, ComboBox, wp  , Off|On||
Gui, Show,, Test

#IfWinActive ahk_class AutoHotkeyGUI
F3::
Control, ChooseString, Off, ComboBox3
SoundBeep, 1500
Return
#IfWinActive

mrdigitalis
Posts: 67
Joined: 23 May 2022, 01:17

Re: Can Autohotkey change Printer settings?

Post by mrdigitalis » 07 Aug 2022, 07:41

@mikeyww
You example code works perfect, but is there a possibilty to use ChooseString in my Xerox window? Or is it just usable in a GUI-situation?
image.png
image.png (65.95 KiB) Viewed 584 times

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Can Autohotkey change Printer settings?

Post by boiler » 07 Aug 2022, 07:56

The Control… commands such as Control and ControlGet are meant to be used with any window, while commands like GuiControl and GuiControlGet are for use only with GUIs that your script generates.

The purpose of mikeyww’s code was to demonstrate how you could use it on your window, and he created a GUI because he doesn’t have your Xerox software installed.

Use the Window Spy tool that came with AHK to get the names of the controls in your window.

mrdigitalis
Posts: 67
Joined: 23 May 2022, 01:17

Re: Can Autohotkey change Printer settings?

Post by mrdigitalis » 08 Aug 2022, 13:56

@boiler and @mickeyww

Yeah, it works! Thank you!

Post Reply

Return to “Ask for Help (v1)”