Jump to content
Sign in to follow this  
water

Query The Current Printer Name Set For Adobe Reader X

Recommended Posts

water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
stormbreaker

: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

Share this post


Link to post
Share on other sites
GMK

Have you tried using the API?

Share this post


Link to post
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
Sign in to follow this  

×