Jump to content

Query The Current Printer Name Set For Adobe Reader X


water
 Share

Recommended Posts

I'm running Adobe Reader 10.1.5 on Windows 7 64 bit german version. AutoIt is 3.3.8.1 and 3.3.9.4.

When I try to extract the currently selected printer from the combobox I always get the first 4 correct characters (the correct result has about 20 characters). Sometimes the returned string is longer but contains garbage from character 5 onwards.

Examples (text in [] is a single control character display with black background):

EG[DC1][GS][sTX]

EGainThreadWndClass

I open a PDF file and then run the following test script:

#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
$sAdobeWindow = "Adobe Reader" ; <== Window title for the PDF document
$sPrintDialog = "Drucken" ; <== Window title for the print dialog
AutoItSetOption("WinTitleMatchMode", 2)
ConsoleWrite("1: " &amp; @error &amp; @LF)
$Result = WinActivate($sAdobeWindow)
ConsoleWrite("2: " &amp; $Result &amp; @LF)
$Result = Send("^p")
ConsoleWrite("3: " &amp; @error &amp; @LF)
$Result = WinWait($sPrintDialog, "")
ConsoleWrite("4: " &amp; $Result &amp; @LF)
$Result = WinActivate($sPrintDialog, "")
ConsoleWrite("5: " &amp; $Result &amp; @LF)
$Result = ControlCommand($sPrintDialog, "", "[CLASS:ComboBox; INSTANCE:1]", "GetCurrentSelection", "")
ConsoleWrite("6: " &amp; $Result &amp; "-" &amp; @error &amp; "-" &amp; StringLen($Result) &amp; @LF)

I ran the script as 32 and 64 from SciTE and compiled with/without UPX. Tried several PDF documents, restarted the computer but always get the same result.

Does anyone know what's going on?

The final goal is not to query the current selection but to set a new printer.

Edit: The AutoIt Window Info Tools result for the ComboBox:

>>>> Control <<<<

Class: ComboBox

Instance: 1

ClassnameNN: ComboBox1

Name:

Advanced (Class): [CLASS:ComboBox; INSTANCE:1]

ID:

Text:

Position: 69, 15

Size: 250, 24

ControlClick Coords: 162, 12

Style: 0x56000413

ExStyle: 0x00000000

Handle: 0x0000000000020B20

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Looks like a bit of an overkill to get the content of a ComboBox. Because this should be possible with Autoit commands.

It works (somehow) but just doesn't return the full entry. Maybe a bug?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:bye: Perhaps, simple workaround (just select your printer in combo-box and then run this code):

ControlClick('Print', '', '[CLASS:Button; INSTANCE:1; TEXT:&Properties]')
;Sometimes doesn't work in the first place
ControlClick('Print', '', '[CLASS:Button; INSTANCE:1; TEXT:&Properties]')
Sleep(1000)
Const $TITLE = WinGetTitle("[ACTIVE]")
$PRINTERNAME = StringReplace($TITLE, ' Properties', '')
WinClose($TITLE)
msgbox(64, '', 'Printer active: ' & $PRINTERNAME)

Works nice for me, I use Samsung SCX-4300 series. ControlGetText, ControlCommand etc. are not working for me as well.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...