From nanotube at gmail.com Fri Apr 1 04:40:02 2005 From: nanotube at gmail.com (Daniel F) Date: Fri Apr 1 04:40:04 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: <424C5A83.5030408@probo.com> References: <20050331100019.432FF1E4061@bag.python.org> <424C5A83.5030408@probo.com> Message-ID: > It depends entirely on what the application expects. When the keyboard > driver sends keystrokes, the generic keyboard driver translates the key > codes to characters, if possible. It will send WM_KEYDOWN, then WM_CHAR > (if an ASCII translation exists), then WM_KEYUP. Applications can > choose which ones they want to handle. > > In your case, you are bypassing the keyboard driver stack entirely. The > standard edit control, which is all Notepad is, apparently looks only at > WM_CHAR. There is no a priori method for figuring out which one is > required. If you need a general solution, you send all three. In this > case, since you want a specific solution, you can send just WM_CHAR. Well, i do need a general solution, I was just using notepad as a test case... So it's definitely good for me to know about this - thanks! But i wonder, isnt there some kind of an "upstream" event, that could be generated and then would automatically generate and propagate all of the keydown, char, and keyup events, so i do not have to worry about sending all three? also, as to roel's earlier post... could I please have some help on how to generate a bit field in python, in order to send a well-formed lParam to SendMessage, and thus create a well-formed WM_KEYUP/KEYDOWN event? Thanks, Daniel From rschroev_nospam_ml at fastmail.fm Fri Apr 1 13:05:38 2005 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Fri Apr 1 13:06:37 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: <424C5A83.5030408@probo.com> References: <20050331100019.432FF1E4061@bag.python.org> <424C5A83.5030408@probo.com> Message-ID: Tim Roberts wrote: > On Wed, 30 Mar 2005 20:46:43 -0500, Daniel F wrote: > >> Well... i figured it out - turns out sending the keystrokes to the top >> window of notepad didnt work, but sending them to the Edit child >> window of notepad did the trick. >> >> But this brings me to another question, although of a less urgent >> manner. i had to send WM_CHAR messages, rather than WM_KEYDOWN/KEYUP >> in order to get it to work. I have nothing against WM_CHAR, as long as >> everything works, but i am just curious why i was not able to achieve >> the same effect with the WM_KEYDOWN/KEYUP pair? any takers? >> > It depends entirely on what the application expects. When the keyboard > driver sends keystrokes, the generic keyboard driver translates the key > codes to characters, if possible. It will send WM_KEYDOWN, then WM_CHAR > (if an ASCII translation exists), then WM_KEYUP. Applications can > choose which ones they want to handle. Not really: AFAIK this is not done by the keyboard driver; it is done by the TranslateMessage function which is normally called in the message loop. MSDN on WM_CHAR: "The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function" > In this case, since you want a specific solution, you can send just WM_CHAR. Indeed. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From theller at python.net Fri Apr 1 14:09:33 2005 From: theller at python.net (Thomas Heller) Date: Fri Apr 1 14:11:08 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes References: <20050331100019.432FF1E4061@bag.python.org> <424C5A83.5030408@probo.com> Message-ID: Roel Schroeven writes: > Tim Roberts wrote: > >> On Wed, 30 Mar 2005 20:46:43 -0500, Daniel F wrote: >> >>> Well... i figured it out - turns out sending the keystrokes to the top >>> window of notepad didnt work, but sending them to the Edit child >>> window of notepad did the trick. >>> >>> But this brings me to another question, although of a less urgent >>> manner. i had to send WM_CHAR messages, rather than WM_KEYDOWN/KEYUP >>> in order to get it to work. I have nothing against WM_CHAR, as long as >>> everything works, but i am just curious why i was not able to achieve >>> the same effect with the WM_KEYDOWN/KEYUP pair? any takers? >>> >> It depends entirely on what the application expects. When the keyboard >> driver sends keystrokes, the generic keyboard driver translates the key >> codes to characters, if possible. It will send WM_KEYDOWN, then WM_CHAR >> (if an ASCII translation exists), then WM_KEYUP. Applications can >> choose which ones they want to handle. > > Not really: AFAIK this is not done by the keyboard driver; it is done by > the TranslateMessage function which is normally called in the message loop. > > MSDN on WM_CHAR: "The WM_CHAR message is posted to the window with the > keyboard focus when a WM_KEYDOWN message is translated by the > TranslateMessage function" > Since TranslateMessage, which is typically called in the application's message pump, creates the WM_CHAR messages, the OP would probably get what he expects when he uses PostMessage for WM_KEYDOWN/WM_KEYUP instead of SendMessage. Thomas From timr at probo.com Fri Apr 1 19:59:50 2005 From: timr at probo.com (Tim Roberts) Date: Fri Apr 1 19:59:56 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: <20050401100050.CBDBF1E4012@bag.python.org> References: <20050401100050.CBDBF1E4012@bag.python.org> Message-ID: <424D8C16.5080805@probo.com> On Thu, 31 Mar 2005 21:40:02 -0500, Daniel F wrote: >Well, i do need a general solution, I was just using notepad as a test >case... So it's definitely good for me to know about this - thanks! >But i wonder, isnt there some kind of an "upstream" event, that could >be generated and then would automatically generate and propagate all >of the keydown, char, and keyup events, so i do not have to worry >about sending all three? > > You might investigate MapVirtualKey, keybd_event, and SendInput. I have no clue whether these are exposed in the Python Win32 extensions. Overall, I would guess the three-message parlay is the lowest-impact method. >also, as to roel's earlier post... could I please have some help on >how to generate a bit field in python, in order to send a well-formed >lParam to SendMessage, and thus create a well-formed WM_KEYUP/KEYDOWN >event? > Python supports C expressions; you just build it by hand: bits = 0x8000000 | 0x00030000 | vkKey Or, if you prefer the bit numbers explicitly: bits = (2 << 30) | (3 << 16) | vkKey -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From nanotube at gmail.com Fri Apr 1 23:19:56 2005 From: nanotube at gmail.com (Daniel F) Date: Fri Apr 1 23:19:58 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: <424D8C16.5080805@probo.com> References: <20050401100050.CBDBF1E4012@bag.python.org> <424D8C16.5080805@probo.com> Message-ID: Thank you all for your suggestions! Using PostMessage with WM_KEYDOWN/KEYUP, and creating the lparam bitfield like that, does the trick quite well. Really appreciate your help! :) On Apr 1, 2005 12:59 PM, Tim Roberts wrote: > On Thu, 31 Mar 2005 21:40:02 -0500, Daniel F wrote: > > >Well, i do need a general solution, I was just using notepad as a test > >case... So it's definitely good for me to know about this - thanks! > >But i wonder, isnt there some kind of an "upstream" event, that could > >be generated and then would automatically generate and propagate all > >of the keydown, char, and keyup events, so i do not have to worry > >about sending all three? > > > > > > You might investigate MapVirtualKey, keybd_event, and SendInput. I have > no clue whether these are exposed in the Python Win32 extensions. > Overall, I would guess the three-message parlay is the lowest-impact method. > > >also, as to roel's earlier post... could I please have some help on > >how to generate a bit field in python, in order to send a well-formed > >lParam to SendMessage, and thus create a well-formed WM_KEYUP/KEYDOWN > >event? > > > > Python supports C expressions; you just build it by hand: > > bits = 0x8000000 | 0x00030000 | vkKey > > Or, if you prefer the bit numbers explicitly: > > bits = (2 << 30) | (3 << 16) | vkKey > > -- > - Tim Roberts, timr@probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From nanotube at gmail.com Sat Apr 2 10:17:46 2005 From: nanotube at gmail.com (Daniel F) Date: Sat Apr 2 10:17:50 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: <20050401100050.CBDBF1E4012@bag.python.org> <424D8C16.5080805@probo.com> Message-ID: Wait, spoke a bit too soon. I noticed that you (Tim) apparently missed a zero in your first method of building the bits (8 with 6 zeros instead of 7), which generates only a 28bit number, not 32bits. (which i blindly copy pasted at first...). when i try to make an actual 32bit value, and then send it to the PostMessage function, i get the following exception: win32api.PostMessage(self.subHwnd, win32con.WM_KEYDOWN, virtualKeyCode, keyDownBits) OverflowError: long int too large to convert to int as i understand it, then... PostMessage expects exactly 32bits... and my guess is that since python has no unsigned ints, a 32bit value needs more than 32bits, so python makes it a long, and then postmessage complains about longs because it expects an int-sized value. Would that be a bug in python's implementation of PostMessage, or am i missing something? btw, postmessage(keydown) works just as well with a 31-bit value... so i guess i have no problem with this, just asking out of curiosity. Thanks, Daniel On Apr 1, 2005 4:19 PM, Daniel F wrote: > Thank you all for your suggestions! Using PostMessage with > WM_KEYDOWN/KEYUP, and creating the lparam bitfield like that, does the > trick quite well. Really appreciate your help! :) > > On Apr 1, 2005 12:59 PM, Tim Roberts wrote: > > On Thu, 31 Mar 2005 21:40:02 -0500, Daniel F wrote: > > > > >Well, i do need a general solution, I was just using notepad as a test > > >case... So it's definitely good for me to know about this - thanks! > > >But i wonder, isnt there some kind of an "upstream" event, that could > > >be generated and then would automatically generate and propagate all > > >of the keydown, char, and keyup events, so i do not have to worry > > >about sending all three? > > > > > > > > > > You might investigate MapVirtualKey, keybd_event, and SendInput. I have > > no clue whether these are exposed in the Python Win32 extensions. > > Overall, I would guess the three-message parlay is the lowest-impact method. > > > > >also, as to roel's earlier post... could I please have some help on > > >how to generate a bit field in python, in order to send a well-formed > > >lParam to SendMessage, and thus create a well-formed WM_KEYUP/KEYDOWN > > >event? > > > > > > > Python supports C expressions; you just build it by hand: > > > > bits = 0x8000000 | 0x00030000 | vkKey > > > > Or, if you prefer the bit numbers explicitly: > > > > bits = (2 << 30) | (3 << 16) | vkKey > > > > -- > > - Tim Roberts, timr@probo.com > > Providenza & Boekelheide, Inc. > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > From graemeglass at gmail.com Sat Apr 2 11:36:30 2005 From: graemeglass at gmail.com (Graeme Glass) Date: Sat Apr 2 11:36:33 2005 Subject: [python-win32] Sparse files and Pickle Message-ID: Is there anyway to create a sparse file win32 platform using python? And out of interested what is the practical limit for pickling an object? I used pickle.dump() on a 89MB object (a binary read from a disk file) and although it worked, my PC was pretty unusable for the 8 minutes it took to pickle. Thanks, Graeme. From me at chi-tai.info Sat Apr 2 21:56:53 2005 From: me at chi-tai.info (Chi Tai) Date: Sat Apr 2 21:57:47 2005 Subject: [python-win32] Handle to a Driver Message-ID: <424EF905.5040809@chi-tai.info> Hello list, maybe someone can help me. I am writing an application, which uses the win32event.CreateEvent to create a synchronisation event which handle is then stored in a PyHANDLE. This handle is then submitted with DeviceIoControl to a Driver which calls the Function ObReferenceObjectByHandle to get a valid kernel handle to the user-mode handle. And here the problem occours. This function returns with a "invalid handle" status. The code is as follows: Python: ReadEvent = CreateEvent ( None, 0, 0, None ) ret = DeviceIoControl (hDevice, IOCTL_SET_READ_EVENT, str(ReadEvent), 0, None) Driver code in Dispatch Routine for IOCTL: ntStatus = ObReferenceObjectByHandle ( handleFromPython, EVENT_MODIFY_STATE, *ExEventObjectType, Irp->RequestorMode, (PVOID*) &EventHandleDestination, NULL); The ReferenceObject has to be done, because each user-mode process has another context, and windows kernle-mode works in an arbitrary-thread-context, thus it is needed to make a kernel-mode eventhandle to access it later. Is it possible that the win32 extensions wrapped the functions whithin it's own handle-table, so that the operating system can't find the handle-id in the system handle table ? i know it's not a common problem... but drivers often have to notify user-mode applications, and this is the way they do it. Chi-Tai From richard at inferspace.com Sun Apr 3 01:48:55 2005 From: richard at inferspace.com (Richard Dybowski) Date: Sun Apr 3 01:51:22 2005 Subject: [python-win32] Cannot move or resize the PythonWin window Message-ID: <5.2.1.1.2.20050403004346.00a1d540@mailhost.zen.co.uk> I cannot move or resize the PythonWin window. Any suggestions please? Thanks, Richard Python 2.4.1 installed from python-2.4.1.msi Python Win32 Extension installed from pywin32-203.win32-py2.4.exe I have Windows 98 SE ------------------------------- Dr Richard Dybowski 143 Village Way Pinner HA5 5AA, UK Tel: 07976 250092 From mhammond at skippinet.com.au Sun Apr 3 05:06:05 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Apr 3 05:06:13 2005 Subject: [python-win32] Handle to a Driver In-Reply-To: <424EF905.5040809@chi-tai.info> Message-ID: <245901c537fa$13e19630$040a0a0a@enfoldsystems.local> > Python: > ReadEvent = CreateEvent ( None, 0, 0, None ) > ret = DeviceIoControl (hDevice, IOCTL_SET_READ_EVENT, str(ReadEvent), > 0, None) str(ReadEvent) would give you a string with something like ''. It seems unlikely to me that this is your intention. Maybe str(int(ReadEvent)) - this would just send the handle value (as a string) > Driver code in Dispatch Routine for IOCTL: > ntStatus = ObReferenceObjectByHandle ( handleFromPython, > EVENT_MODIFY_STATE, *ExEventObjectType, Irp->RequestorMode, (PVOID*) > &EventHandleDestination, NULL); It's not clear to me how 'handleFromPython' gets its value. I expect that is your problem. > Is it possible that the win32 extensions wrapped the functions whithin > it's own handle-table, so that the operating system can't find the > handle-id in the system handle table ? Nope, but there is "auto-close" behaviour that may be biting you (or about to bite you :) As soon as the ReadEvent object goes out of scope, CloseHandle() will be automatically called for the underlying handle. The Detach() method on a handle lets you get the integer handle and "detaches" it from the object, so CloseHandle will not be called. In your example above that should not be a problem (ReadEvent remains in scope during the call to DeviceIoControl) - but if the driver is storing the handle for use internally, things will start going wrong when the object dies. Mark From mhammond at skippinet.com.au Sun Apr 3 05:21:20 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Apr 3 05:21:26 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to sendkeystrokes In-Reply-To: Message-ID: <245c01c537fc$3594aef0$040a0a0a@enfoldsystems.local> > as i understand it, then... PostMessage expects exactly 32bits... and > my guess is that since python has no unsigned ints, a 32bit value > needs more than 32bits, so python makes it a long, and then > postmessage complains about longs because it expects an int-sized > value. PostMessage wants a Python integer object (or a long that could fit in an int). In practice, that means sending a negative integer when you want the MSB set. Sadly (IMO), in Python 2.4, all these bitwise operations have become more "pythonic" rather than like C. Thus, in 2.3 and earlier: >>> 1<<31 -2147483648 but 2.4+: >>> 1<<31 2147483648L > Would that be a bug in python's implementation of PostMessage, > or am i missing something? Many of the pywin32 functions work like this, and will not accept the new long value. I beleive that can be fixed fairly easily - but changing the return values from these functions would open a can of worms. I'm not sure of a clean solution. Mark From rschroev_nospam_ml at fastmail.fm Sun Apr 3 11:07:56 2005 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Sun Apr 3 11:08:21 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to sendkeystrokes In-Reply-To: <245c01c537fc$3594aef0$040a0a0a@enfoldsystems.local> References: <245c01c537fc$3594aef0$040a0a0a@enfoldsystems.local> Message-ID: Mark Hammond wrote: > PostMessage wants a Python integer object (or a long that could fit in an > int). In practice, that means sending a negative integer when you want the > MSB set. > > Sadly (IMO), in Python 2.4, all these bitwise operations have become more > "pythonic" rather than like C. Thus, in 2.3 and earlier: > > >>>>1<<31 > > -2147483648 > > but 2.4+: > > >>>>1<<31 > > 2147483648L > > >>Would that be a bug in python's implementation of PostMessage, >>or am i missing something? > > > Many of the pywin32 functions work like this, and will not accept the new > long value. I beleive that can be fixed fairly easily - but changing the > return values from these functions would open a can of worms. I'm not sure > of a clean solution. One option seems to be to run the desired Python long value trough a pack and unpack sequence to get the corresponding integer value: from struct import * >>> unpack('=l', pack('=L', 0xC0000000))[0] -1073741824 -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From graemeglass at gmail.com Sun Apr 3 12:37:40 2005 From: graemeglass at gmail.com (Graeme Glass) Date: Sun Apr 3 12:37:43 2005 Subject: [python-win32] Sparse files and Pickle Message-ID: Could anyone tell me if it is possible to create a sparse file on win32 platform using python, and if so how? And just out of interest, what is the practical limit for pickling an object? I pickled a 89MB binary read from a disk file, and although it worked, hogged my PC for about 8minutes making it unusable. Many thanks, Graeme From me at chi-tai.info Sun Apr 3 13:32:01 2005 From: me at chi-tai.info (Chi Tai) Date: Sun Apr 3 13:32:53 2005 Subject: [python-win32] Handle to a Driver In-Reply-To: <245901c537fa$13e19630$040a0a0a@enfoldsystems.local> References: <245901c537fa$13e19630$040a0a0a@enfoldsystems.local> Message-ID: <424FD431.8000800@chi-tai.info> i've found the faulty. For those interested in: win32file.DeviceIoControl transfers a string or character array, thus a numerical value like a handle is also transfered as a character array and the cast operation within the driver does not result in a valid handle. > str(ReadEvent) would give you a string with something like > ''. It seems unlikely to me that this is your > intention. Maybe str(int(ReadEvent)) - this would just send the > handle value (as a string) I have tried this, but then it's size is less than "sizeof(HANDLE)" and even if i remove the size-check the Routine fails with an invalid handle error. > > Driver code in Dispatch Routine for IOCTL: ntStatus = > > ObReferenceObjectByHandle ( handleFromPython, EVENT_MODIFY_STATE, > > *ExEventObjectType, Irp->RequestorMode, (PVOID*) > > &EventHandleDestination, NULL); > > > It's not clear to me how 'handleFromPython' gets its value. I > expect that is your problem. Yes, this seems to be the problem. "handleFromPython" must be a valid Handle object which represents a valid handle-entry in the user-modes handle-table of the calling Thread. It's transfered using the buffered i/o mode and the following code snippet in the driver: HANDLE handleFromPython = *( (PHANDLE) Irp->AssociatedIrp.SystemBuffer ) (btw: this call (DeviceIoControl) succeeds with a HANDLE in C++, so it must be something with the PyHANDLE given to the win32file.DeviceIoControl(...), which i don't understand... ) > > Is it possible that the win32 extensions wrapped the functions > > whithin it's own handle-table, so that the operating system can't > > find the handle-id in the system handle table ? > > > Nope, but there is "auto-close" behaviour that may be biting you > (or about to bite you :) > > As soon as the ReadEvent object goes out of scope, CloseHandle() > will be automatically called for the underlying handle. The > Detach() method on a handle lets you get the integer handle and > "detaches" it from the object, so CloseHandle will not be called. > In your example above that should not be a problem (ReadEvent > remains in scope during the call to DeviceIoControl) - but if the > driver is storing the handle for use internally, things will start > going wrong when the object dies. > > Mark From digobaptista at gmail.com Sun Apr 3 22:47:50 2005 From: digobaptista at gmail.com (Rodrigo Baptista) Date: Sun Apr 3 22:47:53 2005 Subject: [python-win32] Fnorb problems Message-ID: Hi im using Python-2.3.5.exe and Fnorb-1.3.win32.exe and i want to use the fnidl to compile idl files. The instalation of fnorb goes ok, but when i execute fnidl it comes this: C:\Python23\Scripts>fnidl Traceback (most recent call last): File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 239, in ? sys.exit(main(sys.argv)) File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 126, in main result = main_interactive(context) File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 144, in main_ interactive ifr = IntRepImpl.RepositoryImpl() File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 675, in __init__ self.get_primitive(CORBA.pk_boolean), File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 748, in get_primitive self._fnorb_register_impl(key, PrimitiveDefImpl._FNORB_ID, definition) File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 80, in _fnorb_register_impl boa = BOA.BOA_init() File "C:\Python23\Lib\site-packages\Fnorb\orb\BOA.py", line 61, in BOA_init boa = BOA(argv, boa_id) File "C:\Python23\Lib\site-packages\Fnorb\orb\BOA.py", line 151, in __init__ protocol.enable(host, port) File "C:\Python23\Lib\site-packages\Fnorb\orb\IIOPProtocol.py", line 61, in en able self.__nudger = Nudger.Nudger() File "C:\Python23\Lib\site-packages\Fnorb\orb\Nudger.py", line 99, in __init__ raise CORBA.COMM_FAILURE() # System exception. Fnorb.orb.CORBA.COMM_FAILURE: Minor: 0 Completed: COMPLETED_NO Exception exceptions.AttributeError: "Nudger instance has no attribute '_Nudger_ _reactor'" in > ignored Someone can help me? Thanks, Digo From me at chi-tai.info Mon Apr 4 15:16:32 2005 From: me at chi-tai.info (Chi Tai) Date: Mon Apr 4 15:17:26 2005 Subject: [python-win32] character to integer Message-ID: <42513E30.2000503@chi-tai.info> Hello, how can i make an integer value from a character value like this. string = "Hallo" integerval = string[0] i = integerval + 2 #this does not work because integerval is not an integer value i want the in integervalue the intvalue of the hexvalue 0x48 ( the character-value of "H") Is there a simple possibility ? Chi-Tai From simon.dahlbacka at gmail.com Mon Apr 4 15:37:00 2005 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Mon Apr 4 15:37:04 2005 Subject: [python-win32] character to integer In-Reply-To: <42513E30.2000503@chi-tai.info> References: <42513E30.2000503@chi-tai.info> Message-ID: <5712472050404063726d4c265@mail.gmail.com> help(ord) On Apr 4, 2005 4:16 PM, Chi Tai wrote: > Hello, > > how can i make an integer value from a character value like this. > > string = "Hallo" > integerval = string[0] > i = integerval + 2 #this does not work because integerval is not an > integer value > > i want the in integervalue the intvalue of the hexvalue 0x48 ( the > character-value of "H") > Is there a simple possibility ? > > Chi-Tai > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From simon.brunning at gmail.com Mon Apr 4 15:48:44 2005 From: simon.brunning at gmail.com (Simon Brunning) Date: Mon Apr 4 15:48:47 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: Message-ID: <8c7f10c605040406483533ab2b@mail.gmail.com> On Mar 30, 2005 4:28 PM, Daniel F wrote: > Hi, > > I am trying to use win32gui.SendMessage API (or PostMessage), and > cannot figure out why > it is not working. I would appreciate any help! Simple test script I > am using is included below. > > I am using pywin32-203 and python 2.4, on winxp pro sp2. > > #### Script to try to write something down in notepad (snip script) You might want to take a look at WATSUP (). It has a Windos GUI automation module that you might want to mine for ideas. -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From digobaptista at gmail.com Sun Apr 3 22:41:08 2005 From: digobaptista at gmail.com (Rodrigo Baptista) Date: Mon Apr 4 17:02:57 2005 Subject: [python-win32] Fnorb problems Message-ID: Hi im using Python-2.3.5.exe and Fnorb-1.3.win32.exe and i want to use the fnidl to compile idl files. The instalation of fnorb goes ok, but when i execute fnidl it comes this: C:\Python23\Scripts>fnidl Traceback (most recent call last): File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 239, in ? sys.exit(main(sys.argv)) File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 126, in main result = main_interactive(context) File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 144, in main_ interactive ifr = IntRepImpl.RepositoryImpl() File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 675, in __init__ self.get_primitive(CORBA.pk_boolean), File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 748, in get_primitive self._fnorb_register_impl(key, PrimitiveDefImpl._FNORB_ID, definition) File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 80, in _fnorb_register_impl boa = BOA.BOA_init() File "C:\Python23\Lib\site-packages\Fnorb\orb\BOA.py", line 61, in BOA_init boa = BOA(argv, boa_id) File "C:\Python23\Lib\site-packages\Fnorb\orb\BOA.py", line 151, in __init__ protocol.enable(host, port) File "C:\Python23\Lib\site-packages\Fnorb\orb\IIOPProtocol.py", line 61, in en able self.__nudger = Nudger.Nudger() File "C:\Python23\Lib\site-packages\Fnorb\orb\Nudger.py", line 99, in __init__ raise CORBA.COMM_FAILURE() # System exception. Fnorb.orb.CORBA.COMM_FAILURE: Minor: 0 Completed: COMPLETED_NO Exception exceptions.AttributeError: "Nudger instance has no attribute '_Nudger_ _reactor'" in > ignored Someone can help me? Thanks, Digo From nanotube at gmail.com Mon Apr 4 17:08:09 2005 From: nanotube at gmail.com (Daniel F) Date: Mon Apr 4 17:08:14 2005 Subject: [python-win32] character to integer In-Reply-To: <42513E30.2000503@chi-tai.info> References: <42513E30.2000503@chi-tai.info> Message-ID: function ord() would get the int value of the char. and in case you want to convert back after playing with the number, function chr() does the trick >>> ord('a') 97 >>> chr(97) 'a' >>> chr(ord('a') + 3) 'd' >>> On Apr 4, 2005 9:16 AM, Chi Tai wrote: > Hello, > > how can i make an integer value from a character value like this. > > string = "Hallo" > integerval = string[0] > i = integerval + 2 #this does not work because integerval is not an > integer value > > i want the in integervalue the intvalue of the hexvalue 0x48 ( the > character-value of "H") > Is there a simple possibility ? > > Chi-Tai > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From timr at probo.com Mon Apr 4 18:29:34 2005 From: timr at probo.com (Tim Roberts) Date: Mon Apr 4 18:29:38 2005 Subject: [python-win32] Sparse files and Pickle In-Reply-To: <20050404100037.764651E4003@bag.python.org> References: <20050404100037.764651E4003@bag.python.org> Message-ID: <42516B6E.1000007@probo.com> On Sun, 3 Apr 2005 12:37:40 +0200, Graeme Glass wrote: >Could anyone tell me if it is possible to create a sparse file on >win32 platform using python, and if so how? > > Sparse files are only supported on Windows 2000 and more, on NTFS partitions. You will not be able to use the Python file I/O operations to do this. You have to send an ioctl (FSCTL_SET_SPARSE) to the file after it is opened, then you have to open a memory growable mapping of the file, and use that memory mapping to do your writes. CreateFile, DeviceIoControl, and the memory mapping methods are all provided in the Win32 extensions, but it makes me wonder if it wouldn't be easier to write a C extension for this. >And just out of interest, what is the practical limit for pickling an object? >I pickled a 89MB binary read from a disk file, and although it worked, >hogged my PC for about 8minutes making it unusable. > > I guess this depends on your threshhold of pain, and is likely to vary from PC to PC. I view pickling as a way to encode small objects for later resurrection. If I needed to refer to an 89MB disk file in an object, I would replace the data with the file name before pickling. I thought pickle recognized a magic method name so the object could "help" put itself into a picklable state, but I don't see it now. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Apr 4 18:37:04 2005 From: timr at probo.com (Tim Roberts) Date: Mon Apr 4 18:37:08 2005 Subject: [python-win32] Handle to a Driver In-Reply-To: <20050404100037.764651E4003@bag.python.org> References: <20050404100037.764651E4003@bag.python.org> Message-ID: <42516D30.9080202@probo.com> On Sun, 03 Apr 2005 13:32:01 +0200, Chi Tai wrote: >i've found the faulty. >For those interested in: win32file.DeviceIoControl transfers a string or >character array, thus a numerical value like a handle is also transfered >as a character array and the cast operation within the driver does not >result in a valid handle. > > Right. In this case, the ioctl wants a 4-byte integer value. win32event.CreateEvent returns a PyHANDLE object. The PyHANDLE object includes a property called "handle", menmonically enough, that returns the 4-byte integer value. Thus, this should do what you want: ret = DeviceIoControl( hDevice, IOCTL_SET_READ_EVENT, ReadEvent.handle, 0, None ) -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From digobaptista at gmail.com Mon Apr 4 18:38:57 2005 From: digobaptista at gmail.com (Rodrigo Baptista) Date: Mon Apr 4 18:39:01 2005 Subject: [python-win32] Fnorb problems In-Reply-To: References: Message-ID: Hi im using Python-2.3.5.exe and Fnorb-1.3.win32.exe and i want to use the fnidl to compile idl files. The instalation of fnorb goes ok, but when i execute fnidl it comes this: C:\Python23\Scripts>fnidl Traceback (most recent call last): File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 239, in ? sys.exit(main(sys.argv)) File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 126, in main result = main_interactive(context) File "C:\Python23\Lib\site-packages\Fnorb\script\fnidl.py", line 144, in main_ interactive ifr = IntRepImpl.RepositoryImpl() File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 675, in __init__ self.get_primitive(CORBA.pk_boolean), File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 748, in get_primitive self._fnorb_register_impl(key, PrimitiveDefImpl._FNORB_ID, definition) File "C:\Python23\Lib\site-packages\Fnorb\cos\interface_repository\IntRepImpl. py", line 80, in _fnorb_register_impl boa = BOA.BOA_init() File "C:\Python23\Lib\site-packages\Fnorb\orb\BOA.py", line 61, in BOA_init boa = BOA(argv, boa_id) File "C:\Python23\Lib\site-packages\Fnorb\orb\BOA.py", line 151, in __init__ protocol.enable(host, port) File "C:\Python23\Lib\site-packages\Fnorb\orb\IIOPProtocol.py", line 61, in en able self.__nudger = Nudger.Nudger() File "C:\Python23\Lib\site-packages\Fnorb\orb\Nudger.py", line 99, in __init__ raise CORBA.COMM_FAILURE() # System exception. Fnorb.orb.CORBA.COMM_FAILURE: Minor: 0 Completed: COMPLETED_NO Exception exceptions.AttributeError: "Nudger instance has no attribute '_Nudger_ _reactor'" in > ignored Someone can help me? Thanks, Digo From timr at probo.com Mon Apr 4 19:07:44 2005 From: timr at probo.com (Tim Roberts) Date: Mon Apr 4 19:07:51 2005 Subject: [python-win32] Handle to a Driver In-Reply-To: <4251707D.7040203@chi-tai.info> References: <20050404100037.764651E4003@bag.python.org> <42516D30.9080202@probo.com> <4251707D.7040203@chi-tai.info> Message-ID: <42517460.9020108@probo.com> Chi Tai wrote: > Thanks Tim, > > i also tried this, but this call returns the following error: > "DeviceIoControl() argument 3 must be string or read-only buffer, not > int" Yes, I should have realized. You need to convert this into a 4-byte string: import struct handle = struct.pack(" References: <20050404100037.764651E4003@bag.python.org> <42516D30.9080202@probo.com> <4251707D.7040203@chi-tai.info> <42517460.9020108@probo.com> Message-ID: <42517624.4030909@chi-tai.info> Cool, thanks a lot :) this is absolutely the better solution. Chi-Tai Tim Roberts schrieb: > Chi Tai wrote: > > > Thanks Tim, > > > > i also tried this, but this call returns the following error: > > "DeviceIoControl() argument 3 must be string or read-only buffer, > > not int" > > > > Yes, I should have realized. You need to convert this into a > 4-byte string: > > import struct handle = struct.pack(" DeviceIoControl( hDevice, IOCTL_SET_READ_EVENT, handle, 0, None ) > From timr at probo.com Mon Apr 4 19:24:35 2005 From: timr at probo.com (Tim Roberts) Date: Mon Apr 4 19:24:54 2005 Subject: [python-win32] Handle to a Driver In-Reply-To: <42517624.4030909@chi-tai.info> References: <20050404100037.764651E4003@bag.python.org> <42516D30.9080202@probo.com> <4251707D.7040203@chi-tai.info> <42517460.9020108@probo.com> <42517624.4030909@chi-tai.info> Message-ID: <42517853.4040005@probo.com> Chi Tai wrote: > Cool, thanks a lot :) > > this is absolutely the better solution. The "struct" module is a very helpful tool when you're doing Win32 API programming like this, especially with the new changes that make it more difficult to manipulate binary values as dwords. It would be worth your time to spend a few minutes playing with it, to figure out for yourself what it does. For example, Win32 programmers are used to combining two 16-bit values into a 32-bit value using this C code (which also happens to be valid Python code): dword = (hi << 16) | (lo & 0xffff); This gets you a deprecation warning in Python 2.3. You can do this same function without the warning using struct: dword = struct.pack( " I'm try to run the profiler on a program that uses win32com.client to access the Msxml2.DOMDocument COM class to load an XML document. I have attaced the stack trace I get when I run: python.exe -m profile profileTest.py I have also attached profileTest.py. The profiler seems to work fine on programs that don't use win32com.client. Has anyone seen this problem before? For those of you who are curious as to why I'm using the microsoft xml parser: The xml files I'm reading were created by a microsoft product and contain newline characters in attribute values. xml.dom.minidom converts the newlines in the attribute values to reqular spaces. It is important that these new line characters are preserved. I discovered that the microsoft xml parser preserves new line characters in an element's attribute value so I started using the win32com.client stuff to get at microsoft's xml parser. Thanks in advance, Christopher Brichford Acrobat Engineering Adobe Systems Inc. -------------- next part -------------- Traceback (most recent call last): File "c:\Program Files\Python\2.4\lib\profile.py", line 611, in ? run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) File "c:\Program Files\Python\2.4\lib\profile.py", line 72, in run prof = prof.run(statement) File "c:\Program Files\Python\2.4\lib\profile.py", line 448, in run return self.runctx(cmd, dict, dict) File "c:\Program Files\Python\2.4\lib\profile.py", line 454, in runctx exec cmd in globals, locals File "", line 1, in ? File "python\profileTest.py", line 22, in ? msXMLDOM.load( xmlFileName ) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\dynamic.py", line 455, in __getattr__ if self.__LazyMap__(attr): File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\dynamic.py", line 355, in __LazyMap__ debug_attr_print("%s.__LazyMap__(%s) added something" % (self._username_,attr)) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\dynamic.py", line 61, in debug_attr_print def debug_attr_print(*args): File "c:\Program Files\Python\2.4\lib\profile.py", line 238, in trace_dispatch_i if self.dispatch[event](self, frame, t): File "c:\Program Files\Python\2.4\lib\profile.py", line 295, in trace_dispatch_call assert (self.cur is None or \ AssertionError: ('Bad call', ('', 0, 'Bind')) -------------- next part -------------- import optparse import win32com.client if __name__ == u'__main__': usageStr = ( u'usage: %prog [options] xmlFileName ' ) optParser = optparse.OptionParser( usage=usageStr ) ( options, args ) = optParser.parse_args() errorStr = u'' if ( len( args ) < 1 ): errorStr = errorStr + u'Missing xml file name argument.' if ( len( errorStr ) > 0 ): raise Exception( errorStr ) assert len( args ) > 0 xmlFileName = args[ 0 ] msXMLDOM = win32com.client.Dispatch( u'Msxml2.DOMDocument' ) assert msXMLDOM is not None msXMLDOM.load( xmlFileName ) From p.f.moore at gmail.com Mon Apr 4 20:05:50 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Mon Apr 4 20:05:54 2005 Subject: [python-win32] Sparse files and Pickle In-Reply-To: <42516B6E.1000007@probo.com> References: <20050404100037.764651E4003@bag.python.org> <42516B6E.1000007@probo.com> Message-ID: <79990c6b05040411055c7b72d4@mail.gmail.com> On Apr 4, 2005 5:29 PM, Tim Roberts wrote: > If I needed to refer to an 89MB disk file in an > object, I would replace the data with the file name before pickling. I > thought pickle recognized a magic method name so the object could "help" > put itself into a picklable state, but I don't see it now. You're probably thinking of __setstate__ and __getstate__. Something like this (untested) should work: def __getstate__(self): state = {} for key in self.__dict__: # don't pickle "data" if key != 'data': state[key] = self.__dict__[key] def __setstate__(self, state): self.__dict__.update(state) # get "data" back from the filesystem self.data = open(self.file).read() There is also a __reduce__ method, and copy_reg.pickle. Paul. From nanotube at gmail.com Mon Apr 4 23:28:09 2005 From: nanotube at gmail.com (Daniel F) Date: Mon Apr 4 23:28:14 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <8c7f10c605040406483533ab2b@mail.gmail.com> References: <8c7f10c605040406483533ab2b@mail.gmail.com> Message-ID: Thank you all for your suggestions. Seems like i had this all figured out... But now I am running into another problem. I was originally planning to use this on a game (final fantasy 7, in fact). I capture keystrokes in the system, then send them over the net and generate them on the remote comp, thus playing the game simultaneously and synchronously on two comps at once. Worked like a charm for any old windows app, including notepad that I used as my test app. But turns out ff7 uses directinput to get its keys (apparently...) because "normal" hooking of messages through SetWindowHookEx (actually, i'm using the pyHook package, which makes the process more pleasant, but is just a wrapper around the said function) doesnt work properly, nor does "normal" message injection through PostMessage. So, in a completely different tack, could anyone help me understand the relationship between directinput and the regular windows hook chain (so far it seems that directinput bypasses it completely), and how i would hook those keypresses/mouse moves, and how i would inject a keypress/mousemove for an application that is using directinput? Is that even possible? I wouldnt even be averse (or at least, not THAT averse) to getting at it through SWIG, if win32all doesnt wrap directx api... Just let me know if there is any way to get at it. I've looked around on the web about DirectX and DirectInput, but all i have found was processing inputs through directinput, not hooking messages on the system level (ie, getting my hands on messages being passed to an application other than the one thats doing the hooking). Would appreciate any and all help in this matter. Thank you, Daniel From mhammond at skippinet.com.au Tue Apr 5 01:10:58 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 5 01:11:05 2005 Subject: [python-win32] Trouble running profiler In-Reply-To: <42517971.9030301@adobe.com> Message-ID: <00b301c5396b$90a0ac20$070a0a0a@enfoldsystems.local> I'm afraid I haven't recently used the profiler with win32com. I have recently used hotshot (which works quite well), but not with "win32com.client.dynamic" objects. I've no idea where that error is coming from. I'm not sure of the real issue, but I do note that the problem occurs when building "dynamic" information for the object. Try running makepy first - this could be as simple as using win32com.client.gencache.EnsureDispatch() instead of a simple Dispatch. That should avoid the failing code (and hopefully not just find something else that fails). Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Christopher > Brichford > Sent: Tuesday, 5 April 2005 3:29 AM > To: python-win32@python.org > Subject: [python-win32] Trouble running profiler > > > I'm try to run the profiler on a program that uses > win32com.client to > access the Msxml2.DOMDocument COM class to load an XML document. I > have attaced the stack trace I get when I run: > > python.exe -m profile profileTest.py > > I have also attached profileTest.py. The profiler seems to work fine > on programs that don't use win32com.client. Has anyone seen this > problem before? > > For those of you who are curious as to why I'm using the microsoft xml > parser: > The xml files I'm reading were created by a microsoft product and > contain newline characters in attribute values. xml.dom.minidom > converts the newlines in the attribute values to reqular spaces. It > is important that these new line characters are preserved. I > discovered that the microsoft xml parser preserves new line characters > in an element's attribute value so I started using the win32com.client > stuff to get at microsoft's xml parser. > > > Thanks in advance, > Christopher Brichford > Acrobat Engineering > Adobe Systems Inc. > From niki at vintech.bg Tue Apr 5 12:15:26 2005 From: niki at vintech.bg (Niki Spahiev) Date: Tue Apr 5 12:15:32 2005 Subject: [python-win32] reading from console child process In-Reply-To: <002401c53992$d9bba910$0400a8c0@cjm> References: <000a01c534e3$e3294380$0400a8c0@cjm> <424A74AC.5020803@vintech.bg> <002401c53992$d9bba910$0400a8c0@cjm> Message-ID: <4252653E.7020007@vintech.bg> Chris Maloof wrote: > Thanks for the help! ctypes ended up working for me, with help from > win32process where possible. I'm not sure why the solutions involving > popen variants failed; I might have missed something easier. Here's the > meat of my solution for the archives anyway, though. IIRC there is new module process which replaces popen with better functionality. Niki Spahiev From cjmaloof at gmail.com Tue Apr 5 05:52:11 2005 From: cjmaloof at gmail.com (Chris Maloof) Date: Tue Apr 5 16:05:21 2005 Subject: [python-win32] reading from console child process References: <000a01c534e3$e3294380$0400a8c0@cjm> <424A74AC.5020803@vintech.bg> Message-ID: <002401c53992$d9bba910$0400a8c0@cjm> Niki Spahiev wrote: > Chris Maloof wrote: >> Hello, >> >> I'm trying to read the output from a WinXP console application using >> PythonWin -- that is, I start the application as a child process, and I >> want to be able to read the ASCII text in the application's screen. >> >> The child app uses MSDN functions WriteConsoleOutputChar() and >> WriteConsoleOutputAttributes() for output. Thus I think I need to use >> ReadConsoleOutput() and WriteConsoleInput() to communicate with it, as >> described here: >> http://homepages.tesco.net/~J.deBoynePollard/FGA/capture-console-win32.html . >> Unfortunately these don't seem to be implemented in PyWin32. >> > > Try console module from effbot or use ctypes. > > HTH > Niki Spahiev Thanks for the help! ctypes ended up working for me, with help from win32process where possible. I'm not sure why the solutions involving popen variants failed; I might have missed something easier. Here's the meat of my solution for the archives anyway, though. import win32process from ctypes import * import time # Constants from winbase.h in .NET SDK STD_INPUT_HANDLE = c_uint(-10) # (not used here) STD_OUTPUT_HANDLE = c_uint(-11) STD_ERROR_HANDLE = c_uint(-12) # (not used here) startup = win32process.STARTUPINFO() (hProcess, hThread, dwProcessId, dwThreadId) = \ win32process.CreateProcess("C:\myConsoleApp.exe", "-X", None, None, 0, 0, None, None, startup) time.sleep(1) #wait for console to initialize # Use ctypes to simulate a struct from the Win32 API class COORD(Structure): _fields_ = [("X", c_short), ("Y", c_short)] topleft = COORD(0,0) CHARS_TO_READ = 200 result = create_string_buffer(CHARS_TO_READ) count = c_int() windll.kernel32.AttachConsole(c_uint(dwProcessId)) inHandle = windll.kernel32.GetStdHandle(STD_INPUT_HANDLE) outHandle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE) errHandle = windll.kernel32.GetStdHandle(STD_ERROR_HANDLE) # See Win32 API for definition windll.kernel32.ReadConsoleOutputCharacterA(outHandle, result, CHARS_TO_READ, topleft, byref(count)) print result.value From theller at python.net Tue Apr 5 16:41:10 2005 From: theller at python.net (Thomas Heller) Date: Tue Apr 5 16:44:25 2005 Subject: [python-win32] Re: reading from console child process References: <000a01c534e3$e3294380$0400a8c0@cjm> <424A74AC.5020803@vintech.bg> <002401c53992$d9bba910$0400a8c0@cjm> <4252653E.7020007@vintech.bg> Message-ID: Niki Spahiev writes: > Chris Maloof wrote: > >> Thanks for the help! ctypes ended up working for me, with help from >> win32process where possible. I'm not sure why the solutions >> involving popen variants failed; I might have missed something >> easier. Here's the meat of my solution for the archives anyway, >> though. > > IIRC there is new module process which replaces popen with better > functionality. This is subprocess (included in Python 2.4). But if the child application really writes to the console directly, and not to standard output, I would guess that subprocess won't be able to read the output. Thomas From timr at probo.com Tue Apr 5 18:41:34 2005 From: timr at probo.com (Tim Roberts) Date: Tue Apr 5 18:41:37 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <20050405100016.82BA31E4020@bag.python.org> References: <20050405100016.82BA31E4020@bag.python.org> Message-ID: <4252BFBE.7050000@probo.com> OnMon, 4 Apr 2005 17:28:09 -0400, Daniel F wrote: >But now I am running into another problem. I was originally planning >to use this on a game (final fantasy 7, in fact). I capture keystrokes >in the system, then send them over the net and generate them on the >remote comp, thus playing the game simultaneously and synchronously on >two comps at once. Worked like a charm for any old windows app, >including notepad that I used as my test app. > >But turns out ff7 uses directinput to get its keys (apparently...) >because "normal" hooking of messages through SetWindowHookEx >(actually, i'm using the pyHook package, which makes the process more >pleasant, but is just a wrapper around the said function) doesnt work >properly, nor does "normal" message injection through PostMessage. > >So, in a completely different tack, could anyone help me understand >the relationship between directinput and the regular windows hook >chain (so far it seems that directinput bypasses it completely), > Correct. DirectInput (on NT systems, at least) disconnects the normal Windows keyboard/mouse event processing and routes a path from the human interface drivers (keyboard, mouse, joystick) directly into the application. The application has exclusive use of the resources. >and >how i would hook those keypresses/mouse moves, and how i would inject >a keypress/mousemove for an application that is using directinput? Is >that even possible? > > No. In order to do what you ask, you would need to write and install a set of kernel filter drivers to inject the events, and you really don't want to do that. The API is not enough. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From chrisb at adobe.com Tue Apr 5 18:43:02 2005 From: chrisb at adobe.com (Christopher Brichford) Date: Tue Apr 5 18:43:15 2005 Subject: [python-win32] Trouble running profiler In-Reply-To: <00b301c5396b$90a0ac20$070a0a0a@enfoldsystems.local> References: <00b301c5396b$90a0ac20$070a0a0a@enfoldsystems.local> Message-ID: <4252C016.5040907@adobe.com> I get a similar errors if I use win32com.client.gencache.EnsureDispatch instead of win32com.client.Dispatch. You get different error depending on the contents of the pythonroot\lib\site-packages\win32com\gen_py\ directory. If pythonroot\lib\site-packages\win32com\gen_py\ is empty then you get the stack trace in the attachment error1.txt. After you run the test program once with or without the profiler, the pythonroot\lib\site-packages\win32com\gen_py\ will not be empty. When you run the test program the second time you get the stack trace in the attachment error2.txt I was purposely using the dynamic version because the gencache stuff does not work if you run python as a restricted user. This seems to be due to the fact that a restricted user can not make directories in pythonroot\lib\site-packages\win32com\gen_py\... If I were to use the non-dynamic code I would need a way to specify that all generated files should be put somewhere under the user's profile. I stopped using the Microsoft XML parser so I don't really need to use win32com anymore. I switch to the sgmlop parser which works fine with the profiler. If you are interested in continuing to work on this issue, I'm more than happy to keep trying your suggestions. Chris Brichford Mark Hammond wrote: > I'm afraid I haven't recently used the profiler with win32com. I have > recently used hotshot (which works quite well), but not with > "win32com.client.dynamic" objects. I've no idea where that error is coming > from. > > I'm not sure of the real issue, but I do note that the problem occurs when > building "dynamic" information for the object. Try running makepy first - > this could be as simple as using win32com.client.gencache.EnsureDispatch() > instead of a simple Dispatch. That should avoid the failing code (and > hopefully not just find something else that fails). > > Mark. > > >>-----Original Message----- >>From: python-win32-bounces@python.org >>[mailto:python-win32-bounces@python.org]On Behalf Of Christopher >>Brichford >>Sent: Tuesday, 5 April 2005 3:29 AM >>To: python-win32@python.org >>Subject: [python-win32] Trouble running profiler >> >> >> I'm try to run the profiler on a program that uses >>win32com.client to >>access the Msxml2.DOMDocument COM class to load an XML document. I >>have attaced the stack trace I get when I run: >> >>python.exe -m profile profileTest.py >> >>I have also attached profileTest.py. The profiler seems to work fine >>on programs that don't use win32com.client. Has anyone seen this >>problem before? >> >>For those of you who are curious as to why I'm using the microsoft xml >>parser: >>The xml files I'm reading were created by a microsoft product and >>contain newline characters in attribute values. xml.dom.minidom >>converts the newlines in the attribute values to reqular spaces. It >>is important that these new line characters are preserved. I >>discovered that the microsoft xml parser preserves new line characters >>in an element's attribute value so I started using the win32com.client >>stuff to get at microsoft's xml parser. >> >> >>Thanks in advance, >>Christopher Brichford >>Acrobat Engineering >>Adobe Systems Inc. >> > > -------------- next part -------------- import optparse import win32com.client if __name__ == u'__main__': usageStr = ( u'usage: %prog [options] xmlFileName ' ) optParser = optparse.OptionParser( usage=usageStr ) ( options, args ) = optParser.parse_args() errorStr = u'' if ( len( args ) < 1 ): errorStr = errorStr + u'Missing xml file name argument.' if ( len( errorStr ) > 0 ): raise Exception( errorStr ) assert len( args ) > 0 xmlFileName = args[ 0 ] #msXMLDOM = win32com.client.Dispatch( u'Msxml2.DOMDocument' ) msXMLDOM = win32com.client.gencache.EnsureDispatch( u'Msxml2.DOMDocument' ) assert msXMLDOM is not None msXMLDOM.load( xmlFileName ) -------------- next part -------------- Traceback (most recent call last): File "c:\Program Files\Python\2.4\lib\profile.py", line 611, in ? run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) File "c:\Program Files\Python\2.4\lib\profile.py", line 72, in run prof = prof.run(statement) File "c:\Program Files\Python\2.4\lib\profile.py", line 448, in run return self.runctx(cmd, dict, dict) File "c:\Program Files\Python\2.4\lib\profile.py", line 454, in runctx exec cmd in globals, locals File "", line 1, in ? File "profileTest.py", line 21, in ? msXMLDOM = win32com.client.gencache.EnsureDispatch( u'Msxml2.DOMDocument' ) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 536, in EnsureDispatch mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 520, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 290, in MakeModuleForTypelib return GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 245, in GetModuleForTypelib def GetModuleForTypelib(typelibCLSID, lcid, major, minor): File "c:\Program Files\Python\2.4\lib\profile.py", line 238, in trace_dispatch_i if self.dispatch[event](self, frame, t): File "c:\Program Files\Python\2.4\lib\profile.py", line 295, in trace_dispatch_call assert (self.cur is None or \ AssertionError: ('Bad call', ('', 0, 'unlink')) -------------- next part -------------- Traceback (most recent call last): File "c:\Program Files\Python\2.4\lib\profile.py", line 611, in ? run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) File "c:\Program Files\Python\2.4\lib\profile.py", line 72, in run prof = prof.run(statement) File "c:\Program Files\Python\2.4\lib\profile.py", line 448, in run return self.runctx(cmd, dict, dict) File "c:\Program Files\Python\2.4\lib\profile.py", line 454, in runctx exec cmd in globals, locals File "", line 1, in ? File "profileTest.py", line 21, in ? msXMLDOM = win32com.client.gencache.EnsureDispatch( u'Msxml2.DOMDocument' ) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 537, in EnsureDispatch GetModuleForCLSID(disp_clsid) File "c:\Program Files\Python\2.4\lib\site-packages\win32com\client\gencache.py", line 204, in GetModuleForCLSID def GetModuleForCLSID(clsid): File "c:\Program Files\Python\2.4\lib\profile.py", line 238, in trace_dispatch_i if self.dispatch[event](self, frame, t): File "c:\Program Files\Python\2.4\lib\profile.py", line 295, in trace_dispatch_call assert (self.cur is None or \ AssertionError: ('Bad call', ('c:\\Program Files\\Python\\2.4\\lib\\site-packages\\win32com\\client\\gencache.py', 368, 'EnsureModule')) From nanotube at gmail.com Tue Apr 5 19:14:07 2005 From: nanotube at gmail.com (Daniel F) Date: Tue Apr 5 19:14:16 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <4252BFBE.7050000@probo.com> References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> Message-ID: > >and > >how i would hook those keypresses/mouse moves, and how i would inject > >a keypress/mousemove for an application that is using directinput? Is > >that even possible? > > No. In order to do what you ask, you would need to write and install a > set of kernel filter drivers to inject the events, and you really don't > want to do that. The API is not enough. > How about getkeyboardstate/setkeyboardstate functions, put together with attachthreadinput? would that be on the keyboard driver level, above directinput? or still below it, and thus bypassed? If the answer to the above is negative, then how about writing a wrapper for the original dinput.dll (basically, make another dinput.dll, that takes messages from the keyboard driver, does whatever with them, before passing them on to the "actual" dinput.dll)? could that work? and how difficult would it be to carry out? Also... why don't i really want to do the kernel filter drivers? They certainly sound like i dont want to do them :) but i wonder why. Too involved and painful? Chance to screw up the whole system? Thanks, Daniel, not liking to give up... From timr at probo.com Tue Apr 5 19:55:33 2005 From: timr at probo.com (Tim Roberts) Date: Tue Apr 5 19:55:35 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> Message-ID: <4252D115.6070903@probo.com> Daniel F wrote: >How about getkeyboardstate/setkeyboardstate functions, put together >with attachthreadinput? would that be on the keyboard driver level, >above directinput? or still below it, and thus bypassed? > > Actually, after doing some more reading, there may be a way to do what you want with the SendInput API. I don't see SendInput in any of the Win32 wrappers in Python, but you should be able to access it with ctypes. Here's a link to some C# code that demonstrates it: http://split-s.blogspot.com/2005/01/emulating-keystrokes-in-windows.html Note that this wants scan codes, not virtual keys. >Also... why don't i really want to do the kernel filter drivers? They >certainly sound like i dont want to do them :) but i wonder why. Too >involved and painful? Chance to screw up the whole system? > > The kernel world is a strange and magical one. The learning curve is steep, and the environment is unforgiving. If you make a mistake in a Python app, you get an exception and you try again. If you make a mistake in a kernel driver, you get a bluescreen and you reboot, and you hope that the NTFS file system remembered to flush the pending changes to disk. I write drivers for a living. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Apr 6 01:38:56 2005 From: timr at probo.com (Tim Roberts) Date: Wed Apr 6 01:39:02 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> Message-ID: <42532190.5090901@probo.com> Daniel F wrote: >hmm, according to that site, sendinput just may be exactly what i need >to send input to a directinput-using app. I will give it a shot and >let know how it goes. i'm curious why pywin32 doesnt wrap sendinput, >among other functions? any specific reason, or "just didnt get to it >yet" ? > > SendInput is "relatively" new. It was first introduced in NT Service Pack 4, and it isn't the kind of API that comes up very often. >but a question still remains - what do i do in order to capture >messages before they get to the app? As you remember, i need to >capture the keystrokes first, then generate them on another machine. >Whin i use pyHook (wrapping setwindowhookex), and hook keystrokes >while ff7 is in the foreground (not even doing anything else - just >hooking and releasing, or hooking and blocking), ff7 gets screwed up >somehow... seems to get the keystrokes in triplicate about 90% of the >time. So i need a way to capture the keystrokes too - if not capture >then at least read, without screwing up the local-running ff7. any >ideas? > > I don't know the answer to this. Games tend to be straight-to-the-metal applications: they don't truck with a lot of filtering and intermediate DLLs. You might be able to use the debug APIs to watch for the loading of the DirectInput DLL and insert some manual hooks, but that's a pretty high level of guruness. Google for "api dll injection". >also, regarding the use of scancodes... looks like python win32 doesnt >wrap MapVirtualKey (to convert form vk to scancode) either. i suppose >ctypes should help me out with this one, too? > > ctypes is a wonderful package -- invaluable for someone doing Win32 API work. Basically, it allows you to call any API in any DLL, as long as you can describe the parameters. >Well then... thanks for warning me off that path before i ventured >down it. :) Though i wonder if i could find an existing kernel filter >driver and put it to work for me. they must be out there somewhere, >no..? but i will try playing with ctypes and sendinput first. > There are some HID filter drivers in the DDK supplied by Microsoft. As a general rule, it is rare to find a publicly-available third-party kernel driver. There are several reasons for that. Most drivers are written for a specific device, and are not useful in the general case. Device-specific drivers often include information that the manufacturer considers to be proprietary. The support burden for a kernel driver is much greater than a user-mode app. And, the investment in creating and debugging a driver is so high, that most manufacturers don't want to help the competition by providing the labor for free. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From wyvernlist at crm3.com Wed Apr 6 02:46:06 2005 From: wyvernlist at crm3.com (wyvernlist) Date: Wed Apr 6 02:47:21 2005 Subject: [python-win32] Can't load wmi with Python 2.4 Message-ID: <4253314E.2020207@crm3.com> I installed ActiveState's version of Python 2.4 (which contains the Win32 extensions) but after installing the Python WMI module I get the following error when I try and import it: >>import wmi Traceback (most recent call last): File "C:\Program Files\ActiveState Komodo 3.1\dbgp\pythonlib\dbgp\client.py", line 3149, in runcode locals = self.frame.f_locals) File "C:\Program Files\ActiveState Komodo 3.1\dbgp\pythonlib\dbgp\client.py", line 1569, in runcode h_exec(code, globals=globals, locals=locals, module=module) File "C:\Program Files\ActiveState Komodo 3.1\dbgp\pythonlib\dbgp\client.py", line 516, in __init__ exec code in globals, locals File "", line 0, in __main__ File "C:\Python24\Lib\site-packages\wmi.py", line 137, in ? win32com.client.gencache.EnsureDispatch (obj._oleobj_) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 541, in EnsureDispatch mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 398, in EnsureModule module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 267, in GetModuleForTypelib AddModuleToCache(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 559, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' Does anyone know how to fix this? It looks like I'm missing some functionality. Thanks, Jan From mhammond at skippinet.com.au Wed Apr 6 06:36:03 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Apr 6 06:36:12 2005 Subject: [python-win32] Can't load wmi with Python 2.4 In-Reply-To: <4253314E.2020207@crm3.com> Message-ID: <02a201c53a62$2587ccf0$070a0a0a@enfoldsystems.local> > "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line > 559, in AddModuleToCache > dict = mod.CLSIDToClassMap > AttributeError: 'module' object has no attribute 'CLSIDToClassMap' > > Does anyone know how to fix this? It looks like I'm missing some > functionality. It looks like something in win32com's makepy support broke. Try deleting the win32com\gen_py directory and trying again. If you are using Python 2.4, there are other strange issues at hand, so the problem may persist. Mark From xeoicq at netscape.net Wed Apr 6 09:16:08 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Wed Apr 6 09:16:18 2005 Subject: [python-win32] win32dph.EnumObjectItems problem Message-ID: <42538CB8.8060107@netscape.net> """ Hi All, I have a problem using win32pdh with Python22. The call of win32pdh.EnumObjectItems changes the decimal point from . to , on my system. I think it could be a problem with the language setting form german. So I run in trouble with unpickle of float objects. Is there a soulution or workaround? The problem occurs under german language setting for windows. For german EnumObjectItems neede 'Prozess' insted of 'Process' to work. """ import pickle def pickle_and_unpickle(to_pickle): pickled = pickle.dumps(to_pickle) print "%s -> %s"%(to_pickle, pickled) return pickled float_obj = 1.2345 str_float_obj_before = str(float_obj) pickled_before=pickle_and_unpickle(float_obj) #the trouble begins: #this commands changes the decimal point from . to , (german language setting) #so the unpickle didn't work for pickle done before the calls import win32pdh Process="Prozess" #German Process="Process" #English junk, processes = win32pdh.EnumObjectItems(None,None,Process,win32pdh.PERF_DETAIL_WIZARD) str_float_obj_after = str(float_obj) print "the string representation of float changed from %s to %s"%(str_float_obj_before,str_float_obj_after) pickled_after=pickle_and_unpickle(float_obj) #this is ok print pickle.loads(pickled_after) #error due to comma(,) insted of point (.) print pickle.loads(pickled_before) """ Ciao, Frank """ From niki at vintech.bg Wed Apr 6 09:26:48 2005 From: niki at vintech.bg (Niki Spahiev) Date: Wed Apr 6 09:26:55 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <42532190.5090901@probo.com> References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> Message-ID: <42538F38.50008@vintech.bg> Tim Roberts wrote: > I don't know the answer to this. Games tend to be straight-to-the-metal > applications: they don't truck with a lot of filtering and intermediate > DLLs. You might be able to use the debug APIs to watch for the loading > of the DirectInput DLL and insert some manual hooks, but that's a pretty > high level of guruness. Google for "api dll injection". There is module for injection of *python* code in win32 apps. http://security.opennet.ru/base/patches/1080837482_191.txt.html HTH Niki Spahiev From mhammond at skippinet.com.au Wed Apr 6 10:44:55 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Apr 6 10:44:57 2005 Subject: [python-win32] win32dph.EnumObjectItems problem In-Reply-To: <42538CB8.8060107@netscape.net> Message-ID: <02c901c53a84$e8cf9720$070a0a0a@enfoldsystems.local> > Hi All, > > I have a problem using win32pdh with Python22. > The call of win32pdh.EnumObjectItems changes the > decimal point from . to , on my system. > I think it could be a problem with the language setting > form german. > So I run in trouble with unpickle of float objects. > Is there a soulution or workaround? > > The problem occurs under german language setting > for windows. > For german EnumObjectItems neede 'Prozess' insted of 'Process' > to work. We struck a very similar problem when using MAPI with SpamBayes. After making the call to the external library (PDH), try adding: locale.setlocale(locale.LC_NUMERIC, "C") (obviously after importing locale) That should reset everything to the state where Python works correctly. I believe this is fixed in Python itself in 2.4. Mark From william at full-moon.com Wed Apr 6 19:57:57 2005 From: william at full-moon.com (* William) Date: Wed Apr 6 20:34:05 2005 Subject: [python-win32] How Can I exec() a statement? Message-ID: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> Skipped content of type multipart/alternative-------------- next part -------------- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.3 - Release Date: 5/Apr/2005 From leske at online.de Wed Apr 6 20:52:50 2005 From: leske at online.de (Christophe Leske) Date: Wed Apr 6 20:52:41 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> Message-ID: <000a01c53ad9$d838c300$63b2a8c0@kiste> Hello there, my name is Christophe Leske and i am a developer based in D?sseldorf, germany. I have a multimedia programming background, but am slowly crawling up to RAD development using Python and am therefore looking for a windows IDE and GUI Designer. Now: Ideally, I'd like to have an IDE with code completion, yet all the IDEs i have seen so far (WingIDE, Komodo, Ecliipse (either as trustudio or the Pydev plugin) don't really cut it for me. Same goes for the Windows GUI Designers (Boa doesn't even work for me, even after compilation - hey, i am a beginner...) So far, i settled for PythonWin, yet am still looking for better alternatives. Any suggestions? I also know about specialized editors like Crimson or ZeusEdit, but i'd rather go with an IDE (if possible). Python seems like a mature development tool for me, which is why i am wondering that there seems to be no really good IDE that fits me (or am just weird? probably...) My rubberboat is full of eels, Christophe Leske tel. +49-(0)211 230 99 70 .:. f?rstenwall 157 .:. ::: 40215 d?sseldorf ::: ::: germany ::: http://www.multimedial.de From steve at holdenweb.com Wed Apr 6 20:55:10 2005 From: steve at holdenweb.com (Steve Holden) Date: Wed Apr 6 20:55:01 2005 Subject: [python-win32] How Can I exec() a statement? In-Reply-To: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> References: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> Message-ID: <4254308E.6040508@holdenweb.com> * William wrote: > Hello all. > > Thanks for the tips and solutions posted to the list so far. This is a > general python question, not windows specific. It is my turn to ask. > (Perhaps the notion below will suggest some development to one of you. > Who knows?) > > I want to execute a statement indirectly in Python. Take the simple case > below. The chevrons ">> " indicate the result of the statement > > b = 2 > a = b + 6 > eval('a = b + 6', globals(), locals() ) > >> File "not_much_at_all.py", line 21, in ? > >> rslt = eval('a = b + 6', globals(), locals() ) > >> File "", line 1 > >> a = b + 6 > >> ^ > >> SyntaxError: invalid syntax > > While I appreciate that "eval()" is not the way to do this, it is also > true that "eval()" accurately signals my intention in this sample. > > HOW -- or, is it possible -- to execute the an assignment statement from > a string? > > I have used compile() and considered using a 'block'. Compile doesn't > help. And I can't find an equivalent for 'eval( )' ... > > Who has the answer? > Well, you do! You ask how to exec a statement, and the answer is ... use an "exec" statement! >>> exec "a = 25/3" >>> a 8 >>> regards Steve -- Steve Holden +1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ From nanotube at gmail.com Wed Apr 6 21:34:13 2005 From: nanotube at gmail.com (Daniel F) Date: Wed Apr 6 21:34:15 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <42532190.5090901@probo.com> References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> Message-ID: > I don't know the answer to this. Games tend to be straight-to-the-metal > applications: they don't truck with a lot of filtering and intermediate > DLLs. You might be able to use the debug APIs to watch for the loading > of the DirectInput DLL and insert some manual hooks, but that's a pretty > high level of guruness. Google for "api dll injection". wow, that opened up a wealth of info. thanks. although i hope to skate by without using it... ;) > There are some HID filter drivers in the DDK supplied by Microsoft. As > a general rule, it is rare to find a publicly-available third-party > kernel driver. There are several reasons for that. Most drivers are > written for a specific device, and are not useful in the general case. > Device-specific drivers often include information that the manufacturer > considers to be proprietary. The support burden for a kernel driver is > much greater than a user-mode app. And, the investment in creating and > debugging a driver is so high, that most manufacturers don't want to > help the competition by providing the labor for free. interesting... thanks for the info. From nanotube at gmail.com Wed Apr 6 21:35:52 2005 From: nanotube at gmail.com (Daniel F) Date: Wed Apr 6 21:35:55 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <42538F38.50008@vintech.bg> References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> <42538F38.50008@vintech.bg> Message-ID: > There is module for injection of *python* code in win32 apps. > > http://security.opennet.ru/base/patches/1080837482_191.txt.html > this looks interesting, i wanted to give it a look, but it seems that rootkit.com (where the actual package is hosted) is not resolvable anymore. you dont happen to have the zips handy, do you? From gagenellina at softlab.com.ar Wed Apr 6 21:47:26 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed Apr 6 21:39:32 2005 Subject: [python-win32] How Can I exec() a statement? In-Reply-To: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> References: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> Message-ID: <6.2.1.2.0.20050406161555.03018e80@192.168.0.115> At Wednesday 6/4/2005 14:57, * William wrote: >HOW -- or, is it possible -- to execute the an assignment statement from a >string? Try 'exec' >>> a=1 >>> b=2 >>> exec 'a=b+3' >>> a 5 Gabriel Genellina Softlab SRL From bgailer at alum.rpi.edu Wed Apr 6 22:20:24 2005 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Wed Apr 6 22:16:32 2005 Subject: [python-win32] How Can I exec() a statement? In-Reply-To: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> References: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> Message-ID: <6.1.2.0.0.20050406131857.03a05fa8@pop.sbcglobal.yahoo.com> At 10:57 AM 4/6/2005, * William wrote: >[snip] >I want to execute a statement indirectly in Python. Take the simple case >below. The chevrons ">> " indicate the result of the statement >b = 2 >a = b + 6 >eval('a = b + 6', globals(), locals() ) There are often better solutions than exec. Tell us a bit more about what you are trying to accomplish. Bob Gailer mailto:bgailer@alum.rpi.edu 510 558 3275 home 720 938 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050406/8725a49e/attachment.html From nanotube at gmail.com Thu Apr 7 00:53:42 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 7 00:54:19 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <42532190.5090901@probo.com> References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> Message-ID: Well... i tried it... and sendinput officially does not work on ff7 (but does on notepad). so either ff7 is doing something really funky (not likely, since it does load dinput.dll), or sendinput is not actually upstream of directinput (more likely). but the only game i have that loads dinput.dll is ff7, so cant test on anything else to make sure... (amazingly, unrealtournament, which i also have, does not load dinput.dll, and sendinput, as well as postmessage, work with it. i wonder why a real-time game such as ut has no problems going through the usual message queue, but ff7, which in a slow-paced rpg, is using directinput. like.... wtf, you know? :) ) so if anyone has any games to test with, here is the sendinput code. it tries sending the up arrow key press. so if anyone wants to test, just get to a screen in the game where you will clearly see the results of the up arrow key press, alt-tab out of it, run the python script, and alt-tab back into the game, and wait for the event (you have 10 seconds). of course, if your game doesnt use the arrow keys... you can change the prog to send whatever key you need it to. ;) ### begin code from ctypes import * import time PUL = POINTER(c_ulong) class KeyBdInput(Structure): _fields_ = [("wVk", c_ushort), ("wScan", c_ushort), ("dwFlags", c_ulong), ("time", c_ulong), ("dwExtraInfo", PUL)] class HardwareInput(Structure): _fields_ = [("uMsg", c_ulong), ("wParamL", c_short), ("wParamH", c_ushort)] class MouseInput(Structure): _fields_ = [("dx", c_long), ("dy", c_long), ("mouseData", c_ulong), ("dwFlags", c_ulong), ("time",c_ulong), ("dwExtraInfo", PUL)] class Input_I(Union): _fields_ = [("ki", KeyBdInput), ("mi", MouseInput), ("hi", HardwareInput)] class Input(Structure): _fields_ = [("type", c_ulong), ("ii", Input_I)] if __name__ == '__main__': for i in xrange(1,11): time.sleep(1) print i FInputs = Input * 1 extra = c_ulong(0) ii_ = Input_I() ii_.ki = KeyBdInput( 0x26, 0x48, 0, 0, pointer(extra) ) x = FInputs( ( 1, ii_ ) ) print sizeof(x[0]) print windll.user32.SendInput(1, pointer(x), sizeof(x[0])) print "err",windll.kernel32.GetLastError() ### end code > > I don't know the answer to this. Games tend to be straight-to-the-metal > applications: they don't truck with a lot of filtering and intermediate > DLLs. You might be able to use the debug APIs to watch for the loading > of the DirectInput DLL and insert some manual hooks, but that's a pretty > high level of guruness. Google for "api dll injection". i guess either im officially dead in the water with this project, or i learn how to do dll injection... (good thing this is a personal project, nobody is nipping at my heels with a deadline) > >also, regarding the use of scancodes... looks like python win32 doesnt > >wrap MapVirtualKey (to convert form vk to scancode) either. i suppose > >ctypes should help me out with this one, too? > > ctypes is a wonderful package -- invaluable for someone doing Win32 API > work. Basically, it allows you to call any API in any DLL, as long as > you can describe the parameters. except mapvirtualkey. not that it matters now, anyway, but, behold this: # ##code: from ctypes import * import time sc = windll.user32.MapVirtualKey(0x41, 0) print sc # ##end code ###output: Traceback (most recent call last): File "C:\Documents and Settings\dfolkins\Desktop\python scripts\mapvirtualkey.py", line 4, in ? sc = windll.user32.MapVirtualKey(0x41, 0) File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 366, in __getattr__ func = self._StdcallFuncPtr(name, self) AttributeError: function 'MapVirtualKey' not found ###end output so... even though i dont care about mapvirtualkey per se, i wonder what gives... any ideas? and... if anyone ever happens upon a way to hook and inject events upstream of directinput in a nice api-like way, please let me know, eh? :) Thank you, Daniel, off to learn how to inject dll.... From b6y9eq902 at sneakemail.com Thu Apr 7 04:15:41 2005 From: b6y9eq902 at sneakemail.com (b6y9eq902@sneakemail.com) Date: Thu Apr 7 04:15:44 2005 Subject: [python-win32] HookMessage failure? Message-ID: <12880-84090@sneakemail.com> Hey, I'm currently trying to detect all clicks to a particular windows application, using win32gui and win32ui. Right now I'm using EnumWindows() to find the hwnd I want via window title, and then CreateWindowFromHandle(hwnd) to get a PyCWnd object that represents the window. I then attempt to use HookMessage() to set up a callback for win32con.LBUTTON_DOWN. However, my callback never gets called. I know I'm getting the right PyCWnd object, because I can use it to set/get the window title, but for some reason the callback function never gets called. Any ideas? Thanks, -Mark From nanotube at gmail.com Thu Apr 7 06:47:40 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 7 06:48:12 2005 Subject: [python-win32] HookMessage failure? In-Reply-To: <12880-84090@sneakemail.com> References: <12880-84090@sneakemail.com> Message-ID: Hey Mark, the correct mesage to hook is "win32con.WM_LBUTTONDOWN" try it with this one, and see if that works. -d On 7 Apr 2005 02:15:41 -0000, b6y9eq902@sneakemail.com wrote: > Hey, > > I'm currently trying to detect all clicks to a particular windows application, using win32gui and win32ui. Right now I'm using EnumWindows() to find the hwnd I want via window title, and then CreateWindowFromHandle(hwnd) to get a PyCWnd object that represents the window. I then attempt to use HookMessage() to set up a callback for win32con.LBUTTON_DOWN. However, my callback never gets called. I know I'm getting the right PyCWnd object, because I can use it to set/get the window title, but for some reason the callback function never gets called. Any ideas? > > Thanks, -Mark > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From nanotube at gmail.com Thu Apr 7 06:47:40 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 7 06:48:25 2005 Subject: [python-win32] HookMessage failure? In-Reply-To: <12880-84090@sneakemail.com> References: <12880-84090@sneakemail.com> Message-ID: Hey Mark, the correct mesage to hook is "win32con.WM_LBUTTONDOWN" try it with this one, and see if that works. -d On 7 Apr 2005 02:15:41 -0000, b6y9eq902@sneakemail.com wrote: > Hey, > > I'm currently trying to detect all clicks to a particular windows application, using win32gui and win32ui. Right now I'm using EnumWindows() to find the hwnd I want via window title, and then CreateWindowFromHandle(hwnd) to get a PyCWnd object that represents the window. I then attempt to use HookMessage() to set up a callback for win32con.LBUTTON_DOWN. However, my callback never gets called. I know I'm getting the right PyCWnd object, because I can use it to set/get the window title, but for some reason the callback function never gets called. Any ideas? > > Thanks, -Mark > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From nanotube at gmail.com Thu Apr 7 07:01:01 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 7 07:01:04 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: <000a01c53ad9$d838c300$63b2a8c0@kiste> References: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> <000a01c53ad9$d838c300$63b2a8c0@kiste> Message-ID: Hi Christophe, I am a newbie to python myself... but i have settled for now on just using the scite editor (http://www.scintilla.org/SciTE.html) to code python. like you, i was not impressed with eclipse+pydev, or pythonwin (and havent even tried all those other ones you mentioned). scite doesnt have code completion, but it does have automatic syntax format, block collapse capability, open multiple files in one window with tabs, and you can run your program from right inside it through a shortcut (and probably a lot of other useful stuff that i havent gotten to use yet). i do have to note that i have not done any gui stuff in python yet, so maybe i will have to start looking for something else when i do. maybe not exactly what you were looking for - just sharing my [admittedly narrow] experience. please feel free to let me know if you find a really smashing ide, as i would not be averse to using one, either. good luck, -d On Apr 6, 2005 2:52 PM, Christophe Leske wrote: > Hello there, > my name is Christophe Leske and i am a developer based in D?sseldorf, > germany. I have a multimedia programming background, but am slowly crawling > up to RAD development using Python and am therefore looking for a windows > IDE and GUI Designer. > > Now: > Ideally, I'd like to have an IDE with code completion, yet all the IDEs i > have seen so far (WingIDE, Komodo, Ecliipse (either as trustudio or the > Pydev plugin) don't really cut it for me. > > Same goes for the Windows GUI Designers (Boa doesn't even work for me, even > after compilation - hey, i am a beginner...) > > So far, i settled for PythonWin, yet am still looking for better > alternatives. > Any suggestions? I also know about specialized editors like Crimson or > ZeusEdit, but i'd rather go with an IDE (if possible). > Python seems like a mature development tool for me, which is why i am > wondering that there seems to be no really good IDE that fits me (or am just > weird? probably...) > > My rubberboat is full of eels, > Christophe Leske > tel. +49-(0)211 230 99 70 > .:. f?rstenwall 157 .:. > ::: 40215 d?sseldorf ::: > ::: germany ::: > http://www.multimedial.de > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From theller at python.net Thu Apr 7 08:55:21 2005 From: theller at python.net (Thomas Heller) Date: Thu Apr 7 08:56:21 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> Message-ID: >> ctypes is a wonderful package -- invaluable for someone doing Win32 API >> work. Basically, it allows you to call any API in any DLL, as long as >> you can describe the parameters. > > except mapvirtualkey. not that it matters now, anyway, but, behold this: > > # ##code: > from ctypes import * > import time > > sc = windll.user32.MapVirtualKey(0x41, 0) > print sc > # ##end code > > ###output: > Traceback (most recent call last): > File "C:\Documents and Settings\dfolkins\Desktop\python > scripts\mapvirtualkey.py", line 4, in ? > sc = windll.user32.MapVirtualKey(0x41, 0) > File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 366, > in __getattr__ > func = self._StdcallFuncPtr(name, self) > AttributeError: function 'MapVirtualKey' not found > ###end output MapVirtualKey is implemented as unicode and ansi function. Quote MSDN: Function Information Minimum DLL Version user32.dll Header Declared in Winuser.h, include Windows.h Import library User32.lib Minimum operating systems Windows 95, Windows NT 3.1 Unicode Implemented as ANSI and Unicode versions. Which means: Call MapVirtualKeyA for ansi strings, MapVirutalKeyW for unicode strings. > so... even though i dont care about mapvirtualkey per se, i wonder > what gives... any ideas? > > and... if anyone ever happens upon a way to hook and inject events > upstream of directinput in a nice api-like way, please let me know, > eh? :) > > Thank you, > Daniel, off to learn how to inject dll.... Hehe. Good luck. Thomas From nicolas.grilly at garden-paris.com Thu Apr 7 11:44:37 2005 From: nicolas.grilly at garden-paris.com (Nicolas Grilly) Date: Thu Apr 7 11:44:46 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: Message-ID: <20050407094441.CD8851D99C0@mrelay2.st2.lyceu.net> Hi, Like Daniel, I use SciTE, primarily to develop data analysis application and contact management applications. I'm very satisfied with SciTE, that is an excellent editor for programmers, until you configured it properly (using SciTEGlobal.properties). The only features I miss are an integrated file manager and an integrated debugger. But it is possible and very handy to manage your project files using the File Explorer and a tool like TortoiseCVS or TortoiseSVN for version control. Concerning debugging, I need to debug my code only once since I develop in Python. So I used the simple text debugger provided in the standard Python distribution. My applications are GUI applications. I choose the wxPython framework to develop those applications. I've a large experience with the Swing framework in Java, and I can say wxPython is a lot simpler to use! It's an excellent tool for rapid application development of GUI applications. To design your screens, it's perfectly possible to use straight code, but I also use XRCed (a graphical tool provided with the wxPython distribution). This tool generates XML resource file that you can load in your applications with a simple line of code. There's also wxGlage, but I never test it. Sincerely, Nicolas Grilly -----Message d'origine----- De : python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] De la part de Daniel F Envoy? : jeudi 7 avril 2005 07:01 ? : Christophe Leske Cc : python-win32@python.org Objet : Re: [python-win32] Intro and Windows Questions Hi Christophe, I am a newbie to python myself... but i have settled for now on just using the scite editor (http://www.scintilla.org/SciTE.html) to code python. like you, i was not impressed with eclipse+pydev, or pythonwin (and havent even tried all those other ones you mentioned). scite doesnt have code completion, but it does have automatic syntax format, block collapse capability, open multiple files in one window with tabs, and you can run your program from right inside it through a shortcut (and probably a lot of other useful stuff that i havent gotten to use yet). i do have to note that i have not done any gui stuff in python yet, so maybe i will have to start looking for something else when i do. maybe not exactly what you were looking for - just sharing my [admittedly narrow] experience. please feel free to let me know if you find a really smashing ide, as i would not be averse to using one, either. good luck, -d On Apr 6, 2005 2:52 PM, Christophe Leske wrote: > Hello there, > my name is Christophe Leske and i am a developer based in D?sseldorf, > germany. I have a multimedia programming background, but am slowly > crawling up to RAD development using Python and am therefore looking > for a windows IDE and GUI Designer. > > Now: > Ideally, I'd like to have an IDE with code completion, yet all the > IDEs i have seen so far (WingIDE, Komodo, Ecliipse (either as > trustudio or the Pydev plugin) don't really cut it for me. > > Same goes for the Windows GUI Designers (Boa doesn't even work for me, > even after compilation - hey, i am a beginner...) > > So far, i settled for PythonWin, yet am still looking for better > alternatives. > Any suggestions? I also know about specialized editors like Crimson or > ZeusEdit, but i'd rather go with an IDE (if possible). > Python seems like a mature development tool for me, which is why i am > wondering that there seems to be no really good IDE that fits me (or > am just weird? probably...) > > My rubberboat is full of eels, > Christophe Leske > tel. +49-(0)211 230 99 70 > .:. f?rstenwall 157 .:. > ::: 40215 d?sseldorf ::: > ::: germany ::: > http://www.multimedial.de > > _______________________________________________ > Python-win32 mailing list > 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 From niki at vintech.bg Thu Apr 7 12:16:54 2005 From: niki at vintech.bg (Niki Spahiev) Date: Thu Apr 7 12:17:03 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> <42538F38.50008@vintech.bg> Message-ID: <42550896.6040607@vintech.bg> Daniel F wrote: >>There is module for injection of *python* code in win32 apps. >> >>http://security.opennet.ru/base/patches/1080837482_191.txt.html >> > > > this looks interesting, i wanted to give it a look, but it seems that > rootkit.com (where the actual package is hosted) is not resolvable > anymore. you dont happen to have the zips handy, do you? I have this: -rw------- 1 niki users 1459352 Apr 1 2004 4-04-01/adder-0.3.3-src.zip -rw------- 1 niki users 137800 Apr 1 2004 4-04-01/adder-0.3.3-win32.zip -rw------- 1 niki users 69801 Apr 1 2004 4-04-01/adder-manual.zip Do you want any of them? By e-mail? Niki Spahiev From niki at vintech.bg Thu Apr 7 12:22:09 2005 From: niki at vintech.bg (Niki Spahiev) Date: Thu Apr 7 12:22:19 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: <20050407094441.CD8851D99C0@mrelay2.st2.lyceu.net> References: <20050407094441.CD8851D99C0@mrelay2.st2.lyceu.net> Message-ID: <425509D1.808@vintech.bg> Nicolas Grilly wrote: > Hi, > > Like Daniel, I use SciTE, primarily to develop data analysis application and > contact management applications. I'm very satisfied with SciTE, that is an > excellent editor for programmers, until you configured it properly (using > SciTEGlobal.properties). The only features I miss are an integrated file > manager and an integrated debugger. There is something called FilerX IIRC for organizing projects with scite. For debugger try HAP debugger @ sf.net (scintilla based too) HTH Niki Spahiev From nicolas.grilly at garden-paris.com Thu Apr 7 12:31:42 2005 From: nicolas.grilly at garden-paris.com (Nicolas Grilly) Date: Thu Apr 7 12:32:53 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: <20050407094441.CD8851D99C0@mrelay2.st2.lyceu.net> Message-ID: <20050407103143.BAF2B1CABE1@mrelay2.st2.lyceu.net> Sorry. There was a typo in my previous email last line: i was talking about wxGlade and not wxGlage. Cheers, Nicolas -----Message d'origine----- De : python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] De la part de Nicolas Grilly Envoy? : jeudi 7 avril 2005 11:45 ? : 'Daniel F'; 'Christophe Leske' Cc : python-win32@python.org Objet : RE: [python-win32] Intro and Windows Questions Hi, Like Daniel, I use SciTE, primarily to develop data analysis application and contact management applications. I'm very satisfied with SciTE, that is an excellent editor for programmers, until you configured it properly (using SciTEGlobal.properties). The only features I miss are an integrated file manager and an integrated debugger. But it is possible and very handy to manage your project files using the File Explorer and a tool like TortoiseCVS or TortoiseSVN for version control. Concerning debugging, I need to debug my code only once since I develop in Python. So I used the simple text debugger provided in the standard Python distribution. My applications are GUI applications. I choose the wxPython framework to develop those applications. I've a large experience with the Swing framework in Java, and I can say wxPython is a lot simpler to use! It's an excellent tool for rapid application development of GUI applications. To design your screens, it's perfectly possible to use straight code, but I also use XRCed (a graphical tool provided with the wxPython distribution). This tool generates XML resource file that you can load in your applications with a simple line of code. There's also wxGlage, but I never test it. Sincerely, Nicolas Grilly -----Message d'origine----- De : python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] De la part de Daniel F Envoy? : jeudi 7 avril 2005 07:01 ? : Christophe Leske Cc : python-win32@python.org Objet : Re: [python-win32] Intro and Windows Questions Hi Christophe, I am a newbie to python myself... but i have settled for now on just using the scite editor (http://www.scintilla.org/SciTE.html) to code python. like you, i was not impressed with eclipse+pydev, or pythonwin (and havent even tried all those other ones you mentioned). scite doesnt have code completion, but it does have automatic syntax format, block collapse capability, open multiple files in one window with tabs, and you can run your program from right inside it through a shortcut (and probably a lot of other useful stuff that i havent gotten to use yet). i do have to note that i have not done any gui stuff in python yet, so maybe i will have to start looking for something else when i do. maybe not exactly what you were looking for - just sharing my [admittedly narrow] experience. please feel free to let me know if you find a really smashing ide, as i would not be averse to using one, either. good luck, -d On Apr 6, 2005 2:52 PM, Christophe Leske wrote: > Hello there, > my name is Christophe Leske and i am a developer based in D?sseldorf, > germany. I have a multimedia programming background, but am slowly > crawling up to RAD development using Python and am therefore looking > for a windows IDE and GUI Designer. > > Now: > Ideally, I'd like to have an IDE with code completion, yet all the > IDEs i have seen so far (WingIDE, Komodo, Ecliipse (either as > trustudio or the Pydev plugin) don't really cut it for me. > > Same goes for the Windows GUI Designers (Boa doesn't even work for me, > even after compilation - hey, i am a beginner...) > > So far, i settled for PythonWin, yet am still looking for better > alternatives. > Any suggestions? I also know about specialized editors like Crimson or > ZeusEdit, but i'd rather go with an IDE (if possible). > Python seems like a mature development tool for me, which is why i am > wondering that there seems to be no really good IDE that fits me (or > am just weird? probably...) > > My rubberboat is full of eels, > Christophe Leske > tel. +49-(0)211 230 99 70 > .:. f?rstenwall 157 .:. > ::: 40215 d?sseldorf ::: > ::: germany ::: > http://www.multimedial.de > > _______________________________________________ > Python-win32 mailing list > 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 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From leske at online.de Thu Apr 7 12:41:36 2005 From: leske at online.de (Christophe Leske) Date: Thu Apr 7 12:41:26 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: <20050407103143.BAF2B1CABE1@mrelay2.st2.lyceu.net> Message-ID: <000001c53b5e$62c30600$63b2a8c0@kiste> Thanks to all that replied. Seems like i will be sticking with PythonWin for the moment (although i had a look at SciEdit, and it looks quite promising). As for GUI development, it shall be PythonWin then... Thanks again, Christophe Leske tel. +49-(0)211 230 99 70 .:. f?rstenwall 157 .:. ::: 40215 d?sseldorf ::: ::: germany ::: http://www.multimedial.de From leske at online.de Thu Apr 7 12:48:01 2005 From: leske at online.de (Christophe Leske) Date: Thu Apr 7 12:47:50 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: <000001c53b5e$62c30600$63b2a8c0@kiste> Message-ID: <000101c53b5f$481736e0$63b2a8c0@kiste> > Thanks to all that replied. Seems like i will be sticking > with PythonWin for the moment (although i had a look at > SciEdit, and it looks quite promising). > > As for GUI development, it shall be PythonWin then... Err, i meant wxPython. Sorry about that, Christophe Leske tel. +49-(0)211 230 99 70 .:. f?rstenwall 157 .:. ::: 40215 d?sseldorf ::: ::: germany ::: http://www.multimedial.de From nicolas.grilly at garden-paris.com Thu Apr 7 14:16:37 2005 From: nicolas.grilly at garden-paris.com (Nicolas Grilly) Date: Thu Apr 7 14:17:16 2005 Subject: [python-win32] Intro and Windows Questions In-Reply-To: <000101c53b5f$481736e0$63b2a8c0@kiste> Message-ID: <20050407121640.2704C1E7609@mrelay1.st2.lyceu.net> Christophe, I recommend you don't use PythonWin to develop a wxPython application, because sometime your wxPython application will block your PythonWin IDE (there is a conflict between the event loop of PythonWin and the event loop of wxPython). This is the reason why I use SciTE in place of PythonWin. Regards, Nicolas -----Message d'origine----- De : Christophe Leske [mailto:leske@online.de] Envoy? : jeudi 7 avril 2005 12:48 ? : 'Christophe Leske'; 'Nicolas Grilly'; 'Daniel F' Cc : python-win32@python.org Objet : RE: [python-win32] Intro and Windows Questions > Thanks to all that replied. Seems like i will be sticking with > PythonWin for the moment (although i had a look at SciEdit, and it > looks quite promising). > > As for GUI development, it shall be PythonWin then... Err, i meant wxPython. Sorry about that, Christophe Leske tel. +49-(0)211 230 99 70 .:. f?rstenwall 157 .:. ::: 40215 d?sseldorf ::: ::: germany ::: http://www.multimedial.de From nanotube at gmail.com Thu Apr 7 17:14:01 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 7 17:14:04 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> Message-ID: > Unicode Implemented as ANSI and Unicode versions. > > Which means: Call MapVirtualKeyA for ansi strings, MapVirutalKeyW for > unicode strings. aha! that works. :) never would have guessed just by looking at that unicode line what it actually means... > > Daniel, off to learn how to inject dll.... > > Hehe. Good luck. thanks, seems like im gonna need it... -d From nanotube at gmail.com Thu Apr 7 17:16:28 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 7 17:16:31 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes In-Reply-To: <42550896.6040607@vintech.bg> References: <20050405100016.82BA31E4020@bag.python.org> <4252BFBE.7050000@probo.com> <4252D115.6070903@probo.com> <42532190.5090901@probo.com> <42538F38.50008@vintech.bg> <42550896.6040607@vintech.bg> Message-ID: > I have this: > > -rw------- 1 niki users 1459352 Apr 1 2004 4-04-01/adder-0.3.3-src.zip > -rw------- 1 niki users 137800 Apr 1 2004 4-04-01/adder-0.3.3-win32.zip > -rw------- 1 niki users 69801 Apr 1 2004 4-04-01/adder-manual.zip > > Do you want any of them? By e-mail? yes, please! with my nifty 2g of space from gmail, should be no problem getting all three of those. :) thank you, daniel From magoldfish at gmail.com Sun Apr 10 07:12:43 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Sun Apr 10 07:12:47 2005 Subject: [python-win32] HookMessage failure? In-Reply-To: References: <12880-84090@sneakemail.com> Message-ID: <5e183f3d050409221238454cf5@mail.gmail.com> On Apr 7, 2005 12:47 AM, Daniel F wrote: > Hey Mark, > the correct mesage to hook is "win32con.WM_LBUTTONDOWN" > try it with this one, and see if that works. > -d > > On 7 Apr 2005 02:15:41 -0000, b6y9eq902@sneakemail.com > wrote: > > Hey, > > > > I'm currently trying to detect all clicks to a particular windows Did you get this to work? I tried the following snippet to no avail. Anyone have suggestions? import winGuiAuto import win32ui, win32con def handler(*args): print "handler called" hwnd = winGuiAuto.findTopWindow("calculator") pwin = win32ui.CreateWindowFromHandle(hwnd) pwin.HookMessage(handler, win32con.WM_LBUTTONDOWN) From bvande at po-box.mcgill.ca Sun Apr 10 21:32:59 2005 From: bvande at po-box.mcgill.ca (Brian van den Broek) Date: Sun Apr 10 21:34:37 2005 Subject: [python-win32] PyWin saving interactive window -- possible bug? Message-ID: <42597F6B.3000706@po-box.mcgill.ca> Hi all, I have come across some PythonWin behaviour I don't understand. (Python 2.4.1, pywin32 extensions (build 203), WindowsMe) In a PythonWin session with the interactive window active, if I try to save the interactive window (no matter which way I invoke the save routine) a "Save As" dialog pops up, with the filename pre-filed to `Interactive Window'. Yet no attempt to save, either under the default name or a different name, actually results in a saved file. Further, if I select a pre-existing file as the file to save to, the content is not saved *and* the pre-existing file is deleted. This strikes me as a bad thing. :-) I would like to be able to save interactive windows (as IDLE allows), but not being able to do so is not too dire a problem. What *is* pretty dire IMHO, is that the interface leaves me thinking I have indeed successfully saved, even though I have not. (Having been burned once, I won't be again, but it still seems buggy.) Is my installation of PythonWin or the extension package possibly mis-configured? Or have I detected a bug? (I did search for previous posts via gmane , but came up empty.) I'm getting the list as a digest, so might not be prompt in responding further. Thanks and best to all, Brian vdB From gagenellina at softlab.com.ar Tue Apr 12 04:59:35 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue Apr 12 04:54:24 2005 Subject: [python-win32] How Can I exec() a statement? In-Reply-To: <03ba01c53b79$2d294c50$70e7dbcb@Amphora> References: <034f01c53ad2$2acb31f0$70e7dbcb@Amphora> <6.2.1.2.0.20050406161555.03018e80@192.168.0.115> <03ba01c53b79$2d294c50$70e7dbcb@Amphora> Message-ID: <6.2.1.2.0.20050411225014.02ff1100@192.168.0.115> At Thursday 7/4/2005 10:53, * William wrote: Please stay in the list - and even move to the Python-list as those topics are not specific to Windows. >Exactly what I want to do -- for the enquiry about "what" I want to do, it >is best to use as an example. >#4 >b = 2 >print "Before:" >print " a = %s" % str( a ) >print " b = %s" % str( b )# >codeLine = 'a = b + 6' >exec codeLine in globals(), locals() ># >print "After:" >print " a = %s"% str( a ) >print " b = %s" % str( b ) > >... of course the notion, is a little more elaborate though still in its >infancy. I am thinking it will be a basic verification tool or even an >aid for debugging. By chopping up the line, I can print the value of all >the symbols in the codeLine. The 'trick' is going to be Not calling >functions twice (in case there is a side-effect). So you are going to write your own debugger? I'd try the existing ones first :) It's hard to recognize automatically the relevant symbols, even using the tokenize/token/parser modules. Unles you restrict yourself to very simple expressions with no objects, no attribute selection, no subscripting... a[round(math.sin(2*math.pi*obj.current_angle/180.0+obj.phase))]*x+config['offset'] There is a lot of names there: a,round,math,sin,pi,obj... Some just make sense in the context of another (by example, there is no phase variable, it's an attribute of obj). Maybe current_angle is a property and getting its value actually means invoking a function wich reads a sensor... > For example, I'd like a way to get the symbol name for variable a > above. Is there a function like "nameOF( a )"? Maybe a Python hacker guru could say something, but AFAIK, once you get inside the function nameOF( a ), there is no way to tell where its argument came from. In the following example, I think there is no way to distinguish inside f if it was called with a or b as an argument, since both are simply names pointing to the same object: >>> def f(x): ... print x, id(x) ... >>> >>> a = [1,2,3] >>> b = a >>> a [1, 2, 3] >>> b [1, 2, 3] >>> id(a) 6999440 >>> id(b) 6999440 >>> f(a) [1, 2, 3] 6999440 >>> f(b) [1, 2, 3] 6999440 >>> Gabriel Genellina Softlab SRL -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050411/37720264/attachment.html From mhammond at skippinet.com.au Tue Apr 12 11:37:52 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 12 11:37:59 2005 Subject: [python-win32] pywin32 build 204 Message-ID: <095601c53f43$4cf17b20$070a0a0a@enfoldsystems.local> Hi all, I have just released build 204 of the pywin32 (previously win32all) extensions. Change log and release notes: https://sourceforge.net/project/shownotes.php?release_id=319716 Download via: https://sourceforge.net/project/showfiles.php?group_id=78018 Please log any issues via the SourceForge bug collector: https://sourceforge.net/tracker/?group_id=78018&atid=551954 Regards, Mark. From tim at alwaysreformed.com Tue Apr 12 12:23:29 2005 From: tim at alwaysreformed.com (Tim Black) Date: Tue Apr 12 12:23:43 2005 Subject: [python-win32] Using SendMessage to send an accelerator key combination Message-ID: <425BA1A1.6080003@alwaysreformed.com> I'm trying to automate a GUI from Python. I've been using AutoHotKey but now in the interest of speeding things up and simplifying my app's structure I am porting my app to use winGuiAuto (which is a great help!) and the Python win32 extensions. I've read the thread on this list titled "Help on using win32api.SendMessage to send keystrokes," some of the PyWin32 documentation, and some of the MSDN docs on SendMessage, but am still unclear about how to construct a message to send simple accelerator key combinations to a window, such as the following: CONTROL+s SHIFT+END Could anyone point me to the right documentation to understand what characters to include in the "message" argument of the win32gui.SendMessage() call to send either of these two accelerator key combinations? I just need a good example to get me going. Thanks in advance! Tim Black -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050412/dcd8ec79/attachment.htm From skepsis at blueyonder.co.uk Tue Apr 12 06:22:49 2005 From: skepsis at blueyonder.co.uk (Ade) Date: Tue Apr 12 16:15:31 2005 Subject: [python-win32] getting the contents of a Control in a window Message-ID: Hi, Just joined the list. I have been using win32 for a couple of years and of cause love Python. I am trying to get the contents of a control in a window, say a TextArea control or a List or a button etc. I can programmatically get the window its in and then the controls handle by enumming the child windows of that window. I cannot get the contents of that control. I'm a tester and I need to be able to confirm the contents programmatically before moving on with the test. I know there are 3rd party applications out there that can do it so it must be possible but I cannot use these it has to be python (unless there is a Python one that I have missed?). I have dug through the python forums and not found anything so far. I thought that since this was all about win32 it would be the best place for an answer or example. Cheers Adrian Smith From timr at probo.com Tue Apr 12 19:19:56 2005 From: timr at probo.com (Tim Roberts) Date: Tue Apr 12 19:20:00 2005 Subject: [python-win32] How Can I exec() a statement? In-Reply-To: <20050412100042.B6CC81E400D@bag.python.org> References: <20050412100042.B6CC81E400D@bag.python.org> Message-ID: <425C033C.4020604@probo.com> On Mon, 11 Apr 2005 23:59:35 -0300, Gabriel Genellina wrote: >At Thursday 7/4/2005 10:53, * William wrote: > > >> For example, I'd like a way to get the symbol name for variable a >>above. Is there a function like "nameOF( a )"? >> >> > >Maybe a Python hacker guru could say something, but AFAIK, once you get >inside the function nameOF( a ), there is no way to tell where its argument >came from. In the following example, I think there is no way to distinguish >inside f if it was called with a or b as an argument, since both are simply >names pointing to the same object > That's exactly right. When programming in Python, there is a very strict distinction between "objects" and "names that happen to be bound to objects". If you are coming from a C or C++ background, for example, think of every variable in Python as being a pointer or reference. An object that is being pointed to has absolutely no idea which variables point to it. Even the run-time library does not know. Consider this pseudo-C++ example. int& i; int& j; i = 3; j = i; At this point, the constant "3" has no clue that two things point to it. If I pass "i" to a function, that function receives "3". It receives no knowledge about "i" or "j", and there is no way to trace it back. That's the situation in Python. A function receives an object, not a name. While inside the function, the parameter name happens to be bound to that object, but it doesn't know what other (outside) names might be bound to that object. (Actually, that's not entirely true: it knows HOW MANY names are bound to it, so it can do reference counting and garbage collection, but not WHICH names.) -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From nanotube at gmail.com Tue Apr 12 19:43:11 2005 From: nanotube at gmail.com (Daniel F) Date: Tue Apr 12 19:43:17 2005 Subject: [python-win32] Using SendMessage to send an accelerator key combination In-Reply-To: <425BA1A1.6080003@alwaysreformed.com> References: <425BA1A1.6080003@alwaysreformed.com> Message-ID: > I've read the thread on this list titled "Help on using > win32api.SendMessage to send keystrokes," some of the PyWin32 documentation, > and some of the MSDN docs on SendMessage, but am still unclear about how to > construct a message to send simple accelerator key combinations to a window, > such as the following: > > CONTROL+s > SHIFT+END > > Could anyone point me to the right documentation to understand what > characters to include in the "message" argument of the > win32gui.SendMessage() call to send either of these two accelerator key > combinations? I just need a good example to get me going. sendmessage itself has no way to specify that you are sending a key combination, it can only send single keys. so... the obvious thing to do would be to do the following: win32api.PostMessage(HWND, win32con.WM_KEYDOWN, win32con.VK_CONTROL, lParamBits) win32api.PostMessage(HWND, win32con.WM_KEYDOWN, 0x53, lParamBits) win32api.PostMessage(HWND, win32con.WM_KEYUP, 0x53, lParamBits) win32api.PostMessage(HWND, win32con.WM_KEYUP, win32con.VK_CONTROL, lParamBits) where the lparambits are the appropriate bits, as per the win api documentation for WM_KEYDOWN (check msdn) in other words: press control, press S (keycode 0x41), release S, release control. however, it seems that some apps (at least notepad - my test case) do not treat that as expected. so that sequence merely produces an 's' in the notepad window, rather than bring up the save box. but if you hold control manually, while sending the s key through your code, that brings up the save as box. So it appears that notepad checks the key state directly, using either GetKeyState or GetKeyboardState for the keystrokes. so in order to fool notepad, and probably other apps as well (havent tested on anything else... it may work for your specific case, depending on what app you want to use this with), you would have to fool getkey[board]state. So, you would have to use SetKeyboardState api and set the values for control, or shift, or whatever you want to use, to the down state, THEN send it the key through sendmessage, and THEN reset the keyboard state to normal. unfortunately, it appears that pywin32 does not wrap the getkeyboardstate/setkeyboardstate api, (although v204 was just released, and i am running 203, so maybe this was added in v204?). so you could get stuck using ctypes, which is generally a somewhat less pleasant experience than using pywin32. now, note that i myself am not a python guru by far (just started playing with python, and the windows api, just about at the start of that win32api.SendMessage thread you referenced), so i may be missing stuff, or be completely wrong, but this is my understanding, and I hope it helps. :) -d From nanotube at gmail.com Tue Apr 12 21:07:26 2005 From: nanotube at gmail.com (Daniel F) Date: Tue Apr 12 21:07:28 2005 Subject: [python-win32] getting the contents of a Control in a window In-Reply-To: References: Message-ID: > I am trying to get the contents of a control in a window, say a TextArea > control or a List or a button etc. > I can programmatically get the window its in and then the controls handle by > enumming the child windows of that window. > I cannot get the contents of that control. > I'm a tester and I need to be able to confirm the contents programmatically > before moving on with the test. > I know there are 3rd party applications out there that can do it so it must > be possible but I cannot use these it has to be python (unless there is a > Python one that I have missed?). > I have dug through the python forums and not found anything so far. > I thought that since this was all about win32 it would be the best place for > an answer or example. have you tried win32gui.GetWindowText(hwnd) ? you may note that the msdn api reference specifies 3 arguments for this function, but pywin32 takes only one, the hwnd. dont know why, but it certainly makes the function much easier to use... -d From daniel at elxlbn.de Tue Apr 12 23:45:20 2005 From: daniel at elxlbn.de (daniel(1und1)) Date: Tue Apr 12 23:42:52 2005 Subject: [python-win32] Python and Hardwaremanagement Message-ID: Dear Experts I'm new to Python. Till today I have only written two small programs and tried out some window object functions. Therefore I apologize for any "nonsense". My problem is how to take control with Python of my hardware (keyboard, monitor, etc.). I have downloaded the win32com.client but could no find any commands/modules related to such issues. Microsoft offer only Python programs which produce information about the drivers and properties but not a way to manage them. Any help or suggestions? Kind regards Daniel T. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050412/b7ef9a6d/attachment.htm From gustabares at verizon.net Wed Apr 13 00:19:05 2005 From: gustabares at verizon.net (Gustavo Tabares) Date: Wed Apr 13 00:19:18 2005 Subject: [python-win32] LsaAddAccountRights help Message-ID: <000b01c53fad$a757d310$0200a8c0@blackbetty> Hello, I'm trying to give a user a "Log on as a Service" right using the Python Win32 modules. Here is the code in question: #!/usr/bin/env python import win32security username = "Administrator" system_name = "temp_system" policy_handle = win32security.LsaOpenPolicy(system_name, win32security.POLICY_ALL_ACCESS) sid_obj, domain, tmp = win32security.LookupAccountName(system_name, username) win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE ) win32security.LsaClose( policy_handle ) I'm running this code as Administrator, so having the proper permissions to perform this operation shouldn't be a question. Here is what I'm getting when I run the above code: Traceback (most recent call last): File "C:\example.py", line 12, in ? win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE ) SystemError: error return without exception set I'm cluess as to what is going on. Any help is appreciated. By the way, I'm using Python 2.3.3 with PythonWin32 build 202. Thanks, Gus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050412/488a636c/attachment.html From gagenellina at softlab.com.ar Wed Apr 13 00:39:31 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed Apr 13 00:34:25 2005 Subject: [python-win32] Python and Hardwaremanagement In-Reply-To: References: Message-ID: <6.2.1.2.0.20050412193637.02dcf540@192.168.0.115> At Tuesday 12/4/2005 18:45, daniel(1und1) wrote: >I'm new to Python. Till today I have only written two small programs and >tried out some window object functions. Therefore I apologize for any >"nonsense". My problem is how to take control with Python of my hardware >(keyboard, monitor, etc.). I have downloaded the win32com.client but could >no find any commands/modules related to such issues. Microsoft offer only >Python programs which produce information about the drivers and properties >but not a way to manage them. Any help or suggestions? That depends on what you mean by "take control of my hardware". Unless you're doing very specific things, just let the OS take control of your hardware... What do you want to do? Gabriel Genellina Softlab SRL From rwupole at msn.com Wed Apr 13 00:47:27 2005 From: rwupole at msn.com (Roger Upole) Date: Wed Apr 13 00:47:36 2005 Subject: [python-win32] Re: LsaAddAccountRights help References: <000b01c53fad$a757d310$0200a8c0@blackbetty> Message-ID: LsaAddAccountRights help The third parm should be a sequence of privilege names. Looks like the argument parsing isn't checking that it's a sequence. Also, that particular privilege constant (SE_SERVICE_LOGON_NAME) isn't defined anywhere yet. I'll correct both of those problems shortly. For the meantime, you should be able to use win32security.LsaAddAccountRights( policy_handle, sid_obj, ('SeServiceLogonRight',) ) hth Roger ----- Original Message ----- From: Gustavo Tabares To: python-win32@python.org Sent: Tuesday, April 12, 2005 6:19 PM Subject: [python-win32] LsaAddAccountRights help Hello, I'm trying to give a user a "Log on as a Service" right using the Python Win32 modules. Here is the code in question: #!/usr/bin/env python import win32security username = "Administrator" system_name = "temp_system" policy_handle = win32security.LsaOpenPolicy(system_name, win32security.POLICY_ALL_ACCESS) sid_obj, domain, tmp = win32security.LookupAccountName(system_name, username) win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE ) win32security.LsaClose( policy_handle ) I'm running this code as Administrator, so having the proper permissions to perform this operation shouldn't be a question. Here is what I'm getting when I run the above code: Traceback (most recent call last): File "C:\example.py", line 12, in ? win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE ) SystemError: error return without exception set I'm cluess as to what is going on. Any help is appreciated. By the way, I'm using Python 2.3.3 with PythonWin32 build 202. Thanks, Gus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050412/20c7bde1/attachment.html From timr at probo.com Wed Apr 13 01:52:00 2005 From: timr at probo.com (Tim Roberts) Date: Wed Apr 13 01:52:04 2005 Subject: [python-win32] getting the contents of a Control in a window In-Reply-To: <20050412221921.C31661E400F@bag.python.org> References: <20050412221921.C31661E400F@bag.python.org> Message-ID: <425C5F20.9000104@probo.com> On Tue, 12 Apr 2005 15:07:26 -0400, Daniel F wrote: > > >have you tried win32gui.GetWindowText(hwnd) ? > >you may note that the msdn api reference specifies 3 arguments for >this function, but pywin32 takes only one, the hwnd. dont know why, >but it certainly makes the function much easier to use... > Because those are outputs of GetWindowText. For any API that returns a string, the Windows API will have you pass in a buffer and a buffer size. In Python, strings can vary in length, so there is no need to send a pre-allocated string. The Python Win32 wrapper conveniently creates the buffer for you, and passes the resulting string as a return from the function. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Apr 13 01:55:48 2005 From: timr at probo.com (Tim Roberts) Date: Wed Apr 13 01:55:52 2005 Subject: [python-win32] Python and Hardwaremanagement In-Reply-To: <20050412221921.C31661E400F@bag.python.org> References: <20050412221921.C31661E400F@bag.python.org> Message-ID: <425C6004.8090309@probo.com> On Tue, 12 Apr 2005 23:45:20 +0200, "daniel(1und1)" wrote: >I'm new to Python. Till today I have only written two small programs and >tried out some window object functions. Therefore I apologize for any >"nonsense". My problem is how to take control with Python of my hardware >(keyboard, monitor, etc.). I have downloaded the win32com.client but could >no find any commands/modules related to such issues. Microsoft offer only >Python programs which produce information about the drivers and properties >but not a way to manage them. Any help or suggestions? > I guess you need to tell us what you mean by "take control". Because of its Linux heratige, basic Python is oriented towards command-line-based processing. It reads from the keyboard as "standard input" and writes to the screen as "standard output": name = input('What is your name? ') print "Hello, %s!" % name If you want to create GUI apps, where you have a window with controls and buttons and such, you will need to investigate one of the add-on packates. wxPython is my favorite, but tkinter and pyGTK have their fans as well. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From gustabares at verizon.net Wed Apr 13 03:29:29 2005 From: gustabares at verizon.net (Gustavo Tabares) Date: Wed Apr 13 03:30:03 2005 Subject: [python-win32] Re: LsaAddAccountRights help In-Reply-To: Message-ID: <000c01c53fc8$46875310$0200a8c0@blackbetty> It worked perfectly. Thank you..... Gus -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] On Behalf Of Roger Upole Sent: Tuesday, April 12, 2005 6:47 PM To: python-win32@python.org Subject: [python-win32] Re: LsaAddAccountRights help The third parm should be a sequence of privilege names. Looks like the argument parsing isn't checking that it's a sequence. Also, that particular privilege constant (SE_SERVICE_LOGON_NAME) isn't defined anywhere yet. I'll correct both of those problems shortly. For the meantime, you should be able to use win32security.LsaAddAccountRights( policy_handle, sid_obj, ('SeServiceLogonRight',) ) hth Roger ----- Original Message ----- From: Gustavo Tabares To: python-win32@python.org Sent: Tuesday, April 12, 2005 6:19 PM Subject: [python-win32] LsaAddAccountRights help Hello, I'm trying to give a user a "Log on as a Service" right using the Python Win32 modules. Here is the code in question: #!/usr/bin/env python import win32security username = "Administrator" system_name = "temp_system" policy_handle = win32security.LsaOpenPolicy(system_name, win32security.POLICY_ALL_ACCESS) sid_obj, domain, tmp = win32security.LookupAccountName(system_name, username) win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE ) win32security.LsaClose( policy_handle ) I'm running this code as Administrator, so having the proper permissions to perform this operation shouldn't be a question. Here is what I'm getting when I run the above code: Traceback (most recent call last): File "C:\example.py", line 12, in ? win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE ) SystemError: error return without exception set I'm cluess as to what is going on. Any help is appreciated. By the way, I'm using Python 2.3.3 with PythonWin32 build 202. Thanks, Gus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050412/664114ae/attachment.html From nanotube at gmail.com Wed Apr 13 06:05:53 2005 From: nanotube at gmail.com (Daniel F) Date: Wed Apr 13 06:06:02 2005 Subject: [python-win32] Using SendMessage to send an accelerator key combination In-Reply-To: <425C5F50.9040802@alwaysreformed.com> References: <425BA1A1.6080003@alwaysreformed.com> <425C5F50.9040802@alwaysreformed.com> Message-ID: > Daniel F wrote: > > >win32api.PostMessage(HWND, win32con.WM_KEYDOWN, win32con.VK_CONTROL, lParamBits) > >win32api.PostMessage(HWND, win32con.WM_KEYDOWN, 0x53, lParamBits) > >win32api.PostMessage(HWND, win32con.WM_KEYUP, 0x53, lParamBits) > >win32api.PostMessage(HWND, win32con.WM_KEYUP, win32con.VK_CONTROL, lParamBits) > > > > > Thank you; this message was very helpful. I will try this without the > getkeyboardstate/setkeyboardstate api or ctypes first, then if necessary > dig deeper. > > I'm a bit disappointed not to find a higher-level general solution to > the problem, though. It seems to me at first glance that sending > accelerator key combinations might be a common task for which people > would want to use PyWin32. AutoHotKey does it and is open source; maybe > some of their code could provide a starting point for a general solution. ah, since you were asking specifically about sendmessage and the win api, i didn't think you were looking for higher-level wrappers. In that case you may want to look at the SendKeys module (http://www.rutherfurd.net/python/sendkeys/). that might be closer to what you are looking for, in terms of higher-level general solution. you can send keypresses by just specifying the characters, and any modifiers, without having to worry about any of that virtual key code and other fancy function arguments stuff. in case you care, sendkeys works by wrapping the keybd_event windows api, which is marked as "superceded by SendInput" for win NT, 2k, and XP, but should work just fine anyway. note that keybd_event (and thus the SendKeys module, too) can only send keys to the window that has focus, you cannot specify which window to send to like you can with sendmessage and its hwnd argument. -d From wschneider at ra.rockwell.com Wed Apr 13 12:06:21 2005 From: wschneider at ra.rockwell.com (Wolfgang Schneider) Date: Wed Apr 13 12:07:56 2005 Subject: [python-win32] Using licensed ActiveX control with win32ui.CreateControl() Message-ID: Hi I have a problem with passing a runtime license key for an ActiveX control to the method CreateControl() of the class pywin.mfc.activex.Control (and the CreateControl() method of win32ui) Can anybody give me a hint in which form the license key string must be passed to this method? I got the license key for the ActiveX control using the "License Key Requester" from Microsoft (http://support.microsoft.com/d?efault.aspx?scid=kb;en-us;1517?71) and I used the string given as comment above the WCHAR array (since I don't know how to convert the WCHAR array for Python). I pass this string to the CreateControl() method of pywin.mfc.activex.Control in the following way: # instead of 'X' I use the correct license key string, of course licKeyString = "XXXXXXXXX" # self.ocx is an instance of pywin.mfc.activex.Control # (actually a subclass of "Control" and the Python wrapper # generated for the ActiveX control I want to use) self.ocx.CreateControl( windowTitle = "Component One Chart 8.0 ActiveX Control", style = win32con.WS_VISIBLE | win32con.WS_CHILD, rect = (0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT), parent = self, id = 1, lic_string = licKeyString) But when creating the control with this string, the control is created in "evaluation mode" and not, as expected, as a licensed control. I looked up the code for the CreateControl() method and found out, that it passes the license key string directly to the CreateControl() of the PyCWnd class (the Python wrapper for the CWnd class of MFC implemented at win32ui). Than I looked at the Python extension, where the PyCWnd::CreateControl() is implemented, and found, that the macro T2OLE is used to convert the given Python string for the license key to an OLE string, before passing it to the original MFC method. ok = pWnd->CreateControl(clsid, szWndName, style, rect, pWndParent, id, NULL, bStorage, T2OLE(szLicKey)); I'm not sure, but when I understand this right, the MFC method CreateControl() wants a BSTR here and I read somewhere that T2OLE does not return a BSTR. Can this be the problem here? Should there be used T2BSTR instead? Is this a bug in win32ui? Has anybody ever used the license key string parameter of the CreateControl() method in Python and can tell my how to pass the license key string correctly? Thanks in advance. Wolfgang Schneider -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050413/7de93d88/attachment.htm From mhammond at skippinet.com.au Wed Apr 13 13:41:39 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Apr 13 13:41:47 2005 Subject: [python-win32] Using licensed ActiveX control withwin32ui.CreateControl() In-Reply-To: Message-ID: <001401c5401d$c240c0e0$0e0a0a0a@enfoldsystems.local> > I'm not sure, but when I understand this right, the MFC method > CreateControl() wants a BSTR here and I read somewhere that T2OLE > does not return a BSTR. Can this be the problem here? Should there > be used T2BSTR instead? Is this a bug in win32ui? T2OLE will convert a Python ascii string to a wide string - that should be fine. > Has anybody ever used the license key string parameter of the CreateControl() > method in Python and can tell my how to pass the license key string correctly? I have many moons ago. I believe you pass the license string in a standard "GUID" format - eg, "{5F584028-15BF-4dcf-AEB2-5FDC9B0C0AA5}" (which is just one guidgen just gave me). Does your license string make itself available in that format? I may well be wrong though... Mark From daniel at elxlbn.de Thu Apr 14 11:42:56 2005 From: daniel at elxlbn.de (daniel(1und1)) Date: Thu Apr 14 17:34:21 2005 Subject: [python-win32] Python und Hardwaremanagement Message-ID: Dear Experts Many thanks so far for your quick response. Basically what I mean with "manage your hardware" is writing a program that can switch on/off the monitor and keyboard as well as setting/change the resolution and frequency. Its just for training. Platform_: Windows XP Python: Version 2.4 + Win32 Extension module Kind regards and many thanks in advance Daniel T. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050414/d36a0a25/attachment.html From nanotube at gmail.com Thu Apr 14 18:00:58 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 14 18:01:05 2005 Subject: [python-win32] Python und Hardwaremanagement In-Reply-To: References: Message-ID: > Many thanks so far for your quick response. Basically what I mean with > "manage your hardware" is writing a program that can switch on/off the > monitor and keyboard as well as setting/change the resolution and frequency. > Its just for training. to play with the monitor settings, check out the following api functions in the msdn api reference: changedisplaysettings enumdisplaysettings these are wrapped by pywin32, and will allow you to change resolution, frequency, etc. (dont think you can turn monitor off through these, but i may be wrong, i havent used these myself...) as to the keyboard... i dont think you can "turn off" the keyboard, but if you want to disable all keyboard input, you can just hook all messages (use setwindowhookex api, or the pyHook module, which wraps setwindowhookex and makes things more convenient), and block them. -d From ryan_p79 at yahoo.com Thu Apr 14 20:33:54 2005 From: ryan_p79 at yahoo.com (ryan pinto) Date: Thu Apr 14 20:33:56 2005 Subject: [python-win32] word Message-ID: <20050414183354.94631.qmail@web52009.mail.yahoo.com> Hi Guys, I am new to Python Win 32. COuld some one send me some py code to open and process word documents. I am trying to talk to work by doing... wordApp = win32com.client.Dispatch("word.Application") wordApp.visible = 1 wordApp.CommandBars.FindControl(Id=23).Execute and it doesnt seem to work. Thanks, Ryan __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ From mc at mclaveau.com Thu Apr 14 20:46:58 2005 From: mc at mclaveau.com (Michel Claveau) Date: Thu Apr 14 20:44:56 2005 Subject: [python-win32] word References: <20050414183354.94631.qmail@web52009.mail.yahoo.com> Message-ID: <008101c54122$5b64e6c0$0701a8c0@PORTABLES> Hi ! A mini example, but already ready (old) : import win32com from win32com.client import Dispatch word = Dispatch('Word.Application') word.visible = 1 doc = word.Documents.Add() rge = doc.Range(0,0) rge.Text="""Bonjour ! Essai OK.\r\n\r\n Please, visit http://mclaveau.com""" doc.SaveAs('c:\\Titi.doc') word.ActiveDocument.Close(SaveChanges = -1) word.Quit() @-salutations Michel Claveau From gagenellina at softlab.com.ar Fri Apr 15 22:49:48 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Fri Apr 15 22:44:22 2005 Subject: [python-win32] word In-Reply-To: <20050414183354.94631.qmail@web52009.mail.yahoo.com> References: <20050414183354.94631.qmail@web52009.mail.yahoo.com> Message-ID: <6.2.1.2.0.20050415174425.03384d60@192.168.0.115> At Thursday 14/4/2005 15:33, ryan pinto wrote: >wordApp.CommandBars.FindControl(Id=23).Execute Remember that, in Python, you must use () to invoke a function, even if it has no arguments. Gabriel Genellina Softlab SRL From mc at mclaveau.com Sat Apr 16 05:40:54 2005 From: mc at mclaveau.com (Michel Claveau) Date: Sat Apr 16 05:38:51 2005 Subject: [python-win32] word References: <20050414183354.94631.qmail@web52009.mail.yahoo.com> Message-ID: <001001c54236$1b98c0b0$0701a8c0@PORTABLES> Hi ! I send again (my previous message, 14 april, not having "passed") ------------------------------------------------------------------- Hi (hi-hi-hi) The information what you want is worth only one million euros. But it is my philantropic evening. Therefore, look : import win32com from win32com.client import Dispatch word = Dispatch('Word.Application') word.visible = 1 doc = word.Documents.Add() rge = doc.Range(0,0) rge.Text="""Bonjour ! Essai OK.\r\n\r\n Please, visit http://bergoiata.org""" hw=doc.InlineShapes hw.AddPicture("C:\\vodka.jpg") doc.SaveAs('c:\\Toto.doc') word.ActiveDocument.Close(SaveChanges = -1) word.Quit() @-salutations -- Michel Claveau From sjmachin at lexicon.net Tue Apr 19 05:09:19 2005 From: sjmachin at lexicon.net (sjmachin@lexicon.net) Date: Tue Apr 19 05:09:31 2005 Subject: [python-win32] COM access to Excel suddenly stopped working Message-ID: <426502FF.3834.1A0EEA5@localhost> Hi, [Windows 2000, build 2195, SP4; Python 2.4.1; pywin32 build 204] I'm experimenting with accessing the contents of Excel workbooks. I've used makepy to build the Excel 10.0 library. Have successfully done various COM fiddling with Excel before with Python 2.3 & 2.4, and with Excel 9.0 and 10.0. Was working OK this morning, right down to digging out the values of individual cells. However it's suddenly stopped working, right up the top. (1) xl = win32com.client.Dispatch("Excel.Application") (2) print repr(xl) (3) xlwb = xl.Workbooks.Open(filename) Before, line 2 would print this: and line 3 would work OK. Now, line 2 prints this: and line 3 causes an exception: File "com_read.py", line 21, in com_open_workbook xlwb = xl.Workbooks.Open(filename) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 489, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: Excel.Application.Workbooks All I did between it working and not working was to shut down a few windows before shutting down the PC then I had an afterthought and ran my script again and whammo! I've since used makepy via the PythonWin tools menu to rebuild the Excel 10.0 library, but that didn't help. Any clues gratefully appreciated, Cheers, John From mhammond at skippinet.com.au Tue Apr 19 06:52:27 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 19 06:52:41 2005 Subject: [python-win32] COM access to Excel suddenly stopped working In-Reply-To: <426502FF.3834.1A0EEA5@localhost> Message-ID: <023e01c5449b$969eb410$0a00a8c0@enfoldsystems.local> Hi John, > (1) xl = win32com.client.Dispatch("Excel.Application") > (2) print repr(xl) > (3) xlwb = xl.Workbooks.Open(filename) > > Before, line 2 would print this: > Library._Application instance at > 0x39073872> > and line 3 would work OK. > > Now, line 2 prints this: > That is strange - the script is not finding the makepy generated file. This could be due to the gen_py directory being removed - by default you should find it in lib\site-packages\win32com\gen_py Using win32com.client.gencache.EnsureDispatch() in place of Dispatch should force that generation - but I'm afraid I have no idea why it suddenly became necessary. Mark From xeoicq at netscape.net Tue Apr 19 18:33:54 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Tue Apr 19 18:34:08 2005 Subject: [python-win32] Python and LabView over COM? Message-ID: <426532F2.9030700@netscape.net> Hi All, I try to access LabView by Python-win32com but LabView crashes on some COM-method calls. The same calls work in VB. Are there some known problem with the LabView COM implementation? Ciao, Frank From gschmidt at gschmidt.org Tue Apr 19 21:55:22 2005 From: gschmidt at gschmidt.org (Geoff Schmidt) Date: Tue Apr 19 21:55:25 2005 Subject: [python-win32] COM and ActiveX controls Message-ID: <2cad8fd56b84cd3f86da3b7ed1df71e6@gschmidt.org> Greetings -- I'm trying to embed a web browser inside a Python application. So far, the most straightforward avenue seems to be to use Mozilla or IE as an ActiveX control -- they have identical interfaces. It seems like this should go as follows: 1) Find the HWND of the window in which the control should appear 2) Create a stub object that implements IOleClientSite with no-op implementations of its methods, since we don't need them 3) Instantiate Mozilla or IE with CoCreateInstance and get the IOleObject interface 4) Call DoVerb on the control with the HWND, a rectangle giving the size and position where the control should appear, the IOleClientSite, and the constant OLEIVERB_INPLACEACTIVATE 5) Call SetExtent on the control as necessary in the future to resize it in response to parent window resizing Then, for my application, I'll want to be able to execute Javascript in the context of the browser, and catch URL loads and trigger application events in response to them. All of these things appear to be possible with the IWebBrowser family of interfaces (for which I seem to have a nice type library, incidentally.) The first problem I've run into is that pythoncom doesn't wrap IOleObject, so there's no way to make the call to DoVerb. (Nor is DoVerb exposed through IDispatch :)) In other words: unk = pythoncom.CoCreateInstance("Mozilla.Browser", None, pythoncom.CLSCTX_INPROC, pythoncom.IID_IUnknown) IID_IOleObject = IID('{00000112-0000-0000-C000-000000000046}') obj = c.QueryInterface(IID_IOleObject) -> TypeError: There is no interface object registered that supports this IID A few questions: * How hard would it be for me to put together a wrapping of IOleObject, IOleClientSite, and whatever else I need to embed a basic ActiveX control? * Is there some other way that I missed to do this without wrapping new interfaces (like some IDispatch trick?) * Is this approach to embedding a web browser tractable at all? Is there as easier way? Has anyone had any luck embedding Mozilla in Python on win32 through a more direct mechanism, like PyXPCOM? (I haven't been able to find any stories about that happening on the web.) FWIW, this is for the Windows port of the desktop video player for the Participatory Culture Foundation's internet TV project. Check it out at http://www.participatoryculture.org/. For the actual widget set, I have started out in PyGTK, for skinning support and to ease Linux portability. It's not at all hard to pull HWND's out of PyGTK. If the idea of embedding an ActiveX control in PyGTK seems hilariously wrong to you for some reason that has eluded me, do let me know :) Thanks a lot -- Geoff Schmidt From kmarks at mac.com Tue Apr 19 22:11:00 2005 From: kmarks at mac.com (Kevin Marks) Date: Tue Apr 19 22:34:36 2005 Subject: [python-win32] Re: [Demotv-devel] COM and ActiveX controls In-Reply-To: <2a7d262f6cfec284aa6bbeeaed202ad6@mit.edu> References: <2a7d262f6cfec284aa6bbeeaed202ad6@mit.edu> Message-ID: <49bf6ac84cc2292e1516a9bbfb3cc137@mac.com> Have you thought of doing this the other way round? Use a browser for the UI and a python backend that serves pages using async javascript & XML (AJAX). What you describe is highly windows-centric. On Apr 19, 2005, at 12:43 PM, Geoff Schmidt wrote: > Greetings -- > > I'm trying to embed a web browser inside a Python application. So far, > the most straightforward avenue seems to be to use Mozilla or IE as an > ActiveX control -- they have identical interfaces. From effbiae at ivorykite.com Wed Apr 20 12:02:59 2005 From: effbiae at ivorykite.com (Jack Andrews) Date: Wed Apr 20 12:03:01 2005 Subject: [python-win32] Can't catch WM_CREATE Message-ID: <59417.202.164.198.46.1113991379.squirrel@www.ivorykite.com> hi, i can't seem to catch a WM_CREATE message in simple code. i expect my code to print 'create', but it doesn't listing follows. tia, jack from win32api import * from win32gui import * from win32con import * wc = WNDCLASS() hi = wc.hInstance = GetModuleHandle(None) wc.lpszClassName = nm = "name" wc.style=0 wc.hCursor=LoadCursor(0,IDC_ARROW) wc.hbrBackground = COLOR_WINDOW def create(hwnd, msg, wparam, lparam): print 'create' def destroy(hwnd, msg, wparam, lparam): print 'destroy';PostQuitMessage(0) wc.lpfnWndProc={WM_CREATE:create,WM_DESTROY:destroy} cl=RegisterClass(wc) hwnd=CreateWindow(cl,nm,WS_OVERLAPPEDWINDOW,0,0, CW_USEDEFAULT,CW_USEDEFAULT,0,0,hi,None) ShowWindow(hwnd) UpdateWindow(hwnd) PumpMessages() From Smola at farbspender.de Wed Apr 20 16:45:38 2005 From: Smola at farbspender.de (Stephan Smola) Date: Wed Apr 20 16:51:33 2005 Subject: [python-win32] Windows Namespace Extensions Message-ID: <42666B12.7050701@farbspender.de> Hello, I'm not a newbie to Python but to all the system-level programming for windows in any language. Is it possible to write windows namespace extensions using Python including writing a new view in the explorer for the namespace using win32ui. If so has anyone done that already and can share some tips? Would be nice to get an answer. Regards, Stephan From mhammond at skippinet.com.au Thu Apr 21 00:54:43 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Apr 21 00:54:51 2005 Subject: [python-win32] Windows Namespace Extensions In-Reply-To: <42666B12.7050701@farbspender.de> Message-ID: <047e01c545fb$f1d05f80$0a00a8c0@enfoldsystems.local> > Is it possible to write windows namespace extensions using Python > including writing a new view in the explorer for the namespace using > win32ui. If so has anyone done that already and can share some tips? It is and it works very nicely :) See the win32comext\shell\demos directory for some starting points. Mark From rwupole at msn.com Thu Apr 21 00:57:01 2005 From: rwupole at msn.com (Roger Upole) Date: Thu Apr 21 00:57:08 2005 Subject: [python-win32] Re: Windows Namespace Extensions Message-ID: > Hello, > > I'm not a newbie to Python but to all the system-level programming for > windows in any language. > > Is it possible to write windows namespace extensions using Python > including writing a new view in the explorer for the namespace using > win32ui. If so has anyone done that already and can share some tips? > > Would be nice to get an answer. > > Regards, > > Stephan There's a demo showing how to implement a namespace extension in \win32comext\shell\demos\servers\shell_view.py. Roger From mhammond at skippinet.com.au Thu Apr 21 01:01:48 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Apr 21 01:01:56 2005 Subject: [python-win32] Can't catch WM_CREATE In-Reply-To: <59417.202.164.198.46.1113991379.squirrel@www.ivorykite.com> Message-ID: <047f01c545fc$ef5557f0$0a00a8c0@enfoldsystems.local> > i can't seem to catch a WM_CREATE message in simple code. > i expect my code to print 'create', but it doesn't The problem is the way win32gui works. win32gui sub-classes the created window *after* the call to CreateWindow returns - however, WM_CREATE is sent *before* CreateWindow returns. It may be possible to rework win32gui to solve that, but I doubt I will do it :) Mark. From sjmachin at lexicon.net Thu Apr 21 02:36:41 2005 From: sjmachin at lexicon.net (sjmachin@lexicon.net) Date: Thu Apr 21 02:36:51 2005 Subject: [python-win32] COM access to Excel suddenly stopped working In-Reply-To: <023e01c5449b$969eb410$0a00a8c0@enfoldsystems.local> References: <426502FF.3834.1A0EEA5@localhost> Message-ID: <42678239.11075.EAF471@localhost> On 19 Apr 2005 at 14:52, Mark Hammond wrote: > Hi John, > > > (1) xl = win32com.client.Dispatch("Excel.Application") > > (2) print repr(xl) > > (3) xlwb = xl.Workbooks.Open(filename) > > > > Before, line 2 would print this: > > > Library._Application instance at > > 0x39073872> > > and line 3 would work OK. > > > > Now, line 2 prints this: > > > > That is strange - the script is not finding the makepy generated file. This > could be due to the gen_py directory being removed - by default you should > find it in lib\site-packages\win32com\gen_py > > Using win32com.client.gencache.EnsureDispatch() in place of Dispatch should > force that generation - but I'm afraid I have no idea why it suddenly became > necessary. Hello again, Mark. A bit of an update: Not a problem with makepy. The gen_py directory was intact. Re-running makepy didn't solve the problem. What I was doing was exploratory programming i.e. [look at VBAXL10.CHM, scratch head, edit, run, exception] * n where n was a large number. I wasn't doing xl.Quit() even when it didn't crash. Next run after an exception, it would pop up a dialog box saying that the XLS file was already open and did I want to discard changes? I also discovered when I finally shut down all my windows that there was a dialog I'd never noticed before, about saving files. My guess is that one of more of the above caused Excel to exceed some resource limit and then run amok. Cheers, John From xeoicq at netscape.net Thu Apr 21 12:31:03 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Thu Apr 21 12:31:14 2005 Subject: [python-win32] Python and LabView over COM? (again) Message-ID: <426780E7.4040406@netscape.net> Hi All, > I try to access LabView by Python-win32com but LabView crashes on some COM-method calls. > The same calls work in VB. > Are there some known problem with the LabView COM implementation? There is a strange behavior of attribute/method access of the COM-Object: Methods are already called without using (..). If I use method(..) I get the TypeError: 'NoneType' object is not callable, but the method is obviously executed. I found an old thread in a python-list that discusses the same problem. http://mail.python.org/pipermail/python-list/2003-February/150857.html If I try the advice to use EnsureDispatch I get following error: File "ExportVIStrings.py", line 19, in ? app=win32com.client.gencache.EnsureDispatch("LabVIEW.Application.7") File "C:\Python22\Core\lib\site-packages\win32com\client\gencache.py", line 434, in EnsureDispatch disp_class = CLSIDToClass.GetClass(str(disp_clsid)) File "C:\Python22\Core\lib\site-packages\win32com\client\CLSIDToClass.py", line 50, in GetClass return mapCLSIDToClass[clsid] KeyError: {9A872071-0A06-11D1-90B7-00A024CE2744} Are there some changes in win32com for Py23 or Py24 so that the problem could be fixed? How can I try to debug the dynamic.py to find the reason for the crashes and strange behavior? From the NI LabView-support I got the answer the reason could be like described here: http://support.microsoft.com/kb/241896/en-us?ln=en-us&sd=gn&fr=0 but I didn't get an explanation and can not see a connection between this thread and my problem. Ciao, Frank From mhammond at skippinet.com.au Thu Apr 21 13:36:51 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Apr 21 13:37:02 2005 Subject: [python-win32] Python and LabView over COM? (again) In-Reply-To: <426780E7.4040406@netscape.net> Message-ID: <04cf01c54666$6986af10$0a00a8c0@enfoldsystems.local> > I found an old thread in a python-list that discusses the > same problem. > http://mail.python.org/pipermail/python-list/2003-February/150857.html > > If I try the advice to use EnsureDispatch I get following error: > File "ExportVIStrings.py", line 19, in ? > > app=win32com.client.gencache.EnsureDispatch("LabVIEW.Application.7") > File > "C:\Python22\Core\lib\site-packages\win32com\client\gencache.py", > line 434, in EnsureDispatch > disp_class = CLSIDToClass.GetClass(str(disp_clsid)) > File > "C:\Python22\Core\lib\site-packages\win32com\client\CLSIDToClass.py", > line 50, in GetClass > return mapCLSIDToClass[clsid] > KeyError: {9A872071-0A06-11D1-90B7-00A024CE2744} > > Are there some changes in win32com for Py23 or Py24 so that > the problem > could be fixed? > How can I try to debug the dynamic.py to find the reason for > the crashes > and strange behavior? Sorry to give such little info and send you fishing, but this sounds similar to the problem we had with Lotus Notes in the early days - adding "lotus notes" to your search may dig up more than you want to know :) Try something like: mod = gencache.EnsureModule(...) app = mod.Application() For the exact spelling of the first line, run "makepy.py -i" and select the LabView typelib. For the second line, ".Application()" may not be correct, but given your example (LabVIEW.Application.7), I suspect it is. Examine the generated .py file - 'mod' is that module. Cheers, Mark From ryan_p79 at yahoo.com Thu Apr 21 16:15:55 2005 From: ryan_p79 at yahoo.com (ryan pinto) Date: Thu Apr 21 16:15:57 2005 Subject: [python-win32] pasting from clip-board Message-ID: <20050421141555.8848.qmail@web52007.mail.yahoo.com> Hi Guys, I am new to python WIN-32 and am trying to automate a word document creation. I am trying to paste clipboard that I capture from an application to MS Word and I was wondering if this can be done through python WIN-32. I am a doing a sequence of tests which saves simulation results to the clip-board and need to paste clip-boad to MS-Word. I was wondering if anyone has done something similiar Thanks, Ryan Pinto __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From nanotube at gmail.com Thu Apr 21 18:00:08 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 21 18:13:33 2005 Subject: [python-win32] pasting from clip-board In-Reply-To: <20050421141555.8848.qmail@web52007.mail.yahoo.com> References: <20050421141555.8848.qmail@web52007.mail.yahoo.com> Message-ID: > I am new to python WIN-32 and am trying to automate a > word document creation. I am trying to paste clipboard > that I capture from an application to MS Word and I > was wondering if this can be done through python > WIN-32. I am a doing a sequence of tests which saves > simulation results to the clip-board and need to paste > clip-boad to MS-Word. I was wondering if anyone has > done something similiar howdy ryan, well, you could try doing a win32gui.SendMessage and send WM_COPY and WM_PASTE messages to the applications where you want copies and pastes to be carried out. they should be easy to play with, since the lparam and wparam are just set to zero. so you would just get the appropriate window handles, and then win32gui.SendMessage(hwnd1, WM_COPY, 0, 0) win32gui.SendMessage(hwnd2, WM_PASTE, 0, 0) or, you could explore the functions available in the appropriately-named win32clipboard module (the GetClipboardData function looks like it could be appropriate for your purposes). try the following docs for more detail: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard.asp http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32clipboard.html -d From ryan_p79 at yahoo.com Thu Apr 21 20:14:37 2005 From: ryan_p79 at yahoo.com (ryan pinto) Date: Thu Apr 21 20:14:41 2005 Subject: [python-win32] pasting from clip-board In-Reply-To: 6667 Message-ID: <20050421181438.3708.qmail@web52005.mail.yahoo.com> Hi Everyone, William I found quite a lot of code on capturing text from the clip-board and pasting it. But couldnt find any information on pasting screenshots into MS-WORD. This seems to work fine for pasting text def GetClipboardText(): text = "" if OpenClipboard(c_int(0)): hClipMem = GetClipboardData(c_int(CF_TEXT)) GlobalLock.restype = c_char_p text = GlobalLock(c_int(hClipMem)) GlobalUnlock(c_int(hClipMem)) CloseClipboard() return text trying to find something similair which pastes a pre-captured screenshot into MSWord. If you guys have seen this somewhere before could you point me to the sources Thanks Ryan Pinto --- * William wrote: > Hi everyone ... Ryan, > > There was a recent post on the list concerning this > ... not too long ago if you look in the archives > you'll find most of what you want I think. > > That said, my main reason to post is to ask of there > is a win32 FAQ or "recipe book" for what seems to be > common questions? If there is one, I think it would > be a good thing to put the URL in the automatic > trailer for the yahoo email. I'm meaning the part > at the end that starts with: "Python-win32 mailing > list ..." > > Thanks for your time. > > Cheers, > Will. > ----- Original Message ----- > From: ryan pinto > To: python-win32@python.org > Sent: Friday, April 22, 2005 12:15 AM > Subject: [python-win32] pasting from clip-board > > > Hi Guys, > > I am new to python WIN-32 and am trying to > automate a > word document creation. I am trying to paste > clipboard > that I capture from an application to MS Word and > I > was wondering if this can be done through python > WIN-32. I am a doing a sequence of tests which > saves > simulation results to the clip-board and need to > paste > clip-boad to MS-Word. I was wondering if anyone > has > done something similiar > > Thanks, > Ryan Pinto > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.308 / Virus Database: 266.9.18 - > Release Date: 19/Apr/2005 > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From nanotube at gmail.com Thu Apr 21 20:38:56 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Apr 21 20:39:00 2005 Subject: [python-win32] pasting from clip-board In-Reply-To: <20050421175336.74407.qmail@web52006.mail.yahoo.com> References: <20050421175336.74407.qmail@web52006.mail.yahoo.com> Message-ID: > The code below seems to work. > > def GetClipboardText(): > text = "" > if OpenClipboard(c_int(0)): > hClipMem = GetClipboardData(c_int(CF_TEXT)) > GlobalLock.restype = c_char_p > text = GlobalLock(c_int(hClipMem)) > GlobalUnlock(c_int(hClipMem)) > CloseClipboard() > return text > > Was wondering if there was something like this for a > screenshot or when a window is copied to clip-board. this link describes the standard clipboard formats: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard/clipboardformats.asp you probably want to use CF_BITMAP instead of CF_TEXT above, if you want to get an image. so just replace CF_TEXT with CF_BITMAP there, and then the text variable will be pointing to the image data. now, if you want to subsequently use that variable to do "InlineShapes.AddPicture" bit, you probably have to save that pic data to a temp file, and then do the addpicture routine with that file, as i think addpicture requires a path to a file as the argument. but a disclaimer: i have not played with any of these fancy clipboard functions myself, so i may be wrong. > How can I get the windows handles to MS-WORD? > > So far I have playing with > wordApp = Dispatch('Word.Application') > wordApp.Documents.Add() > InlineShapes.AddPicture(pic_name) > > which allows me to dump text and pictures from a sim > into word... > Looking for something that will help me dump a > screenshot into word. i do not know if there is a nice and direct way to get a hwnd from an object returned by dispatch. maybe someone else can help out here? if that nice and direct way is not available, then you would have to go through the FindWindowEx and/or EnumWindows api to get at the window handles, and it is somewhat of a pain to do. but the "winguiauto" package should take some of that pain away, if you dont care to work with the details. so basically, i guess now you have two possible pathways to accomplish a solution to your problem. :) -d From effbiae at ivorykite.com Fri Apr 22 06:55:38 2005 From: effbiae at ivorykite.com (Jack Andrews) Date: Fri Apr 22 06:55:41 2005 Subject: [python-win32] (no subject) Message-ID: <59938.202.164.198.46.1114145738.squirrel@www.ivorykite.com> hi, i can't seem to create a bitmap in memory using pywin32. my assert fails, telling me that the bitmap size is (0,0)? here's fragments: class window: def __init__ ... self.hwnd = CreateWindow(...) wnd=CreateWindowFromHandle(self.hwnd) wdc=wnd.GetDC() dc=wdc.CreateCompatibleDC(wdc) (l,t,r,b)=wnd.GetWindowRect();h,w=b-t,r-l bm=CreateBitmap() bm.CreateCompatibleBitmap(dc,w,h) assert bm.GetSize()==(w,h),bm.GetSize() oldbm=dc.SelectObject(bm) br=CreateBrush(BS_SOLID,0xffffff,0) dc.FillRect((0,0,w,h),br) pen=CreatePen(PS_SOLID,0,0xeeee00) dc.SelectObject(pen) dc.Ellipse((0,0,w-20,h-20)) bm.SaveBitmapFile(dc,"a.bmp") dc.SelectObject(oldbm) thanks in advance, jack From effbiae at ivorykite.com Fri Apr 22 07:08:03 2005 From: effbiae at ivorykite.com (Jack Andrews) Date: Fri Apr 22 07:08:11 2005 Subject: [python-win32] drawing a bitmap In-Reply-To: <59938.202.164.198.46.1114145738.squirrel@www.ivorykite.com> References: <59938.202.164.198.46.1114145738.squirrel@www.ivorykite.com> Message-ID: <59946.202.164.198.46.1114146483.squirrel@www.ivorykite.com> hi, i can't seem to create a bitmap in memory using pywin32. my assert fails, telling me that the bitmap size is (0,0)? here's fragments: class window: def __init__ ... self.hwnd = CreateWindow(...) wnd=CreateWindowFromHandle(self.hwnd) wdc=wnd.GetDC() dc=wdc.CreateCompatibleDC(wdc) (l,t,r,b)=wnd.GetWindowRect();h,w=b-t,r-l bm=CreateBitmap() bm.CreateCompatibleBitmap(dc,w,h) assert bm.GetSize()==(w,h),bm.GetSize() oldbm=dc.SelectObject(bm) br=CreateBrush(BS_SOLID,0xffffff,0) dc.FillRect((0,0,w,h),br) pen=CreatePen(PS_SOLID,0,0xeeee00) dc.SelectObject(pen) dc.Ellipse((0,0,w-20,h-20)) bm.SaveBitmapFile(dc,"a.bmp") dc.SelectObject(oldbm) also, does the code generally look right? thanks in advance, jack From mhammond at skippinet.com.au Fri Apr 22 07:50:58 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Apr 22 07:51:05 2005 Subject: [python-win32] drawing a bitmap In-Reply-To: <59946.202.164.198.46.1114146483.squirrel@www.ivorykite.com> Message-ID: <056d01c546ff$4240e080$0a00a8c0@enfoldsystems.local> > hi, i can't seem to create a bitmap in memory using pywin32. > my assert > fails, telling me that the bitmap size is (0,0)? I'm no expert on GDI programming at all. However, I have code that works that looks like: hdcBitmap = win32gui.CreateCompatibleDC(0) hdcScreen = win32gui.GetDC(0) hbm = win32gui.CreateCompatibleBitmap(hdcScreen, size_x, size_y) hbmOld = win32gui.SelectObject(hdcBitmap, hbm) # draw on hbm win32gui.SelectObject(hdcBitmap, hbmOld) win32gui.DeleteDC(hdcBitmap) win32gui.DeleteDC(hdcScreen) # hbm can now be used. That appears subtly different. The code is from win32\Demos\win32gui_menu.py - it draws some bitmaps on menus. Mark From effbiae at ivorykite.com Fri Apr 22 08:49:24 2005 From: effbiae at ivorykite.com (Jack Andrews) Date: Fri Apr 22 08:49:38 2005 Subject: [python-win32] RE: drawing a bitmap In-Reply-To: <056d01c546ff$4240e080$0a00a8c0@enfoldsystems.local> References: <59946.202.164.198.46.1114146483.squirrel@www.ivorykite.com> <056d01c546ff$4240e080$0a00a8c0@enfoldsystems.local> Message-ID: <59950.202.164.198.46.1114152564.squirrel@www.ivorykite.com> thanks mark. i've got to the bottom of the problem -- there seems to be a problem with constructing/updating PyBitmaps. or, more generally, the fuzzy boundary between win32gui and win32ui. what do you think about python-wrapping the win32 api, and building the MFC-like class system in python? a few win32gui functions are missing, which means i have to use win32ui. but i guess there's venster for that... but it appears pretty inactive. this code works: hwnd=CreateWindow(...) wnd=CreateWindowFromHandle(hwnd) dc=GetDC(hwnd) bm=CreateBitmapFromHandle(CreateCompatibleBitmap(dc,w,h)) print bm.GetSize() --> (944,734) while this (supposedly evuivalent) code: wdc=wnd.GetDC() bm=CreateBitmap() bm.CreateCompatibleBitmap(wdc,w,h) print bm.GetSize() --> (0,0) Mark Hammond said: >> hi, i can't seem to create a bitmap in memory using pywin32. >> my assert >> fails, telling me that the bitmap size is (0,0)? > > I'm no expert on GDI programming at all. However, I have code that works > that looks like: > > hdcBitmap = win32gui.CreateCompatibleDC(0) > hdcScreen = win32gui.GetDC(0) > hbm = win32gui.CreateCompatibleBitmap(hdcScreen, size_x, size_y) hbmOld = win32gui.SelectObject(hdcBitmap, hbm) > # draw on hbm > win32gui.SelectObject(hdcBitmap, hbmOld) > win32gui.DeleteDC(hdcBitmap) > win32gui.DeleteDC(hdcScreen) > # hbm can now be used. > > That appears subtly different. The code is from > win32\Demos\win32gui_menu.py - it draws some bitmaps on menus. > > Mark > From betterwang at gmail.com Fri Apr 22 11:32:01 2005 From: betterwang at gmail.com (Wang Charles) Date: Fri Apr 22 11:32:03 2005 Subject: [python-win32] hex(-1) at python 2.4 Message-ID: under phython >>> hex(-1) '-0x1' but i want a 2.3 style output like >>> hex(-1) '0xffffffff' what should i do? -- http://mail.ustc.edu.cn/~better/gmail3.png From simon.brunning at gmail.com Fri Apr 22 14:24:33 2005 From: simon.brunning at gmail.com (Simon Brunning) Date: Fri Apr 22 14:24:36 2005 Subject: [python-win32] Window system tray menu problem - text overlapping icons on XP Message-ID: <8c7f10c6050422052439b2dbfe@mail.gmail.com> I've got a bit of a problem that I'm sure one of you chaps can help me with. Basically, I've been playing with Mark's demo code in win32gui_taskbar.py and win32gui_menu.py, trying to build a general purpose system tray menu module. It's working fairly well - see http://www.brunningonline.net/simon/blog/archives/001835.html - but I'm getting problems with the menu item text overlapping the icons, and I'm not really sure how to proceed. Any pointers? -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From robin at reportlab.com Fri Apr 22 15:24:18 2005 From: robin at reportlab.com (Robin Becker) Date: Fri Apr 22 15:24:21 2005 Subject: [python-win32] dynamic Word strangeness In-Reply-To: <42678239.11075.EAF471@localhost> References: <426502FF.3834.1A0EEA5@localhost> <42678239.11075.EAF471@localhost> Message-ID: <4268FB02.7040202@chamonix.reportlab.co.uk> ...I've started getting problems with dynamic dispatch eg PythonWin 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond (mhammond@skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> import win32com.client.dynamic >>> word = win32com.client.dynamic.Dispatch("Word.Application") Traceback (most recent call last): File "", line 1, in ? File "C:\Python\Lib\site-packages\win32com\client\dynamic.py", line 98, in Dispatch IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx) File "C:\Python\Lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python\Lib\site-packages\win32com\client\dynamic.py", line 79, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147024770, 'The specified module could not be found.', None, None) >>> I'm running xp sp2 with word 2003 (I think it's version 11). The code I'm using is based entirely on the test stuff. When I run the test I see the following C:\Python\Lib\site-packages\win32com\test>testMSOffice.py Starting Word 8 for dynamic test Starting Word 7 for dynamic test Traceback (most recent call last): File "C:\Python\Lib\site-packages\win32com\test\testMSOffice.py", line 138, in TestAll TestWord() File "C:\Python\Lib\site-packages\win32com\test\testMSOffice.py", line 41, in TestWord TestWord7(word) File "C:\Python\Lib\site-packages\win32com\test\testMSOffice.py", line 49, in TestWord7 word.FileNew() TypeError: 'NoneType' object is not callable C:\Python\Lib\site-packages\win32com\test>testMSOffice.py Starting Word 8 for dynamic test Starting Word 8 for non-lazy dynamic test Starting Word 7 for dynamic test Traceback (most recent call last): File "C:\Python\Lib\site-packages\win32com\test\testMSOffice.py", line 138, in TestAll TestWord() File "C:\Python\Lib\site-packages\win32com\test\testMSOffice.py", line 41, in TestWord TestWord7(word) File "C:\Python\Lib\site-packages\win32com\test\testMSOffice.py", line 49, in TestWord7 word.FileNew() TypeError: 'NoneType' object is not callable nothing happens in the first run, but the second does open word and do the writes etc. After I have done the tesMSOffice I see that >>> word = win32com.client.dynamic.Dispatch("Word.Application") >>> works as expected. Is word non-dynamic now? As an extra nastiness my test code also works after the testMSOffice run, but seems to disable it for the next run. My test looks like def doWordDoc(wd): wd.Visible=1 doc=wd.Documents.Add() wrange=doc.Range() for i in xrange(10): wrange.InsertAfter("Hello from Python %d\n" % i) paras = doc.Paragraphs for i in xrange(len(paras)): p = paras[i]() p.Font.ColorIndex = i+1 p.Font.Size = 12 + (4 * i) del wrange, paras, p doc.Close(SaveChanges = 0) wd.Quit() del doc and is missing the win32api.sleep(1000). Any ideas? -- Robin Becker From mli at deform.com Fri Apr 22 16:00:33 2005 From: mli at deform.com (Michael Li) Date: Fri Apr 22 16:00:39 2005 Subject: [python-win32] how to browse another computer's folder tree structure ? In-Reply-To: <4268FB02.7040202@chamonix.reportlab.co.uk> References: <426502FF.3834.1A0EEA5@localhost> <42678239.11075.EAF471@localhost> <4268FB02.7040202@chamonix.reportlab.co.uk> Message-ID: <42690381.9080205@deform.com> Hi, Is there an easy way to browse folders at another computer ? Basically it's the same as C:\Python24\Lib\site-packages\win32comext\shell\demos\browse_for_folder.py just show another computer's folder tree structure, not local computer's. I am in computer A and I want to see the folders on computer B Best regards. Michael Li From jelle.feringa at ezct.net Fri Apr 22 12:26:58 2005 From: jelle.feringa at ezct.net (Jelle Feringa / EZCT Architecture & Design Research) Date: Fri Apr 22 16:16:48 2005 Subject: [python-win32] scripting Rhino via win32com Message-ID: <20050422102649.90AF01E4002@bag.python.org> Hi all, I'm trying to script Rhino -a 3d CAD nurbs modeler- via python. Which looks to be very cool, if it wasn't for some gnarly problem I'm running into: from jf.interface import RhinoScript #interface to rhino by makepy import os, sys, win32com.client Rhino = win32com.client.Dispatch("Rhino3.Application") time.sleep(1) Rhino.Visible = True RS = Rhino.GetScriptObject RS = RhinoScript.IRxRhino(RS) So far so good. Now if I use RS.AddLine((0,0,0),(10,10,10)) -which produces a line from 2 coords- all works well. Too bad that when I have to use an array of points all goes wrong: RS.Curve(points,degree) RS.AddCurve(((1,2,3),(4,5,6),(7,8,9)),3) --- Traceback (most recent call last): File "", line 1, in ? File "c:\Python23\lib\site-packages\jf\interface\RhinoScript.py", line 48, in AddCurve return self._ApplyTypes_(77, 1, (12, 0), ((12, 0), (12, 16)), 'AddCurve', None,vaPoints, vaDegree) File "c:\Python23\lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (6, 'RhinoScript_m', 'Type mismatch in parameter. One-dimensional array required.', 'C:\\Program Files\\Rhinoceros 3.0\\RhinoScript_m.HLP', 393222, 0), None) --- Even when I use it own method of getting points -via the GUI- I get the same error: RS.AddCurve(RS.GetPoints(),3) --- Traceback (most recent call last): File "", line 1, in ? File "c:\Python23\lib\site-packages\jf\interface\RhinoScript.py", line 48, in AddCurve return self._ApplyTypes_(77, 1, (12, 0), ((12, 0), (12, 16)), 'AddCurve', None,vaPoints, vaDegree) File "c:\Python23\lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (6, 'RhinoScript_m', 'Type mismatch in parameter. One-dimensional array required.', 'C:\\Program Files\\Rhinoceros 3.0\\RhinoScript_m.HLP', 393222, 0), None) --- More in detail: s = RS.GetPoints() s ((-7.0, -30.0, 0.0), (15.0, -24.0, 0.0), (-7.0, 12.0, 0.0), (14.0, 29.0, 0.0), (28.0, 10.0, 0.0), (20.0, 1.0, 0.0)) Cool, I get to choose points in the GUI, right back into python, wicked! Though when I send these points back to the app: RS.AddPolyline(s) The same error all over again: --- Traceback (most recent call last): File "", line 1, in ? File "c:\Python23\lib\site-packages\jf\interface\RhinoScript.py", line 129, in AddPolyline return self._ApplyTypes_(85, 1, (12, 0), ((12, 0),), 'AddPolyline', None,vaPoints) File "c:\Python23\lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (6, 'RhinoScript_m', 'Type mismatch in parameter. One-dimensional array required.', 'C:\\Program Files\\Rhinoceros 3.0\\RhinoScript_m.HLP', 393222, 0), None) --- RS.AddPolyline(((1,1,1),(2,2,2),(3,3,3))) Again, the same error persists. So this leaves me to believe that the problem lies in sending the array to the app... Now I have no idea to solve this... but having too much fun to give this up... any suggestions? Cheers, Jelle. From mahs at telcopartners.com Fri Apr 22 23:47:30 2005 From: mahs at telcopartners.com (Michael Spencer) Date: Sat Apr 23 00:05:21 2005 Subject: [python-win32] Re: hex(-1) at python 2.4 In-Reply-To: References: Message-ID: Wang Charles wrote: > under phython > >>>>hex(-1) > > '-0x1' > > but i want a 2.3 style output like > > >>>>hex(-1) > > '0xffffffff' > > what should i do? The following: >>> def hex(x): ... return "0x%x" % ((x < 0) * 0x100000000 + x) should return the same output on 2.3/2.4 If you are concerned about non-32 bit systems, then you could write more conservatively: >>> import sys >>> WORD = (sys.maxint+1)*2 >>> def hex(x): ... return "0x%x" % ((x < 0) * WORD + x) ... HTH Michael From Smola at farbspender.de Sat Apr 23 17:08:22 2005 From: Smola at farbspender.de (Stephan Smola) Date: Sat Apr 23 17:14:36 2005 Subject: [python-win32] Windows Namespace Extensions In-Reply-To: <047e01c545fb$f1d05f80$0a00a8c0@enfoldsystems.local> References: <047e01c545fb$f1d05f80$0a00a8c0@enfoldsystems.local> Message-ID: <426A64E6.3030404@farbspender.de> @Mark & Roger: Thanks alot for the hint. Didn't expect that a demo exists. Great. Seems easy enough for me ;-) Stephan Mark Hammond schrieb: >>Is it possible to write windows namespace extensions using Python >>including writing a new view in the explorer for the namespace using >>win32ui. If so has anyone done that already and can share some tips? >> >> > >It is and it works very nicely :) See the win32comext\shell\demos directory >for some starting points. > >Mark > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > > From jeffpeery at seametrics.com Mon Apr 25 18:23:44 2005 From: jeffpeery at seametrics.com (Jeff Peery) Date: Mon Apr 25 18:23:52 2005 Subject: [python-win32] py2exe problems Message-ID: <000001c549b3$27b25760$7600000a@seametrics.local> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: python.zip Type: application/x-zip-compressed Size: 8407 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050425/c2db6ca2/python.bin From jeffpeery at seametrics.com Mon Apr 25 18:24:47 2005 From: jeffpeery at seametrics.com (Jeff Peery) Date: Mon Apr 25 18:24:53 2005 Subject: [python-win32] py2exe problems Message-ID: <000601c549b3$4cd1aaf0$7600000a@seametrics.local> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: wxFrame1.zip Type: application/x-zip-compressed Size: 7189 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050425/7a995c03/wxFrame1-0001.bin From emlynj at gmail.com Mon Apr 25 19:47:12 2005 From: emlynj at gmail.com (Emlyn Jones) Date: Mon Apr 25 19:47:14 2005 Subject: [python-win32] Sending a binary file from ASP Message-ID: Hello, I am trying to get an ASP script to download a file. The file arrives at the correct size but is corrupted, what am I missing? If I run the get_file function directly at the command prompt and save the resulting data it is fine, so there must be something wrong with the way I send the data from the browser? If have this code in the asp page: <% ... filename,data = get_file(file_path) Response.AddHeader("content-disposition","attachment; filename=%s" % (filename,)) Response.ContentType="application/zip" Response.BinaryWrite(buffer(data)) %> the get_file function just does this: def get_file(path): file = open(path,"rb") data = file.read() file.close() return os.path.split(path)[1],data Any pointers will be greatfully recieved. Thanks, Emlyn. From leske at online.de Mon Apr 25 19:56:34 2005 From: leske at online.de (Christophe Leske) Date: Mon Apr 25 19:56:11 2005 Subject: [python-win32] HTML-Textlinks In-Reply-To: Message-ID: <000801c549c0$258af7a0$63b2a8c0@kiste> Hi there, I am starting to play around with wxPython and would like to implement something like a clickable Html-Text link. I understand that there is wxHtmlWindow, but this seems like overkill to me. I just want to render a static text which has a link linked to it. Also, there is a class called "Ticker" in http://www.wxpython.org/docs/api/wx.lib.ticker-module.html I got wxPython installed on my machine here (i am on Windows...), but it does not seem to be part of the package, or am i missing something? When i do from wxPython.wx.lib import * I get "ImportError: No module named lib". What gives? Thanks for any help you might bring to this, Christophe Leske tel. +49-(0)211 230 99 70 .:. f?rstenwall 157 .:. ::: 40215 d?sseldorf ::: ::: germany ::: http://www.multimedial.de From leske at online.de Mon Apr 25 22:42:34 2005 From: leske at online.de (Christophe Leske) Date: Mon Apr 25 22:41:23 2005 Subject: [python-win32] wxStaticTxt In-Reply-To: <000801c549c0$258af7a0$63b2a8c0@kiste> Message-ID: <001401c549d7$529e0090$63b2a8c0@kiste> Is there a way to get a wxStaticText to scroll out of the wxFrame to the left? I can't seem to let it scroll "out of the window" to the left... Any ideas? Thank you, Christophe Leske tel. +49-(0)211 230 99 70 .:. f?rstenwall 157 .:. ::: 40215 d?sseldorf ::: ::: germany ::: http://www.multimedial.de From shendley at email.unc.edu Tue Apr 26 07:20:30 2005 From: shendley at email.unc.edu (Sam Hendley) Date: Tue Apr 26 07:21:20 2005 Subject: [python-win32] py2exe, COM servers on machine without py2exe Message-ID: <426DCF9E.4070205@email.unc.edu> I hope I am posting on the correct list but in my trolling (as in google, not the bad kind) of the web I found some posts from both Mark Hammond and Thomas Heller, who I gathered wrote py2exe. Here is the situation: We wrote a PowerPoint plugin in python. It uses a number of com classes for recieving events but there is apparently only one comserver and that creates PowerPointUI.dll. It also creates 13 .pyd files, python23.dll, pythoncom23.dll, pywintypes23.dll. On the machine we run the original setup the dll registers fine and the plugin works great running from the dll. On a machine without py2exe (either with Python installed or without) I get the following error: Command Line: regsvr32 PowerPointUI.dll Returned: DllRegisterServer in PowerPointUI.dll failed. Return code was: 0x80040201 I did a bunch of searching on the web and ran into a post that suggested using regmon to see what registry entries regsvr32 is accessing. I found that regsvr32 had all attempts to access missing keys. (listed at the bottom; sorry for the length, i am not sure what will be important). We do the traceutils stuff and it has allways worked but I dont see anything at all when I try to register the dll. I am hoping that we are just miss configuring something beacuse we really didnt want to have to force our users to have python, py2exe, win32all installed to run the powerpoint plugin. Here is the setup file we use: ########################################################################### #### PY2EXE INSTALLER SCRIPT #### Collects all necessary python infrastructure needed to run our #### program and compiles our program as well as necessary python #### infrastructure components into a DLL and compiled python classes ########################################################################### from distutils.core import setup import py2exe ## Py2exe target package information class Target: def __init__(self, **kw): self.__dict__.update(kw) ## Information for the version and info resources self.version = "1.2" self.company_name = "UNC Remote PowerPoint Team" self.name = "RemotePowerPoint" ######################################################################### ## Create PowerPoint Addin COM server DLL, server module is required arg ######################################################################### powerpoint = Target( description = "Python Remote PowerPoint Server", ## Build source file. For COM servers, the module name (not the ## filename) must be specified! modules = ["PowerPointUI"], create_exe = False, ) ######################################################################### ## This is a list of modules to include in our DLL (includes) ######################################################################### includes = ["encodings", "encodings.*"] ########################################################################################### ## Build function. (Creates the DLL) ## Options: typelibs specifies the external libraries needed for program gotten from Python ## gen_py directory when necessary. ## Zipfile: Determines whether compiled code and external libraries are placed ## in a zipfile or in the DLL itself, specify zipfile name or None. ## Com_server: specify name of source functions for COM servers listed above for building. ## Console: specify name of source functions for scripts listed above for building. ########################################################################################### setup( options = {"py2exe": {"packages": ["encodings"], "typelibs": ## typelib for PowerPoint, Microsoft Office, and Microsoft Addin [('{91493440-5A91-11CF-8700-00AA0060263B}', 0, 2, 8), ('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 3), ('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0,)], "includes": includes, }}, zipfile=None, com_server = [powerpoint], ) ############################################################################################# If anyone has any hints or questions let me know, I wrote this email at 1am after me and my group spent ~30 of the last 65 hours working on getting the Addin running. Thanks, Sam -----------------------------Registry Entries-------- 105.42526245 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\python23.dll NOT FOUND 105.42537689 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\PowerPointUI.dll NOT FOUND 105.42812347 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\PythonPath SUCCESS Access: 0x20019 105.42816925 regsvr32.exe:544 QueryKey HKLM\Software\Python\PythonCore\2.3\PythonPath SUCCESS Subkeys = 0 105.42823792 regsvr32.exe:544 CloseKey HKLM\Software\Python\PythonCore\2.3\PythonPath SUCCESS 105.42832184 regsvr32.exe:544 OpenKey HKCU SUCCESS Access: 0x2000000 105.42836761 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\PythonPath NOT FOUND 105.42970276 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\warnings NOT FOUND 105.42974854 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\warnings NOT FOUND 105.44274902 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\types NOT FOUND 105.44279480 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\types NOT FOUND 105.44439697 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\linecache NOT FOUND 105.44444275 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\linecache NOT FOUND 105.44573975 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\os NOT FOUND 105.44578552 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\os NOT FOUND 105.44841003 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\ntpath NOT FOUND 105.44846344 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\ntpath NOT FOUND 105.45022583 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\stat NOT FOUND 105.45028687 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\stat NOT FOUND 105.45209503 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\UserDict NOT FOUND 105.45214081 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\UserDict NOT FOUND 105.45619202 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\copy_reg NOT FOUND 105.45624542 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\copy_reg NOT FOUND 105.45875549 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\win32api NOT FOUND 105.45880127 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\win32api NOT FOUND 105.46139526 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\pywintypes23.dll NOT FOUND 105.46148682 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\win32api.pyd NOT FOUND 105.46235657 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\secur32.dll NOT FOUND 105.46266174 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\pythoncom NOT FOUND 105.46270752 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\pythoncom NOT FOUND 105.46308899 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\pywintypes NOT FOUND 105.46313477 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\pywintypes NOT FOUND 105.46788025 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\pythoncom23.dll NOT FOUND 105.46907806 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\win32com NOT FOUND 105.46913147 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\win32com NOT FOUND 105.47978210 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\winerror NOT FOUND 105.47983551 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\winerror NOT FOUND 105.48683167 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\string NOT FOUND 105.48687744 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\string NOT FOUND 105.50009155 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\win32con NOT FOUND 105.50014496 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\win32con NOT FOUND 105.52662659 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\traceback NOT FOUND 105.52857208 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\traceback NOT FOUND 105.54042816 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\win32trace NOT FOUND 105.54047394 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\win32trace NOT FOUND 105.54355621 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\win32trace.pyd NOT FOUND 105.54669952 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\PowerPointUI NOT FOUND 105.54882813 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\PowerPointUI NOT FOUND 105.57278442 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\new NOT FOUND 105.57474518 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\new NOT FOUND 105.59278107 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\keyword NOT FOUND 105.59474182 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\keyword NOT FOUND 105.61274719 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\glob NOT FOUND 105.61279297 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\glob NOT FOUND 105.61373138 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\fnmatch NOT FOUND 105.61582947 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\fnmatch NOT FOUND 105.61833954 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\re NOT FOUND 105.61838531 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\re NOT FOUND 105.61870575 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\sre NOT FOUND 105.62093353 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\sre NOT FOUND 105.62374115 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\sre_compile NOT FOUND 105.62377930 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\sre_compile NOT FOUND 105.62651062 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\_sre NOT FOUND 105.62852478 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\_sre NOT FOUND 105.62955475 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\_sre.pyd NOT FOUND 105.63195801 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\sre_constants NOT FOUND 105.63223267 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\sre_constants NOT FOUND 105.63526917 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\sre_parse NOT FOUND 105.63531494 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\sre_parse NOT FOUND 105.65231323 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\socket NOT FOUND 105.65461731 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\socket NOT FOUND 105.65761566 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\_socket NOT FOUND 105.65766144 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\_socket NOT FOUND 105.66287994 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\WS2HELP.dll NOT FOUND 105.66292572 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\WS2_32.dll NOT FOUND 105.66300201 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\WSOCK32.dll NOT FOUND 105.66305542 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\_socket.pyd NOT FOUND 105.73336792 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\_ssl NOT FOUND 105.73340607 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\_ssl NOT FOUND 105.73645020 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\_ssl.pyd NOT FOUND 105.74414825 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\win32clipboard NOT FOUND 105.74418640 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\win32clipboard NOT FOUND 105.74540710 regsvr32.exe:544 OpenKey HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\win32clipboard.pyd NOT FOUND 105.74559784 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\handler NOT FOUND 105.74562836 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\handler NOT FOUND 105.74611664 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\pickle NOT FOUND 105.74614716 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\pickle NOT FOUND 105.74835205 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\org NOT FOUND 105.74839020 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\org NOT FOUND 105.75250244 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\StringIO NOT FOUND 105.75253296 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\StringIO NOT FOUND 105.75356293 regsvr32.exe:544 OpenKey HKCU\Software\Python\PythonCore\2.3\Modules\win32traceutil NOT FOUND 105.75360107 regsvr32.exe:544 OpenKey HKLM\Software\Python\PythonCore\2.3\Modules\win32traceutil NOT FOUND From mhammond at skippinet.com.au Tue Apr 26 08:35:37 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 26 08:35:53 2005 Subject: [python-win32] py2exe, COM servers on machine without py2exe In-Reply-To: <426DCF9E.4070205@email.unc.edu> Message-ID: <09f401c54a2a$29065590$0a00a8c0@enfoldsystems.local> > powerpoint = Target( > description = "Python Remote PowerPoint Server", > ## Build source file. For COM servers, the module name (not the > ## filename) must be specified! > modules = ["PowerPointUI"], > create_exe = False, > ) Try adding dest_base="ppui" to those params. That should create a "ppui.dll". I'm guessing that maybe the py2exe created PowerPointUI.dll is satisfying an "import PowerPointUI" done by Python, but failing. Also, have a look at py2exe/boot_com_servers.py - by enabling the "if 0:" block, you should be able to see the error written to c:\comerror.txt. Mark From mhammond at skippinet.com.au Tue Apr 26 09:35:42 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 26 09:35:47 2005 Subject: [python-win32] how to browse another computer's folder treestructure ? In-Reply-To: <42690381.9080205@deform.com> Message-ID: <0a0101c54a32$8d69d270$0a00a8c0@enfoldsystems.local> > Hi, > Is there an easy way to browse folders at another computer ? > Basically it's the same as > C:\Python24\Lib\site-packages\win32comext\shell\demos\browse_f > or_folder.py > just show another computer's folder tree structure, not local > computer's. > > I am in computer A and I want to see the folders on computer B Just specify r"\\machine-name-or-ip-address" inplace of os.getcwd() in that sample. Mark From mhammond at skippinet.com.au Tue Apr 26 09:37:11 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 26 09:37:16 2005 Subject: [python-win32] dynamic Word strangeness In-Reply-To: <4268FB02.7040202@chamonix.reportlab.co.uk> Message-ID: <0a0201c54a32$c2d0c810$0a00a8c0@enfoldsystems.local> > ...I've started getting problems with dynamic dispatch G'day Robin, Is there a phantom Word process still hanging around? Does the error persist after a reboot. Do you have access to another machine which can run the tests? Mark From niki at vintech.bg Tue Apr 26 09:41:56 2005 From: niki at vintech.bg (Niki Spahiev) Date: Tue Apr 26 09:42:04 2005 Subject: [python-win32] wxStaticTxt In-Reply-To: <001401c549d7$529e0090$63b2a8c0@kiste> References: <001401c549d7$529e0090$63b2a8c0@kiste> Message-ID: <426DF0C4.5090904@vintech.bg> It's better to use wxPython list questions about wxPython. Niki Spahiev From emlynj at gmail.com Tue Apr 26 10:47:16 2005 From: emlynj at gmail.com (Emlyn Jones) Date: Tue Apr 26 10:47:20 2005 Subject: [python-win32] Binary data in ASP Message-ID: Hello, I am trying to get an ASP script to download a file. The file arrives at the correct size but is corrupted, what am I missing? If I run the get_file function directly at the command prompt and save the resulting data it is fine, so there must be something wrong with the way I send the data from the browser? If have this code in the asp page: <% ... filename,data = get_file(file_path) Response.AddHeader("content-disposition","attachment; filename=%s" % (filename,)) Response.ContentType="application/zip" Response.BinaryWrite(buffer(data)) %> the get_file function just does this: def get_file(path): file = open(path,"rb") data = file.read() file.close() return os.path.split(path)[1],data Any pointers will be greatfully recieved. Thanks, Emlyn. From mhammond at skippinet.com.au Tue Apr 26 13:00:55 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 26 13:01:02 2005 Subject: [python-win32] Binary data in ASP In-Reply-To: Message-ID: <0a1901c54a4f$38c67850$0a00a8c0@enfoldsystems.local> > Hello, > I am trying to get an ASP script to download a file. The file > arrives at the > correct size but is corrupted, what am I missing? > If I run the get_file function directly at the command prompt > and save the > resulting data it is fine, so there must be something wrong > with the way I send > the data from the browser? I can't recall hearing of anything similar. It would be great to know in what way the data is corrupted - you should be able to test that by hard-coding a string in your ASP page, and comparing this string with the data actually received by the client. Good characters to have in this literal test data include \0, \n and \r. Mark From 7qrj45 at clayelectric.com Wed Apr 27 14:38:02 2005 From: 7qrj45 at clayelectric.com (Ronnie Jones) Date: Wed Apr 27 14:34:26 2005 Subject: [python-win32] XP sp2 permissions Message-ID: <5555C0CF56DDD24BBF143A7454A266CA10CC75@khw3sent01.clayelectric.com> I just recently installed ActivePython 2.4.2 build 245 on XP sp2 and none of the programs that is use for automating COM objects seem to work. The script is running on the local machine trying to operate local COM objects. Sample script: import win32com.client import win32api def _BusyWait(self): win32api.Sleep(100) while self.Busy: win32api.Sleep(100) print 'Busy:', win32api.Sleep(100) print '\n' print 'Finished Script' path = 'http://www.foxnews.com' endline = '\r\n' shell = win32com.client.Dispatch('WScript.Shell') shell.Run('IEXPLORE') win32api.Sleep(5000) ie = win32com.client.GetActiveObject('InternetExplorer.Application') print ie.LocationURL shell.AppActivate('ClayNet') win32api.Sleep(1000) shell.SendKeys('\t') win32api.Sleep(100) shell.SendKeys(path) win32api.Sleep(100) shell.SendKeys(endline) _BusyWait(ie) The error I get is: At the GetActiveObject line I get "Operation Unavailable" The Shell part and the win32api sleep function seem to work normally. I get this same behavior from the wmi interface COM objects. Question: What permissions need to be set to these types of objects as well as Word, Outlook, Excel, Power Point etc.? Ronnie Jones -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050427/9e4c0c6c/attachment.html From eric.ries at aya.yale.edu Wed Apr 27 19:49:48 2005 From: eric.ries at aya.yale.edu (Eric Ries) Date: Wed Apr 27 20:05:23 2005 Subject: [python-win32] win32 python module memory usage Message-ID: I have been receiving complaints from some of my users that my win32 python app takes a lot of memory - before the program even starts doing anything. By adding "pause" statements before loading modules, I've been able to determine a little bit of what's going on. I'm curious where all this memory is going and what I can do (if anything) to reduce it. When my app starts up, before loading any modules, the memory footprint is 4MB. After all the standard python modules (including win32con, win32api, etc) are loaded, the footprint is 9MB. By the time all my custom modules are loaded and my app is showing a win32 "login" dialog - my app weighs in at a whopping 32MB. That seems pretty high. Any suggestions for ways to diagnose the usage and/or slim it down? Thanks in advance, Eric From rwupole at msn.com Wed Apr 27 21:20:02 2005 From: rwupole at msn.com (Roger Upole) Date: Wed Apr 27 21:20:31 2005 Subject: [python-win32] Sending a binary file from ASP Message-ID: You might want to try base64 encoding the zip file, since it's binary data. Roger From mli at deform.com Thu Apr 28 21:43:25 2005 From: mli at deform.com (Michael Li) Date: Fri Apr 29 02:32:38 2005 Subject: [python-win32] how to browse another computer's folder treestructure ? In-Reply-To: <0a0101c54a32$8d69d270$0a00a8c0@enfoldsystems.local> References: <0a0101c54a32$8d69d270$0a00a8c0@enfoldsystems.local> Message-ID: <42713CDD.5050700@deform.com> Hi, Mark Thank you very much. It works, but only shows shared folders, not all the folders, is it possible to show all folders ? Mark Hammond wrote: >>Hi, >>Is there an easy way to browse folders at another computer ? >>Basically it's the same as >>C:\Python24\Lib\site-packages\win32comext\shell\demos\browse_f >>or_folder.py >>just show another computer's folder tree structure, not local >>computer's. >> >> I am in computer A and I want to see the folders on computer B > > > Just specify r"\\machine-name-or-ip-address" inplace of os.getcwd() in that > sample. > > Mark > From jimmcloughlin at earthlink.net Thu Apr 28 21:11:48 2005 From: jimmcloughlin at earthlink.net (Jim McLoughlin) Date: Fri Apr 29 02:32:47 2005 Subject: [python-win32] cleaning up after DDE client requests Message-ID: <8b530975329e64792e51fd4f15bd9666@earthlink.net> Hi I have successfully used the DDE apis as a client to some DDE data services (normally accessed by excel). These services have a limit on the number of simultaneous DDE requests I can make (~300 at one time) - but this should not be a problem, as I make all of these requests sequentially. For a small number of requests, things are fine. However, a sequence of 1000 requests seems to run into problems. So my question is: is there some clean up code that can be used for conversations, servers, etc? Can I do something like conversation.terminate() or server.destroy() to make sure I am cleaning things up properly? An unrelated question: If I am only acting as a DDE client, why do I need to instantiate a server - is it behaving as a proxy to the (non-python) DDE server process that already exists on my machine? Thanks for any help. JM E.g. code I am using: import win32ui import dde function getDataViaDDE(myRequests) server = dde.CreateServer() server.Create('MyDataProxy') conversation = dde.CreateConversation(server) conversation.ConnectTo("DDEServiceName", "DataTopic") myResults = {} for request in myRequests myResults[request] = conversation.Request(request) return myResults -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 1301 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050428/4160c2b5/attachment.bin From rwupole at msn.com Fri Apr 29 05:14:55 2005 From: rwupole at msn.com (Roger Upole) Date: Fri Apr 29 05:15:01 2005 Subject: [python-win32] Re: XP sp2 permissions Message-ID: For the GetActiveObject to work, the application has to register itself with the Running Object Table. Looks like IE has stopped registering in the ROT at some point. According to this: http://support.microsoft.com/default.aspx?scid=kb;en-us;176792 looping thru ShellWindows is the 'official' way to get an existing IE instance. Roger From steve at holdenweb.com Fri Apr 29 17:22:07 2005 From: steve at holdenweb.com (Steve Holden) Date: Fri Apr 29 17:22:05 2005 Subject: [python-win32] how to browse another computer's folder treestructure ? In-Reply-To: <42713CDD.5050700@deform.com> References: <0a0101c54a32$8d69d270$0a00a8c0@enfoldsystems.local> <42713CDD.5050700@deform.com> Message-ID: <4272511F.6000906@holdenweb.com> Michael Li wrote: > Hi, Mark > > Thank you very much. > It works, but only shows shared folders, not all the folders, > is it possible to show all folders ? > [...] Assuming you don't have permission to access administrative shares, what legitimate use case could there be for accessing non-shared materials on other computers? regards Steve -- Steve Holden +1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ From rays at blue-cove.com Fri Apr 29 19:10:49 2005 From: rays at blue-cove.com (Ray S) Date: Fri Apr 29 19:07:10 2005 Subject: [python-win32] cleaning up after DDE client requests In-Reply-To: <8b530975329e64792e51fd4f15bd9666@earthlink.net> Message-ID: <5.2.0.4.2.20050429095341.06b9f080@blue-cove.com> At 12:11 PM 4/28/2005, Jim McLoughlin wrote: >For a small number of requests, things are fine. However, a sequence of 1000 requests seems to run into problems. So my question is: is there some clean up code that can be used for conversations, servers, etc? Can I do something like conversation.terminate() or server.destroy() to make sure I am cleaning things up properly? (pardon if this is a dupe; I don't think the last went out...) I also have just seen a WIndows error, in dde.pyd. It occurs with sequential requests after ~480+ seconds - ~1500+ DDE requests. All use one server and connection. ?? Ray Schumacher From rogelio.flores at gmail.com Fri Apr 29 19:27:33 2005 From: rogelio.flores at gmail.com (Rogelio Flores) Date: Fri Apr 29 19:27:37 2005 Subject: [python-win32] Allowing service to interact with desktop In-Reply-To: <012401c4dd88$e2ff00f0$0f0a0a0a@enfoldsystems.local> References: <012401c4dd88$e2ff00f0$0f0a0a0a@enfoldsystems.local> Message-ID: On 12/8/04, Mark Hammond wrote: > > Is there a way to set my python windows service to run witht the > > option "Allowing service to interact with desktop" turned on at > > installation time? I know how to enable it from the windows Services > > UI, but I'm hoping there is an option similar to "--startup auto" (to > > set the service to start automatically when the machine starts) so > > that I can do it from the command-line. > > How did you find out about "--startup"? Running "your_service.py" with no > args prints: > > Options for 'install' and 'update' commands only: > --username domain\username : The Username the service is to run under > --password password : The password for the username > --startup [manual|auto|disabled] : How the service starts, default = manual > --interactive : Allow the service to interact with the desktop. > ... > > I think the last one shown is what you are after. > > Be sure to look for the MSDN documentation on this flag - it may not do > exactly what you want ("interact with the desktop" is slightly > misleading...) > > Mark. > Actually, running python 2.0 and win32all-144.exe I don't see that: C:\>python my_service.py --interactive option --interactive not recognized Usage: 'my_service.py [options] install|update|remove|start [...]|stop|restar t [...]|debug [...]' Options for 'install' and 'update' commands only: --username domain\username : The Username the service is to run under --password password : The password for the username --startup [manual|auto|disabled] : How the service starts, default = manual I guess build 144 doesn't support that option (otherwise please let me know), but thanks anyway. At least I know that upgrading will work. -- Rogelio From timr at probo.com Fri Apr 29 19:39:29 2005 From: timr at probo.com (Tim Roberts) Date: Fri Apr 29 19:39:33 2005 Subject: [python-win32] how to browse another computer's folder treestructure ? In-Reply-To: <20050429100044.D53B51E4016@bag.python.org> References: <20050429100044.D53B51E4016@bag.python.org> Message-ID: <42727151.9000408@probo.com> On Thu, 28 Apr 2005 15:43:25 -0400, Michael Li wrote: >Hi, Mark > >Thank you very much. >It works, but only shows shared folders, not all the folders, >is it possible to show all folders ? > > Of course not. Windows security wouldn't be worth very much if it could. -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From news at markus-hillebrand.de Fri Apr 29 20:03:46 2005 From: news at markus-hillebrand.de (Markus Hillebrand) Date: Fri Apr 29 20:04:08 2005 Subject: [python-win32] Infos on the python win32 build process Message-ID: <42727702.8010801@markus-hillebrand.de> Hello out there! For a new release of the Python centered application-framework FreeGee (http://freegee.sf.net) I'm looking for informations (or scripts) upon the Python Win32 build process. My goal is to automize the build process including other open source packages (omniORB, postgresql, gnupg, wxPython ... ) to provide a consistent application framework that can be installed with a single installation step. With best regards Markus Hillebrand P.S.: and please don't wonder about the Win32 release of FreeGee on source-forge. For our projects we currently using a much newer internal release. At the moment we reorganize the build process for Win32 so that we can provide a clean and reliable public release ... From Kelly at JackpineGroup.com Fri Apr 29 23:18:25 2005 From: Kelly at JackpineGroup.com (Kelly Kranabetter) Date: Fri Apr 29 23:18:30 2005 Subject: [python-win32] win32print.SetPrinter Message-ID: <814E6AC484A2B548A08D8D5C055344CA42E9@jackpine03.ad.jackpinegroup.com> I'm trying to set the port of a printer (on Windows 98) but it fails if the devmode of the printer is NULL. Here is some sample code: h= win32print.OpenPrinter("Printername") settings= win32print.GetPrinter(h, 2) settings["pPortName"]= r"\\newserver\printer" win32print.SetPrinter(h, 2, settings, 0) # setprinter fails because devmode is None # exception thrown is ValueError - PyDEVMODE cannot be None in this context I've confirmed with a little C program that the DevMode is definitely NULL for the printer. How can I get around this? Kelly From rwupole at msn.com Fri Apr 29 23:53:30 2005 From: rwupole at msn.com (Roger Upole) Date: Fri Apr 29 23:53:36 2005 Subject: [python-win32] Re: Infos on the python win32 build process Message-ID: You can use setup.py in the source distribution to do an automated build. For example, I use python.exe setup.py build --debug install to install a debug build of the extensions. Roger From rwupole at msn.com Sat Apr 30 00:21:25 2005 From: rwupole at msn.com (Roger Upole) Date: Sat Apr 30 00:21:32 2005 Subject: [python-win32] Re: win32print.SetPrinter Message-ID: Strange, the DEVMODE for a printer shouldn't be null if the driver is installed correctly. Although I guess it's possible this doesn't apply on Win98. You might be able to retrieve a DEVMODE to pass back in using DocumentProperties. Alternately, you can create a new one using pywintypes.DEVMODEType() and set the appropriate values. hth Roger From mhammond at skippinet.com.au Sat Apr 30 03:09:19 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat Apr 30 03:09:25 2005 Subject: [python-win32] Allowing service to interact with desktop In-Reply-To: Message-ID: <028401c54d21$3d2f80b0$0a0a0a0a@enfoldsystems.local> > Actually, running python 2.0 and win32all-144.exe I don't see that: win32all-144 is *very* old. You are after the pywin32 builds - 204 is the latest. A service with that version of pywin32 supports: Usage: 'pipeTestService.py [options] install|update|remove|start [...]|stop|restart [...]|debug [...]' Options for 'install' and 'update' commands only: --username domain\username : The Username the service is to run under --password password : The password for the username --startup [manual|auto|disabled] : How the service starts, default = manual --interactive : Allow the service to interact with the desktop. --perfmonini file: .ini file to use for registering performance monitor data --perfmondll file: .dll file to use when querying the service for performance data, default = perfmondata.dll Options for 'start' and 'stop' commands only: --wait seconds: Wait for the service to actually start or stop. If you specify --wait with the 'stop' option, the service and all dependent services will be stopped, each waiting the specified period. Mark From cattom2000 at gmail.com Sat Apr 30 03:22:02 2005 From: cattom2000 at gmail.com (cattom) Date: Sat Apr 30 07:56:00 2005 Subject: [python-win32] How to use win32api.UpdateResource Message-ID: I wanted to update some resource in an exe file, then I wrote some procedure like this: def updateStringTable... .... try: def win32_uc(text): return unicode(text, "unicode-escape").encode("utf-16-le") ruUpdateContent = win32_uc(updateContent) fmt = "h%ds" % len(ruUpdateContent) updateSection = struct.pack(fmt, len(ruUpdateContent)/2, ruUpdateContent) + \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" updateRes = win32api.BeginUpdateResource(self.file, False) win32api.UpdateResource(updateRes, win32con.RT_STRING, 1, updateSection, wLanguage) win32api.EndUpdateResource(updateRes, False) return True except win32api.error: return False .... When I ran it, this function named "updateStringTable" returned True. It seems that everything was ok, but the StringTable was unchangeable when I saw it again. But I wrote same manner procedure by VC6.0 like this: ... HANDLE hUpdateRes = BeginUpdateResource( _T("UpdateResource.exe"), FALSE ); BYTE pRes[] = { 0x4, 0x0, 'H', 0x0, 'a', 0x0, 'h', 0x0, 'a', 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; UpdateResource( hUpdateRes, RT_STRING, MAKEINTRESOURCE(1), 2052, pRes, sizeof(pRes) ); EndUpdateResource( hUpdateRes, FALSE ); ... It worked fine. What's wrong with my python procedure? Thanks for your reply. Btw: Python version:2.4.1, Pywin32 Version:Build204 for 2.4 From news at markus-hillebrand.de Sat Apr 30 14:11:13 2005 From: news at markus-hillebrand.de (Markus Hillebrand) Date: Sat Apr 30 14:11:19 2005 Subject: [python-win32] Re: Infos on the python win32 build process In-Reply-To: References: Message-ID: <427375E1.3050103@markus-hillebrand.de> Thanks for your answer, but therefore I still need a Visual C++ 6.0 Compiler right? I only have a V7.0 and don't want the FreeGee-Developers to be dependend on a proprietary compiler ... I have read about that the current Python-Windows Distribution has been done with a certain script, but I don't find the website anymore ;-( I'm thinking about compiling all that stuff with a free compiler for Win32 like MingW or maybe, if it works, with the Open-Watcom Compiler ... So I'm still looking for informations and scripts about the Win32 build process for Python - and not (only) the extensions ;-) With best regards Markus Roger Upole wrote: > You can use setup.py in the source distribution to do an > automated build. For example, I use > python.exe setup.py build --debug install > to install a debug build of the extensions. > > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 >