Re: [python-win32] WMI and Terminal Services

2011-03-28 Thread Mike Driscoll

On 1:59 PM, Tim Golden wrote:

On 25/03/2011 6:19 PM, Mike Driscoll wrote:

Hi,

I am looking for a way to query the client name parameter from Terminal
Services. I have been testing several scripts I've found that use either
win32com.client or win32ts, but they are giving me weird errors on
Windows 7 64-bit.

I get this traceback:

traceback

Traceback (most recent call last):
File \\server\loginscript$\getTSInfo.py, line 10, in ?
  for objItem in colItems:
File
\\server\loginscript$\Python24\lib\site-packages\win32com\client\util.
py, line 84, in next
  return _get_good_object_(self._iter_.next(), resultCLSID =
self.resultCLSID)

pywintypes.com_error: (-2147217392, 'OLE error 0x80041010', None, None)
/traceback


Try this instead (using my wmi module 'cos I'm lazy):

code
import wmi

#
# Note the namespace
#
c = wmi.wmi (namespace=cimv2/TerminalServices)
for i in c.Win32_TSClientSetting ():
  print i

/code

TJG



That codes run just fine. I don't know if that's the info my colleague 
needs or not, but thanks a lot!


- Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] WMI and Terminal Services

2011-03-25 Thread Mike Driscoll

Hi,

I am looking for a way to query the client name parameter from Terminal 
Services. I have been testing several scripts I've found that use either 
win32com.client or win32ts, but they are giving me weird errors on 
Windows 7 64-bit.


I get this traceback:

traceback

Traceback (most recent call last):
  File \\server\loginscript$\getTSInfo.py, line 10, in ?
for objItem in colItems:
  File 
\\server\loginscript$\Python24\lib\site-packages\win32com\client\util.

py, line 84, in next
return _get_good_object_(self._iter_.next(), resultCLSID = 
self.resultCLSID)


pywintypes.com_error: (-2147217392, 'OLE error 0x80041010', None, None)
/traceback

When I run this:

code
objWMIService = win32com.client.Dispatch(WbemScripting.SWbemLocator)
objSWbemServices = objWMIService.ConnectServer(strComputer,root\cimv2)
colItems = objSWbemServices.ExecQuery(Select * from Win32_TSClientSetting)
for objItem in colItems:   # this is line 10
# code snipped
/code

If I try running this code instead:

code
server = win32ts.WTSOpenServer(.)
print server info  ,
print server
print - * 80

for s in win32ts.WTSEnumerateSessions(server, 1):
  if s['State'] == win32ts.WTSActive:
  print s
  session = s
/code

I get this:

traceback

Traceback (most recent call last):
  File \\debianis\loginscript$\getTSInfo.py, line 34, in ?
for s in win32ts.WTSEnumerateSessions(server, 1):
pywintypes.error: (5, 'WTSEnumerateSessions', 'Access is denied.')

/traceback

I'm assuming that this must be an incorrect way of accessing Telnet 
information on 64-bit Windows since it works on 32-bit. I never did 
figure out how to return the client name though except via the os 
module, like this: os.getenv(CLIENTNAME)


Is there a way to get it and other Terminal Services session information 
via these methods or WMI? Thanks!


--
Mike Driscoll
Applications Specialist

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Catching Send To in Office

2011-03-24 Thread Mike Driscoll

Hi Tony,

On 1:59 PM, Tony Cappellini wrote:



On 1:59 PM, Tim Roberts wrote:
 Mike Driscoll wrote:
 Does anyone know of a way to catch the Send To Mail Recipient in
 Microsoft Word or Excel? I want to redirect that to our web mail
 somehow.
 Well, let's brainstorm for a moment.  That link fires up the default
 mail provider for your computer, which in found in the registry.
 Theoretically, you ought to be able to rewrite that key to a browser
 command that brings up your webmail page, or to an application that does
 the same thing.  Check HKCU\Software\Clients\Mail or
 HKLM\Software\Clients\Mail.


Mike,

If I've understood you correctly ...
Why not just create a new sendto shortcut which points to your 
application,

and copy it to the SendTo directory?

I've created custom sendtos before, and it's quite convenient to make 
sendtos for other systems.
You then just right click and send entire directories across the 
network like this.







I think I know how to do the Send To right-click stuff now (thanks to 
the guys on this list and on wxPython IRC), the problem is catching the 
Send To inside MS Word, Excel, etc. They are not using the same process. 
Maybe I need to create my own VBA junk in them that does it for me. I'm 
going to try using procmon to try to see what Word is doing. If anyone 
has any ideas, that would be great. Thanks!


- Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Catching Send To in Office

2011-03-23 Thread Mike Driscoll

On 1:59 PM, Tim Roberts wrote:

Mike Driscoll wrote:

Does anyone know of a way to catch the Send To Mail Recipient in
Microsoft Word or Excel? I want to redirect that to our web mail
somehow.

Well, let's brainstorm for a moment.  That link fires up the default
mail provider for your computer, which in found in the registry.
Theoretically, you ought to be able to rewrite that key to a browser
command that brings up your webmail page, or to an application that does
the same thing.  Check HKCU\Software\Clients\Mail or
HKLM\Software\Clients\Mail.



Well, on my PC  HKLM\Software\Clients\Mail is set to MS Outlook, but 
HKCU\Software\Clients\Mail is set to Thunderbird. If I right-click a 
file on my file system and send to to Mail Recipient, it goes to 
Thunderbird. The Registry just has the name of the program in the keys, 
but nothing else.


If I try to use the Send To inside MS Word, I get an error dialog that 
says the following:


Word could not load the e-mail envelope. This could be caused by a 
network connection problem or a problem with your Office installation.


- Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Catching Send To in Office

2011-03-23 Thread Mike Driscoll

Hi Vernon,

On 3/23/2011 10:53 AM, Vernon Cole wrote:

One of the executives where I used to work actually made use of the
¨send to feature in Word.  The resulting bloat that appeared was
appalling, and IIRC the recipient had to have Word installed to read
the mail, when she finally imported it. Perhaps later versions of Word
do a better job.  Our answer was to teach the user to send e-mail
using a mail agent, not his word processor. YMMV.
--
Vernon



Yeah, we've tried to do that for several years. They've been using 
Zimbra Web mail for at least 3 years, but we still have users that claim 
they can't live without this ability. So I'm supposed to look into it.


- Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] odbc under windows 7?

2011-01-24 Thread Mike Driscoll

On 1:59 PM, Gary L Smith wrote:


Dear Pythoners,

I need to access data in an MS Access 2003 database using Python 2.5 
or 2.6 running in Windows7.  Windows7 doesn't seem to have appropriate 
drivers for ODBC.  My error messages consistently contain the phrase, 
Data source name not found and no default driver specified.


While I see that others have run into the same problem, my web 
searches have only deepened my confusion -- questions are routinely 
answered with suggestions that turn out to not work in Windows7.


Suggestions such as SQL Alchemy or pyODBC don't solve the problem, 
because it still boils down to the missing drivers.


This is a volunteer effort, so even the Egenix product, mxODBC, at $69 
is a little much.


Are there suitable open-source codes to get at Access 2003 data in 
Windows7?  Please point me in a productive direction, or, it it's just 
not possible, put me out of my misery.


Cheers, Gary Smith



I've used SqlAlchemy to get data out of MS Access, but you have to use 
one of the old 0.5 versions. I only did that on Windows XP though.


I also found this recipe which might help you: 
http://code.activestate.com/recipes/528868-extraction-and-manipulation-class-for-microsoft-ac/


--
Mike Driscoll

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Intenet explorer using PythonWin Help

2010-12-22 Thread Mike Driscoll

On 1:59 PM, Pat McGuire wrote:


I am new at programming with Python and am using Pythonwin.  I have a 
couple of questions'


1.  The code below after doc.FormName.submit() will navigate to 
the correct page but if I print the url it shows the url of the page I 
logged in at.  I thought submit would be just like if I clicked on the 
submit button.


import win32com.client
import win32api
ie = win32com.client.Dispatch( InternetExplorer.Application )
ie.Visible = 1
ie.Navigate(urlhere 
http://posting.www.backpage.com/classifieds/central/index)

while ie.Busy == True:
win32api.Sleep(1000)
doc = ie.Document
doc.FormName.email.value = emailaddress mailto:doublep...@gmail.com
doc.FormName.password.value = mypassword
doc.FormName.submit()

2.  Can you point me to a site that which show me how to access each 
type of form element, i.e. option, hrefs, links, etc



Any help is greatly appreciated.



I've heard good things about Mechanize: 
http://mechanize.rubyforge.org/mechanize/


It's not PyWin32, but it's probably easier to use than win32com methods.



--
Mike Driscoll

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How do I get the URL of the active tab in Internet Explorer

2010-11-30 Thread Mike Driscoll

On 1:59 PM, He Jibo wrote:

Hi,
I am writing a small program, which needs to get the URL of the active
tab in either of firefox, internet exploerer or chrome.
My need is similar as the one posted at,
http://stackoverflow.com/questions/3631216/how-do-i-get-the-url-of-the-visible-tab-in-firefox-ie-chrome 
http://stackoverflow.com/questions/3631216/how-do-i-get-the-url-of-the-visible-tab-in-firefox-ie-chrome


I did a lot of Googling, and get the following code. The following
code can get the url of the first tab in internet explorer. My
question is, how can I get the url of the current active tab? Thanks.

'''
http://efreedom.com/Question/1-2555905/Get-Internet-Explorer-Address-Bar-Python
http://blogs.msdn.com/b/oldnewthing/archive/2005/07/05/435657.aspx
http://mail.python.org/pipermail/python-win32/2004-June/002040.html
http://code.activestate.com/recipes/302324-browser-automation-tool-py-class-file/
'''
from win32com.client import Dispatch
import win32api, win32con,win32gui


SHELL = Dispatch(Shell.Application)

def get_ie(shell):
   for win in shell.Windows():
#print win
   if win.Name == Windows Internet Explorer:
   return win
   return None

def main():
ie = get_ie(SHELL)
   if ie:
   print ie.LocationURL
   print ie.LocationName
   print ie.ReadyState
   print ie
   print ie.Document.title
   print ie.Document.location
   print ie.Document.forms

#title = win32gui.GetWindowText(ie)
#print title

   else:
   print no ie window

if __name__ == '__main__':
   main()
---
He Jibo
Department of Psychology,
Beckman Institute for Advanced Science and Technology
University of Illinois, Urbana Champaign,
603 East Daniel St.,
Champaign, IL 61820
website: www.hejibo.info http://www.hejibo.info



It will probably be frowned on here, but one of the easiest ways would 
be to use SendKeys in combination with some Windows hackery. I have 
attached some code I came up with after getting help from several of the 
fine people on this list. It shows how to bring a window into focus by 
just passing in an expected string. In this case, you would want to use 
something like Windows Internet Explorer and have it search for that.


Once that's in focus, you can use the SendKeys package 
(http://www.rutherfurd.net/python/sendkeys/) to send an ALT+D to select 
the url and then CTRL+C to copy it. Then you can use the win32clipboard 
module from PyWin32 to grab the text from the clipboard.


It's a hack, but it's kind of fun. Of course, you can't use your PC 
while the script runs or you might interrupt the process and send the 
keys to the wrong window.



--
Mike Driscoll
Applications Specialist
Blog:   http://blog.pythonlibrary.org
import win32gui


def windowEnumerationHandler(hwnd, resultList):
'''
This is a handler to be passed to win32gui.EnumWindows() to generate
a list of (window handle, window text) tuples.
'''

resultList.append((hwnd, win32gui.GetWindowText(hwnd)))

def bringToFront(windowText):
'''
Method to look for an open window that has a title that
matches the passed in text. If found, it will proceed to
attempt to make that window the Foreground Window.
'''
secondsPassed = 0
while secondsPassed = 5:
# sleep one second to give the window time to appear
wx.Sleep(1)

print 'bringing to front'
topWindows = []
# pass in an empty list to be filled
# somehow this call returns the list with the same variable name
win32gui.EnumWindows(windowEnumerationHandler, topWindows)
print len(topWindows)
# loop through windows and find the one we want
for i in topWindows:
if windowText in i[1]:
print i[1]
win32gui.ShowWindow(i[0],5)
win32gui.SetForegroundWindow(i[0])
# loop for 5-10 seconds, then break or raise
handle = win32gui.GetForegroundWindow()
if windowText in win32gui.GetWindowText(handle):
break
else:
# increment counter and loop again
secondsPassed += 1
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] granting SeServiceLogonRight on a network account with pywin32?

2010-10-15 Thread Mike Driscoll

 On 1:59 PM, Tim Roberts wrote:

  Tim Roberts wrote:

However, I admit that NT security is a twisty maze of little passages,
all different, so it's quite possible this is just a wrong turn.

And I wonder how many of you are old enough to get the reference in that
sentence...



I'm pretty sure I played that adventure on an old DEC workstation in 
high school...


--
Mike Driscoll
Applications Specialist
MCIS - Technology Center
1 E. Main St.
Marshalltown, IA 50158
mdrisc...@co.marshall.ia.us
641-844-2802
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Simple Windows progressbar dialog (like messagebox) via Win32 API?

2010-10-01 Thread Mike Driscoll

 On 1:59 PM, pyt...@bdurham.com wrote:

I know there is a simple interface to the Windows messagebox interface.
Is there an equivalent type of simple dialog box for showing a 
progressbar or progressbar-like information?
Use case: I have a collection of Python command line utilties that can 
take up to several minutes to run. These are utilities may be called 
from other applications. Our users have asked whether these utilities 
can display a progressbar while they are running.
Our utilities are very lean right now and easy to distribute and 
support. We would like to avoid having to use Tkinter or large GUI 
frameworks like wxPython and pyQt if at all possible.

Thank you,
Malcolm


Stupid question, but since you're using command line utilities, why not 
just use a command line progress bar? This fellow wrote one that might 
work: 
http://coreygoldberg.blogspot.com/2010/01/python-command-line-progress-bar-with.html


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to click on a word confirm popup

2010-08-11 Thread Mike Driscoll

 On 1:59 PM, Axel Rousseau wrote:

Hi,
I've open and print word document with a python script (using
win32com.client) but some documents have macro which ask to click on
a confirm popup.
How can I automatically make this ?

Thank you for your help,

Regards,

Axel



You can try the following:

1) Open the document in Word and record a macro of you clicking the popup.
2) Stop the recording and open the macro to see what happened.
3) Replicate the code in Python

Good luck!


--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] SetPrinterDataEx or SetPrinterData

2010-06-14 Thread Mike Driscoll

Hi,

I am looking for a way to call SetPrinterDataEx or SetPrinterData so I 
can set some parameters for one our admins. For some reason, the new 
Brother printer we bought thinks that we're not admins, so we need a way 
to hack it. I can't find anything in Python about these functions. Here 
are the MSDN pages I found:


http://msdn.microsoft.com/en-us/library/dd145084%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/dd145083%28VS.85%29.aspx

I googled various terms, but it doesn't look like PyWin32 wraps either 
of these directly. Does anyone know any workarounds? Thanks!




--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Setting UserInitials in Office

2010-05-03 Thread Mike Driscoll

On 1:59 PM, Tim Golden wrote:

On 28/04/2010 14:23, Mike Driscoll wrote:


Sorry for the delay in checking this out. I was out of the office
yesterday. Your code almost worked for reading the key, but I get a
tuple back:


[goes back to check what he wrote...]

That's why my code does this (note the nearly-invisible
underscore before the equals), discarding the datatype
value which is the second item of the tuple returned:

username, _ = _winreg.QueryValueEx (k, UserName)

TJG



Ah...I must have had something in my eye at the time. Anyway, I figured 
out how to get the information from it, but not how to write it. I tried 
writing to the Registry using _winreg.SetValueEx and passed a plain 
string and then various encoded strings (like utf16, utf32, etc). It 
writes just fine, but if I open Microsoft Word and check for the new 
initials or Full Name, Word just shows junk.


- Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Setting UserInitials in Office

2010-04-28 Thread Mike Driscoll

On 1:59 PM, Tim Golden wrote:

On 27/04/2010 22:43, Tim Roberts wrote:

Tim Golden wrote:

On 26/04/2010 23:56, Tim Roberts wrote:

Mike Driscoll wrote:

...
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo

I tried to use the base64 module to decode it, but I must be doing
something wrong. Does anyone know of a good way to get and set this
information? I am dealing with users on Windows XP and Python 2.4


???  The strings in there are not encoded in any way.  They are
plaintext Unicode strings.  They happen to be identified as 
REG_BINARY,

but that's just a silly accident.


On my (WinXP SP3, Office 2003) machine, they look to be utf16-encoded
strings (null-terminated):


Exactly.  They are really just REG_SZ, although they set the type as
REG_BINARY for their own inscrutable reasons.



Ah. Amazing how I managed to read your explanation and then internally
translate it into meaning something rather different.

Hopefully my code will have helped the OP out at any rate... I seem to be
having a bad week for offering help :)

TJG



Sorry for the delay in checking this out. I was out of the office 
yesterday. Your code almost worked for reading the key, but I get a 
tuple back:


('m\x00l\x00d\x00\x00\x00', 3)

So I had to change your last line to: print repr (res[0].decode (utf16))

I'll try setting the value later today since that's the main goal of 
this little project. I suppose I'll need to encode it in utf16 too. 
Thanks for the assist!


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Setting UserInitials in Office

2010-04-26 Thread Mike Driscoll

Hi,

I am looking for a way to set the UserInitials and Username in Microsoft 
Office applications. The reason is that we have had some users who have 
managed to put their initials into some Office programs when a different 
user was logged in and this has made it difficult to tell who has what 
open. From what I've read so far, the information is encoded in the 
Registry here:


HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo

I tried to use the base64 module to decode it, but I must be doing 
something wrong. Does anyone know of a good way to get and set this 
information? I am dealing with users on Windows XP and Python 2.4


Thanks,

- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] administration script

2010-03-25 Thread Mike Driscoll

On 1:59 PM, pacopyc pacopyc wrote:
Hello, I'm a NT domain system administrator and I'd like develop 
simple administration scripts with Python. I'm not expert and then I 
need some examples to understand. Initially I must listing all LAN's 
PC, for each PC get users and password, change password local 
administrator, run shutdown machines after 21:00 (also printer), get 
listing installed software, change PC's name. Can you help me?


Thanks
Here's a few links on the subject, however Tim is correct. Checking out 
VBScript examples is a good was too learn too.


http://timgolden.me.uk/python/wmi/
http://timgolden.me.uk/python-on-windows/
http://gallery.technet.microsoft.com/ScriptCenter/en-us/site/search?f[0].Type=ScriptLanguagef[0].Value=Pythonf[0].Text=Python
http://www.blog.pythonlibrary.org/tag/windows/


--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app?

2010-03-23 Thread Mike Driscoll

Hi Malcolm

On 1:59 PM, pyt...@bdurham.com wrote:
Is there a Windows API call I can use to display a BMP or a PNG file 
in a window centered on a user's display? This function would be 
called from a console app to display a splash screen.
Motivation: I would like some of our customer facing Python console 
utilities to display a splash screen. I don't need the complexity of a 
full GUI framework like wxPython or pyQT and hopefully I can avoid the 
need to use a full library like PIL.

Thank you,
Malcolm


There are ways to significantly reduce the wxPython footprint in your 
py2exe binary. Ask on the mailing list. Steven Sproat was talking about 
some methods last month and I think he said he had an exe that was 5 or 
7 MB when he was done.




--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] MAPI with win32com

2010-03-22 Thread Mike Driscoll

Hi Werner,

snip

I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611Edisplaylang=en 



At least I get past the above error, will see how far I get with this.
 but that still only gives you access to Exchange, not to

whatever interface TB exposes.
Clients and me using TB are fine, I support that with the 
simplemapi.py (http://www.johnnypops.demon.co.uk/python/simplemapi.py) 
and it works fine, but clients who use Outlook (e.g. Office 11) get a 
MAPI error 2 (failure).


TJG


I don't want to use Outlook, but I like to provide an additional way 
of sending problem reports from within my application to me (MAPI, 
smtplib), so hoped that I could use extended MAPI stuff.


I guess I just have to get my hands onto an Outlook to be able to test 
this stuff.



Werner




I found this recipe: http://code.activestate.com/recipes/149461-mapi-send/

Since we dropped Exchange in favor of Zimbra, I cannot test this 
solution, but maybe it will help you. By the way, is smtplib not working 
for you?


--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to query the peak commit charge

2010-03-01 Thread Mike Driscoll

Hi Mark,

On 2/26/2010 5:14 PM, Mark Hammond wrote:

On 27/02/2010 2:22 AM, Mike Driscoll wrote:

Hi,

I have been tasked with trying to find a way to query the peak commit
charge of our various workstations. It would be great if I could do it
remotely, but logging is also a possibility. Unfortunately, my Google
skills have failed me as I can't find anyone else who is doing this
publicly. Do you guys have any hints for how best to approach this task?

Here's the use case: We are using Sun Ray virtual desktops and are
trying to figure out how much RAM each VM is using. We are trying to
decide if we can shrink the allocated amount of RAM of if we should just
upgrade the servers.


Maybe look into the win32pdh/win32pdhutil modules?

Mark


I must be dense, but I'm not seeing how to tell win32pdh which counter I 
want it to count. I did some research on Google and Windows forums and 
they seemed to either have nothing on the subject or they would mention 
the Win32_PerfFormattedData_PerfOS_Memory class. I tried querying that 
with Tim Golden's WMI, but this class only seems to expose the Total 
commit charge and the limit commit, but not the peak (see 
http://msdn.microsoft.com/en-us/library/aa394268%28VS.85%29.aspx).


The only other hint I found was this: 
http://forum.sysinternals.com/forum_posts.asp?TID=15540PID=75852 where 
someone says the following: The only way I'm aware of that one can get 
this detail is from the uMmPeakCommitLimit member of the 
SYSTEM_PERFORMANCE_INFORMATION structure one passes to 
NtQuerySystemInformation when calling it with the 
SystemPerformanceInformation type.


Unfortunately, I don't have a clue as to how to do that in Python. From 
what I've seen on the list about NtQuerySystemInformation, it doesn't 
sound like PyWin32 wraps it. Is that correct? Thanks!


- Mike


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] How to query the peak commit charge

2010-02-26 Thread Mike Driscoll

Hi,

I have been tasked with trying to find a way to query the peak commit 
charge of our various workstations. It would be great if I could do it 
remotely, but logging is also a possibility. Unfortunately, my Google 
skills have failed me as I can't find anyone else who is doing this 
publicly. Do you guys have any hints for how best to approach this task?


Here's the use case: We are using Sun Ray virtual desktops and are 
trying to figure out how much RAM each VM is using. We are trying to 
decide if we can shrink the allocated amount of RAM of if we should just 
upgrade the servers.


Thanks,

- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python Automation Question

2010-02-22 Thread Mike Driscoll

Hi Greg,

On 1:59 PM, Roberts, Gregory (Contractor) wrote:

We have decided to oset the default printer in a macro which we must run
on the excel report and hope that all will work on Monday when in
production.

I would like to find a python solution which I could refactor into the
correct place.  Again, my wits with Python still have not formed.
Also... I am unable to dedicate to much time to this task for the time
being.

Thanks for the suggestions.  I will try and think outside the box using
them as guidance.

Greg


   


I'm not sure why the other PyWin32 guys didn't mention this, but you can 
do either of the following:


import  win32print
win32print.SetDefaultPrinter('My Printer Name')

import  subprocess
subprocess.call(r'rundll32 printui.dll PrintUIEntry /y /n\\UNC\path\to\printer')


I have a couple of other tips here: 
http://www.blog.pythonlibrary.org/2010/02/14/python-windows-and-printers/  
and Tim Golden's site has at least one other script based on printers:
http://timgolden.me.uk/python/wmi/cookbook.html#show-print-jobs 
(although it has nothing to do with what you're doing).


The other guys had good suggestions too though.


--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Question concerning wmi c.CIM_DataFile

2010-01-11 Thread Mike Driscoll

On 1:59 PM, Tim Golden wrote:

On 04/01/2010 21:18, Mike Driscoll wrote:

The OP should check out Tim Golden's winshell module as it gives access
to the common folders quite easily:

http://timgolden.me.uk/python/winshell.html


Thanks for the plug, Mike. Problem is that the
OP is after running this code on multiple machines (ie
remotely) so the winshell approach won't work.

TJG



I must have read the question wrong then. At my workplace, we use the 
winshell module in our login scripts, so it works fine on remote 
machines. Alas, I didn't realize he was wanting to do it from his own 
machine or I wouldn't have said that.


Anyway, thanks for the handy module. I use it a quite a bit for various 
manipulations of files on user accounts.


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Question concerning wmi c.CIM_DataFile

2010-01-04 Thread Mike Driscoll

On 1:59 PM, Tim Roberts wrote:

Kelvin Lomboy Mendez wrote:
   

I'm currently writing a script to access approximately 400 computers
for removing a particular app from the system. I'm having problems
getting results using the wmi c.CIM_DataFile (name=file). When I use
file as a variable which equals to the path to the app I want to
remove I don't get nothing back, however, if I hard code the path, I
get results. See snippet below for an example of what I'm talking
about. I appreciate in advance for any help I can get. Thank you.



import wmi

import re



def queryFile(file, host):

 print '[Debug nukeXmas()]:' + file

 c = wmi.WMI(host)

 for f in c.CIM_DataFile (name=file):

 print 'Install Date:', f.InstallDate



def queryFile2(file, host):

 print '[Debug nukeXmas()]:' + file

 c = wmi.WMI(host)

 for f in c.CIM_DataFile
(name=C:\\DOCUME~1\\profileName\\LOCALS~1\\Temp\\Temporary Directory
1 for deluxetreee (2).zip\\Christmas.exe):

 print 'Install Date:', f.InstallDate



  #File to query

string = C:\DOCUME~1\profileName\LOCALS~1\Temp\\Temporary Directory 1
for deluxetreee (2).zip\Christmas.exe



#Substitute \ to \\

path = re.sub('', '', string)

 

Don't do this.  You WANT the string to contain single backslashes.  This
is one of the most confusing things about working with strings in Python
on Windows.  Here's a test.  How many characters are in this string?

 xyz = a\\b\tc

The answer is 5.  There's a letter a, a backslash, a letter b, a
tab, and a letter c.

When you pass a file name into an API, the name should only contain
single backslashes (or forward slashes -- both work equally well in the
Win32 API).  In order to GET single backslashes in a Python string
literal, you need to type TWO (or use the raw rstring concept), but
the string itself only contains one.

   

#Close query path with double quotes

file = ''+path+''

 

Don't do this either.  The file name does not contain quotes.  If you
are typing the file name on a command-line, you have to provide quotes
so they get handled by the command line parser properly, but when you're
calling an API, you should NEVER use quotes.

   

#I'm having problems here, query brings back nothing

queryFile(file, '172.27.1.5')

 

Right, because the file name you are passing here is literally this:
 C:\\DOCUME~1\\profileName\\LOCALS~1\\Temp\\Temporary Directory 1
for deluxetreee (2).zip\\Christmas.exe

   



#Here, I hard code the path to the exe and it works

queryFile2(file, '172.27.1.5')

 

Right, because the file name you are passing here is literally this:
 C:\DOCUME~1\profileName\LOCALS~1\Temp\Temporary Directory 1 for
deluxetreee (2).zip\Christmas.exe

And THAT is what the file name really is.

By the way, your whole concept is loony.  This will not work at all on
Vista or Win 7, because the Documents and Settings tree is now called
Users.  You are assuming that every system is going to have this file
as ...tree (2).zip, but depending on how many times it has been
downloaded, it might be called something different (like ...tree.zip
or ...tree(3).zip).  Further, the directory names you are using are
configurable.  They don't have to be called Documents and Setting or
Local Settings, and they don't have to be located on C:.  You should
be using the shell folder APIs to find the names of the well-known
folders.

Plus, the whole Local Settings\Temp folder is volatile.  You should
just be able to wipe out that whole directory without causing any damage.

   


The OP should check out Tim Golden's winshell module as it gives access 
to the common folders quite easily:


http://timgolden.me.uk/python/winshell.html



--
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Unmuting the Microphone

2009-11-09 Thread Mike Driscoll

Hi,

I received a request to un-mute the microphone on Windows XP. I've 
looked around online and all I've seen are people recommending ctypes, 
but no examples (in Python). I did find this C++ code, but I can't tell 
if if just toggles mute or allows the programmer to specify that they 
want the mic unmuted. Here's the link: 
http://www.associatedcontent.com/article/1171176/how_to_mute_or_unmute_the_system_volume.html?cat=59


I found an even longer piece of c# code, but it looks like it's mostly 
constants:


http://blog.xploiter.com/c-and-aspnet/muting-audio-channels-mixer-control-api/

Does anyone have any tips or could point me in the right direction? I 
didn't find any obvious wrappers in the docs.


Thanks,

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] thread not posting events woes

2009-09-14 Thread Mike Driscoll

Tim Roberts wrote:

Jeff Peery wrote:
  

Hello,
I'm having trouble catching events from my multi threaded app. I'm
using wxpython and running several threads under the main wxApp
thread. One of the threads creates a COM object for an OPC server. 
I'm using dispatchWithEvents() to get the COM object. When I do this

the server will post an event to the OnDataChange() method in my
application.
 
Everything runs wonderfully when I create the COM object within the

main thread (wxApp). However if I create it from within a sub thread
then the OnDataChange is not being called.
 
My understanding of how multithreaded applications work is basic. I'm

using queue's and threading.locks to safely manage data. However I
don't understand how messages and events are handled in multi threaded
apps with different apartments. The COM object I created is a client
to an OPC server. I suspect the server lives in a different apartment
and that I must handle how messages and events are passed between
different threads/apartments.




Every thread in a Windows application has its own message queue.  If you
create a COM object in a different thread, then its messages will all be
delivered to that thread's queue.  However, wxPython is only responding
to messages on the main thread, where you created the window.

Is there a way you can organize things to create your object in the main
thread?  If not, you need to have a message pump in the second thread
dispatching messages.  I can do that in C, but I honestly don't know how
to do that in Python.

You might ask this question on the wxPython mailing list, although it
may be a bit obscure for them.

  


I'm probably being naive, but I think using wx.CallAfter or wx.CallLater 
in combination with pubsub (http://wiki.wxpython.org/PubSub) would be 
one of the easiest ways to send messages back to your application.


---
Mike Driscoll

Blog:   http://blog.pythonlibrary.org


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem registering Python COM object

2009-08-13 Thread Mike Driscoll

Gary Smith wrote:


Re: Problem registering Python COM object (suddenly)

Hi,

I’ve been volunteering for the Research Dept. of Selby Botanical 
Gardens here in Sarasota, FL. In support of my project I wrote a 
Python COM server to extend Python’s regular expression capabilities 
to VB. (I’m aware of VB regular expression support, which doesn’t 
include look-behinds.)


The computer I use at the Gardens has XP SP2 and Access 2003. Two or 
three weeks ago I installed Pywin32 (Active State) at the Gardens by 
downloading the latest version of 2.5 (build 211?). At home I run 
Active State 2.5 211.1.





ActiveState must not be keeping up. The latest version is 214. See here: 
http://sourceforge.net/projects/pywin32/files/




I believe the software is up-to-date. When I originally installed my 
Python COM object, the Access application ran flawlessly. However, 
after a week’s absence, I can’t even seem to register the COM object 
(which has changed).


The symptoms occur during a query that computes a value using the COM 
object. I get the Access message “Error ??? the object doesn’t support 
that method”. If I stop the query with a break point in VB, I can see 
that my object exists (probably from the DIM statement). However, it 
doesn’t seem to be associated with the Python COM object.


Everything works swimmingly at my development computer. Between last 
week’s visit and today’s visit, things won’t work at the Gardens.


The computer there is very low on C: disk space. Could this have an 
effect on win32com’s registration of the COM object?





You can free up some space on the hard drive by going to Start, 
Programs, Accessories, System Tools and Disk Cleanup.


I can't tell if anything is wrong with the code or not as I try to limit 
my COM experience. Hopefully someone else here will pipe up.


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Winshell issues

2009-08-12 Thread Mike Driscoll

Michael M Mason wrote:

Hi,

I've been using Tim Golden's winshell module for a couple of years and



  
just in the last week or so, I've been receiving the following error 
from multiple users:


Traceback (most recent call last):
  File \\debianso\loginscript$\MCISpy.py, line 267, in ?
import SoScripts
  File


\\debianso\loginscript$\PythonPackages\Utilities\SoScripts.py, line
49, in ?
  
program_files =inshell.programs() 
  File


\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py, line
71, in programs
  

return get_path ((shellcon.CSIDL_PROGRAMS,


shellcon.CSIDL_COMMON_PROGRAMS)[common])
  

  File


\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py, line
44, in get_path
  

return shell.SHGetPathFromIDList (shell.SHGetSpecialFolderLocation


(0, folder_id))
  

com_error: (-2147024893, 'The system cannot find the path


specified.', None, None)

Does it work any better if you try this (in the Python Shell):-

  

from win32com.shell import shell, shellcon
shell.SHGetFolderPath (0, shellcon.CSIDL_COMMON_PROGRAMS, None, 0)



I'm using Python 3 so I had to mess about to get winshell.py to work.
I've also found that the results returned from winshell are byte arrays
whereas the results returned from the example above are strings.  I
don't know whether that matters in Python 2.4, but it matters in Python
3.

I have no idea at all why you should suddenly have a problem if it was
working before.

  


Well, I haven't figured it out either. One of my colleagues suggested 
that maybe a MS update broke something, which is possible I suppose. 
They've been releasing a lot of updates lately. For the time being, I've 
wrapped it in a try/except and am creating the path in a more convoluted 
fashion if it fails. Not ideal, but it works. Hopefully Golden will have 
an idea.



- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Winshell issues

2009-08-11 Thread Mike Driscoll

Hi,

I've been using Tim Golden's winshell module for a couple of years and 
just in the last week or so, I've been receiving the following error 
from multiple users:


Traceback (most recent call last):
 File \\debianso\loginscript$\MCISpy.py, line 267, in ?
   import SoScripts
 File \\debianso\loginscript$\PythonPackages\Utilities\SoScripts.py, line 49, 
in ?
   program_files = winshell.programs() 
 File \\Debianis\loginscript$\Python24\lib\site-packages\winshell.py, line 71, in programs

   return get_path ((shellcon.CSIDL_PROGRAMS, 
shellcon.CSIDL_COMMON_PROGRAMS)[common])
 File \\Debianis\loginscript$\Python24\lib\site-packages\winshell.py, line 
44, in get_path
   return shell.SHGetPathFromIDList (shell.SHGetSpecialFolderLocation (0, 
folder_id))
com_error: (-2147024893, 'The system cannot find the path specified.', None, 
None)


I don't understand why this is happening. Nothing has been changed with 
their Python install or the winshell module. Can this be caused if the 
user's remote roaming profile cannot be located and they end up logged 
in as a temporary user? Oddly enough, right before that line, I call 
winshell.desktop() and that works.


This is running from a Python 2.4 installation with winshell 0.2 (I 
think). As you can see from the paths above, it is running from a 
network location on a linux box, although the client is a Windows XP Pro 
box.


Thanks,

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Dealing with windows in Windows

2009-08-04 Thread Mike Driscoll

Kimmo Kekkonen wrote:

Hi!

I were wondering if it is possible to use Python to select a window
(by title or somehow) and then input text into it? I'd need the trick
to input text to program I am running from cmd. When program opens it
also opens one GUI window and focus to the cmd will lost. Now I'd
like to get focus back to cmd and then input text into it. I tried
PIPEs with Popen but after 6 hours of work it still did not work. I
think it is because of this my program.

Also I am trying to close active window. Is there a solution to send
alt+f4 to currently active window?

There's SendKeys: http://pypi.python.org/pypi/SendKeys/0.3

Or if you know the application will only have one instance running at 
any one time, you can use the sledgehammer approach and do one of the 
following:


from killProcName import killProcName
killProcName(procName)

or

import subprocess
subprocess.Popen('taskkill /f /im evilGUI_process.exe')


Note that the first method presumes that you have PyWin32 installed as 
it is included with that package. On my PC, it's located here: 
C:\Python25\Lib\site-packages\win32\scripts




I managed to do these tricks using WSH but I would like to use Python
so I would not have to do these window activations and closing by
WSH. Then I will have 100% Python script without any others.

Thanks in advance! 


HTH

- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Please suggest me a good Python MAPI module...

2009-08-03 Thread Mike Driscoll

durumd...@gmail.com wrote:

Hi!

I'm searching a good Python MAPI module...

I wanna send many pictures, I wanna split them into 5 MB sized mails, 
and I wanna see them in default mailer as new mails.


The sending is not needed, only mapi call with New mail/Mailto and 
with attachments.


Thanks for your help:
   dd


I think you're looking for is the email module. See the following:

http://docs.python.org/library/email
http://docs.python.org/library/email-examples.html

The second link actually has code that sounds almost like what you want 
to do.


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Copying a MS Access Table

2009-07-29 Thread Mike Driscoll

Tim Golden wrote:
div class=moz-text-flowed style=font-family: -moz-fixed[copying 
back to the list]


Not sure how to reply to the thread, since I thought that if I reply 
to python-win32@python.org then it would start a new thread? 


Replying to python-win32@python.org is the right thing to
do; the mailing list software should recognise all the
clues it needs to continue the thread.


sebastian.ve...@uk.bnpparibas.com wrote:

Hi Tim,

I tried this:

a = win32com.client.Dispatch(access.application)
connStr = 'Driver={PostgreSQL 
Unicode};Server=%s;Database=%s;Uid=%s;Pwd=%s;ConnSettings=set 
TimeZone to -8; set search_path to pid,public;'


Well that surprised me: you're using Access as a frontend
to PostgreSQL?

a.OpenCurrentDatabase(r'C:/TEMP/db1.mdb')
a.DoCmd.CopyObject(connStr,'MyTable2',0,'MyTable1')


but it threw an exception that I couldn't interpret. Can you please 
help? 


This is obviously tricky with two different databases in the equation, 
one of them PostgreSQL, but what will be

most helpful is for you to produce an easily reproducible
sample which someone else can run, plus the traceback you
get. Going through this exercise may even cause you to
track down the problem yourself. In particular, try to
eliminate external dependencies: try to do the copy table
thing between two Access databases, or within the same
one (if that's possible; I haven't used Access in earnest
for a while now).

TJG




This may be a stupid idea, but I've used SqlAlchemy to get information 
out of Access before. Since SqlAlchemy is database-agnostic, you should 
be able to grab the info from Access, connect to another database with a 
pre-created matched db schema and just tell SqlAlchemy to put the data 
into it. For  the most part, it can translate db differences such that 
this will work without any (or few) issues.


Note that SqlAlchemy's support of Access is experimental. See the 
following thread: 
http://www.mail-archive.com/sqlalch...@googlegroups.com/msg06112.html


- Mike

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem with Python win32com while loading facebook homepage

2009-07-27 Thread Mike Driscoll

Adrien,

Hi dear members of the python-win32 python mailing list,

I'm trying to connect to my facebook account.. I'd like to automate 
some tasks like closing applications requests, and why not automate 
task for application games of facebook, if I arrive to do this.


But I can't arrive to connect to homepage..
First, without win32com, the code page return by the script was a 
javascript script :


script type=text/javascript
(function(loc) { if (loc.pathname == '/') { return; } var uri_re =
/^(?:(?:[^:\/?#]+):)?(?:\/\/(?:[^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/;
var target_domain = ''; loc.href.replace(uri_re, function(all,
path, query, frag) { var dst, src; dst = src = path + (query ? '?'
+ query : ''); if (frag) { if (frag.charAt(0) == '/') { dst =
frag.replace(/^\/+/, '/') .replace(/_fb_qsub=([^]+)?/,
function(all, domain){ if (domain.substring(domain.length - 13) ==
'.facebook.com http://facebook.com') { target_domain =
'http://'+domain; } return ''; }); } else if (/|=/.test(frag)) {
var q = {}; var m = frag.match(/([^#]*)(#.*)?/); var arr =
(query||'').split('').concat((m[1]||'').split('')); for (var
i=0, length=arr.length; ilength; i++) { var t =
arr[i].split('='); if (t.length  t[0] != '') { q[t[0]] = t[1]; }
} var s = []; for (var i in q) { s.push(i+ (q[i]?'='+q[i]:'')); }
dst = path+'?'+s.join('')+(m[2]||''); } } dst =  + dst; if (dst
!= src) { window.location.replace(target_domain + dst); } });
})(window.location);
/script
scriptwindow.location.replace(http:\/\/www.facebook.com
http://www.facebook.com\/common\/browser.php);/script



After reading a little on the web ( I searched a solution to execute 
javascript code from python), I've found the next added lines, which 
use win32com. I have installed pywin32-214 (I use python 2.6.2).


See below my code :

# -*- coding:Utf-8 -*-
#!/usr/bin/python
import httplib
import urllib

Connexion = httplib.HTTP('www.facebook.com http://www.facebook.com')
Connexion.putrequest('GET', '/home.php')
Connexion.putheader('Host', 'www.facebook.com
http://www.facebook.com')
Connexion.putheader('Accept', 'text/html')
Connexion.putheader('Cookie', 'the_long_cookie_from_facebook')
Connexion.endheaders()
ErrCode, ErrMsg, Headers = Connexion.getreply()
Handle = Connexion.getfile()
Buffer = Handle.read()

from win32com.client.gencache import EnsureDispatch
ie = EnsureDispatch('InternetExplorer.Application')
ie.Navigate('http://www.facebook.com')
print ie.Document.documentElement.innerHTML

 
When I execute the script, I have this error :



Traceback (most recent call last):
  File C:\Documents and
Settings\adlemair\Bureau\exos\connectFacebook.py, line 18, in
module
from win32com.client.gencache import EnsureDispatch
  File C:\Python26\lib\site-packages\win32com\__init__.py, line
5, in module
import win32api, sys, os
ImportError: DLL load failed: Le module spécifié est introuvable.


Do you know why ? Do you arrive to execute this script on your side ?


Thank you so much for your advise

Best regards,

Why not just use the pyFacebook module? It wraps Facebook's API and 
would probably be more reliable for communicating with their services. 
Here's a link: http://wiki.developers.facebook.com/index.php/Python


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Examples of Win32Inet use

2009-07-07 Thread Mike Driscoll

Fadhley Salim wrote:

Now that SF seems to be back online, could somebody point me to some
examples for how to use the win32inet functions? 


There's almost no documentation for this library, and I have not managed
to find any examples working code which actually uses these functions. 


FYI, I'm still struggling to get win32inet.InternetOpen and
win32inet.WinHttpGetProxyForUrl to do anything sensible for me. I'd be
particularly delighted to see an example of how to use those functions. 


Thanks
  


There are lots of docs:

http://docs.activestate.com/activepython/2.4/pywin32/win32_modules.html
http://timgolden.me.uk/python-on-windows/
http://timgolden.me.uk/python/win32_how_do_i.html

However, there aren't tons of examples out there in the wild. What you 
should probably do is look up the functions you're interested in on 
MSDN. You can usually translate the examples there directly into Python 
code.


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] problem in making exe of python

2009-07-06 Thread Mike Driscoll

Marium,

hi all,
i m new to wx python.i found difficulty in making its exe.Although m 
using the code for exe as:

#
from distutils.core import setup
import py2exe
import sys,glob,os
 


if len(sys.argv) == 1:
sys.argv.append(py2exe)
 
# creates a standalone .exe file, no zip files


setup( options = {py2exe: {compressed: 1, optimize: 2, ascii: 
1, bundle_files: 1}},

   zipfile = None,
   windows = [{script: 'testing gui.py'}] )


but when i clicked gui.exe from dist folder then it raises module 
error as:


Traceback (most recent call last):
  File gui.py, line 1, in module
  File zipextimporter.pyo, line 82, in load_module
  File wx\__init__.pyo, line 45, in module
  File zipextimporter.pyo, line 82, in load_module
  File wx\_core.pyo, line 4, in module
  File zipextimporter.pyo, line 98, in load_module
ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd


Although with the help of this exe code i have generated many exe 
files(not based on wxpython)


Kindly help me in this regard.ur every suggestion will b honoured.
Thanks in advance!

Marium



This list is for developers that use the PyWin32 package or similar 
packages. You really want the wxPython or py2exe mailing list.


I have seen this error before though. I think it's related to not having 
one or more of the required dlls on your system. Make sure you have 
msvcp71.dll and MSVCR71.dll and (maybe) gdiplus.dll.


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] python and wow64 filesystem redirection

2009-06-23 Thread Mike Driscoll

Guy,

Hi all,

I have (2003/2008) x64 systems with 32bit python installed, and my 
code needs access to %SystemRoot%\system32, but the wow64 filesystem 
redirection thing is in my way.
I looked from the *Wow64DisableWow64FsRedirection *function in the 
win32 extensions, but I can't find it.


So, my question is, if that function is implemented in the extensions 
at all? is there another way to disable the redirection in python? or 
do I need to write a binary module that disables/enables the redirection?



Thanks in advance,
Guy



The usual answer is that if PyWin32 doesn't wrap it, do it with ctypes. 
Sometimes Roger or one of the others has some special way of 
accomplishing the task though...


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] python-win32 Digest, Vol 74, Issue 5

2009-05-04 Thread Mike Driscoll

python-win32-requ...@python.org wrote:

Send python-win32 mailing list submissions to
python-win32@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-win32
or, via email, send a message with subject or body 'help' to
python-win32-requ...@python.org

You can reach the person managing the list at
python-win32-ow...@python.org

When replying, please edit your Subject line so it is more specific
than Re: Contents of python-win32 digest...
  



Today's Topics:

   1. Re: Modify only the first line of a big file (Roughly 1.5MB -
  For thousands of file). (Robert)
   2. Re: Modify only the first line of a big file  (Roughly 1.5MB -
  For thousands of file). (Gerdus van Zyl)
   3. Python Windows MSI installs now fails with error  2755...
  (J. Marc Edwards)
  




Subject:
Re: [python-win32] Modify only the first line of a big file (Roughly 
1.5MB - For thousands of file).

From:
Robert kxrobe...@googlemail.com
Date:
Sun, 03 May 2009 13:01:27 +0200
To:
python-win32@python.org

To:
python-win32@python.org


Khalid Moulfi wrote:

Hi all,
 
I have thousands of file and I must update only the first line.
My concern is : is it possible to read only the first line for each 
of these files and update the first line only without reading the 
file completely ?
 
Version of Python is 2.2.1
 
Thanks for any help,
 


when the length of the line/initial bytes doesn't change (by means of 
enough balancing spaces or so) you can open the file in r+ mode and 
overwrite sections; e.g. after reading some bytes/line or so do 
f.seek(0) and overwrite the initial bytes.







Subject:
Re: [python-win32] Modify only the first line of a big file (Roughly 
1.5MB - For thousands of file).

From:
Gerdus van Zyl gerdusvan...@gmail.com
Date:
Sun, 3 May 2009 16:02:52 +0200
To:
python-win32@python.org

To:
python-win32@python.org


It seems it's not possible if as mentioned you aren't replacing a line
with a line of the same lenght/bytes. You then have to resort to using
intermediate files see: http://python.pastebin.com/f539b4e46

On Sun, May 3, 2009 at 1:01 PM, Robert kxrobe...@googlemail.com wrote:
  

Khalid Moulfi wrote:


Hi all,
 I have thousands of file and I must update only the first line.
My concern is : is it possible to read only the first line for each of
these files and update the first line only without reading the file
completely ?
 Version of Python is 2.2.1
 Thanks for any help,

  

when the length of the line/initial bytes doesn't change (by means of enough
balancing spaces or so) you can open the file in r+ mode and overwrite
sections; e.g. after reading some bytes/line or so do f.seek(0) and
overwrite the initial bytes.


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32




  




Subject:
[python-win32] Python Windows MSI installs now fails with error 2755...
From:
J. Marc Edwards jmarcedwa...@gmail.com
Date:
Sun, 3 May 2009 16:15:01 -0400
To:
python-win32@python.org

To:
python-win32@python.org


I am a new Python user.  I was experimenting with a variety of Python 
versions on Windows XP, e.g. 2.6.2, 3.0.1, ActiveState 2.6.2/3.0.1, etc.


 

I then also wanted to start using iPython, which I also installed on 
my Windows XP system.


 

I am also an emacs user, so I was trying to get the Python pdb 
debugger to work with emacs, but I was having problems that seemed to 
point to having multiple Python versions on my system.


 


So, I wanted to then clean my system up from all the Python versions.

 

After removing all of my Python versions, I then tried to re-install 
just Python 2.6.2.


 

However, I am now receiving an error message from the Windows MSI 
installer that says:


 


*The system cannot open the device or file specified.*

 


And then a windowed message:

 

*The installer has encountered an unexpected error installing this 
package.  This may indicate a problem with this package.  The error 
code is 2755.*


 

Now I can't install any of the previous Python packages on my Windows 
laptop.


 

I have tried researching this on the Internet, and it seems to 
indicate a Windows registry error point to an incomplete uninstall of 
an application, notably the previous Python versions that I had on my 
system.


 

Does anyone know how I could clean up the registry so that I can 
successfully reinstall Python?


 


Many thanks in advance, Marc

 



One way to go about it would be to back up your registry and then open 
regedit and do a search for the term python. Then delete those keys or 

Re: [python-win32] Probelm with win32api dll load failed

2009-03-31 Thread Mike Driscoll

Andrew Spagnoletti wrote:
Hi, 
? 
I have developed an application with Python 2.6 and wxPython and prepared the set up using py2exe and InstallJammer. 
? 
When I generated the installation from ?my Vista machine and then install it on an XP computer (not sure if there is any significance to the Vista - XP), when I run the installed program on the XP machine I get the following log (note that LegaliteInvoice contains the following import, but so does LegaliteMain ? which calls LegaliteViewTransactions which calls LegaliteInvoice): - 
from win32com.client import Dispatch 
? 
Traceback (most recent call last): 
? File LegaliteMain.pyw, line 13, in module 
? File LegaliteViewTransactions.pyc, line 8, in module 
? File LegaliteInvoice.pyc, line 7, in module 
? File win32com\__init__.pyc, line 5, in module 
? File win32api.pyc, line 12, in module 
? File win32api.pyc, line 10, in __load 
ImportError: DLL load failed: The specified procedure could not be found. 
? 
Any ideas? 
? 
 
Andrew Spagnoletti 
 
--


This is a py2exe question, but I think you need to specifically include 
the win32com library in your setup.py file that you use to build the 
executable with py2exe. See their docs for how to do that.


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] SetWindowTheme for Vista

2009-01-16 Thread Mike Driscoll

Hi,

There has been a discussion on the wxPython user's group about how the 
new QT licensing will affect wx's viability. They got  slightly 
off-topic and pointed out that the wx treectrl isn't wrapping Vista's 
theme like it should. They pointed to this article on setting the window 
theme: http://www.danielmoth.com/Blog/2007/01/treeviewvista.html


Is there a way to call SetWindowTheme in pywin32? I'm not sure if this 
would affect wx anyway, but I don't mind trying it out if I knew how to 
call it.


Thanks.

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Walking the registry and creating reg files

2008-12-05 Thread Mike Driscoll

Tim Roberts wrote:

Mike Driscoll wrote:
  

We're doing what amounts to a registry session audit here at work, so
I need to walk a specific set of subfolders in our registry and get
the contents thereof. The subfolders will vary from user to user. I
found Tim Golden's excellent registry walking script on his website here:

http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html


My problem is that I need to output the data into *.reg files. Is
there a builtin way to do that with _winreg or PyWin32 or do I just
need to roll my own?



I'm not answering the question you asked, but are you aware of the very
handy reg tool included with XP?  reg export can export a full key
in a format that is compatible with regedit.
reg export HKLM\system\CurrentControlSet\Services\vgasave  xxx.reg

  


I suppose I should have completely explained the project, but I didn't 
think the other details mattered. I will be running this as part of my 
login script, and writing each subfolder to a directory tree on a per 
user basis. We are trying to figure out which users have which sessions 
of a certain program and how to best manage said sessions and their 
respective configurations, hence the audit.


I wasn't aware of this function but I don't know if it will run on every 
XP machine I touch. I keep running into screwy oddities on our machines 
where stuff that I thought should be standard isn't actually there. I'll 
look into your suggestion and see if it's viable though. Thanks for the 
info.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Walking the registry and creating reg files

2008-12-05 Thread Mike Driscoll

Tim Golden wrote:
div class=moz-text-flowed style=font-family: 
-moz-fixedDahlstrom, Roger wrote:
If you can read the registry, you can save it without any other 
special permissions.  It is just text.


Just export a branch of your own registry and open it with notepad to 
see the format.  I do it all the time, it works fine.


You're quite right, Roger, and other people earlier in the thread
have more-or-less suggested this approach. I think Mike was looking
for something programmatic and there doesn't seem to be anything in
the API which offers the same output as the Export action gives you
from the menu.


Yeah, that's what I was looking for. I apologize for not making that 
clearer. Thanks for reading my mind, Tim!




My point about the backup (and later restore) privs refers to the
specific API calls RegSaveKey and RegRestoreKey. These produce
an opaque binary format which doesn't look quite so good in notepad. :)

TJG


As I said before, I'll give the export method a try since that's what 
most of the guys have suggested. Then I'll look at writing something 
myself that uses Python rather than subprocess if I can find a moment...


Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] rebooting windows from Python?

2008-12-05 Thread Mike Driscoll

Alec,


I've been using the following method that I found on
ActiveState's Cookbook, which I modified a little
(http://code.activestate.com/recipes/360649/):



Does that method ever hang during shutdown? I've tested the WMI method a few 
times and got one hang, where it was asking me to terminate a process during 
logout. This even though I'm specifying the force shutdown flag.

  


I haven't had it hang yet, but I'm using it for installing updates on 
freshly configured PCs, so theoretically, there's not much cruft running 
on the PCs I'm doing this to. We've had some McAfee and Nero related 
hangups when the user's restart their PCs, so it's possible that some 
poorly coded programs could hang it up...


All I can say is give it a shot and find out.

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to make python scripts output to current cmd window? (like linux terminal)

2008-11-18 Thread Mike Driscoll

Tim Roberts wrote:

Tim Roberts wrote:
  

sayeo87 wrote:
  


Right now on Windows I have added .py to my PATHEXT so that I can run .py
files by doing ./filename.py. But when I do this the output of the program
goes to a new command prompt window which instantly disappears. How can I
instead make the output go to the current command prompt window I'm working
in, like in a linux terminal?

Sorry if this has been answered before but I've googled high and low and
still can't seem to find how to do this.
  

  

What PATHEXT lets you do is run the command without specifying a path at
all.



I realized when I read my reply that I really did nothing to clear up
any confusion.  Allow me to provide an example.

Let's say I have c:\bin\remote.py, and client.py in the current
directory.  WIthout the file associations for .py and .pyw, I can say:
python client.py
pythonw client.py
If I set up file associations for .py and .py, then I can also say:
client.py
.\client.py
Further, as long as c:\bin is in the path, I can also say:
remote.py
  



Sorry to intrude, but what is C:\bin ? I don't have it on Windows XP 
and I couldn't find a bin folder in my Python25 directory either. Is 
this some kind of custom wizardry on your part?


Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Virtual print driver - similiar to winpdf

2008-09-23 Thread Mike Driscoll

geoff wrote:

Thanks for you guidance Tim.  After reviewing I am coming to the same
conclusion.

  

This is trickier than you might guess.  Does the application actually
write to the printer using a Windows printer driver?  Some old
applications that just used a printer for logging wrote directly to the
parallel ports.  That kind of thing is almost impossible to trap.  If it
does, how does it pick the printer?



The application is quite configurable.  Printers can be configured
so the application to write to either a port (including UNC path), a
Windows print driver or directly to a file that is specificed within
the application.  We typically use the generic/text driver to
define the windows printers, however, just pointing the app to
LPT1: works just fine too.

If it doesn't present you with a
  

dialog, then it might be picking the printer by name.  That means you
can't just install your own driver, unless you use the same name.  If it
does present you with a dialog, can you use the Generic / Text-Only
printer driver, and have it dump to a text file?  (That's one of the
standard printer drivers built-in to Windows.)



I have thought of the Windows printer defined as file however, I
don't want the user to be prompted for the file name each time and
haven't found a way to suppress this.

  

If you really need a driver, you are not going to be able to do this
from Python.  There are a sample printer drivers in the WDK (Windows
Driver Kit).  It is not a project to be undertaken lightly.



Yes, I am starting to understand that :-(

What we are trying to do is capture the printing dynamically while
the user is running the application ( -- think of invoice printing in
a business).  The app output is text, with some printer control codes
embedded to change fonts, colors, newlines, etc, but other than that
it is just ascii text printed line-by-line sent to the specificied
port or file.

The problem we see with the print to a file approach is we would
like the system to react immediately when the user prints and having
some sort of polling to watch the file isn't the best solution as it
introduces a delay/latency.

One option I was considering is using Windows printer defined as a
Standard TCP/IP Printer Port.  Our thinking is to manually configure
a printer in Windows and then use the LPR or RAW method of this print
monitor to redirect the output to our program via TCP/IP.  Haven't
tested this , however, the thinking is that this would tell us
immediately when the user is printing and our utility could re-act
accordingly.

Any thoughts or comments or guidance would be truly appreciated.

g.

  


You might take a look at Pyla. It's a print to fax library. I think it's 
kind of what you're talking about. I've been trying to hack it off and 
on for a while now as we only need a little of its functionality here at 
work. There isn't much for docs, so you'll have to read the source. 
Here's a link: http://www.teamsw.it/pyla/


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Internet Explorer constants

2008-09-05 Thread Mike Driscoll

Hi Gabriel,
div class=moz-text-flowed style=font-family: -moz-fixedEn Fri, 
05 Sep 2008 05:23:01 -0300, Tim Golden [EMAIL PROTECTED] escribió:



Gabriel Genellina wrote:

Hello
 I want to control Internet Explorer. This is what I have so far:
 import win32com.client
from win32com.client.gencache import EnsureDispatch
url = ...
IE = EnsureDispatch(InternetExplorer.Application)
IE.Navigate(url)
IE.Visible = 1
 It works fine and shows the requested page. Now I want to use the 
Save As command. Looks like I should call the
IWebBrowser2.ExecWB method, passing IDM_SAVEAS as the command and 
MSOCMDEXECOPT_DONTPROMPTUSER in the options. But I don't know how to 
obtain the value for such constants... I could dig into the C header 
files looking for them, but is there some other way?
 The ExecWB method is documented here 
http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx


The usual way to get at constants after a Dispatch
is via the win32com.client.constants object. In this
case, the constant you want is OLECMDID_SAVEAS which...

code
import win32com.client

IE = InternetExplorer.Application
ie = win32com.client.gencache.EnsureDispatch (IE)

print win32com.client.constants.OLECMDID_SAVEAS /code


Ok, thanks! Looks like these are the names to use instead:

IE.ExecWB(
  constants.OLECMDID_SAVEAS,
  constants.OLECMDEXECOPT_DONTPROMPTUSER,
  filename,
  None)

Altough the ...DONTPROMPTUSER option doesn't work - the Save As dialog 
always appears. Some kind of permission or safety measure, I presume.


My original intent was to save the file using the .mht format, but 
that format is not listed on the Save As dialog. I'll investigate 
using IMessage.CreateMHTMLBody but that's a different topic.




You could also look at PAMIE: http://pamie.sourceforge.net/  or 
Mechanize: http://pypi.python.org/pypi/mechanize/0.1.7b


I don't think either uses the PyWin32 library, but I hear that they're 
both pretty good.


---
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Pb IE8-b2 + Python like ActiveScripting language

2008-09-02 Thread Mike Driscoll

Michel Claveau wrote:

div class=moz-text-flowed style=font-family: -moz-fixedHi!

Impossible, for me, to use Python like ActiveScripting language, in a 
HTA, since IE-8 beta-2 installed.


Run OK with IE5, IE6, IE7. But IE8 does not recognize Python  (I 
however recorded several times python like language of ActiveScripting)


Any idea or solution?


I'll bee honest and say that I've never heard of an HTA. Upon doing a 
little research though, it looks like it's a self-contained web app of 
sorts. You might look at CherryPy. We use it for a web app on a couple 
of laptops and it works great. Of course, there's also IronPython + 
Silverlight. Both of these solutions are probably more complicated 
though.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Fwd: Renaming Excel Spreadsheets

2008-08-27 Thread Mike Driscoll

James Matthews wrote:



-- Forwarded message --
From: *Greg Lindstrom* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

Date: Tue, Aug 26, 2008 at 11:54 AM
Subject: Renaming Excel Spreadsheets
To: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Hello,

I am working with Python to create Excel spreadsheets and have run 
into a couple of problems I hope you can help me with.


First...are there any bindings/libraries into Open Office?

Now, back to Excel. 

-- Does anyone know a way to create N worksheets?  By default, 3 are 
created, but I would like more.


-- Is it possible to rename a worksheet inside of the workbook 
(change Sheet1 to July 08, for example).


I've been working with Mark Hammond's book on Windows programming with 
Python, but these have me stumped.


Better yet, an Open Source reporting system (ala Crystal Reports) 
would keep me from having to write this.  I've looked at Jasper and 
DataVision;


Thanks,
--greg

--
http://mail.python.org/mailman/listinfo/python-list



You might also look at Dabo, which has a Report Designer that's similar 
to Crystal Reports, but written in Python. There are a couple of 
screencasts here:


http://dabodev.com/documentation

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Created Map NetWork Drive is not visible in My Computer window

2008-08-25 Thread Mike Driscoll

siddhartha veedaluru wrote:

Hi,
 
i have used the following code to create Map NetWork Drive.

But it is not visble when i open My Computer window.
 
---

import win32net,time
data = {}
data['remote'] = r'\\fredo\Project'
data['local'] = 'K:'
data['user'] = 'builder'
data['password'] = 'builder'
data['asg_type'] = 0
data['status'] = 1
data['domainname'] = 'conindia'
win32net.NetUseAdd(None,1,data)
---
 
Help me in making it visible.
 
Regards,

Siddhartha


I recommend this method instead:

code
import win32wnet
from win32netcon import RESOURCETYPE_DISK as DISK

drive_letter = K:
path = \\fredo\Project
win32wnet.WNetAddConnection2(DISK, drive_letter, path)

/code

We use this method at my place of employment as part of our login script.

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Created Map NetWork Drive is not visible in My Computer window

2008-08-25 Thread Mike Driscoll

siddhartha veedaluru wrote:

That worked.
 
Thanks very much Mike
 
Sid



One thing I forgot to mention. You might want to check if that drive is 
already mapped or you'll get an error. We force our drive letters by 
using the WNetCancelConnection2() method of win32wnet to un-map the 
drive letter if it's already mapped before we map the drives. We do this 
because some of users stick USB drives or other devices into their PCs 
before they login and the USB drive will grab the drive letter.


Mike





On Mon, Aug 25, 2008 at 7:31 PM, Mike Driscoll 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


siddhartha veedaluru wrote:

Hi,
 i have used the following code to create Map NetWork Drive.
But it is not visble when i open My Computer window.
 
---
import win32net,time
data = {}
data['remote'] = r'\\fredo\Project'
data['local'] = 'K:'
data['user'] = 'builder'
data['password'] = 'builder'
data['asg_type'] = 0
data['status'] = 1
data['domainname'] = 'conindia'
win32net.NetUseAdd(None,1,data)
---
 Help me in making it visible.
 Regards,
Siddhartha


I recommend this method instead:

code
import win32wnet
from win32netcon import RESOURCETYPE_DISK as DISK

drive_letter = K:
path = \\fredo\Project
win32wnet.WNetAddConnection2(DISK, drive_letter, path)

/code

We use this method at my place of employment as part of our login
script.

Mike




___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Getting a printer's port

2008-08-21 Thread Mike Driscoll

Roger Upole wrote:

Hi all,

I am in need of a way to get a printer's port with Python. I can get 
the name of a printer and the comments field (I think) using 
win32print.EnumPrinters(), but that's as close as I can get. Most of 
the printers in my organization are networked through Linux CUPS.


Any pointers are appreciated. We have Python 2.4 and the script will 
run on Windows XP machines.


Thanks!

Mike


You should be able to get the port using data level 2.

win32print.EnumPrinters(win32print.PRINTER_ENUM_NAME, None, 2)

 Roger




Roger,

Thanks for the quick response. This does work! I was doing almost 
exactly the same thing, but I wasn't passing the PRINTER_ENUM_NAME 
flag. I guess that's what adds the additional information.


Thanks again,

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Getting a printer's port

2008-08-20 Thread Mike Driscoll

Hi all,

I am in need of a way to get a printer's port with Python. I can get the 
name of a printer and the comments field (I think) using 
win32print.EnumPrinters(), but that's as close as I can get. Most of the 
printers in my organization are networked through Linux CUPS.


Any pointers are appreciated. We have Python 2.4 and the script will run 
on Windows XP machines.


Thanks!

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Build 211 still linked from main page

2008-08-09 Thread Mike Driscoll
Hi,

I noticed just now that if I go to the main page for pywin32 on SourceForge and 
click the big green button, I get taken to the 211 build instead of the 212:

http://sourceforge.net/projects/pywin32/

Is this intentional?

Mike 
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywin32 install via setuptools -- conclusion?

2008-08-08 Thread Mike Driscoll

Christopher Galvan wrote:

Michael Gundlach wrote:

On Fri, Aug 8, 2008 at 9:52 AM, Mike Driscoll
[EMAIL PROTECTED] wrote:
 

Michael Gundlach wrote:
   

Hi,

Sorry to be dense, but I assume you mean the ActiveState cookbook 
at http://code.activestate.com/recipes/langs/python/ ?


  

He's probably referring to ActivePython:

http://www.activestate.com/Products/activepython/index.mhtml
http://www.activestate.com/Products/activepython/feature_list.mhtml

Mike



Thanks, Mike.

Michel, thanks for the tip.  Having my users install the ActivePython
distribution isn't really a better solution, as I'd just be replacing
install pywin32 with install ActivePython.

Instead, I'm looking for a way to use distutils to install my module
on a user's computer, and at the same time, install the necessary bits
of pywin32 so that COM object consumption and COM event registration
are supported.  That way, the user just types

easy_install my_package_name

and voila, everything is in place.

If this doesn't exist yet for pywin32, I might be willing to have a go
at writing the patch, if I had some pointers.  Perhaps it would be
possible to make a distutils pywin32 package which turned around,
downloaded the install executable, and ran it; then module developers
could install_requires pywin32 and it would Just Work.  I'm new to
distutils, pywin32, and COM, but I'm willing to learn :)

Any more ideas, anyone?

Michael
___
  
I work for a company called Enthought who also ships a Python 
Distribution(EPD) which includes an 'egg' version
of pywin32 that someone could easy_install.  The entire distribution 
is free, but unfortunately there is an annual fee
to access the egg repository for individual packages.  However, I 
would be more than willing to help you get
started  with using setuptools and creating an egg for pywin32 :).  
Even if the pywin32 project doesn't upload the egg to
PyPi, there is still another way through setuptools to make a single 
install step for your users.


-- Chris Galvan

If they don't want it, I can host the egg at pythonlibrary.org. Let me 
know if I can help. I'm kind of green with the setuptools / easy_install 
thing too, but it's on my TODO list of things to learn.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywin32 install via setuptools -- conclusion?

2008-08-08 Thread Mike Driscoll

Michael Gundlach wrote:

On Fri, Aug 8, 2008 at 9:52 AM, Mike Driscoll
[EMAIL PROTECTED] wrote:
  

Michael Gundlach wrote:


Hi,

Sorry to be dense, but I assume you mean the ActiveState cookbook at 
http://code.activestate.com/recipes/langs/python/ ?

  

He's probably referring to ActivePython:

http://www.activestate.com/Products/activepython/index.mhtml
http://www.activestate.com/Products/activepython/feature_list.mhtml

Mike



Thanks, Mike.

Michel, thanks for the tip.  Having my users install the ActivePython
distribution isn't really a better solution, as I'd just be replacing
install pywin32 with install ActivePython.

Instead, I'm looking for a way to use distutils to install my module
on a user's computer, and at the same time, install the necessary bits
of pywin32 so that COM object consumption and COM event registration
are supported.  That way, the user just types

easy_install my_package_name

and voila, everything is in place.

If this doesn't exist yet for pywin32, I might be willing to have a go
at writing the patch, if I had some pointers.  Perhaps it would be
possible to make a distutils pywin32 package which turned around,
downloaded the install executable, and ran it; then module developers
could install_requires pywin32 and it would Just Work.  I'm new to
distutils, pywin32, and COM, but I'm willing to learn :)

Any more ideas, anyone?

Michael
  
I think easy_install supports a lot of that. If you set up your 
setup.py file correctly, it will try to download what you want or give 
a message to the user to do it manually. Getting just bits and pieces of 
pywin32 probably isn't something that it supports, however. And I don't 
think Hammond has an egg version of Pywin32 either...if there was one, 
then easy_install would work.


---
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] FW: MSMQ - cannot catchCOM_ERROR withpythoncom.com_error

2008-07-23 Thread Mike Driscoll

Lynton Grice wrote:

Hey Tim,

Wow, you are 100% correctthere was something in WingIDE that is not
happystrange

I ran the same code in the standard interpreter and it caught the error
perfectly

BTW: What IDE's do you guys use for Python?

Thanks a million, have a great day!

Lynton
  
I usually just use IDLE for Python stuff. My boss recently bought Wing 
for me and it's code-completion is great, but it's definitely much more 
sensitive to errors and I haven't used it enough to figure out how to 
find the tracebacks. PythonWin is ok, and PyDev for Eclipse is cool, but 
kind of bloated.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Querying the VNC Service fails sometimes

2008-06-25 Thread Mike Driscoll

Mark,


fter upgrading to 211, I am getting
an
import error on my wx module. Are these tied together in some weird
way?



Not that I can think of, and build 211 didn't add any funky new import
tricks or anything.  However, build 211 is packing the MFC DLL now, so
*that* could be related - try removing the MFC that is installed in the
site-packages\pythonwin directory.  What does the import error say?

Cheers,

Mark

  


I still don't know what caused the error exactly, but I got it fixed by 
deleting the wx install and reinstalling it. I did the same with ctypes 
as it was giving me version mis-match issues.


I don't know why I was so absent-minded yesterday. But for completeness, 
here's the traceback:


Traceback (most recent call last):
 File \\path\to\my\scripts\Utilities\SoScripts.py, line 105, in ?
   import printer_dlg
 File \\path\to\my\scripts\printer_dlg.py, line 12, in ?
   import wx
ImportError: No module named wx


Thanks for all the tips, guys.

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Querying the VNC Service fails sometimes

2008-06-23 Thread Mike Driscoll

Tim,

div class=moz-text-flowed style=font-family: -moz-fixedMike 
Driscoll wrote:

[... snip problems checking service status ...]

Well I've no idea if this suggestion will actually work
round whatever the issue is but...

... you can use WMI to query service info. (You knew I
was going to say that, didn't you?)


I knew you'd have some idea...you almost always do...I may try build 211 
first since WMI always tends to slow my login scripts down 
significantly. Other than that, WMI is a very cool tool.




Example you can modify:

http://tgolden.sc.sabren.com/python/wmi_cookbook.html#automatic_services

TJG

/div


Thanks. I'll read up on it and see if I can get it to work on my 
development machine. That way I'll have it for backup if the 211 idea 
falls through.


Mike


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Querying the VNC Service fails sometimes

2008-06-23 Thread Mike Driscoll

Roger Upole wrote:

div class=moz-text-flowed style=font-family: -moz-fixed
Mike Driscoll wrote:

Mike Driscoll wrote:

Hi,

In one of my login scripts for work, I run a query to see if the VNC
service is running using the win32serviceutil module. The code for
that I am using looks something like this:

code
import win32serviceutil
serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1]
/code

This works in 99.99% of cases. However, I have on user that keeps
getting the following traceback:

Traceback (most recent call last):
 File \\ourServer\pathName\PostLogon.py, line 207, in ?
   serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1]
 File
\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py, 


line 479, in QueryServiceStatus
   hs = SmartOpenService(hscm, serviceName,
win32service.SERVICE_QUERY_STATUS)
 File
\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py, 


line 81, in SmartOpenService
   name = _GetServiceShortName(name)
 File
\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py, 


line 62, in _GetServiceShortName
   skey = win32api.RegOpenKey(hkey, svc, 0, access)
error: (2, 'RegOpenKeyEx', 'The system cannot find the file 
specified.')



I used regmon to try and figure out what part of the Registry my code
looks at and it appears to be looking for the DisplayName value in
HKLM\SYSTEM\CurrentControlSet\Services\winvnc

I cannot see a difference in this user's registry versus my own, which
does not have this issue. However, I can duplicate the error by
connecting to the user's PC's registry using the _winreg module and
querying the DisplayName value, like this:

QueryValue(key, 'DisplayName')

Which give me this traceback:

Traceback (most recent call last):
 File pyshell#14, line 1, in module
   QueryValue(key, 'DisplayName')
WindowsError: [Error 2] The system cannot find the file specified

But if I use use _winreg's EnumValue, I get this:


EnumValue(key, 4)

('DisplayName', u'VNC Server', 1)

What the!? Does anyone have any suggestions? Maybe a better way to get
the information? I only need to know if the service is running or not,
and if not, to start it.

Thanks!




I forgot to mention that we use Windows XP, Python 2.4 and PyWin32
version 210.

Mike


You might want to try build 211.  It uses the API function
GetServiceKeyName instead of manually enumerating the
registry.


That's good to know.



However, it sounds like you could have a corrupt registry key.
Try reinstalling the service and see if that helps.

Roger


/div


I keep forgetting that registry keys can get corrupt. I'll try that if 
the 211 idea doesn't work and then I'll give the WMI solution of 
Golden's a go.


Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Webbrowser control and Tab Navigation

2008-06-10 Thread Mike Driscoll

Christof Ecker wrote:

Hi all,

I am using the webbrowser control (internet explorer) as display
component in a project. Unfortunately the Tab and Enter keys do not
work, i.e. it is impossible to switch between input fields of the
displayed html-page and it is impossible to enter a newline in an
input field.

The shortened listing is below.

Can anyone help?

Christof


# file htmlwidget.py
import wx

from wx.lib.activexwrapper import MakeActiveXClass
import win32com.client.gencache
browserModule = win32com.client.gencache.EnsureModule(
{EAB22AC0-30C1-11CF-A7EB-C05BAE0B}, 0, 1, 1)


# Flags to be used with the RefreshPage method
REFRESH_NORMAL = 0
REFRESH_IFEXPIRED = 1
REFRESH_CONTINUE = 2
REFRESH_COMPLETELY = 3


# Flags to be used with LoadUrl, Navigate, Navigate2 methods
NAV_OpenInNewWindow = 0x1
NAV_NoHistory = 0x2
NAV_NoReadFromCache = 0x4
NAV_NoWriteToCache = 0x8
NAV_AllowAutosearch = 0x10
NAV_BrowserBar = 0x20
NAV_Hyperlink = 0x40


class HtmlView(wx.Panel):
url = None

_needs_update = False
def __init__(self, parent):
wx.Panel.__init__(
self, parent, -1,
style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE
)
##
# Make a new class that derives from the WebBrowser class in the
# COM module imported above.  This class also derives from wxWindow and
# implements the machinery needed to integrate the two worlds.
theClass = MakeActiveXClass(browserModule.WebBrowser, eventObj=self)

# Create an instance of that class
self.ie = theClass(self, -1)

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.ie, 1, wx.EXPAND)
self.SetSizer(sizer)
self.ie.offline = False


def SetChanged(self):
self._needs_update = True
if self.IsShownOnScreen():
wx.CallAfter(self.update)

def Navigate2(self, url):
self.ie.Navigate2(url,
Flags=NAV_NoReadFromCache|NAV_NoWriteToCache|NAV_NoHistory)


if __name__ == '__main__':
app = wx.PySimpleApp()
frame = wx.Frame(None, -1)
sizer = wx.BoxSizer(wx.VERTICAL)
win1 = HtmlView(frame)
win1.Navigate2(http://www.google.com;)
sizer.Add(win1, 1, wx.EXPAND)
win1.Show()

import wx.py.shell
win = wx.py.shell.Shell(frame, -1)
sizer.Add(win, 1, wx.EXPAND)
frame.SetSizer(sizer)
frame.Show(True)

app.MainLoop()

  


You might want to re-post this to the wxPython user's group just in case 
you're missing a wx method. I use wxPython extensively, but I'm not 
familiar with that particular widget. The link to the mail list is below:


http://wxpython.org/maillist.php

Also, there's the PAMIE project which you may or may not find useful: 
http://pamie.sourceforge.net/


I personally have used the SendKeys module to automate IE, however it's 
rather like black magic and kind of sucks: 
http://www.rutherfurd.net/python/sendkeys/


---
Mike Driscoll

Blog:   http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Request for comments

2008-05-30 Thread Mike Driscoll

Tim Golden wrote:
div class=moz-text-flowed style=font-family: -moz-fixed[Ton van 
Vliet]

IMHO the links could be a bit more visible.

When looking at the 'Where do I begin' paragraph, it took me quite 
some time to notice that there *were* actually links in there (after 
being taken there by clicking on the 'Where do I begin' link in the 
left hand column already several times)


Using Opera and FF on W2K at 1600x1200


[Larry Bates]

On my monitors the blue links look fuzzy.
Table of contents blue on blue is hard for me to read.
While I'm not crazy about the pink background, that is probably a 
personal preference.
(Windows XP Pro, running dual monitors at 1600 x 1200). 


Thanks, Larry and Ton. FWIW, my visual design skills are pretty
much nil. The best I can hope for is clean and workmanlike. I 
inherited most of the Sphinx default styles (including

that red-on-pink for the warning) and adjusted a few, not least
to make a clear distinction from the official Python docs.

For now, I've modifed the styles to something a little more bland,
using the conventional blue for links and a mild grey for the sidebar.
I've left the red-on-pink, partly because it only appears for warnings
and if it jars a bit, well that's probably not a bad thing in the circs.
While I do want the appearance to be both attractive and readable,
I'm trying to avoid spending too much time poking at RGB codes in
the hope of achieving Visual Nirvana :)

The front page is in one way the most important page and I'm not
at all sure I've got it right yet. (Suggestions will be appreciated). But
for now, my focus is getting content in, without which the front page
is so much vapourware.

Thanks v. much for the input. Keep it coming.

TJG

/div


Tim,

I was looking at the front page and thought it might be nice to have a 
section devoted to Networking / Remote Access. Or maybe that's rolled 
into one of the other categories and I missed it.


In the building and deploying section, I see you have MinGW. I have a 
generic tutorial on how to compile extensions using that compiler that 
you're welcome to use and/or re-work for your site. You can find it 
here: http://pythonlibrary.org/mingw.htm  If you need help, let me know.


I have a similar one for VS2003, but it's much rougher 
(http://pythonlibrary.org/visual_studio.htm).


Also, there's a cool wrapper for py2exe called GUI2exe that makes using 
it much easier (at least for me): 
http://xoomer.alice.it/infinity77/main/GUI2Exe.html


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Request for comments - the spaces issue

2008-05-28 Thread Mike Driscoll

Vernon,


Tim:
  I think you missed my point...
As you say, the PEP8 style guide is a starting point for new Python 
coders.

That is precisely why it ought to be followed in sample code.

I normally format my function calls exactly the way you do, and I do 
so in open source code which I contribute to the community. That is 
not EXAMPLE code which also works, it is working code which might be 
used as an example: a subtle but important difference.

--
Vernon Cole


I always find it interesting when people flip out over semantics like 
this. This seems especially true when someone is trying to contribute 
back to the community. I get flak every time I talk about my Python 
Extension Building Network because people don't like executables and 
think that everyone should use the command line. I admit that I have 
found it personally discouraging when this happens, which is why my site 
doesn't get updated regularly any more.


I'm sure I'll get some hate mail over my wxPython tutorials soon since I 
use camelCase as Tim R. does. Oddly enough, this seems to be the 
convention in the wxPython camp, which flies in the face of PEP8.


I guess I would recommend that you create a mirror site and reformat it 
to the standards you use. Then Tim can link to your site too. I also 
recommend that you read Aesop's Fable: The Man, the boy and the donkey 
: http://members.cox.net/deleyd2/prose/aesop63.htm


Mike



On Wed, May 28, 2008 at 10:46 AM, Tim Roberts [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Vernon Cole wrote:

Let's not loose track of the thread here.
The question was whether there should be a space between the
function name and the leading parenthesis, as:
 my_function (arg)
vs:
 my_function(arg)

PEP8 clearly requires the latter.


PEP8 is a coding standard document for the Python standard
library.  Nothing more.  It is not a mandate for all Python code.
 I disagree with several of the conventions in PEP8, although if I
ever submit anything to the standard library, I will reformat it
to match.

The key lesson in that PEP is that you should stick to SOME
standard.  It need not be the same standard used by others.



IMHO any published example code, which is what we are talking
about here, should follow the PEP8 style guide.


No, that's going WAY too far.  It is a mandate for the standard
library, and it is a starting point for new Python coders.



(Besides which I personally REALLY hate the extra space.)


You are entitled to do so.  I don't like it either, but I will
certainly defend TJG's right to write his code using his own
standards.  I, personally, like Camel-cased names with an extra
space inside the parentheses, both of which are discouraged by PEP8:

  obj = myFunction( one, two )


-- 
Tim Roberts, [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

Providenza  Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org mailto:python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32




___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Request for comments

2008-05-27 Thread Mike Driscoll

Tim Golden wrote:
div class=moz-text-flowed style=font-family: -moz-fixedbob 
gailer wrote:

Tim Roberts wrote:

bob gailer wrote:


Please omit the space before ( in code. I find that very 
distracting. Example:


print result.Properties_ (sValue).Value # current

print result.Properties_(sValue).Value # preferred, and how most 
code I've seen looks.


Do you understand that this is strictly a personal preference?  Some 
people like it, some people don't.  You are certainly allowed to 
prefer one over the other, but it's a bit much to ask someone else 
to change their coding style to match yours, unless you are a paying 
client.  ;)


I agree. Please consider that all of the code examples I've seen in 
the official Python documentation have no space before the (. Most 
newcomers to Python who goes thru the tutorial will learn that way of 
coding. I imagine it would be confusing for them to later see code 
with the space. Same true for Python cookbook. Follow Tim's link to 
Windows Registry Functions 
http://msdn.microsoft.com/en-us/library/ms724875%28VS.85%29.aspx. 
MS's examples. Ditto. I'm aiming for consistency, and minimal 
confusion for many.


It's a fair point. For now (basically because I can do it faster)
I'll go with my spaces-before convention. When I get a chance to
breathe we can revisit this and other other coding style issues.
All the example code is in individual Python files so a global
search-and-replace should be possible if it becomes desirable.

[... snip description of problems with the PythonWin interpreter ...]

Yes, I tried that to see what you meant. I'm not sure there's
much I'm going to be able to do about that, unless someone
jumps in with a solution. My main point about the examples is
that they're self-contained. (ie you don't need to prearrange
any data or install any modules unless indicated). The ability
to drop them into a Python interpreter window is a nice-to-have
which I make use of whenever I'm posting code.

If anyone can suggest anything here, even in the form of a hint
in the docs, please let me know.


Well, there's at least 2 ways around this.

1) Change it to:  import win32api; import win32con   (note the 
important semi-colon)
2) Change it to:  import win32api, win32con 



Thanks for your continued interest, Bob.

TJG

/div


I personally like to use my delete key, so when I try to copy and paste 
something like this into IDLE or PythonWin, I position my cursor at the 
end of the first import, add a semi-colon and hit delete until the 2nd 
import jumps to the first line.


However, any code that is more than one statement, I tend to copy into a 
blank file and save it before running it, which circumvents this issue 
entirely.


Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Request for comments

2008-05-27 Thread Mike Driscoll

Tim Golden wrote:
div class=moz-text-flowed style=font-family: -moz-fixedMike 
Driscoll wrote:

Tim Golden wrote:

Yes, I tried that to see what you meant. I'm not sure there's
much I'm going to be able to do about that, unless someone
jumps in with a solution. My main point about the examples is
that they're self-contained. (ie you don't need to prearrange
any data or install any modules unless indicated). The ability
to drop them into a Python interpreter window is a nice-to-have
which I make use of whenever I'm posting code.

If anyone can suggest anything here, even in the form of a hint
in the docs, please let me know.


Well, there's at least 2 ways around this.

1) Change it to:  import win32api; import win32con   (note the 
important semi-colon)

2) Change it to:  import win32api, win32con


That's fine for two lines, but I can't change a whole script to work
that way :) The intepreter window in PythonWin just doesn't work
the same way as the conventional console-based one, it seems.

However, any code that is more than one statement, I tend to copy 
into a blank file and save it before running it, which circumvents 
this issue entirely.


Fair enough, and I think that my main point is that the code can run
as-is, without needing any kind of setup. Pasting it direct into an
interpreter session is handy to check it runs, but it's not a must-have.

TJG

/div


True enough. I was only commenting on what the OP was commenting on. 
Putting semi-colons throughout would make for pretty ugly looking code.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem creating a shortcut

2008-05-16 Thread Mike Driscoll

Tim Golden wrote:
div class=moz-text-flowed style=font-family: -moz-fixedSorry, 
missed this one going through. Looks like

Roger's hit the nail on the head, though. Bizarre
behaviour by the IShellLink interface: I can't find
any kind of reference to this but I assume that
since the Path attribute of the link should *only*
contain an executable, there's no need for the
quotes -- which then confuse it when they're there
as it tries to make the executable into an absolute
path.

One small comment, Mike. Since you're using the
winshell module -- which I assume is the one from
my site -- why not use its CreateShortcut function?
It's basically just a light wrapper around the IShellLink
functionality which someone else mentioned:

code
import os, sys
import winshell

winshell.CreateShortcut (
Path=os.path.join (winshell.desktop (), shortcut.lnk),
Target=rc:\Program Files\Mozilla Firefox\firefox.exe,
Arguments=http://localhost;,
Description=Open http://localhost with Firefox
)

/code

But maybe you're using the WScript.Shell functionality
elsewhere as well?

TJG


/div


Good point. I am using your module (thanks!). Somehow I missed it's 
shortcut creating abilities. I do use the WScript.Shell earlier in my 
script, but I think it's just for other types of shortcut creation.


I'll have to look. It would be good not to have to import extra stuff.

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Will wmi can a command on remore host and get the return code

2008-05-15 Thread Mike Driscoll

siddhartha veedaluru wrote:

Hi,
 
i'm tring to execute a exe that is placed in the mapped network drive 
on remote machine

it seems it is not getting recognised.
 
How can i run the exe on the mapped network drive
 
Thanks,

Siddhartha


I would use the subprocess module.

code

import subprocess

# replace C:\ with map drive letter or use UNC path
subprocess.Popen(r'C:\path\to\exe')


/code

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to activate subwindow of the application ???

2008-05-09 Thread Mike Driscoll

Tim Golden wrote:
div class=moz-text-flowed style=font-family: -moz-fixedneha rai 
wrote:

 I am making a tool that needs to open subwindow of another application,
enter some text in it click ok and then open the same window again. i am
able to  put text and click 'OK'  but I am not able to open the same 
window

again using the python code. I need some thing that can remember what i
opened(or the last window opened) and open it again.


I'm sorry, but for the life of me I can't work out what you're trying
to do here. Unless someone has better intuition than me and comes
to the rescue, could you post some code to show what's you're doing
and indicate where it doesn't work?

Thanks

TJG

PS If you aren't already, worth looking at WATSUP [1] and PyWinAuto [2]

[1] http://www.tizmoi.net/watsup/intro.html
[2] http://pywinauto.pbwiki.com/

/div

Tim,

The OP is probably talking about a window that's part of the 
application, like when you open the Preferences dialog or how some Excel 
versions can allow one to open multiple spreadsheets and minimize them 
within the application.


As to how to manipulate that sort of thing in a pre-made app... I 
haven't the slightest... except maybe SendKeys or the links you gave.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] FileWatcher

2008-04-28 Thread Mike Driscoll

Pierre-Yves Delens wrote:

Bonjour,

in the context of CAD management (layersmanagement, etc...),

we are storing our Layers management in a reference.dwg file, for 
obvious reasons.
But some aspects of this management have to be maintained in 
alphanumeric format.


Therefore

we need to trigger each time this reference.dwg file is modified.
This trigger would launch a small exe our py script,
so that we can extract datas from it (layers definitions actually), 
and integrate them in a database (SqLite ~Python).

We should therefore be able to monitor this file.

Can Python, can PythonWin help me to do that?
Could you give me the [beginning  of ] a clue?

I read through the book 'Py progamming on Win32', but I didn't find this.
Although I guess that a Win 'service' (the topic is in the book) 
should be created.


I found about FileWatcher DLL which is what we need, butthisis in 
context of C# and IronPython. I was hoping to find a shorter way 
between Python and the file-Sytem. Is there some kind of FileWatcher 
DLL accessible from Pywin32?


Thanks on forward.

Yours
--

__
pour P-Y Delens sprl, Bureau d'Architectes,

Pierre-Yves Delens, ir-arch.

  

Hi Pierre-Yves,

I've used Tim Golden's folder watcher script to do this sort of thing. 
You can check it out as well as a couple of other methods on his site: 
http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_changes.html


It uses various parts from the pyWin32 package, so be sure to download 
that.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] (no subject)

2008-04-28 Thread Mike Driscoll

Alex Denham wrote:

Hi all,

I'm just wondering but when i try to access/update anything on my 
Tkinter GUI from one particular function, my whole program 
crashes/freezes with no error.


The function is part of a class which handles all the GUI 
drawing/event handling etc.
The function in question gets called from a win32 DesignatedWrapPolicy 
class. Sample code below:


[code]
# this function is part of an IDropTarget class, the TargetWidget 
was definined in the __init__ method of this functoin and it points to 
my class which handles the GUI.

def Drop(self, data_object, key_state, point, effect):
data = data_object.GetData((15, None, 1, -1, 1))
print data
n_files = shell.DragQueryFileW(data.data_handle, -1)
print n_files
filenames = [shell.DragQueryFileW(data.data_handle, n_file) 
for n_file in range(n_files)]

print filenames
self.TargetWidget.filesDropped(filenames) # this calls the 
filesDropped function of the TargetWidget class and passes the 
filename list to it.


# this function is part of the GUI class (which inherits from 
Tkinter.Toplevel) the print commands work however if i uncomment the 
clearInput function (which just calls self.filepathInput.delete(0, 
END) to clear the text)
# the program hangs, same for the second commented line, and 
anything else that requires a call to tk it appears. Is there some 
sort of conflict going on between win32 and Tk ??

def filesDropped(self, fileList):
print fileList
#self.clearInput()
#self.filepathInput.insert(Tkinter.END, fileList[0])
[/code]

I'm just wondering if there's something i need to do to 'release' the GUI?
I'm pretty sure it's got nothing to do with my code elsewhere because 
it was all working smoothly before, and if i call the filesDropped 
function from somewhere else (not from the IDropTarget class) i don't 
have any issues.


Thanks in advance,
Alex
This is just a guess, but you usually cannot update a GUI from an 
outside process directly. At least, this is true of wxPython. I think 
your blocking the idle event in Tkinter, which causes it to hang and 
then when you try to update it, Tkinter crashes because you're making a 
call on it from what amounts to a separate thread.


Instead, you ought to write to a file or post an event when the win32 
part is finished that the Tkinter GUI can check periodically and then 
react. In other words, have the win32 portion of your code write 
something to a file and have Tkinter check the file every few seconds 
and then update itself when it finds something in there.


In wxPython there is a way to subscribe to special events using the 
PubSub module. Tkinter probably has its own nomenclature. If you can't 
figure it out, I'd recommend the Tkinter mailing list.


Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Drag and Drop issues

2008-04-22 Thread Mike Driscoll

Alex Denham wrote:

Hi,

I'm trying to implement a drag and drop feature in my Tkinter based gui.
I want to be able to drag a file from windows (explorer/desktop etc) 
into my program. Then i need my program to get the filepath for the 
file that was dropped.


I've tried to search all over the internet, in books and in the win32 
documentation provided with the win32 package but i keep finding 
conflicting information.


Furthest i have gotten is the following:

_id = root.winfo_id()
win32gui.DragAcceptFiles(_id, 1)

That works, without that i don't get the little 'drop' icon  when i 
drag something over, however after that i'm completly stuck, i've 
tried using win32gui.GetMessage() to see if there is anything in that 
output that relates to a drop,

I've tried win32api.DragQueryFile(_id).

I think i need to do something using a PyIDropTarget but i have no 
idea where to import that from, i've tried making a class with that as 
the name and then initializing it and passing it to 
pythoncom.RegisterDragDrop(_id, dropTarget)
dropTarget being the initialized PyIDropTarget class, however it says, 
it's not a com object...


I think i've just managed to get myself confused, i just need a 
pointer on the right way to do it, do i use registerdrag drop or do i 
use dragqueryfile and dragacceptfiles, and how to i check to see if my 
program has recieved a drop request, is there some sort of event or 
something i can listen for (thats initially what i thought 
GetMessage() was for but i'm unsure how to use it)


Any help would be much appreciated.
And if you need any more info don't hesitate to ask.

Thanks in advance
Alex
I did a quick Google search and found this: 
http://sourceforge.net/projects/tkdnd


Alternatively, I know wxPython has DnD capabilities of sorts too, so if 
you can't get it in Tkinter, you might check it out there. By the way, 
did you try asking for help on the Tkinter mailing list? If not, you can 
find it here: http://mail.python.org/mailman/listinfo/tkinter-discuss


Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Windows programing cookbook?

2008-04-21 Thread Mike Driscoll
Trent,
 div class=moz-text-flowed style=font-family: -moz-fixed I have 
 googled this have not found much.  I know about
 Activestate's site but does not seemed to be organized
 in a way to get these easily.

 (Jumping in late on this thread. Apologies if I've missed a lot of 
 context.)

 We [ActiveState] hope to be giving a big refresh to the cookbook site 
 in the next month or two. My hope is that the refresh would make it 
 perfect for putting up a bunch of pywin32 programming examples.

 Part of the re-work of the site will include more typical tagging of 
 recipes -- rather than the somewhat limited categorization there right 
 now. For example, you'd be able to tag all Windows programming 
 examples with pywin32 or whatever, and then browse only that set of 
 recipes.

 Any feedback on what kinds of things out of a refreshed cookbook site 
 would be essential for making this all easier would be welcome.

 Cheers,
 Trent (Python Lead at ActiveState)

You haven't missed anything. It was only me responding to the OP and no 
one else has commented. I do think it would be nice if there was a 
centralized repository of some sort for pywin32 examples and such. Will 
the tags make it easier or harder to find stuff? I've had problems 
finding recipes on there because I used one general term and the chef 
used a different general or specific term. I'm not sure how that could 
be fixed though.

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Windows programing cookbook?

2008-04-21 Thread Mike Driscoll
Trent Mick wrote:
 Mike Driscoll wrote:
 Will the tags make it easier or harder to find stuff? I've had 
 problems finding recipes on there because I used one general term and 
 the chef used a different general or specific term. I'm not sure 
 how that could be fixed though.

 Certainly I think basic tagging support for the Python Cookbook will 
 help over the static set of categories in use now.

 It is a valid point, tho. This is a common problem for all sites that 
 use free-form tagging for categorization. My (limited) experience is 
 that some popular tags eventually coalesce -- i.e. people settle on 
 one tag name for one kind of thing.

 Full-text search is, obviously, that partner to this that can help 
 with finding what you are looking for. For example, I would expect 
 that the vast majority of recipes dealing with PyWin32 would have the 
 words Python, Windows and maybe win32 in them so a search on 
 those words would tend to hit the recipes you are looking for.

 Trent

That's true. I just seem to always hit the weird corner cases and end up 
screwing around the entire afternoon looking for something that should 
have been obvious from the beginning. Usually in retrospect, it WAS 
obvious, but not to me.

I'm sure it's not your company's fault and I didn't mean to imply that. 
If I did, I apologize.

Thanks for the updates. I look forward to using them.

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Skip Alt+F4 (le dahut)

2008-03-18 Thread Mike Driscoll
Hi, 

 Date: Mon, 17 Mar 2008 14:11:14 +0100
 From: le dahut [EMAIL PROTECTED]
 Subject: Re: [python-win32] Skip Alt+F4
 To: Paul Moore [EMAIL PROTECTED]
 Cc: Python-Win32 List python-win32@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 Oh yes ! That's it. Thank you.
 
 It is a frame that's used by a service to display some 
 information before uncancelable forced reboot.
 
 I now have to determinate how to modify the informations 
 displayed in the frame.
 
 Should my program run in the class of the frame ? Or should 
 it get a sort of handler to the frame and modify the content 
 of a text box ?
 I don't know if the second way is possible.


If you created the frame and the TextCtrl in wxPython, then it's pretty
trivial to grab the contents from it and edit it as much as you like.
Something like this will get the info:

text = myTextCtrl.GetValue()

Now it's up to you what you want to do with it. You can use the SetValue()
method to change it to something else. If you're using StaticText
controls, the methods would be GetLabel() and SetLabel() respectively. All
of this is in the wx docs: 

http://www.wxpython.org/docs/api/wx.TextCtrl-class.html
http://www.wxpython.org/docs/api/wx.StaticText-class.html

And why are you posting wx questions to the pywin32 list anyway?

Mike


 
 Paul Moore a ?crit :
  On 17/03/2008, le dahut [EMAIL PROTECTED] wrote:
  I'm writting a Wx app and I want to skip Alt+F4. I've used 
 somehting 
  like that :
  def OnKeyDown(self, event):
  print event.AltDown(), event.GetKeyCode()
  if event.AltDown() and event.GetKeyCode() == wx.WXK_F4:
  print 'try to close'
 
  Everything gets printed but my app closes anyway on 
 Alt+F4, is there 
  a way to skip this ?
  
  (a) you should think hard before doing this - about the only 
  reasonable reason for overriding the standard Alt-F4 on 
 Windows, is to 
  minimise to the tray rather than closing
  
  (b) if you still want to do this, look at the OnClose 
 event, and override that.
  
  Paul.
  
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Monitor directories/files

2008-03-07 Thread Mike Driscoll
Hi Julius, 

 
 Message: 7
 Date: Fri, 07 Mar 2008 21:44:36 +0100
 From: Julius [EMAIL PROTECTED]
 Subject: [python-win32] Monitor directories/files
 To: python-win32@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain
 
 Hi,
 
 how do you monitor files/directories on windows systems with python?
 gamin in linux is really nice, but i wasnt able to find something that
 works on windows systems.
 
 greets
 

I'm sure Tim will jump on this too, but I recommend his site for the
answer to this question (and many other win32 questions):

http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_cha
nges.html

He lists 3 ways to do it there. Have fun!

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Windows Vista slow down Python xmlrpc

2008-03-06 Thread Mike Driscoll
Paul,

 Message: 8
 Date: Thu, 6 Mar 2008 19:31:59 +
 From: Paul Moore [EMAIL PROTECTED]
 Subject: Re: [python-win32] Windows Vista slow down Python xmlrpc
 To: Tim Roberts [EMAIL PROTECTED]
 Cc: Python-Win32 List python-win32@python.org
 Message-ID:
   [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1
 
 On 06/03/2008, Tim Roberts [EMAIL PROTECTED] wrote:
  caxelrud wrote:
The XP was about 100 times faster !
   
Does anybody now how to seepup the Vista execution?
 
  Yes: upgrade to Windows XP.  ;)
 
 Is it also possible that Vista has some form of firewall enabled by
 default, that is not on XP? If so, disabling that may help.
 
 (Disclaimer: I've not used Vista, I'm just going off the various
 postings around, which seem to imply that Vista takes a much harder
 line on the secure by default approach - so having a firewall on by
 default seems plausible).
 
 Paul.
 
 

I've been watching the whole Vista debate and this guy at zdnet did some
testing with Vista's SP1 vs. XP SP2. The results are that XP is just plain
faster in most cases. You can check it out here:

http://blogs.zdnet.com/hardware/?p=1332
http://blogs.zdnet.com/hardware/?p=1338

I have only used Vista when working on a client's PC or to uninstall it to
be replaced with its predecessor. From what I've seen personally, I also
think it's slower in general.

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] createtoolbar

2008-02-28 Thread Mike Driscoll
Hi, 

 
 Message: 1
 Date: Thu, 28 Feb 2008 14:34:12 +0530
 From: kNish [EMAIL PROTECTED]
 Subject: [python-win32] createtoolbar
 To: python-win32@python.org
 Message-ID:
   [EMAIL PROTECTED]
 Content-Type: text/plain; charset=iso-8859-1
 
 Hi,
 
 #!/usr/bin/python
 
 # panels.py
 
 import wx
 
 
 class Panels(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
 
hbox = wx.BoxSizer(wx.HORIZONTAL)
splitter = wx.SplitterWindow(self, -1)
 
vbox1 = wx.BoxSizer(wx.VERTICAL)
panel1 = wx.Panel(splitter, -1)
panel11 = wx.Panel(panel1, -1, size=(-1, 40))
panel11.SetBackgroundColour('#53728c')
st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5))
st1.SetForegroundColour('WHITE')
 
panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN)
panel12.SetBackgroundColour('WHITE')
 
vbox1.Add(panel11, 0, wx.EXPAND)
vbox1.Add(panel12, 1, wx.EXPAND)
 
panel1.SetSizer(vbox1)
 
vbox2 = wx.BoxSizer(wx.VERTICAL)
panel2 = wx.Panel(splitter, -1)
panel21 = wx.Panel(panel2, -1, size=(-1, 40), 
 style=wx.NO_BORDER)
st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5))
st2.SetForegroundColour('WHITE')
 
panel21.SetBackgroundColour('#53728c')
panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED)
 
panel22.SetBackgroundColour('WHITE')
vbox2.Add(panel21, 0, wx.EXPAND)
vbox2.Add(panel22, 1, wx.EXPAND)
 
panel2.SetSizer(vbox2)
 
toolbar = self.CreateToolBar(self)
toolbar.AddLabelTool(1, 'Exit', 
 wx.Bitmap('icons/stock_exit.png'))
toolbar.Realize()
self.Bind(wx.EVT_TOOL, self.ExitApp, id=1)
 
hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
self.SetSizer(hbox)
self.CreateStatusBar()
splitter.SplitVertically(panel1, panel2)
self.Centre()
self.Show(True)
 
 
def ExitApp(self, event):
self.Close()
 
 
 app = wx.App()
 Panels(None, -1, 'Panels')
 app.MainLoop()
 
 
 createToolbar gives an error. (Look at the Attachment). How 
 may I get this to work successfully.
 
 BRgds,
 
 kNish

First of all, this is a wxPython question, NOT a PyWin32 question. You
should be posting there: http://wxpython.org/maillist.php

Secondly, you sent code that does not work. You need to change line 41
from

toolbar = self.CreateToolBar(self)

to

toolbar = self.CreateToolBar()

And if you use images in your code, you need to provide them. I added the
following line right after the one above:

ico = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, (16,16))

and then changed 

toolbar.AddLabelTool(1, 'Exit', wx.Bitmap('icons/stock_exit.png'))

to

toolbar.AddLabelTool(1, 'Exit', ico)

See http://www.wxpython.org/docs/api/wx.ArtProvider-class.html for more
information on generic icons for wxPython.

So the full code with changes if below:

code

import wx


class Panels(wx.Frame):
   def __init__(self, parent, id, title):
   wx.Frame.__init__(self, parent, id, title)

   hbox = wx.BoxSizer(wx.HORIZONTAL)
   splitter = wx.SplitterWindow(self, -1)

   vbox1 = wx.BoxSizer(wx.VERTICAL)
   panel1 = wx.Panel(splitter, -1)
   panel11 = wx.Panel(panel1, -1, size=(-1, 40))
   panel11.SetBackgroundColour('#53728c')
   st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5))
   st1.SetForegroundColour('WHITE')

   panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN)
   panel12.SetBackgroundColour('WHITE')

   vbox1.Add(panel11, 0, wx.EXPAND)
   vbox1.Add(panel12, 1, wx.EXPAND)

   panel1.SetSizer(vbox1)

   vbox2 = wx.BoxSizer(wx.VERTICAL)
   panel2 = wx.Panel(splitter, -1)
   panel21 = wx.Panel(panel2, -1, size=(-1, 40), style=wx.NO_BORDER)
   st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5))
   st2.SetForegroundColour('WHITE')

   panel21.SetBackgroundColour('#53728c')
   panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED)

   panel22.SetBackgroundColour('WHITE')
   vbox2.Add(panel21, 0, wx.EXPAND)
   vbox2.Add(panel22, 1, wx.EXPAND)

   panel2.SetSizer(vbox2)

   toolbar = self.CreateToolBar()
   ico = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR,
(16,16))
   toolbar.AddLabelTool(1, 'Exit', ico)
   toolbar.Realize()
   self.Bind(wx.EVT_TOOL, self.ExitApp, id=1)

   hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
   self.SetSizer(hbox)
   self.CreateStatusBar()
   splitter.SplitVertically(panel1, panel2)
   self.Centre()
   self.Show(True)


   def ExitApp(self, event):
   self.Close()


app = wx.App(0)
Panels(None, -1, 'Panels')
app.MainLoop()

/code

In the future, be sure to post to the wxPython group if you have a
question about that GUI toolkit. If you need help with Mark Hammond's
win32 modules, drop us a line.

Mike

Re: [python-win32] python-win32 Digest, Vol 58, Issue 53

2008-01-31 Thread Mike Driscoll
Hi,

Are you wanting to use Python in Excel instead of VBA? There's a thread
about just that sort of thing here:

http://www.velocityreviews.com/forums/t319222-re-python-in-excel.html

Otherwise you'll need to figure out how to use VBA to do some kind of
Python voodoo to check the data type. I suppose something that checks if
it is a long, pass that info along so Python doesn't think it's an int. In
fact, you'll probably have to pass some kind of flag or sentinel value
along to identify the data type for Python.

Maybe one of the gurus here will weigh in with more and better
information.

Mike

 Message: 4
 Date: Thu, 31 Jan 2008 16:06:08 +0530
 From: Pallavi Apotikar [EMAIL PROTECTED]
 Subject: Re: [python-win32] Reading .py or .pyc from an excel sheet
 To: Graeme Glass [EMAIL PROTECTED]
 Cc: python-win32@python.org
 Message-ID:
   
 [EMAIL PROTECTED]
 Content-Type: text/plain; charset=us-ascii
 
 Actually, I have an excel sheet, where I am entering the data.
 
 I am reading the entered data in python.
 
 excel takes data as a string.
 
 before passing it to python, i wanted to check whether the entered
 data(value) is a valid python data type. 
 
 so instead of checking this in python script(/ say program), 
 I wanted to put macro in excel , so that all the values are 
 checked at a stretch (or say while entering - before passing 
 it to the python program.)
 
 So is it possible ?
 
 Pallavi Ajabrao Apotikar
 Tata Consultancy Services
 Mailto: [EMAIL PROTECTED]
 Website: http://www.tcs.com
 
 Experience certainty.   IT Services
 Business Solutions
 Outsourcing
 
 
 
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Manipulating MAPI

2008-01-29 Thread Mike Driscoll
Tim, 

 -Original Message-
 From: Tim Golden [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, January 29, 2008 3:54 AM
 To: Mike Driscoll
 Cc: python-win32@python.org
 Subject: Re: [python-win32] Manipulating MAPI
 
 Mike Driscoll wrote:
  Our organization has been slowly migrating away from closed source 
  software. ... Now we use a web client instead of Outlook (in most 
  cases) to check out email.
  
  Unfortunately, we discovered that there a number of users 
 who like to 
  be able to use MS Word to send email. So I wrote a Python 
 script using 
  wxPython that can send email, including attachments. My problem is 
  getting the email function in MS Word/Office to send its 
 information 
  to my program. I've been able to get the mailto 
 functionality from web 
  pages to work, but not this.
 
 OK. Gleaned knowledge here with just a touch of experience.
 I think that any email client must actually support MAPI via 
 a DLL. I remembered this from looking into Eudora's support a 
 while ago which gave me a leg up in searching and led me to this page:
 
 http://kb.mozillazine.org/MAPI_Support
 
 It occurred to me that you could look at the Thunderbird 
 source if you were really serious, but I suspect it would be 
 no small amount of work to get it to work. I don't know where 
 your registry keys came from, but running RegMon while asking 
 Thunderbird or Outlook to set themselves as the default email 
 client is quite illustrative.
 
 Could you not simply have Thunderbird installed for those 
 users who wanted a non-web email client? (Maybe that's what 
 you already do). It seems better than the old wheel reinvention :)
 
 TJG
 

We are looking at Thunderbird, but only a couple of people in the IS
department have it. We may go with it, but we have to make sure that
Thunderbird doesn't allow extremely non-standard things like Outlook did.
For instance, Outlook/Exchange allowed the user to open an Office document
from within Outlook, edit the document and save it back to its email
location somewhere in the nebulous Exchange server. Basically this opens
the door for litigation if someone sends a legal document here and one of
the users edits it, then there is no record of the original document being
received anymore.

Anyway, I agree that reinventing wheels is usually not a good
idea...except for practice or in the pursuit of learning.

Thank you for your input. I'll check out your link as well.

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Changing a drive letter

2008-01-28 Thread Mike Driscoll
Tim, 

 -Original Message-
 From: Tim Golden [mailto:[EMAIL PROTECTED] 
 Sent: Monday, January 28, 2008 9:51 AM
 To: Mike Driscoll
 Cc: python-win32@python.org
 Subject: Re: [python-win32] Changing a drive letter
 
 Mike Driscoll wrote:
  Just an FYI here. When using Roger's method, I get a 
 traceback, so you 
  might want to add some caveats to your How-do-I:
  
  Traceback (most recent call last):
File \\someServer\scripts\changeDriveLetter.py, line 4, 
 in -toplevel-
  v = win32file.GetVolumeNameForVolumeMountPoint('L:\\')
  error: (3, 'GetVolumeNameForVolumeMountPoint', 'The system 
 cannot find 
  the path specified.')
 
 Well I did try it before posting it up (I always do!) and it 
 worked fine for me. That said, I'm using XP against a Win2k3 
 and I don't have access to NT4 or Samba. I note, though, that 
 the msdn page [1] indicates Requires Windows Server 2008, 
 Windows Server 2003, or Windows 2000 Server. which would 
 seem to rule out NT4 and possibly Samba. Shame.
 
 TJG
 

I figured you checked them before posting. I didn't mean to imply that you
didn't. I'll try to be more verbose in my future postings so that everyone
know what I'm using. I'll stick with diskpart and generalize it a bit for
future use.

Thanks again!

Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Manipulating MAPI

2008-01-28 Thread Mike Driscoll
Hi,

Our organization has been slowly migrating away from closed source
software. As part of this, we recently had to upgrade our mail system and
found that going from Exchange 5 to its newest version was cost
prohibitive. Thus we went with Zimbra, an open source / open standards
alternative. Now we use a web client instead of Outlook (in most cases) to
check out email.

Unfortunately, we discovered that there a number of users who like to be
able to use MS Word to send email. So I wrote a Python script using
wxPython that can send email, including attachments. My problem is getting
the email function in MS Word/Office to send its information to my
program. I've been able to get the mailto functionality from web pages to
work, but not this.

Mozilla Thunderbird works, so there must be some change I need to make in
the registry. Here's what Thunderbird changes:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.eml]
@=ThunderbirdEML

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{29F458BE-8866-11D5-A3DD-00B0D0
F3BAA7}]
@=Mozilla MAPI

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\DefaultIcon]
@=C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe,0

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\open\command]
@=\C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe\ -osint
-compose \%1\


I'm pretty sure it has something to do with the .eml and the mailto
directories, but I'm not sure what to do. I tried changing the paths to
point to my program rather than Thunderbird, but nothing happens when I
try to send an email with Word. I've googled for this off and on for quite
a while (read: months) but haven't found much so I thought that there
might be some experts in this group who could give me a push in the right
direction.

Any hints and/or tips are appreciated. Thanks!

Mike Driscoll
Applications Specialist
MCIS - Technology Center

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Changing a drive letter

2008-01-25 Thread Mike Driscoll
Tim,

 Date: Thu, 24 Jan 2008 20:55:55 +
 From: Tim Golden [EMAIL PROTECTED]
 Subject: Re: [python-win32] Changing a drive letter
 Cc: python-win32@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 Paul Koning wrote:
  I agree.  If you do want to use an API rather than a 
 subprocess, WMI 
  might serve.  The biggest drawback of WMI is that the 
 documentation is 
  partly nonexistent and, when it does exist, is of very low quality.
  
  On the other hand, the Python WMI module is quite nice.
 
 Why, thank you! grin
 
 I did a bit of research and it seems that you can only do 
 this via WMI from Win2k3 onwards (which I assume your users, 
 Mike, are not running on their desktops?). There are a couple 
 of workaround suggestions involving the registry and/or the 
 mountvol command, but I don't think they amount to anything 
 better than the original proposal. Good luck!
 
 TJG
 


You are correct. We do not have Win2k3 on any desktops, nor are we running
Vista. We have stuck with XP. Since I work for the government, we have
enough old equipment and software that upgrading would not only be too
costly monetarily but also in time and aggravation. Besides, we just got
done upgrading all the Win98 machines to XP last year. I'll give Roger's
idea a whirl (see other post) and see if it's more reliable than diskpart.

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] winshell error

2008-01-25 Thread Mike Driscoll
 

 -Original Message-
 From: Kevin Horn [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, January 24, 2008 4:44 PM
 To: Mike Driscoll
 Subject: Re: [python-win32] winshell error
   
   I don't suppose anyone knows how to do a logout script? 
 There are some
   things that would be better off if we could do them on 
 logout rather than
   login.
   
   
   Mike Driscoll
   Applications Specialist 

 Its not a whole lot different, just point the appropriate 
 setting in Group Policy to your logoff script, and it should be run.
 
 Look here in Group Policy:
 User Configuration-Windows Settings-Scripts (Logon/Logoff)-Logoff 
 
 Kevin Horn
 
 
 

Hmmm...that sounds easy, except that we run Windows NT4 for our primary
domain controller. Of course, that also means we don't have Active
Directory. I wonder if there's an equivalent in NT4?

I'll look on Google. If someone else knows, drop me a line, please.

Thanks.

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Changing a drive letter

2008-01-25 Thread Mike Driscoll
Roger,


 
 Message: 5
 Date: Thu, 24 Jan 2008 17:04:33 -0500
 From: Roger Upole [EMAIL PROTECTED]
 Subject: [python-win32]  Re: Changing a drive letter
 To: python-win32@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; format=flowed; charset=iso-8859-1;
   reply-type=original
 
 Mike Driscoll wrote:
  Hi,
 
  In a login script I helped write, we have some code that 
 maps drives 
  based on what department or group the user belongs to. One of our 
  groups has users that use USB devices that will occasionally be 
  plugged in before they log in. This causes the map drive 
 part of the 
  script to fail at mapping one of the drives if the USB 
 device grabs that drive letter first.
 
  Here's how we map a drive:
 
  from win32netcon import RESOURCETYPE_DISK as DISK 
  win32wnet.WNetAddConnection2(DISK, mapping[0], mapping[1])
 
 
  And here's the diskpart line:
 
  subprocess.call(r'diskpart /s \\%s\someFolder\change_g.txt' 
 % pdcName)
 
  where the text file contains the following two lines:
 
 
  select volume G:
  assign letter=T
 
 
  Any ideas or tips would be appreciated. Thanks!
 
 You can use functions in win32file to remap a drive letter.
 
 import win32file
 v=win32file.GetVolumeNameForVolumeMountPoint('x:\\')
 win32file.DeleteVolumeMountPoint('x:\\')
 win32file.SetVolumeMountPoint('t:\\',v)
 
 Roger
 

This sounds pretty cool. I'll give it go and see if it works better than
what I am already doing. Thanks!

Mike



___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] winshell error

2008-01-24 Thread Mike Driscoll
Hi,

I have a Python login script that runs various things on login for the
users in our Windows domain. Every once in a while, I'll get a traceback
when I use winshell to try to find the user's desktop. The offending code
is:

userDesktop = winshell.desktop()

And the traceback:

File \\servername\logon\MCISpy.py, line 256, in ?
import SoScripts
  File \\servername\logon\PythonPackages\Utilities\SoScripts.py, line
42, in ?
userDesktop = winshell.desktop()
  File \\servername\logon\Python24\lib\site-packages\winshell.py, line
48, in desktop
return get_path ((shellcon.CSIDL_DESKTOP,
shellcon.CSIDL_COMMON_DESKTOPDIRECTORY)[common])
  File \\servername\logon\Python24\lib\site-packages\winshell.py, line
44, in get_path
return shell.SHGetPathFromIDList (shell.SHGetSpecialFolderLocation (0,
folder_id))
com_error: (-2147467259, 'Unspecified error', None, None)


Our login scripts have an error reporting module that emails the
tracebacks to us when they occur. Since this doesn't happen every time the
user logs in, it is difficult to track down. Does anyone know what this is
and how to fix it?

Thanks!

Mike Driscoll
Applications Specialist
MCIS - Technology Center


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Changing a drive letter

2008-01-24 Thread Mike Driscoll
Hi,

In a login script I helped write, we have some code that maps drives based
on what department or group the user belongs to. One of our groups has
users that use USB devices that will occasionally be plugged in before
they log in. This causes the map drive part of the script to fail at
mapping one of the drives if the USB device grabs that drive letter first.

If the map drives script doesn't get the drives mapped correctly, then we
usually get calls because the user cannot get to their network share. I
came up with a hack that uses a diskpart script to re-map the errant USB
drive to another letter and then map the correct network share to the
drive letter that the USB device had stolen. What I would like to know is
if there is a better way to do that?

Here's how we map a drive:

from win32netcon import RESOURCETYPE_DISK as DISK
win32wnet.WNetAddConnection2(DISK, mapping[0], mapping[1])


And here's the diskpart line:

subprocess.call(r'diskpart /s \\%s\someFolder\change_g.txt' % pdcName) 

where the text file contains the following two lines:


select volume G:
assign letter=T


Any ideas or tips would be appreciated. Thanks!

Mike Driscoll
Applications Specialist
MCIS - Technology Center


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] python-win32 Digest, Vol 58, Issue 40

2008-01-24 Thread Mike Driscoll
Hi,

 thunder thunder54007 wrote:
  I got it, I should get an instance first before i can use
 it, and here is
  another problem, when I use Win32_Product to fetch the
 installed software on
  my system, but only some of them are returned, I don't know
 why? how can i
  get all the installed software on my system?
 
 (Please keep copying back to this; you'll get more help that way)
 
 That's a more general windows / Win32_Product question. If I remember 
 correctly, Win32_Product only lists products installed in a certain 
 way (probably via .MSI). Win32_SoftwareElement or associated classes 
 [1] may give you something. After that, you're just down to scraping 
 the registry, I think. I'm afraid this isn't really my area of 
 expertise. (He says, as though he *has* an area of expertise :)
 
 TJG
 
 [1] http://msdn2.microsoft.com/en-us/library/aa390887(VS.85).aspx
 
 
 --

I had to write a script that was supposed to get all the installed
software on any system. There is no way to get everything because some
software does not write anything to the registry or if they do, they don't
follow the normal standard locations. The following script which I built
from examples I found will get you most of your installed software:

code

import StringIO
import traceback
import wmi
import win32api
from _winreg import HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, OpenKey,
EnumValue, QueryValueEx

# logs the software to a text file
# edit to your taste
appFile = open(r'c:\software.log', 'w')

r = wmi.Registry ()
result, names = r.EnumKey (hDefKey=HKEY_LOCAL_MACHINE,
sSubKeyName=rSoftware\Microsoft\Windows\CurrentVersion\Uninstall)
index = 0

userName = win32api.GetUserName()
domainName = win32api.GetDomainName()
compName = win32api.GetComputerName()

appFile.write('Computer Name: \t%s\n' % compName)
appFile.write('Domain: \t\t%s\n' % domainName)
appFile.write('User ID: \t\t%s\n\n' % userName)

appFile.write('These subkeys are found under
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\n
\n')

for subkey in names:
try:
 
appFile.write('+++
++\n\n')
key = OpenKey(HKEY_LOCAL_MACHINE,
 
rSoftware\Microsoft\Windows\CurrentVersion\Uninstall\%s % subkey,0,
KEY_ALL_ACCESS) 
try:
temp = QueryValueEx(key, 'DisplayName')
display = str(temp[0])
appFile.write('Display Name: ' + display + '\nRegkey: ' +
subkey + '\n')
except:
appFile.write('Regkey: ' + subkey + '\n')

except:
fp = StringIO.StringIO()
traceback.print_exc(file=fp)
errorMessage = fp.getvalue()
##print 'Error for ' + key + '. Message follows:\n' + errorMessage
index = 0

appFile.close()

/code

Hope that helps. I have a more complicated one too, but I don't think it
gets much more information than the above.

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] winshell error

2008-01-24 Thread Mike Driscoll
Hi Tim,

 Message: 6
 Date: Thu, 24 Jan 2008 16:23:47 +
 From: Tim Golden [EMAIL PROTECTED]
 Subject: Re: [python-win32] winshell error
 Cc: python-win32@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 Mike Driscoll wrote:
  I have a Python login script that runs various things on 
 login for the
  users in our Windows domain. Every once in a while, I'll 
 get a traceback
  when I use winshell to try to find the user's desktop. The 
 offending code
  is:
  
  userDesktop = winshell.desktop()
  
  And the traceback:
  
  File \\servername\logon\MCISpy.py, line 256, in ?
  import SoScripts
File 
 \\servername\logon\PythonPackages\Utilities\SoScripts.py, line
  42, in ?
  userDesktop = winshell.desktop()
File 
 \\servername\logon\Python24\lib\site-packages\winshell.py, line
  48, in desktop
  return get_path ((shellcon.CSIDL_DESKTOP,
  shellcon.CSIDL_COMMON_DESKTOPDIRECTORY)[common])
File 
 \\servername\logon\Python24\lib\site-packages\winshell.py, line
  44, in get_path
  return shell.SHGetPathFromIDList 
 (shell.SHGetSpecialFolderLocation (0,
  folder_id))
  com_error: (-2147467259, 'Unspecified error', None, None)
  
  
  Our login scripts have an error reporting module that emails the
  tracebacks to us when they occur. Since this doesn't happen 
 every time the
  user logs in, it is difficult to track down. Does anyone 
 know what this is
  and how to fix it?
 
 Doing things in login scripts is, unfortunately, a recipe for
 sporadic issues of this sort. I don't know if it's documented
 (and I haven't actually looked too hard) but the interaction
 between the Windows Shell's own startup activities and a
 domain-level logon script seems to be ill-defined.
 
 I hope that someone reading this has more recent experience
 (and more knowledge) than I do re login scripts, but when I
 was responsible for a several-thousand-line Kixtart login
 script, we found that we just had to throw in random delays
 -- perhaps, here, catching the exception and trying again after
 delay -- because the login script had somehow got ahead of the
 desktop / profile setup.
 
 TJG
 
 

When I was hired, I had to convert almost all our Kixtart scripts to
Python. The Kixtart programmer we had didn't seem to understand loops or
functions, so the code was a mess and very difficult to follow. Thus, I
don't know if his was any more reliable than the Python login scripts, but
at least we know when the Python ones have a problem.

I don't know if putting in a delay is feasible. We get complaints from
users on our T1 and wireless connections that it's too slow. Maybe I'll
spin some of the stuff into their own threads that can repeat themselves
in some kind of try/exception loop for x iterations...

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Why Win32_ prefixed classed in wmi didn't work?

2008-01-24 Thread Mike Driscoll
Sorry...forgot to change the Subject line on that last one. This is a
repost

 thunder thunder54007 wrote:
  I got it, I should get an instance first before i can use
 it, and here is
  another problem, when I use Win32_Product to fetch the
 installed software on
  my system, but only some of them are returned, I don't know
 why? how can i
  get all the installed software on my system?
 
 (Please keep copying back to this; you'll get more help that way)
 
 That's a more general windows / Win32_Product question. If I remember 
 correctly, Win32_Product only lists products installed in a certain 
 way (probably via .MSI). Win32_SoftwareElement or associated classes 
 [1] may give you something. After that, you're just down to scraping 
 the registry, I think. I'm afraid this isn't really my area of 
 expertise. (He says, as though he *has* an area of expertise :)
 
 TJG
 
 [1] http://msdn2.microsoft.com/en-us/library/aa390887(VS.85).aspx
 
 
 --

I had to write a script that was supposed to get all the installed
software on any system. There is no way to get everything because some
software does not write anything to the registry or if they do, they don't
follow the normal standard locations. The following script which I built
from examples I found will get you most of your installed software:

code

import StringIO
import traceback
import wmi
import win32api
from _winreg import HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, OpenKey,
EnumValue, QueryValueEx

# logs the software to a text file
# edit to your taste
appFile = open(r'c:\software.log', 'w')

r = wmi.Registry ()
result, names = r.EnumKey (hDefKey=HKEY_LOCAL_MACHINE,
sSubKeyName=rSoftware\Microsoft\Windows\CurrentVersion\Uninstall)
index = 0

userName = win32api.GetUserName()
domainName = win32api.GetDomainName()
compName = win32api.GetComputerName()

appFile.write('Computer Name: \t%s\n' % compName)
appFile.write('Domain: \t\t%s\n' % domainName) appFile.write('User ID:
\t\t%s\n\n' % userName)

appFile.write('These subkeys are found under
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\n
\n')

for subkey in names:
try:
 
appFile.write('+++
++\n\n')
key = OpenKey(HKEY_LOCAL_MACHINE,
 
rSoftware\Microsoft\Windows\CurrentVersion\Uninstall\%s % subkey,0,
KEY_ALL_ACCESS) 
try:
temp = QueryValueEx(key, 'DisplayName')
display = str(temp[0])
appFile.write('Display Name: ' + display + '\nRegkey: ' +
subkey + '\n')
except:
appFile.write('Regkey: ' + subkey + '\n')

except:
fp = StringIO.StringIO()
traceback.print_exc(file=fp)
errorMessage = fp.getvalue()
##print 'Error for ' + key + '. Message follows:\n' + errorMessage
index = 0

appFile.close()

/code

Hope that helps. I have a more complicated one too, but I don't think it
gets much more information than the above.

Mike


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] winshell error

2008-01-24 Thread Mike Driscoll
 --
 
 Message: 9
 Date: Thu, 24 Jan 2008 10:40:27 -0800
 From: Tim Roberts [EMAIL PROTECTED]
 Subject: Re: [python-win32] winshell error
 To: Python-Win32 List python-win32@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 Mike Driscoll wrote:
  I have a Python login script that runs various things on 
 login for the
  users in our Windows domain. Every once in a while, I'll 
 get a traceback
  when I use winshell to try to find the user's desktop. The 
 offending code
  is:
 
  userDesktop = winshell.desktop()
 
  And the traceback:
  ...
  com_error: (-2147467259, 'Unspecified error', None, None)

 
 That's 80004005, or E_FAIL.  Not very helpful.
 
 How quickly does this run?  At login time, there is a transition from 
 the login window station to the interactive window station.  
 The login 
 window station runs under a system user account that doesn't have a 
 desktop.  As an experiment, you might try adding a delay of a 
 few seconds.


The run time depends on which location the user is in. We have some users
on a T1 and others on microwave. This particular user is on the T1, so the
script probably runs 20-40 seconds depending on the load. We have set a
registry setting to force the login script to run before the desktop is
loaded...not sure if that helps though.

I'll ask my boss if putting in a delay is something he would want.


 
 Is it possible that this happens for a user that doesn't 
 currently have 
 a profile on that machine?  It takes time for the system to 
 build a new 
 profile for a first-time user, and until it's built, the 
 CSIDLs probably 
 do not exist.


This is a possibility, I suppose. I know that this user has been with our
company for quite a while, but since his department shares PCs, he may
have logged into a PC that he hasn't logged into before or that has had
its profiles cleaned.

I don't suppose anyone knows how to do a logout script? There are some
things that would be better off if we could do them on logout rather than
login.

 
 -- 
 Tim Roberts, [EMAIL PROTECTED]
 Providenza  Boekelheide, Inc.
 
 

Mike Driscoll
Applications Specialist


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Creating a process and getting a handle

2008-01-23 Thread Mike Driscoll
Tim, 

Mike Driscoll wrote:
  I am trying to get a handle on an external process (Internet Explorer
6 in
  this case) that I open using win32process. I need the handle so that I
can
  make said process the top window. 

 When you call CreateProcess, that window should automatically become the

 top window.  Are you saying that's not happening?  Have you tried 
 creating a STARTUPINFO struct and filling in the wShowWindow element?

Sorry, I guess I thought more than I actually typed. It does make the
newly created window the top window. But later on in my program, I open
the source code for the displayed page and will need to make sure that I
return to the correct IE instance, which is why I wanted a handle on the
IE window. I thought I knew the correct terminology to express this, but I
guess not.

snip

 
  # attempt to make Internet Explorer 6 the Foreground Window
  win32gui.SetForegroundWindow(handle)


 No, the error message is right.  A process handle is not the same as a 
 window handle.  Indeed, a process need not have any windows at all.

  I can get the handle by doing this:
 
  hwnd = win32gui.FindWindow('IEFrame',None)
 
  But if there's multiple Explorer windows open, I may not get the
window I
  want. That's why I would like to create my own so I can have what
amounts
  to an exclusive handle to it. Any hints would be appreciated.


 One possibility is to enumerate through all of the top-level windows 
 using EnumWindows, and for each window call GetWindowThreadProcessId to 
 find the process ID associated with that window to find the one that 
 matches your process.  Remember that the process ID is not the same as a

 process handle; the process ID is the third thing in the tuple 
 CreateProcess returns.

Yeah, I am well aware of this method and was hoping to avoid it. Thanks
for the clarification on window handle versus process handle. I was
thinking about this the wrong way because I thought they were the same.


 -- 
 Tim Roberts, [EMAIL PROTECTED]
 Providenza  Boekelheide, Inc.

Mike Driscoll
Applications Specialist
MCIS - Technology Center


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Creating a process and getting a handle

2008-01-23 Thread Mike Driscoll
Alec,

 
 Date: Tue, 22 Jan 2008 23:26:50 -0800 (PST)
 From: Alec Bennett [EMAIL PROTECTED]
 Subject: Re: [python-win32] Creating a process and getting a handle
 To: Tim Roberts [EMAIL PROTECTED], Python-Win32 List
   python-win32@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=iso-8859-1
 
 Please post what you find on this, I'm curious too.
 
 If you do go the enum windows route, It thought I'd
 post my notes on this since I recently got it working.
 It's somewhat confusing (for me at least) since it
 uses a callback:
 
 
 # Callback function for findWindowHandle
 def windowEnumerationHandler(hwnd, resultList):
 
 resultList.append((hwnd,
 win32gui.GetWindowText(hwnd)))
 
 
 def findWindowHandle(string):
 
 topWindows = []
 
 win32gui.EnumWindows(windowEnumerationHandler,
 topWindows)
 
 for window in topWindows:
 if string in window[1]: return window[0],
 window[1]
 
 # Looks like we didn't find anything
 return None, None
 
 
 handle, windowtext = findWindowHandle(Notepad)

I actually use a method similar to this later on in my program. But as I
mentioned to Tim, I was trying to get a handle on a window that I open so
I wouldn't have to search for it. I use the search method already to find
the source code window that I open from within IE. Sometimes automation
sucks.

Mike Driscoll
Applications Specialist
MCIS - Technology Center

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Creating a process and getting a handle

2008-01-23 Thread Mike Driscoll
Hi Tim G., 

snipped for brevity

  I can get the handle by doing this:
  
  hwnd = win32gui.FindWindow('IEFrame',None)
  
  But if there's multiple Explorer windows open, I may not get the 
  window I want. That's why I would like to create my own so 
 I can have 
  what amounts to an exclusive handle to it. Any hints 
 would be appreciated.
 
 I thought I'd posted a How-Do-I? on this one, but obviously 
 not. At any rate, here's the code I intended to post up. Hope 
 it helps as a starting point:
 
 code
 import subprocess
 import time
 
 import win32con
 import win32gui
 import win32process
 
 
 def get_hwnds_for_pid (pid):
 
def callback (hwnd, hwnds):
  if win32gui.IsWindowVisible (hwnd) and 
 win32gui.IsWindowEnabled (hwnd):
_, found_pid = win32process.GetWindowThreadProcessId (hwnd)
if found_pid == pid:
  hwnds.append (hwnd)
  return True
 
hwnds = []
win32gui.EnumWindows (callback, hwnds)
return hwnds
 
 if __name__ == '__main__':
notepad = subprocess.Popen ([rnotepad.exe])
#
# sleep to give the window time to appear
#
time.sleep (2.0)
 
for hwnd in get_hwnds_for_pid (notepad.pid):
  print hwnd, =, win32gui.GetWindowText (hwnd)
  win32gui.SendMessage (hwnd, win32con.WM_CLOSE, 0, 0)
 
 /code
 
 TJG
 

I think this will work. It's a little bit quicker than the method Alec
mentioned (and which I use in another part of my app) and it's definitely
a little less confusing. I just tested it by opening a couple other
instances of Notepad before running it and your script kills only the
Notepad process that it opens, as expected. Very cool.

Thanks for helping me once again.

Mike

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Creating a process and getting a handle

2008-01-22 Thread Mike Driscoll
Hi,

I am trying to get a handle on an external process (Internet Explorer 6 in
this case) that I open using win32process. I need the handle so that I can
make said process the top window. Here's what I've tried so far:

code

import win32process
import win32gui

info = win32process.CreateProcess(None, proc, None, None, 0,
win32process.NORMAL_PRIORITY_CLASS, None, None,
win32process.STARTUPINFO())
handle = info[0]

# attempt to make Internet Explorer 6 the Foreground Window
win32gui.SetForegroundWindow(handle)

/code

Unfortunately, this results in a traceback:

Traceback (most recent call last):
  File pyshell#12, line 1, in ?
win32gui.SetForegroundWindow(info[2])
error: (1400, 'SetForegroundWindow', 'Invalid window handle.')

I can get the handle by doing this:

hwnd = win32gui.FindWindow('IEFrame',None)

But if there's multiple Explorer windows open, I may not get the window I
want. That's why I would like to create my own so I can have what amounts
to an exclusive handle to it. Any hints would be appreciated.

I am using Windows XP SP2 with Python 2.4.3. Thanks!

Mike Driscoll
Applications Specialist
MCIS - Technology Center

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32