From francisco.leskovar at gmail.com Wed Feb 12 03:50:19 2020 From: francisco.leskovar at gmail.com (Francisco Leskovar) Date: Wed, 12 Feb 2020 09:50:19 +0100 Subject: [python-win32] C# ref argument in pywin32 COM server Message-ID: Hi there! I am using win32com.server to make a COM server with Python that is used by a C# app. I want to implement a C# function in a Python COM server that looks like this: public void GetArgs(ref string[] connArgs){ connArgs= new string[3] { "a", "b", "c" };} I have tried different approaches with Python but none seem to work. Tried looking for the documentation but cannot find how to handle arguments that are passed as reference to Python in the server side. Returning a list or tuple of utf-8 encoded strings causes the error "All dimensions must be a sequence of the same size". Any suggestions on how to approach this? Thanks in advance for the help. Kind regards, Francisco -------------- next part -------------- An HTML attachment was scrubbed... URL: From citycarter73 at yahoo.com Mon Feb 24 13:31:11 2020 From: citycarter73 at yahoo.com (Aidan Carter) Date: Mon, 24 Feb 2020 18:31:11 +0000 (UTC) Subject: [python-win32] printing hard copies References: <1939398455.924428.1582569071255.ref@mail.yahoo.com> Message-ID: <1939398455.924428.1582569071255@mail.yahoo.com> Not sure if this is the appropriate place for this question, but I was wondering how one prints (hard copies, with an actual printer) PDF documents using python. For example, if I want to write a script to automatically print hard copies of pdfs saved on my computer. I have tried to search online for an answer and believe it should be possible through win32api / win32print but I haven't been able to find an approach that works. If this isn't the appropriate forum for this question any advice as to where I should look is appreciated! I am running python 3.7.4, 32 bit Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnf at jfcomputer.com Tue Feb 25 20:50:11 2020 From: johnf at jfcomputer.com (john) Date: Tue, 25 Feb 2020 17:50:11 -0800 Subject: [python-win32] determine the default printer from RDP Message-ID: Hi, I need a way to determine the default printer (on the users computer) from a RDP session. The user logs on to a RDP session and win32print.GetDefaultPrinter() returns a blank.? That makes sense on the RDP session because there aren't any default printers.? RDP printing is directed to the default printer on the users desktop. Is there a way to get the default printer from the RDP session. Johnf -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnf at jfcomputer.com Wed Feb 26 11:51:12 2020 From: johnf at jfcomputer.com (john) Date: Wed, 26 Feb 2020 08:51:12 -0800 Subject: [python-win32] determine the default printer from RDP In-Reply-To: References: Message-ID: Thanks for the response - and yes I do have the printers checkbox - checked.? It returns a blank. Johnf On 2/26/20 8:48 AM, Terry Davis wrote: > Hi John, > > In the Windows RDP client, under "Show Options" -> "Local Resources" > -> section "Local devices and resources" is "Printers" checked? > > I haven't tried what you're referring to, but perhaps that setting is > relevant to your problem? > > - Terry > > On Tue, Feb 25, 2020 at 5:51 PM john > wrote: > > Hi, > > I need a way to determine the default printer (on the users > computer) from a RDP session. > > The user logs on to a RDP session and > win32print.GetDefaultPrinter() returns a blank.? That makes sense > on the RDP session because there aren't any default printers.? RDP > printing is directed to the default printer on the users desktop. > > Is there a way to get the default printer from the RDP session. > > Johnf > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From terry.y.davis at gmail.com Wed Feb 26 11:48:39 2020 From: terry.y.davis at gmail.com (Terry Davis) Date: Wed, 26 Feb 2020 08:48:39 -0800 Subject: [python-win32] determine the default printer from RDP In-Reply-To: References: Message-ID: Hi John, In the Windows RDP client, under "Show Options" -> "Local Resources" -> section "Local devices and resources" is "Printers" checked? I haven't tried what you're referring to, but perhaps that setting is relevant to your problem? - Terry On Tue, Feb 25, 2020 at 5:51 PM john wrote: > Hi, > > I need a way to determine the default printer (on the users computer) from > a RDP session. > > The user logs on to a RDP session and win32print.GetDefaultPrinter() > returns a blank. That makes sense on the RDP session because there aren't > any default printers. RDP printing is directed to the default printer on > the users desktop. > > Is there a way to get the default printer from the RDP session. > > Johnf > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnf at jfcomputer.com Wed Feb 26 22:07:26 2020 From: johnf at jfcomputer.com (john) Date: Wed, 26 Feb 2020 19:07:26 -0800 Subject: [python-win32] determine the default printer from RDP In-Reply-To: References: Message-ID: <21e35d09-714f-80fc-4bd6-237fa9ca69a2@jfcomputer.com> I was able to discover that a powershell command does in fact find the correct default printer. powershell.exe -command "& {(Get-WmiObject -class win32_printer | where {$_.default -eq $true}).name}" or ?Get-WmiObject -query "SELECT * FROM WIN32_PRINTER WHERE Default = TRUE" is there something in python-win32 I can do to get the same results. Johnf On 2/26/20 8:48 AM, Terry Davis wrote: > Hi John, > > In the Windows RDP client, under "Show Options" -> "Local Resources" > -> section "Local devices and resources" is "Printers" checked? > > I haven't tried what you're referring to, but perhaps that setting is > relevant to your problem? > > - Terry > > On Tue, Feb 25, 2020 at 5:51 PM john > wrote: > > Hi, > > I need a way to determine the default printer (on the users > computer) from a RDP session. > > The user logs on to a RDP session and > win32print.GetDefaultPrinter() returns a blank.? That makes sense > on the RDP session because there aren't any default printers.? RDP > printing is directed to the default printer on the users desktop. > > Is there a way to get the default printer from the RDP session. > > Johnf > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnf at jfcomputer.com Thu Feb 27 15:23:13 2020 From: johnf at jfcomputer.com (john) Date: Thu, 27 Feb 2020 12:23:13 -0800 Subject: [python-win32] determine the default printer from RDP In-Reply-To: References: Message-ID: <4de4cadf-bac7-e1e3-d1c5-1b42b285d8e2@jfcomputer.com> I have discovered a solution to the issue. import wmi c = wmi.WMI() ?wql = "SELECT * FROM WIN32_PRINTER WHERE Default = TRUE" ?for printer in c.query(wql): ??????? selectedPrinter = printer.caption where selectPrinter is the device name of the printer. Hope this helps somebody in the future. Johnf On 2/26/20 8:48 AM, Terry Davis wrote: > Hi John, > > In the Windows RDP client, under "Show Options" -> "Local Resources" > -> section "Local devices and resources" is "Printers" checked? > > I haven't tried what you're referring to, but perhaps that setting is > relevant to your problem? > > - Terry > > On Tue, Feb 25, 2020 at 5:51 PM john > wrote: > > Hi, > > I need a way to determine the default printer (on the users > computer) from a RDP session. > > The user logs on to a RDP session and > win32print.GetDefaultPrinter() returns a blank.? That makes sense > on the RDP session because there aren't any default printers.? RDP > printing is directed to the default printer on the users desktop. > > Is there a way to get the default printer from the RDP session. > > Johnf > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: