ctypes-users Mailing List for ctypes (Page 6)
Brought to you by:
theller
You can subscribe to this list here.
2003 |
Jan
(3) |
Feb
(97) |
Mar
(38) |
Apr
(50) |
May
(68) |
Jun
(67) |
Jul
(184) |
Aug
(58) |
Sep
(30) |
Oct
(40) |
Nov
(41) |
Dec
(53) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(81) |
Feb
(48) |
Mar
(35) |
Apr
(85) |
May
(47) |
Jun
(56) |
Jul
(60) |
Aug
(103) |
Sep
(46) |
Oct
(39) |
Nov
(19) |
Dec
(50) |
2005 |
Jan
(36) |
Feb
(65) |
Mar
(119) |
Apr
(132) |
May
(93) |
Jun
(71) |
Jul
(42) |
Aug
(69) |
Sep
(41) |
Oct
(61) |
Nov
(31) |
Dec
(42) |
2006 |
Jan
(59) |
Feb
(112) |
Mar
(60) |
Apr
(64) |
May
(116) |
Jun
(128) |
Jul
(68) |
Aug
(92) |
Sep
(58) |
Oct
(91) |
Nov
(73) |
Dec
(52) |
2007 |
Jan
(37) |
Feb
(59) |
Mar
(26) |
Apr
(30) |
May
(37) |
Jun
(25) |
Jul
(20) |
Aug
(54) |
Sep
(68) |
Oct
(16) |
Nov
(34) |
Dec
(34) |
2008 |
Jan
(72) |
Feb
(40) |
Mar
(25) |
Apr
(54) |
May
(61) |
Jun
(22) |
Jul
(41) |
Aug
(26) |
Sep
(26) |
Oct
(66) |
Nov
(42) |
Dec
(58) |
2009 |
Jan
(100) |
Feb
(48) |
Mar
(20) |
Apr
(13) |
May
(10) |
Jun
(33) |
Jul
(9) |
Aug
|
Sep
(17) |
Oct
(9) |
Nov
(4) |
Dec
(64) |
2010 |
Jan
(18) |
Feb
(8) |
Mar
(37) |
Apr
(14) |
May
(9) |
Jun
(21) |
Jul
(1) |
Aug
(18) |
Sep
(12) |
Oct
(8) |
Nov
(4) |
Dec
(4) |
2011 |
Jan
(31) |
Feb
(3) |
Mar
(6) |
Apr
(1) |
May
(10) |
Jun
(9) |
Jul
(16) |
Aug
(5) |
Sep
(1) |
Oct
(5) |
Nov
(1) |
Dec
(11) |
2012 |
Jan
(4) |
Feb
(8) |
Mar
(14) |
Apr
(1) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(10) |
Sep
(5) |
Oct
|
Nov
(4) |
Dec
(2) |
2013 |
Jan
(2) |
Feb
|
Mar
(1) |
Apr
|
May
(4) |
Jun
|
Jul
(3) |
Aug
(5) |
Sep
(12) |
Oct
|
Nov
|
Dec
(3) |
2014 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
(5) |
Oct
|
Nov
|
Dec
(2) |
2015 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(7) |
Nov
|
Dec
(2) |
2016 |
Jan
(3) |
Feb
(6) |
Mar
(3) |
Apr
|
May
|
Jun
(9) |
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
(28) |
Dec
(31) |
2017 |
Jan
|
Feb
|
Mar
|
Apr
(10) |
May
(28) |
Jun
(2) |
Jul
(3) |
Aug
(2) |
Sep
(4) |
Oct
(31) |
Nov
(2) |
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael C <mys...@gm...> - 2016-11-29 03:16:03
|
i understand. On Mon, Nov 28, 2016 at 7:14 PM, eryk sun <er...@gm...> wrote: > On Tue, Nov 29, 2016 at 2:53 AM, Michael C > <mys...@gm...> wrote: > > I get what you are saying, but not the how-to part. It's ok for me for > now > > because I just started last week. :) > > Please reply to the original message, without changing the subject > line. Also, please quote the message to which you're replying. > Otherwise there's no threading and no context. This isn't a chat room. > > Gmail probably won't reply to the list unless you select "Reply to > all" from the drop-down menu. > |
From: eryk s. <er...@gm...> - 2016-11-29 03:15:03
|
On Tue, Nov 29, 2016 at 2:53 AM, Michael C <mys...@gm...> wrote: > I get what you are saying, but not the how-to part. It's ok for me for now > because I just started last week. :) Please reply to the original message, without changing the subject line. Also, please quote the message to which you're replying. Otherwise there's no threading and no context. This isn't a chat room. Gmail probably won't reply to the list unless you select "Reply to all" from the drop-down menu. |
From: Michael C <mys...@gm...> - 2016-11-29 03:08:09
|
Hi all: I am trying to create a combined sendinput function with holding down right mouse button, moving the mouse, and releasing the mouse button inside ONE sendinput functon. Here is my current code: import ctypes INPUT mouseinput input.type = INPUT_MOUSE input.mi.dx = 0 input.mi.dy = 0 input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN input.mi.time = 10 input.mi.time = 0 #Sleep(50); input.type = INPUT_MOUSE input.mi.dx = 100 input.mi.dy = 0 input.mi.dwFlags = MOUSEEVENTF_MOVE input.mi.time = 10 #Sleep(50); input.type = INPUT_MOUSE input.mi.dx = 0 input.mi.dy = 0 input.mi.dwFlags = MOUSEEVENTF_RIGHTUP input.mi.time = 0 SendInput(3, &input, sizeof(input)); This part by itself pops a syntax error: import ctypes INPUT mouseinput How do I create an array of this type? https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspxhttps://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx thx all! |
From: Michael C <mys...@gm...> - 2016-11-29 02:53:29
|
I get what you are saying, but not the how-to part. It's ok for me for now because I just started last week. :) |
From: eryk s. <er...@gm...> - 2016-11-29 02:45:47
|
On Mon, Nov 28, 2016 at 5:08 PM, Michael C <mys...@gm...> wrote: > sorry I am new to this thing, I guess what I mean is I am looking for a list > of every functions and classes available under ctypes, as seen here: > > http://nullege.com/codes/search/ctypes.windll.user32.SetWindowPos > > a complete list everything and a description for them, > > Is there something like that? especially for windll, Actually, please avoid using cdll and windll. These global LibraryLoader instances weren't a good idea. They cache CDLL and WinDLL instances when accessed as attributes (e.g. windll.user32), which cache function pointers. This leads to definition conflicts between libraries that use the same DLL and define function prototypes (i.e. restype, argtypes, errcheck), which is especially problematic for common CRT and Windows API functions. Use CDLL and WinDLL directly. I also recommend passing use_last_error=True to WinDLL, e.g. user32 = ctypes.WinDLL('user32', use_last_error=True) . This calls SetLastError and GetLastError around each library function call, to set and get a thread-local value that's more reliable in Python. You can get and set this thread-local value via ctypes.get_last_error and ctypes.set_last_error. |
From: Michael C <mys...@gm...> - 2016-11-29 02:27:44
|
I didn't know about the MSDN library, thanks a lot, people. |
From: Michael C <mys...@gm...> - 2016-11-29 02:26:07
|
I have this code here I am working on. Right now it has 3 problems and then I still don't know if it works: what type of buffer should I create? buff = ctypes.create_string_buffer(4) I am not sure what sort of buffer ReadProcessMemory expect, and LPVOID, from MSDN, https://msdn.microsoft.com/en-us/library/windows/desktop/ms680553(v=vs.85).aspx doens't ring a bell for me. 2ndly, what's the number I should use here? addresses_list = range(????,????,???) I am not sure how memory spaces are named, does each program get its own memory space? So do I put down 99999999? 3rdly, I believe I configured unpack incorrectly, as I don't understand what sort of parameters to give because I don't understand how the memory works. Basically my goal is to write a memory scanner so I'd better understand how memories work. import ctypes from ctypes import wintypes as w from struct import * from time import * import datetime import sys import time PID = 15872 OpenProcess = ctypes.windll.kernel32.OpenProcess OpenProcess.argtypes = [w.DWORD,w.BOOL,w.DWORD] OpenProcess.restype = w.HANDLE ReadProcessMemory = ctypes.windll.kernel32.ReadProcessMemory ReadProcessMemory.argtypes = [w.HANDLE,w.LPCVOID,w.LPVOID, ctypes.c_size_t,ctypes.POINTER(ctypes.c_size_t)] ReadProcessMemory.restype = w.BOOL PROCESS_QUERY_INFORMATION = 0x0400 PROCESS_VM_READ = 0x0010 ph = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,False,int(PID)) #program handle #this is a problem: what type of buffer should I create? buff = ctypes.create_string_buffer(4) bufferSize = ctypes.sizeof(buff) bytesRead = ctypes.c_size_t(bufferSize) # what's the number I should use here? #addresses_list = range(0x99999999999) address = 0x4000000 addresses_list = range(address,0x9000000,0x4) for i in addresses_list: ReadProcessMemory(ph, ctypes.c_void_p(i), buff, bufferSize, ctypes.byref(bytesRead)) # I am uncertain how to configure unpack print(buff) value = unpack('I', buff)[0] if value == int(64953): print(i) |
From: Michael C <mys...@gm...> - 2016-11-28 21:35:51
|
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684320(v=vs.85).aspx thx all |
From: Michael C <mys...@gm...> - 2016-11-28 20:56:45
|
hi all: i am trying to write a memory scanner in python, nothing fancy and I know I am new but if it's only this long http://stackoverflow.com/questions/28672271/writing-memory-scanner-in-python then I can understand it within a week or so, if i do it slowly. |
From: Michael C <mys...@gm...> - 2016-11-28 20:55:24
|
oh I am trying to convert my pet project from c++, that's why. Also, I used only 2 lines of code to move windows around, so i am fine now with it now that i have the API reference. |
From: Rob G. <rg...@hi...> - 2016-11-28 18:53:02
|
Michael, I think you may have gotten wrapped around the axle a bit. USER32.DLL is one of the core DLLs of the Windows system, been around since at least Windows 3.0. When you talk about windll.user32, that's just ctypes accessing that library, and looks the same as the ctypes interface to any library. That said, if I recall correctly, most what happens in there is GUI management. If that's what you're trying to do, you almost certainly want to use one of the many GUI toolkits available for Python rather than try to bang against the DLL yourself. On November 28, 2016 8:06:33 AM GMT-07:00, "Diez B. Roggisch" <de...@we...> wrote: >I don’t understand your inquiry. > >Everything relevant to ctypes is in the first link of yours. What are >you missing there? > >Your second link talks about a specific windows DLL and it’s >functionality. Do you expect ctypes to contain documentation for >*arbirtrary* libraries out there? That’s quite impossible. You will >need to look at the DLL in question (or better it’s documentation), and >learn from that how to use it through ctypes. > >Diez > >> On 28 Nov 2016, at 03:33, Michael C <mys...@gm...> >wrote: >> >> Sorry guys, but I can't find the reference book of ctypes, and I am >looking for everythign there is under ctype.user32 >> >> I have this already >> >> https://docs.python.org/3/library/ctypes.html#ctypes.WinDLL ><https://docs.python.org/3/library/ctypes.html#ctypes.WinDLL> >> >> the best I can find to what I am describing to you is this: >> >> >http://nullege.com/codes/show/src@m@o@mozharness-HEAD@external_tools@mouse_and_screen_resolution.py/115/ctypes.windll.user32.GetCursorPos ><http://nullege.com/codes/show/src@m@o@mozharness-HEAD@external_tools@mouse_and_screen_resolution.py/115/ctypes.windll.user32.GetCursorPos> >> >> >> >> I need everything there is to know about the ctypes. Yes I googled >for it. >> >> thanks! >> >------------------------------------------------------------------------------ >> _______________________________________________ >> ctypes-users mailing list >> cty...@li... >> https://lists.sourceforge.net/lists/listinfo/ctypes-users > > > >------------------------------------------------------------------------ > >------------------------------------------------------------------------------ > > >------------------------------------------------------------------------ > >_______________________________________________ >ctypes-users mailing list >cty...@li... >https://lists.sourceforge.net/lists/listinfo/ctypes-users -- Sent from my Android device with K-9 Mail. Please excuse my brevity. |
From: Michael C <mys...@gm...> - 2016-11-28 17:58:31
|
how about windll.kernel32? |
From: Michael C <mys...@gm...> - 2016-11-28 17:55:07
|
thanks!!! I didnt know that |
From: Mark L. <lar...@gm...> - 2016-11-28 17:45:52
|
Michael, You aren't understanding. ctypes doesn't provide these functions. It's Python module that allows you to call C functions exposed in DLLs (externed). The functions are you interested are provided by the Windows operating system. These are commonly referred to as win32 functions. They are very well documented on MSDN. For instance, the documentation for the functions under User32.dll are located here: https://msdn.microsoft.com/en-us/library/windows/desktop/ff468919(v=vs.85).aspx Another great resource is http://www.pinvoke.net/. While that is geared toward .NET's implementation of a cytpes like library (interop services), the function definitions are the same. Thanks, Mark On Mon, Nov 28, 2016 at 12:12 PM, Michael C <mys...@gm...> wrote: > googling python windll returns python ctypes. i dont understand how the > documentation works for this thing. :( > > ------------------------------------------------------------ > ------------------ > > _______________________________________________ > ctypes-users mailing list > cty...@li... > https://lists.sourceforge.net/lists/listinfo/ctypes-users > > |
From: Michael C <mys...@gm...> - 2016-11-28 17:13:01
|
googling python windll returns python ctypes. i dont understand how the documentation works for this thing. :( |
From: Michael C <mys...@gm...> - 2016-11-28 17:08:11
|
sorry I am new to this thing, I guess what I mean is I am looking for a list of every functions and classes available under ctypes, as seen here: http://nullege.com/codes/search/ctypes.windll.user32.SetWindowPos a complete list everything and a description for them, Is there something like that? especially for windll, sorry for being a noob |
From: Diez B. R. <de...@we...> - 2016-11-28 15:06:47
|
I don’t understand your inquiry. Everything relevant to ctypes is in the first link of yours. What are you missing there? Your second link talks about a specific windows DLL and it’s functionality. Do you expect ctypes to contain documentation for *arbirtrary* libraries out there? That’s quite impossible. You will need to look at the DLL in question (or better it’s documentation), and learn from that how to use it through ctypes. Diez > On 28 Nov 2016, at 03:33, Michael C <mys...@gm...> wrote: > > Sorry guys, but I can't find the reference book of ctypes, and I am looking for everythign there is under ctype.user32 > > I have this already > > https://docs.python.org/3/library/ctypes.html#ctypes.WinDLL <https://docs.python.org/3/library/ctypes.html#ctypes.WinDLL> > > the best I can find to what I am describing to you is this: > > http://nullege.com/codes/show/src@m@o@mozharness-HEAD@external_tools@mouse_and_screen_resolution.py/115/ctypes.windll.user32.GetCursorPos <http://nullege.com/codes/show/src@m@o@mozharness-HEAD@external_tools@mouse_and_screen_resolution.py/115/ctypes.windll.user32.GetCursorPos> > > > > I need everything there is to know about the ctypes. Yes I googled for it. > > thanks! > ------------------------------------------------------------------------------ > _______________________________________________ > ctypes-users mailing list > cty...@li... > https://lists.sourceforge.net/lists/listinfo/ctypes-users |
From: Michael C <mys...@gm...> - 2016-11-28 02:33:38
|
Sorry guys, but I can't find the reference book of ctypes, and I am looking for everythign there is under ctype.user32 I have this already https://docs.python.org/3/library/ctypes.html#ctypes.WinDLL the best I can find to what I am describing to you is this: http://nullege.com/codes/show/src@m@o@mozharness-HEAD@external_tools@mouse_and_screen_resolution.py/115/ctypes.windll.user32.GetCursorPos I need everything there is to know about the ctypes. Yes I googled for it. thanks! |
From: Diez B. R. <de...@we...> - 2016-08-28 15:28:40
|
It is not possible for ctypes (or anything else, for that matter) to force a running thread to execute arbitrary other code, and the just jump back to execution. I see two options that need investigation: - currentThread is for whatever reason confused. You could try that out by making your callback stall for several seconds (time.sleep), and observe if the mainloop is still running. - the mainloop you describe is an actual eventloop, in which case the design of your application needs to be altered. For this we would need to see more code. So - which is it? Diez > On 19 Aug 2016, at 23:44, KP <pat...@gm...> wrote: > > I have a python client with ctypes wrappers to call in to a DLL that in turn talks to a server process. One of the features is to register a callback on an event. I am able to successfully register callbacks, and they do get called on events...so all is working well there. > > However, it seems the callbacks are always executed in the "main" thread...even when I know there are other commands running in the main thread. > > I'm not entirely sure how this happens/or is possible. The main thread is running a loop, but the callback also reports being in the main thread (by printing threading.currentThread()). Is this something ctypes has control over that I can tweak? > > I need it to be in a different thread so that any CTRL-C will _not_ end up in that thread, and will instead impact the main thread...er, well, what I am thinking of as the main thread (not the callback). > > Any ideas? Thanks, > Kevin > ------------------------------------------------------------------------------ > _______________________________________________ > ctypes-users mailing list > cty...@li... > https://lists.sourceforge.net/lists/listinfo/ctypes-users |
From: KP <pat...@gm...> - 2016-08-19 21:44:11
|
I have a python client with ctypes wrappers to call in to a DLL that in turn talks to a server process. One of the features is to register a callback on an event. I am able to successfully register callbacks, and they do get called on events...so all is working well there. However, it seems the callbacks are always executed in the "main" thread...even when I know there are other commands running in the main thread. I'm not entirely sure how this happens/or is possible. The main thread is running a loop, but the callback also reports being in the main thread (by printing threading.currentThread()). Is this something ctypes has control over that I can tweak? I need it to be in a different thread so that any CTRL-C will _not_ end up in that thread, and will instead impact the main thread...er, well, what I am thinking of as the main thread (not the callback). Any ideas? Thanks, Kevin |
From: Diez B. R. <de...@we...> - 2016-07-18 22:13:56
|
Hi, while the error-message looks like it could be a path-problem for now, eventually this is bound to fail - you can’t use DLLs built for windows under Unix. At least not just like this. If you can’t use windows, you could try WINE & a Windows-Python. No idea how easy/good that works though. Diez > On 18 Jul 2016, at 21:26, kristine l <per...@gm...> wrote: > > Hi guys! > > I am trying to load the '__CLDevIFace.dll' library found on this page: > > https://github.com/charlie1kimo/Zygo/tree/master/wave_meter_wrapper <https://github.com/charlie1kimo/Zygo/tree/master/wave_meter_wrapper> > > to communicate with a Bristol 621 wavemeter. I would be doing this on a Unix computer, and each time I try to run: > > """ > from ctypes import * > dll = cdll.LoadLibrary('__CLDevIFace.dll') > """ > > It gives me the error: > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary > return self._dlltype(name) > File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__ > self._handle = _dlopen(self._name, mode) > OSError: __CLDevIFace.dll: cannot open shared object file: No such file or directory > > > > I have no idea where to go from here, and the tutorial on the ctypes package is not helping me. > > Thanks for any help! > ------------------------------------------------------------------------------ > What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic > patterns at an interface-level. Reveals which users, apps, and protocols are > consuming the most bandwidth. Provides multi-vendor support for NetFlow, > J-Flow, sFlow and other flows. Make informed decisions using capacity planning > reports.http://sdm.link/zohodev2dev_______________________________________________ > ctypes-users mailing list > cty...@li... > https://lists.sourceforge.net/lists/listinfo/ctypes-users |
From: kristine l <per...@gm...> - 2016-07-18 19:26:19
|
Hi guys! I am trying to load the '__CLDevIFace.dll' library found on this page: https://github.com/charlie1kimo/Zygo/tree/master/wave_meter_wrapper to communicate with a Bristol 621 wavemeter. I would be doing this on a Unix computer, and each time I try to run: """ from ctypes import * dll = cdll.LoadLibrary('__CLDevIFace.dll') """ It gives me the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary return self._dlltype(name) File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) OSError: __CLDevIFace.dll: cannot open shared object file: No such file or directory I have no idea where to go from here, and the tutorial on the ctypes package is not helping me. Thanks for any help! |
From: eryk s. <er...@gm...> - 2016-06-17 05:24:10
|
On Thu, Jun 16, 2016 at 4:43 AM, jef...@gm... <jef...@gm...> wrote: > > I just created the issue[0] and will start reading the documentation to > create and submit the patch. Thank you. |
From: <jef...@gm...> - 2016-06-16 04:43:25
|
Hi Eryk, On Thu, Jun 9, 2016 at 1:09 PM, eryk sun <er...@gm...> wrote: > On Thu, Jun 9, 2016 at 4:35 PM, jef...@gm... > <jef...@gm...> wrote: > > > > Great to read that! Is there any way I can help to get this documented? > > Should I submit a PR to the documentation or something like that? > > Here's the link to create a new issue: > > http://bugs.python.org/issue?@template=item > > It's an enhancement for components "ctypes" and "Documentation" for > 2.7, 3.5, and 3.6. See the dev guide for how to get started with > submitting patches and writing docs using reStructuredText. > > https://docs.python.org/devguide > I just created the issue[0] and will start reading the documentation to create and submit the patch. Thank you very much, [0] http://bugs.python.org/issue27329 -- Jeffrey Esquivel S. |
From: Carlos P. <car...@gm...> - 2016-06-09 19:38:24
|
> > bytearray's __reduce_ex__ creates a bytes copy in the args tuple (see > _common_reduce in Objects/bytearrayobject.c): > > Oh, I see, it seems that all hope is lost until someone makes memoryviews picklable, then. But it's not that clear how memoryviews would reconstruct their dumps at load-side, anyway, since they are just views to proper objects. Thank you again -- Carlos |