Package winappdbg :: Package win32 :: Module user32
[hide private]
[frames] | no frames]

Source Code for Module winappdbg.win32.user32

   1  # Copyright (c) 2009-2010, Mario Vilas 
   2  # All rights reserved. 
   3  # 
   4  # Redistribution and use in source and binary forms, with or without 
   5  # modification, are permitted provided that the following conditions are met: 
   6  # 
   7  #     * Redistributions of source code must retain the above copyright notice, 
   8  #       this list of conditions and the following disclaimer. 
   9  #     * Redistributions in binary form must reproduce the above copyright 
  10  #       notice,this list of conditions and the following disclaimer in the 
  11  #       documentation and/or other materials provided with the distribution. 
  12  #     * Neither the name of the copyright holder nor the names of its 
  13  #       contributors may be used to endorse or promote products derived from 
  14  #       this software without specific prior written permission. 
  15  # 
  16  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
  17  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  18  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  19  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
  20  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  21  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  22  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
  23  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
  24  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  25  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  26  # POSSIBILITY OF SUCH DAMAGE. 
  27   
  28  """ 
  29  Wrapper for user32.dll in ctypes. 
  30  """ 
  31   
  32  __revision__ = "$Id: user32.py 705 2010-07-07 22:21:08Z qvasimodo $" 
  33   
  34  from defines import * 
  35  from kernel32 import GetLastError, SetLastError 
  36  from gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT 
37 38 #--- Helpers ------------------------------------------------------------------ 39 40 -def MAKE_WPARAM(wParam):
41 """ 42 Convert arguments to the WPARAM type. 43 Used automatically by SendMessage, PostMessage, etc. 44 You shouldn't need to call this function. 45 """ 46 wParam = ctypes.cast(wParam, LPVOID).value 47 if wParam is None: 48 wParam = 0 49 return wParam
50
51 -def MAKE_LPARAM(lParam):
52 """ 53 Convert arguments to the LPARAM type. 54 Used automatically by SendMessage, PostMessage, etc. 55 You shouldn't need to call this function. 56 """ 57 return ctypes.cast(lParam, LPARAM)
58
59 -class WindowEnumerator (object):
60 """ 61 Window enumerator class. You can pass it's instances 62 as callback functions in window enumeration APIs. 63 """
64 - def __init__(self):
65 self.hwnd = list()
66 - def __call__(self, hwnd, lParam):
67 ## print hwnd # XXX DEBUG 68 self.hwnd.append(hwnd) 69 return TRUE
70 71 #--- Types -------------------------------------------------------------------- 72 73 WNDENUMPROC = WINFUNCTYPE(BOOL, HWND, PVOID) 74 75 #--- Constants ---------------------------------------------------------------- 76 77 HWND_DESKTOP = 0 78 HWND_TOP = 1 79 HWND_BOTTOM = 1 80 HWND_TOPMOST = -1 81 HWND_NOTOPMOST = -2 82 HWND_MESSAGE = -3 83 84 # GetWindowLong / SetWindowLong / GetWindowLongPtr / SetWindowLongPtr 85 GWL_WNDPROC = -4 86 GWL_HINSTANCE = -6 87 GWL_HWNDPARENT = -8 88 GWL_STYLE = -16 89 GWL_EXSTYLE = -20 90 GWL_USERDATA = -21 91 GWL_ID = -12 92 93 # ShowWindow 94 SW_HIDE = 0 95 SW_SHOWNORMAL = 1 96 SW_NORMAL = 1 97 SW_SHOWMINIMIZED = 2 98 SW_SHOWMAXIMIZED = 3 99 SW_MAXIMIZE = 3 100 SW_SHOWNOACTIVATE = 4 101 SW_SHOW = 5 102 SW_MINIMIZE = 6 103 SW_SHOWMINNOACTIVE = 7 104 SW_SHOWNA = 8 105 SW_RESTORE = 9 106 SW_SHOWDEFAULT = 10 107 SW_FORCEMINIMIZE = 11 108 109 # SendMessageTimeout flags 110 SMTO_NORMAL = 0 111 SMTO_BLOCK = 1 112 SMTO_ABORTIFHUNG = 2 113 SMTO_NOTIMEOUTIFNOTHUNG = 8 114 SMTO_ERRORONEXIT = 0x20 115 116 # WINDOWPLACEMENT flags 117 WPF_SETMINPOSITION = 1 118 WPF_RESTORETOMAXIMIZED = 2 119 WPF_ASYNCWINDOWPLACEMENT = 4 120 121 #--- Window messages ---------------------------------------------------------- 122 123 WM_USER = 0x400 124 WM_APP = 0x800 125 126 WM_NULL = 0 127 WM_CREATE = 1 128 WM_DESTROY = 2 129 WM_MOVE = 3 130 WM_SIZE = 5 131 WM_ACTIVATE = 6 132 WA_INACTIVE = 0 133 WA_ACTIVE = 1 134 WA_CLICKACTIVE = 2 135 WM_SETFOCUS = 7 136 WM_KILLFOCUS = 8 137 WM_ENABLE = 0x0A 138 WM_SETREDRAW = 0x0B 139 WM_SETTEXT = 0x0C 140 WM_GETTEXT = 0x0D 141 WM_GETTEXTLENGTH = 0x0E 142 WM_PAINT = 0x0F 143 WM_CLOSE = 0x10 144 WM_QUERYENDSESSION = 0x11 145 WM_QUIT = 0x12 146 WM_QUERYOPEN = 0x13 147 WM_ERASEBKGND = 0x14 148 WM_SYSCOLORCHANGE = 0x15 149 WM_ENDSESSION = 0x16 150 WM_SHOWWINDOW = 0x18 151 WM_WININICHANGE = 0x1A 152 WM_SETTINGCHANGE = WM_WININICHANGE 153 WM_DEVMODECHANGE = 0x1B 154 WM_ACTIVATEAPP = 0x1C 155 WM_FONTCHANGE = 0x1D 156 WM_TIMECHANGE = 0x1E 157 WM_CANCELMODE = 0x1F 158 WM_SETCURSOR = 0x20 159 WM_MOUSEACTIVATE = 0x21 160 WM_CHILDACTIVATE = 0x22 161 WM_QUEUESYNC = 0x23 162 WM_GETMINMAXINFO = 0x24 163 WM_PAINTICON = 0x26 164 WM_ICONERASEBKGND = 0x27 165 WM_NEXTDLGCTL = 0x28 166 WM_SPOOLERSTATUS = 0x2A 167 WM_DRAWITEM = 0x2B 168 WM_MEASUREITEM = 0x2C 169 WM_DELETEITEM = 0x2D 170 WM_VKEYTOITEM = 0x2E 171 WM_CHARTOITEM = 0x2F 172 WM_SETFONT = 0x30 173 WM_GETFONT = 0x31 174 WM_SETHOTKEY = 0x32 175 WM_GETHOTKEY = 0x33 176 WM_QUERYDRAGICON = 0x37 177 WM_COMPAREITEM = 0x39 178 WM_GETOBJECT = 0x3D 179 WM_COMPACTING = 0x41 180 WM_OTHERWINDOWCREATED = 0x42 181 WM_OTHERWINDOWDESTROYED = 0x43 182 WM_COMMNOTIFY = 0x44 183 184 CN_RECEIVE = 0x1 185 CN_TRANSMIT = 0x2 186 CN_EVENT = 0x4 187 188 WM_WINDOWPOSCHANGING = 0x46 189 WM_WINDOWPOSCHANGED = 0x47 190 WM_POWER = 0x48 191 192 PWR_OK = 1 193 PWR_FAIL = -1 194 PWR_SUSPENDREQUEST = 1 195 PWR_SUSPENDRESUME = 2 196 PWR_CRITICALRESUME = 3 197 198 WM_COPYDATA = 0x4A 199 WM_CANCELJOURNAL = 0x4B 200 WM_NOTIFY = 0x4E 201 WM_INPUTLANGCHANGEREQUEST = 0x50 202 WM_INPUTLANGCHANGE = 0x51 203 WM_TCARD = 0x52 204 WM_HELP = 0x53 205 WM_USERCHANGED = 0x54 206 WM_NOTIFYFORMAT = 0x55 207 WM_CONTEXTMENU = 0x7B 208 WM_STYLECHANGING = 0x7C 209 WM_STYLECHANGED = 0x7D 210 WM_DISPLAYCHANGE = 0x7E 211 WM_GETICON = 0x7F 212 WM_SETICON = 0x80 213 WM_NCCREATE = 0x81 214 WM_NCDESTROY = 0x82 215 WM_NCCALCSIZE = 0x83 216 WM_NCHITTEST = 0x84 217 WM_NCPAINT = 0x85 218 WM_NCACTIVATE = 0x86 219 WM_GETDLGCODE = 0x87 220 WM_SYNCPAINT = 0x88 221 WM_NCMOUSEMOVE = 0x0A0 222 WM_NCLBUTTONDOWN = 0x0A1 223 WM_NCLBUTTONUP = 0x0A2 224 WM_NCLBUTTONDBLCLK = 0x0A3 225 WM_NCRBUTTONDOWN = 0x0A4 226 WM_NCRBUTTONUP = 0x0A5 227 WM_NCRBUTTONDBLCLK = 0x0A6 228 WM_NCMBUTTONDOWN = 0x0A7 229 WM_NCMBUTTONUP = 0x0A8 230 WM_NCMBUTTONDBLCLK = 0x0A9 231 WM_KEYFIRST = 0x100 232 WM_KEYDOWN = 0x100 233 WM_KEYUP = 0x101 234 WM_CHAR = 0x102 235 WM_DEADCHAR = 0x103 236 WM_SYSKEYDOWN = 0x104 237 WM_SYSKEYUP = 0x105 238 WM_SYSCHAR = 0x106 239 WM_SYSDEADCHAR = 0x107 240 WM_KEYLAST = 0x108 241 WM_INITDIALOG = 0x110 242 WM_COMMAND = 0x111 243 WM_SYSCOMMAND = 0x112 244 WM_TIMER = 0x113 245 WM_HSCROLL = 0x114 246 WM_VSCROLL = 0x115 247 WM_INITMENU = 0x116 248 WM_INITMENUPOPUP = 0x117 249 WM_MENUSELECT = 0x11F 250 WM_MENUCHAR = 0x120 251 WM_ENTERIDLE = 0x121 252 WM_CTLCOLORMSGBOX = 0x132 253 WM_CTLCOLOREDIT = 0x133 254 WM_CTLCOLORLISTBOX = 0x134 255 WM_CTLCOLORBTN = 0x135 256 WM_CTLCOLORDLG = 0x136 257 WM_CTLCOLORSCROLLBAR = 0x137 258 WM_CTLCOLORSTATIC = 0x138 259 WM_MOUSEFIRST = 0x200 260 WM_MOUSEMOVE = 0x200 261 WM_LBUTTONDOWN = 0x201 262 WM_LBUTTONUP = 0x202 263 WM_LBUTTONDBLCLK = 0x203 264 WM_RBUTTONDOWN = 0x204 265 WM_RBUTTONUP = 0x205 266 WM_RBUTTONDBLCLK = 0x206 267 WM_MBUTTONDOWN = 0x207 268 WM_MBUTTONUP = 0x208 269 WM_MBUTTONDBLCLK = 0x209 270 WM_MOUSELAST = 0x209 271 WM_PARENTNOTIFY = 0x210 272 WM_ENTERMENULOOP = 0x211 273 WM_EXITMENULOOP = 0x212 274 WM_MDICREATE = 0x220 275 WM_MDIDESTROY = 0x221 276 WM_MDIACTIVATE = 0x222 277 WM_MDIRESTORE = 0x223 278 WM_MDINEXT = 0x224 279 WM_MDIMAXIMIZE = 0x225 280 WM_MDITILE = 0x226 281 WM_MDICASCADE = 0x227 282 WM_MDIICONARRANGE = 0x228 283 WM_MDIGETACTIVE = 0x229 284 WM_MDISETMENU = 0x230 285 WM_DROPFILES = 0x233 286 WM_MDIREFRESHMENU = 0x234 287 WM_CUT = 0x300 288 WM_COPY = 0x301 289 WM_PASTE = 0x302 290 WM_CLEAR = 0x303 291 WM_UNDO = 0x304 292 WM_RENDERFORMAT = 0x305 293 WM_RENDERALLFORMATS = 0x306 294 WM_DESTROYCLIPBOARD = 0x307 295 WM_DRAWCLIPBOARD = 0x308 296 WM_PAINTCLIPBOARD = 0x309 297 WM_VSCROLLCLIPBOARD = 0x30A 298 WM_SIZECLIPBOARD = 0x30B 299 WM_ASKCBFORMATNAME = 0x30C 300 WM_CHANGECBCHAIN = 0x30D 301 WM_HSCROLLCLIPBOARD = 0x30E 302 WM_QUERYNEWPALETTE = 0x30F 303 WM_PALETTEISCHANGING = 0x310 304 WM_PALETTECHANGED = 0x311 305 WM_HOTKEY = 0x312 306 WM_PRINT = 0x317 307 WM_PRINTCLIENT = 0x318 308 WM_PENWINFIRST = 0x380 309 WM_PENWINLAST = 0x38F
310 311 #--- Structures --------------------------------------------------------------- 312 313 # typedef struct _WINDOWPLACEMENT { 314 # UINT length; 315 # UINT flags; 316 # UINT showCmd; 317 # POINT ptMinPosition; 318 # POINT ptMaxPosition; 319 # RECT rcNormalPosition; 320 # } WINDOWPLACEMENT; 321 -class WINDOWPLACEMENT(Structure):
322 _fields_ = [ 323 ('length', UINT), 324 ('flags', UINT), 325 ('showCmd', UINT), 326 ('ptMinPosition', POINT), 327 ('ptMaxPosition', POINT), 328 ('rcNormalPosition', RECT), 329 ]
330 PWINDOWPLACEMENT = POINTER(WINDOWPLACEMENT) 331 LPWINDOWPLACEMENT = PWINDOWPLACEMENT
332 333 # typedef struct tagGUITHREADINFO { 334 # DWORD cbSize; 335 # DWORD flags; 336 # HWND hwndActive; 337 # HWND hwndFocus; 338 # HWND hwndCapture; 339 # HWND hwndMenuOwner; 340 # HWND hwndMoveSize; 341 # HWND hwndCaret; 342 # RECT rcCaret; 343 # } GUITHREADINFO, *PGUITHREADINFO; 344 -class GUITHREADINFO(Structure):
345 _fields_ = [ 346 ('cbSize', DWORD), 347 ('flags', DWORD), 348 ('hwndActive', HWND), 349 ('hwndFocus', HWND), 350 ('hwndCapture', HWND), 351 ('hwndMenuOwner', HWND), 352 ('hwndMoveSize', HWND), 353 ('hwndCaret', HWND), 354 ('rcCaret', RECT), 355 ]
356 PGUITHREADINFO = POINTER(GUITHREADINFO) 357 LPGUITHREADINFO = PGUITHREADINFO
358 359 #--- High level classes ------------------------------------------------------- 360 361 # Point() and Rect() are here instead of gdi32.py because they were mainly 362 # created to handle window coordinates rather than drawing on the screen. 363 364 -class Point(object):
365 """ 366 Python wrapper over the L{POINT} class. 367 368 @type x: int 369 @ivar x: Horizontal coordinate 370 @type y: int 371 @ivar y: Vertical coordinate 372 """ 373
374 - def __init__(self, x = 0, y = 0):
375 """ 376 @see: L{POINT} 377 @type x: int 378 @param x: Horizontal coordinate 379 @type y: int 380 @param y: Vertical coordinate 381 """ 382 self.x = x 383 self.y = y
384
385 - def __iter__(self):
386 return (self.x, self.y).__iter__()
387
388 - def __len__(self):
389 return 2
390
391 - def __getitem__(self, index):
392 return (self.x, self.y) [index]
393
394 - def __setitem__(self, index, value):
395 if index == 0: 396 self.x = value 397 elif index == 1: 398 self.y = value 399 else: 400 raise IndexError, "index out of range"
401 402 @property
403 - def _as_parameter_(self):
404 """ 405 Compatibility with ctypes. 406 Allows passing transparently a Point object to an API call. 407 """ 408 return POINT(self.x, self.y)
409
410 - def screen_to_client(self, hWnd):
411 """ 412 Translates window screen coordinates to client coordinates. 413 414 @see: L{client_to_screen}, L{translate} 415 416 @type hWnd: int or L{HWND} or L{system.Window} 417 @param hWnd: Window handle. 418 419 @rtype: L{Point} 420 @return: New object containing the translated coordinates. 421 """ 422 return ScreenToClient(hWnd, self)
423
424 - def client_to_screen(self, hWnd):
425 """ 426 Translates window client coordinates to screen coordinates. 427 428 @see: L{screen_to_client}, L{translate} 429 430 @type hWnd: int or L{HWND} or L{system.Window} 431 @param hWnd: Window handle. 432 433 @rtype: L{Point} 434 @return: New object containing the translated coordinates. 435 """ 436 return ClientToScreen(hWnd, self)
437
438 - def translate(self, hWndFrom = HWND_DESKTOP, hWndTo = HWND_DESKTOP):
439 """ 440 Translate coordinates from one window to another. 441 442 @note: To translate multiple points it's more efficient to use the 443 L{MapWindowPoints} function instead. 444 445 @see: L{client_to_screen}, L{screen_to_client} 446 447 @type hWndFrom: int or L{HWND} or L{system.Window} 448 @param hWndFrom: Window handle to translate from. 449 Use C{HWND_DESKTOP} for screen coordinates. 450 451 @type hWndTo: int or L{HWND} or L{system.Window} 452 @param hWndTo: Window handle to translate to. 453 Use C{HWND_DESKTOP} for screen coordinates. 454 455 @rtype: L{Point} 456 @return: New object containing the translated coordinates. 457 """ 458 return MapWindowPoints(hWndFrom, hWndTo, [self])
459
460 -class Rect(object):
461 """ 462 Python wrapper over the L{RECT} class. 463 464 @type left: int 465 @ivar left: Horizontal coordinate for the top left corner. 466 @type top: int 467 @ivar top: Vertical coordinate for the top left corner. 468 @type right: int 469 @ivar right: Horizontal coordinate for the bottom right corner. 470 @type bottom: int 471 @ivar bottom: Vertical coordinate for the bottom right corner. 472 473 @type width: int 474 @ivar width: Width in pixels. Same as C{right - left}. 475 @type height: int 476 @ivar height: Height in pixels. Same as C{bottom - top}. 477 """ 478
479 - def __init__(self, left = 0, top = 0, right = 0, bottom = 0):
480 """ 481 @see: L{RECT} 482 @type left: int 483 @param left: Horizontal coordinate for the top left corner. 484 @type top: int 485 @param top: Vertical coordinate for the top left corner. 486 @type right: int 487 @param right: Horizontal coordinate for the bottom right corner. 488 @type bottom: int 489 @param bottom: Vertical coordinate for the bottom right corner. 490 """ 491 self.left = left 492 self.top = top 493 self.right = right 494 self.bottom = bottom
495
496 - def __iter__(self):
497 return (self.left, self.top, self.right, self.bottom).__iter__()
498
499 - def __len__(self):
500 return 2
501
502 - def __getitem__(self, index):
503 return (self.left, self.top, self.right, self.bottom) [index]
504
505 - def __setitem__(self, index, value):
506 if index == 0: 507 self.left = value 508 elif index == 1: 509 self.top = value 510 elif index == 2: 511 self.right = value 512 elif index == 3: 513 self.bottom = value 514 else: 515 raise IndexError, "index out of range"
516 517 @property
518 - def _as_parameter_(self):
519 """ 520 Compatibility with ctypes. 521 Allows passing transparently a Point object to an API call. 522 """ 523 return RECT(self.left, self.top, self.right, self.bottom)
524
525 - def __get_width(self):
526 return self.right - self.left
527
528 - def __get_height(self):
529 return self.bottom - self.top
530
531 - def __set_width(self, value):
532 self.right = value - self.left
533
534 - def __set_height(self, value):
535 self.bottom = value - self.top
536 537 width = property(__get_width, __set_width) 538 height = property(__get_height, __set_height) 539
540 - def screen_to_client(self, hWnd):
541 """ 542 Translates window screen coordinates to client coordinates. 543 544 @see: L{client_to_screen}, L{translate} 545 546 @type hWnd: int or L{HWND} or L{system.Window} 547 @param hWnd: Window handle. 548 549 @rtype: L{Rect} 550 @return: New object containing the translated coordinates. 551 """ 552 topleft = ScreenToClient(hWnd, (self.left, self.top)) 553 bottomright = ScreenToClient(hWnd, (self.bottom, self.right)) 554 return Rect( topleft.x, topleft.y, bottomright.x, bottomright.y )
555
556 - def client_to_screen(self, hWnd):
557 """ 558 Translates window client coordinates to screen coordinates. 559 560 @see: L{screen_to_client}, L{translate} 561 562 @type hWnd: int or L{HWND} or L{system.Window} 563 @param hWnd: Window handle. 564 565 @rtype: L{Rect} 566 @return: New object containing the translated coordinates. 567 """ 568 topleft = ClientToScreen(hWnd, (self.left, self.top)) 569 bottomright = ClientToScreen(hWnd, (self.bottom, self.right)) 570 return Rect( topleft.x, topleft.y, bottomright.x, bottomright.y )
571
572 - def translate(self, hWndFrom = HWND_DESKTOP, hWndTo = HWND_DESKTOP):
573 """ 574 Translate coordinates from one window to another. 575 576 @see: L{client_to_screen}, L{screen_to_client} 577 578 @type hWndFrom: int or L{HWND} or L{system.Window} 579 @param hWndFrom: Window handle to translate from. 580 Use C{HWND_DESKTOP} for screen coordinates. 581 582 @type hWndTo: int or L{HWND} or L{system.Window} 583 @param hWndTo: Window handle to translate to. 584 Use C{HWND_DESKTOP} for screen coordinates. 585 586 @rtype: L{Rect} 587 @return: New object containing the translated coordinates. 588 """ 589 points = [ (self.left, self.top), (self.right, self.bottom) ] 590 return MapWindowPoints(hWndFrom, hWndTo, points)
591
592 -class WindowPlacement(object):
593 """ 594 Python wrapper over the L{WINDOWPLACEMENT} class. 595 """ 596
597 - def __init__(self, wp = None):
598 """ 599 @type wp: L{WindowPlacement} or L{WINDOWPLACEMENT} 600 @param wp: Another window placement object. 601 """ 602 603 # Initialize all properties with empty values. 604 self.flags = 0 605 self.showCmd = 0 606 self.ptMinPosition = Point() 607 self.ptMaxPosition = Point() 608 self.rcNormalPosition = Rect() 609 610 # If a window placement was given copy it's properties. 611 if wp: 612 self.flags = wp.flags 613 self.showCmd = wp.showCmd 614 self.ptMinPosition = Point( wp.ptMinPosition.x, wp.ptMinPosition.y ) 615 self.ptMaxPosition = Point( wp.ptMaxPosition.x, wp.ptMaxPosition.y ) 616 self.rcNormalPosition = Rect( 617 wp.rcNormalPosition.left, 618 wp.rcNormalPosition.top, 619 wp.rcNormalPosition.right, 620 wp.rcNormalPosition.bottom, 621 )
622 623 @property
624 - def _as_parameter_(self):
625 """ 626 Compatibility with ctypes. 627 Allows passing transparently a Point object to an API call. 628 """ 629 wp = WINDOWPLACEMENT() 630 wp.length = ctypes.sizeof(wp) 631 wp.flags = self.flags 632 wp.showCmd = self.showCmd 633 wp.ptMinPosition.x = self.ptMinPosition.x 634 wp.ptMinPosition.y = self.ptMinPosition.y 635 wp.ptMaxPosition.x = self.ptMaxPosition.x 636 wp.ptMaxPosition.y = self.ptMaxPosition.y 637 wp.rcNormalPosition.left = self.rcNormalPosition.left 638 wp.rcNormalPosition.top = self.rcNormalPosition.top 639 wp.rcNormalPosition.right = self.rcNormalPosition.right 640 wp.rcNormalPosition.bottom = self.rcNormalPosition.bottom 641 return wp
642
643 #--- user32.dll --------------------------------------------------------------- 644 645 # void WINAPI SetLastErrorEx( 646 # __in DWORD dwErrCode, 647 # __in DWORD dwType 648 # ); 649 -def SetLastErrorEx(dwErrCode, dwType = 0):
650 _SetLastErrorEx = windll.user32.SetLastErrorEx 651 _SetLastErrorEx.argtypes = [DWORD, DWORD] 652 _SetLastErrorEx.restype = None 653 _SetLastErrorEx(dwErrCode, dwType)
654
655 # HWND FindWindow( 656 # LPCTSTR lpClassName, 657 # LPCTSTR lpWindowName 658 # ); 659 -def FindWindowA(lpClassName = None, lpWindowName = None):
660 _FindWindowA = windll.user32.FindWindowA 661 _FindWindowA.argtypes = [LPSTR, LPSTR] 662 _FindWindowA.restype = HWND 663 664 hWnd = _FindWindowA(lpClassName, lpWindowName) 665 if not hWnd: 666 errcode = GetLastError() 667 if errcode != ERROR_SUCCESS: 668 raise ctypes.WinError(errcode) 669 return hWnd
670
671 -def FindWindowW(lpClassName = None, lpWindowName = None):
672 _FindWindowW = windll.user32.FindWindowW 673 _FindWindowW.argtypes = [LPWSTR, LPWSTR] 674 _FindWindowW.restype = HWND 675 676 hWnd = _FindWindowW(lpClassName, lpWindowName) 677 if not hWnd: 678 errcode = GetLastError() 679 if errcode != ERROR_SUCCESS: 680 raise ctypes.WinError(errcode) 681 return hWnd
682 683 FindWindow = GuessStringType(FindWindowA, FindWindowW)
684 685 # int GetClassName( 686 # HWND hWnd, 687 # LPTSTR lpClassName, 688 # int nMaxCount 689 # ); 690 -def GetClassNameA(hWnd):
691 _GetClassNameA = windll.user32.GetClassNameA 692 _GetClassNameA.argtypes = [HWND, LPSTR, ctypes.c_int] 693 _GetClassNameA.restype = ctypes.c_int 694 695 nMaxCount = 0x1000 696 dwCharSize = sizeof(CHAR) 697 while 1: 698 lpClassName = ctypes.create_string_buffer("", nMaxCount) 699 nCount = _GetClassNameA(hWnd, lpClassName, nMaxCount) 700 if nCount == 0: 701 raise ctypes.WinError() 702 if nCount < nMaxCount - dwCharSize: 703 break 704 nMaxCount += 0x1000 705 return lpClassName.value
706
707 -def GetClassNameW(hWnd):
708 _GetClassNameW = windll.user32.GetClassNameW 709 _GetClassNameW.argtypes = [HWND, LPWSTR, ctypes.c_int] 710 _GetClassNameW.restype = ctypes.c_int 711 712 nMaxCount = 0x1000 713 dwCharSize = sizeof(WCHAR) 714 while 1: 715 lpClassName = ctypes.create_unicode_buffer(u"", nMaxCount) 716 nCount = _GetClassNameW(hWnd, lpClassName, nMaxCount) 717 if nCount == 0: 718 raise ctypes.WinError() 719 if nCount < nMaxCount - dwCharSize: 720 break 721 nMaxCount += 0x1000 722 return lpClassName.value
723 724 GetClassName = GuessStringType(GetClassNameA, GetClassNameW)
725 726 # LONG GetWindowLong( 727 # HWND hWnd, 728 # int nIndex 729 # ); 730 -def GetWindowLongA(hWnd, nIndex = 0):
731 _GetWindowLongA = windll.user32.GetWindowLongA 732 _GetWindowLongA.argtypes = [HWND, ctypes.c_int] 733 _GetWindowLongA.restype = LONG 734 return _GetWindowLongA(hWnd, nIndex)
735
736 -def GetWindowLongW(hWnd, nIndex = 0):
737 _GetWindowLongW = windll.user32.GetWindowLongW 738 _GetWindowLongW.argtypes = [HWND, ctypes.c_int] 739 _GetWindowLongW.restype = LONG 740 return _GetWindowLongW(hWnd, nIndex)
741 742 ##GetWindowLong = GuessStringType(GetWindowLongA, GetWindowLongW) 743 GetWindowLong = GetWindowLongA # XXX HACK
744 745 # HWND GetShellWindow(VOID); 746 -def GetShellWindow():
747 _GetShellWindow = windll.user32.GetShellWindow 748 _GetShellWindow.argtypes = [] 749 _GetShellWindow.restype = HWND 750 _GetShellWindow.errcheck = RaiseIfZero 751 return _GetShellWindow()
752
753 # DWORD GetWindowThreadProcessId( 754 # HWND hWnd, 755 # LPDWORD lpdwProcessId 756 # ); 757 -def GetWindowThreadProcessId(hWnd):
758 _GetWindowThreadProcessId = windll.user32.GetWindowThreadProcessId 759 _GetWindowThreadProcessId.argtypes = [HWND, LPDWORD] 760 _GetWindowThreadProcessId.restype = DWORD 761 _GetWindowThreadProcessId.errcheck = RaiseIfZero 762 763 dwProcessId = DWORD(0) 764 dwThreadId = _GetWindowThreadProcessId(hWnd, ctypes.byref(dwProcessId)) 765 return dwThreadId, dwProcessId.value
766
767 # HWND GetParent( 768 # HWND hWnd 769 # ); 770 -def GetParent(hWnd):
771 _GetParent = windll.user32.GetParent 772 _GetParent.argtypes = [HWND] 773 _GetParent.restype = HWND 774 775 hWndParent = _GetParent(hWnd) 776 if not hWndParent: 777 winerr = GetLastError() 778 if winerr != ERROR_SUCCESS: 779 raise ctypes.WinError(winerr) 780 return hWndParent
781
782 # BOOL EnableWindow( 783 # HWND hWnd, 784 # BOOL bEnable 785 # ); 786 -def EnableWindow(hWnd, bEnable = True):
787 _EnableWindow = windll.user32.EnableWindow 788 _EnableWindow.argtypes = [HWND, BOOL] 789 _EnableWindow.restype = bool 790 return _EnableWindow(hWnd, bool(bEnable))
791
792 # BOOL ShowWindow( 793 # HWND hWnd, 794 # int nCmdShow 795 # ); 796 -def ShowWindow(hWnd, nCmdShow = SW_SHOW):
797 _ShowWindow = windll.user32.ShowWindow 798 _ShowWindow.argtypes = [HWND, ctypes.c_int] 799 _ShowWindow.restype = bool 800 return _ShowWindow(hWnd, nCmdShow)
801
802 # BOOL ShowWindowAsync( 803 # HWND hWnd, 804 # int nCmdShow 805 # ); 806 -def ShowWindowAsync(hWnd, nCmdShow = SW_SHOW):
807 _ShowWindowAsync = windll.user32.ShowWindowAsync 808 _ShowWindowAsync.argtypes = [HWND, ctypes.c_int] 809 _ShowWindowAsync.restype = bool 810 return _ShowWindowAsync(hWnd, nCmdShow)
811
812 # HWND GetDesktopWindow(VOID); 813 -def GetDesktopWindow():
814 _GetDesktopWindow = windll.user32.GetDesktopWindow 815 _GetDesktopWindow.argtypes = [] 816 _GetDesktopWindow.restype = HWND 817 _GetDesktopWindow.errcheck = RaiseIfZero 818 return _GetDesktopWindow()
819
820 # HWND GetForegroundWindow(VOID); 821 -def GetForegroundWindow():
822 _GetForegroundWindow = windll.user32.GetForegroundWindow 823 _GetForegroundWindow.argtypes = [] 824 _GetForegroundWindow.restype = HWND 825 _GetForegroundWindow.errcheck = RaiseIfZero 826 return _GetForegroundWindow()
827
828 # BOOL IsWindow( 829 # HWND hWnd 830 # ); 831 -def IsWindow(hWnd):
832 _IsWindow = windll.user32.IsWindow 833 _IsWindow.argtypes = [HWND] 834 _IsWindow.restype = bool 835 return _IsWindow(hWnd)
836
837 # BOOL IsWindowVisible( 838 # HWND hWnd 839 # ); 840 -def IsWindowVisible(hWnd):
841 _IsWindowVisible = windll.user32.IsWindowVisible 842 _IsWindowVisible.argtypes = [HWND] 843 _IsWindowVisible.restype = bool 844 return _IsWindowVisible(hWnd)
845
846 # BOOL IsWindowEnabled( 847 # HWND hWnd 848 # ); 849 -def IsWindowEnabled(hWnd):
850 _IsWindowEnabled = windll.user32.IsWindowEnabled 851 _IsWindowEnabled.argtypes = [HWND] 852 _IsWindowEnabled.restype = bool 853 return _IsWindowEnabled(hWnd)
854
855 # BOOL IsZoomed( 856 # HWND hWnd 857 # ); 858 -def IsZoomed(hWnd):
859 _IsZoomed = windll.user32.IsZoomed 860 _IsZoomed.argtypes = [HWND] 861 _IsZoomed.restype = bool 862 return _IsZoomed(hWnd)
863
864 # BOOL IsIconic( 865 # HWND hWnd 866 # ); 867 -def IsIconic(hWnd):
868 _IsIconic = windll.user32.IsIconic 869 _IsIconic.argtypes = [HWND] 870 _IsIconic.restype = bool 871 return _IsIconic(hWnd)
872
873 # BOOL IsChild( 874 # HWND hWnd 875 # ); 876 -def IsChild(hWnd):
877 _IsChild = windll.user32.IsChild 878 _IsChild.argtypes = [HWND] 879 _IsChild.restype = bool 880 return _IsChild(hWnd)
881
882 # DWORD GetWindowThreadProcessId( 883 # HWND hWnd, 884 # LPDWORD lpdwProcessId 885 # ); 886 -def GetWindowThreadProcessId(hWnd):
887 _GetWindowThreadProcessId = windll.user32.GetWindowThreadProcessId 888 _GetWindowThreadProcessId.argtypes = [HWND, LPDWORD] 889 _GetWindowThreadProcessId.restype = DWORD 890 _GetWindowThreadProcessId.errcheck = RaiseIfZero 891 892 dwProcessId = DWORD(0) 893 dwThreadId = _GetWindowThreadProcessId(hWnd, ctypes.byref(dwProcessId)) 894 return (dwThreadId, dwProcessId)
895
896 # HWND WindowFromPoint( 897 # POINT Point 898 # ); 899 -def WindowFromPoint(point):
900 _WindowFromPoint = windll.user32.WindowFromPoint 901 _WindowFromPoint.argtypes = [POINT] 902 _WindowFromPoint.restype = HWND 903 _WindowFromPoint.errcheck = RaiseIfZero 904 if isinstance(point, tuple): 905 point = POINT(*point) 906 return _WindowFromPoint(point)
907
908 # HWND ChildWindowFromPoint( 909 # HWND hWndParent, 910 # POINT Point 911 # ); 912 -def ChildWindowFromPoint(hWndParent, point):
913 _ChildWindowFromPoint = windll.user32.ChildWindowFromPoint 914 _ChildWindowFromPoint.argtypes = [HWND, POINT] 915 _ChildWindowFromPoint.restype = HWND 916 _ChildWindowFromPoint.errcheck = RaiseIfZero 917 if isinstance(point, tuple): 918 point = POINT(*point) 919 return _ChildWindowFromPoint(hWndParent, point)
920
921 #HWND RealChildWindowFromPoint( 922 # HWND hwndParent, 923 # POINT ptParentClientCoords 924 #); 925 -def RealChildWindowFromPoint(hWndParent, ptParentClientCoords):
926 _RealChildWindowFromPoint = windll.user32.RealChildWindowFromPoint 927 _RealChildWindowFromPoint.argtypes = [HWND, POINT] 928 _RealChildWindowFromPoint.restype = HWND 929 _RealChildWindowFromPoint.errcheck = RaiseIfZero 930 if isinstance(ptParentClientCoords, tuple): 931 ptParentClientCoords = POINT(*ptParentClientCoords) 932 return _RealChildWindowFromPoint(hWndParent, ptParentClientCoords)
933
934 # BOOL ScreenToClient( 935 # __in HWND hWnd, 936 # LPPOINT lpPoint 937 # ); 938 -def ScreenToClient(hWnd, lpPoint):
939 _ScreenToClient = windll.user32.ScreenToClient 940 _ScreenToClient.argtypes = [HWND, LPPOINT] 941 _ScreenToClient.restype = bool 942 _ScreenToClient.errcheck = RaiseIfZero 943 944 if isinstance(lpPoint, tuple): 945 lpPoint = POINT(*lpPoint) 946 else: 947 lpPoint = POINT() 948 lpPoint.x = x 949 lpPoint.y = y 950 _ScreenToClient(hWnd, ctypes.byref(lpPoint)) 951 return Point(lpPoint.x, lpPoint.y)
952
953 # BOOL ClientToScreen( 954 # HWND hWnd, 955 # LPPOINT lpPoint 956 # ); 957 -def ClientToScreen(hWnd, x, y):
958 _ClientToScreen = windll.user32.ClientToScreen 959 _ClientToScreen.argtypes = [HWND, LPPOINT] 960 _ClientToScreen.restype = bool 961 _ClientToScreen.errcheck = RaiseIfZero 962 963 if isinstance(lpPoint, tuple): 964 lpPoint = POINT(*lpPoint) 965 else: 966 lpPoint = POINT() 967 lpPoint.x = x 968 lpPoint.y = y 969 _ClientToScreen(hWnd, ctypes.byref(lpPoint)) 970 return Point(lpPoint.x, lpPoint.y)
971
972 # int MapWindowPoints( 973 # __in HWND hWndFrom, 974 # __in HWND hWndTo, 975 # __inout LPPOINT lpPoints, 976 # __in UINT cPoints 977 # ); 978 -def MapWindowPoints(hWndFrom, hWndTo, lpPoints):
979 _MapWindowPoints = windll.user32.MapWindowPoints 980 _MapWindowPoints.argtypes = [HWND, HWND, LPPOINT, UINT] 981 _MapWindowPoints.restype = ctypes.c_int 982 983 cPoints = len(lpPoints) 984 lpPoints = (POINT * cPoints)(* lpPoints) 985 SetLastError(ERROR_SUCCESS) 986 number = _MapWindowPoints(hWndFrom, hWndTo, ctypes.byref(lpPoints), cPoints) 987 if number == 0: 988 errcode = GetLastError() 989 if errcode != ERROR_SUCCESS: 990 raise ctypes.WinError(errcode) 991 x_delta = number & 0xFFFF 992 y_delta = (number >> 16) & 0xFFFF 993 return x_delta, y_delta, [ (Point.x, Point.y) for Point in lpPoints ]
994
995 #BOOL SetForegroundWindow( 996 # HWND hWnd 997 #); 998 -def SetForegroundWindow(hWnd):
999 _SetForegroundWindow = windll.user32.SetForegroundWindow 1000 _SetForegroundWindow.argtypes = [HWND] 1001 _SetForegroundWindow.restype = bool 1002 _SetForegroundWindow.errcheck = RaiseIfZero 1003 return _SetForegroundWindow(hWnd)
1004
1005 # BOOL GetWindowPlacement( 1006 # HWND hWnd, 1007 # WINDOWPLACEMENT *lpwndpl 1008 # ); 1009 -def GetWindowPlacement(hWnd):
1010 _GetWindowPlacement = windll.user32.GetWindowPlacement 1011 _GetWindowPlacement.argtypes = [HWND, PWINDOWPLACEMENT] 1012 _GetWindowPlacement.restype = bool 1013 _GetWindowPlacement.errcheck = RaiseIfZero 1014 1015 lpwndpl = WINDOWPLACEMENT() 1016 lpwndpl.length = ctypes.sizeof(lpwndpl) 1017 _GetWindowPlacement(hWnd, ctypes.byref(lpwndpl)) 1018 return WindowPlacement(lpwndpl)
1019
1020 # BOOL SetWindowPlacement( 1021 # HWND hWnd, 1022 # WINDOWPLACEMENT *lpwndpl 1023 # ); 1024 -def SetWindowPlacement(hWnd, lpwndpl):
1025 _SetWindowPlacement = windll.user32.SetWindowPlacement 1026 _SetWindowPlacement.argtypes = [HWND, PWINDOWPLACEMENT] 1027 _SetWindowPlacement.restype = bool 1028 _SetWindowPlacement.errcheck = RaiseIfZero 1029 1030 if isinstance(lpwndpl, WINDOWPLACEMENT): 1031 lpwndpl.length = ctypes.sizeof(lpwndpl) 1032 _SetWindowPlacement(hWnd, ctypes.byref(lpwndpl))
1033
1034 #BOOL MoveWindow( 1035 # HWND hWnd, 1036 # int X, 1037 # int Y, 1038 # int nWidth, 1039 # int nHeight, 1040 # BOOL bRepaint 1041 #); 1042 -def MoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint = True):
1043 _MoveWindow = windll.user32.MoveWindow 1044 _MoveWindow.argtypes = [HWND, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, BOOL] 1045 _MoveWindow.restype = bool 1046 _MoveWindow.errcheck = RaiseIfZero 1047 _MoveWindow(hWnd, X, Y, nWidth, nHeight, bool(bRepaint))
1048
1049 # BOOL GetGUIThreadInfo( 1050 # DWORD idThread, 1051 # LPGUITHREADINFO lpgui 1052 # ); 1053 -def GetGUIThreadInfo(idThread):
1054 _GetGUIThreadInfo = windll.user32.GetGUIThreadInfo 1055 _GetGUIThreadInfo.argtypes = [DWORD, LPGUITHREADINFO] 1056 _GetGUIThreadInfo.restype = bool 1057 _GetGUIThreadInfo.errcheck = RaiseIfZero 1058 1059 gui = GUITHREADINFO() 1060 _GetGUIThreadInfo(idThread, ctypes.byref(gui)) 1061 return gui
1062
1063 # BOOL CALLBACK EnumWndProc( 1064 # HWND hwnd, 1065 # LPARAM lParam 1066 # ); 1067 -class __EnumWndProc (WindowEnumerator):
1068 pass
1069
1070 # BOOL EnumWindows( 1071 # WNDENUMPROC lpEnumFunc, 1072 # LPARAM lParam 1073 # ); 1074 -def EnumWindows():
1075 _EnumWindows = windll.user32.EnumWindows 1076 _EnumWindows.argtypes = [WNDENUMPROC, LPARAM] 1077 _EnumWindows.restype = bool 1078 1079 EnumFunc = __EnumWndProc() 1080 lpEnumFunc = WNDENUMPROC(EnumFunc) 1081 if not _EnumWindows(lpEnumFunc, NULL): 1082 errcode = GetLastError() 1083 if errcode not in (ERROR_NO_MORE_FILES, ERROR_SUCCESS): 1084 raise ctypes.WinError(errcode) 1085 return EnumFunc.hwnd
1086
1087 # BOOL CALLBACK EnumThreadWndProc( 1088 # HWND hwnd, 1089 # LPARAM lParam 1090 # ); 1091 -class __EnumThreadWndProc (WindowEnumerator):
1092 pass
1093
1094 # BOOL EnumThreadWindows( 1095 # DWORD dwThreadId, 1096 # WNDENUMPROC lpfn, 1097 # LPARAM lParam 1098 # ); 1099 -def EnumThreadWindows(dwThreadId):
1100 _EnumThreadWindows = windll.user32.EnumThreadWindows 1101 _EnumThreadWindows.argtypes = [DWORD, WNDENUMPROC, LPARAM] 1102 _EnumThreadWindows.restype = bool 1103 1104 fn = __EnumThreadWndProc() 1105 lpfn = WNDENUMPROC(fn) 1106 if not _EnumThreadWindows(dwThreadId, lpfn, NULL): 1107 errcode = GetLastError() 1108 if errcode not in (ERROR_NO_MORE_FILES, ERROR_SUCCESS): 1109 raise ctypes.WinError(errcode) 1110 return fn.hwnd
1111
1112 # BOOL CALLBACK EnumChildProc( 1113 # HWND hwnd, 1114 # LPARAM lParam 1115 # ); 1116 -class __EnumChildProc (WindowEnumerator):
1117 pass
1118
1119 # BOOL EnumChildWindows( 1120 # HWND hWndParent, 1121 # WNDENUMPROC lpEnumFunc, 1122 # LPARAM lParam 1123 # ); 1124 -def EnumChildWindows(hWndParent = NULL):
1125 _EnumChildWindows = windll.user32.EnumChildWindows 1126 _EnumChildWindows.argtypes = [HWND, WNDENUMPROC, LPARAM] 1127 _EnumChildWindows.restype = bool 1128 1129 EnumFunc = __EnumChildProc() 1130 lpEnumFunc = WNDENUMPROC(EnumFunc) 1131 if not _EnumChildWindows(hWndParent, lpEnumFunc, NULL): 1132 errcode = GetLastError() 1133 if errcode not in (ERROR_NO_MORE_FILES, ERROR_SUCCESS): 1134 raise ctypes.WinError(errcode) 1135 return EnumFunc.hwnd
1136
1137 # LRESULT SendMessage( 1138 # HWND hWnd, 1139 # UINT Msg, 1140 # WPARAM wParam, 1141 # LPARAM lParam 1142 # ); 1143 -def SendMessageA(hWnd, Msg, wParam = 0, lParam = 0):
1144 _SendMessageA = windll.user32.SendMessageA 1145 _SendMessageA.argtypes = [HWND, UINT, WPARAM, LPARAM] 1146 _SendMessageA.restype = LRESULT 1147 1148 wParam = MAKE_WPARAM(wParam) 1149 lParam = MAKE_LPARAM(lParam) 1150 return _SendMessageA(hWnd, Msg, wParam, lParam)
1151
1152 -def SendMessageW(hWnd, Msg, wParam = 0, lParam = 0):
1153 _SendMessageW = windll.user32.SendMessageW 1154 _SendMessageW.argtypes = [HWND, UINT, WPARAM, LPARAM] 1155 _SendMessageW.restype = LRESULT 1156 1157 wParam = MAKE_WPARAM(wParam) 1158 lParam = MAKE_LPARAM(lParam) 1159 return _SendMessageW(hWnd, Msg, wParam, lParam)
1160 1161 SendMessage = GuessStringType(SendMessageA, SendMessageW)
1162 1163 # BOOL PostMessage( 1164 # HWND hWnd, 1165 # UINT Msg, 1166 # WPARAM wParam, 1167 # LPARAM lParam 1168 # ); 1169 -def PostMessageA(hWnd, Msg, wParam = 0, lParam = 0):
1170 _PostMessageA = windll.user32.PostMessageA 1171 _PostMessageA.argtypes = [HWND, UINT, WPARAM, LPARAM] 1172 _PostMessageA.restype = bool 1173 _PostMessageA.errcheck = RaiseIfZero 1174 1175 wParam = MAKE_WPARAM(wParam) 1176 lParam = MAKE_LPARAM(lParam) 1177 _PostMessageA(hWnd, Msg, wParam, lParam)
1178
1179 -def PostMessageW(hWnd, Msg, wParam = 0, lParam = 0):
1180 _PostMessageW = windll.user32.PostMessageW 1181 _PostMessageW.argtypes = [HWND, UINT, WPARAM, LPARAM] 1182 _PostMessageW.restype = bool 1183 _PostMessageW.errcheck = RaiseIfZero 1184 1185 wParam = MAKE_WPARAM(wParam) 1186 lParam = MAKE_LPARAM(lParam) 1187 _PostMessageW(hWnd, Msg, wParam, lParam)
1188 1189 PostMessage = GuessStringType(PostMessageA, PostMessageW)
1190 1191 # BOOL PostThreadMessage( 1192 # DWORD idThread, 1193 # UINT Msg, 1194 # WPARAM wParam, 1195 # LPARAM lParam 1196 # ); 1197 -def PostThreadMessageA(idThread, Msg, wParam = 0, lParam = 0):
1198 _PostThreadMessageA = windll.user32.PostThreadMessageA 1199 _PostThreadMessageA.argtypes = [DWORD, UINT, WPARAM, LPARAM] 1200 _PostThreadMessageA.restype = bool 1201 _PostThreadMessageA.errcheck = RaiseIfZero 1202 1203 wParam = MAKE_WPARAM(wParam) 1204 lParam = MAKE_LPARAM(lParam) 1205 _PostThreadMessageA(idThread, Msg, wParam, lParam)
1206
1207 -def PostThreadMessageW(idThread, Msg, wParam = 0, lParam = 0):
1208 _PostThreadMessageW = windll.user32.PostThreadMessageW 1209 _PostThreadMessageW.argtypes = [DWORD, UINT, WPARAM, LPARAM] 1210 _PostThreadMessageW.restype = bool 1211 _PostThreadMessageW.errcheck = RaiseIfZero 1212 1213 wParam = MAKE_WPARAM(wParam) 1214 lParam = MAKE_LPARAM(lParam) 1215 _PostThreadMessageW(idThread, Msg, wParam, lParam)
1216 1217 PostThreadMessage = GuessStringType(PostThreadMessageA, PostThreadMessageW)
1218 1219 # LRESULT c( 1220 # HWND hWnd, 1221 # UINT Msg, 1222 # WPARAM wParam, 1223 # LPARAM lParam, 1224 # UINT fuFlags, 1225 # UINT uTimeout, 1226 # PDWORD_PTR lpdwResult 1227 # ); 1228 -def SendMessageTimeoutA(hWnd, Msg, wParam = 0, lParam = 0, fuFlags = 0, uTimeout = 0):
1229 _SendMessageTimeoutA = windll.user32.SendMessageTimeoutA 1230 _SendMessageTimeoutA.argtypes = [HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR] 1231 _SendMessageTimeoutA.restype = LRESULT 1232 _SendMessageTimeoutA.errcheck = RaiseIfZero 1233 1234 wParam = MAKE_WPARAM(wParam) 1235 lParam = MAKE_LPARAM(lParam) 1236 dwResult = DWORD(0) 1237 _SendMessageTimeoutA(hWnd, Msg, wParam, lParam, fuFlags, uTimeout, ctypes.byref(dwResult)) 1238 return dwResult.value
1239
1240 -def SendMessageTimeoutW(hWnd, Msg, wParam = 0, lParam = 0):
1241 _SendMessageTimeoutW = windll.user32.SendMessageTimeoutW 1242 _SendMessageTimeoutW.argtypes = [HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR] 1243 _SendMessageTimeoutW.restype = LRESULT 1244 _SendMessageTimeoutW.errcheck = RaiseIfZero 1245 1246 wParam = MAKE_WPARAM(wParam) 1247 lParam = MAKE_LPARAM(lParam) 1248 dwResult = DWORD(0) 1249 _SendMessageTimeoutW(hWnd, Msg, wParam, lParam, fuFlags, uTimeout, ctypes.byref(dwResult)) 1250 return dwResult.value
1251 1252 SendMessageTimeout = GuessStringType(SendMessageTimeoutA, SendMessageTimeoutW)
1253 1254 # BOOL SendNotifyMessage( 1255 # HWND hWnd, 1256 # UINT Msg, 1257 # WPARAM wParam, 1258 # LPARAM lParam 1259 # ); 1260 -def SendNotifyMessageA(hWnd, Msg, wParam = 0, lParam = 0):
1261 _SendNotifyMessageA = windll.user32.SendNotifyMessageA 1262 _SendNotifyMessageA.argtypes = [HWND, UINT, WPARAM, LPARAM] 1263 _SendNotifyMessageA.restype = bool 1264 _SendNotifyMessageA.errcheck = RaiseIfZero 1265 1266 wParam = MAKE_WPARAM(wParam) 1267 lParam = MAKE_LPARAM(lParam) 1268 _SendNotifyMessageA(hWnd, Msg, wParam, lParam)
1269
1270 -def SendNotifyMessageW(hWnd, Msg, wParam = 0, lParam = 0):
1271 _SendNotifyMessageW = windll.user32.SendNotifyMessageW 1272 _SendNotifyMessageW.argtypes = [HWND, UINT, WPARAM, LPARAM] 1273 _SendNotifyMessageW.restype = bool 1274 _SendNotifyMessageW.errcheck = RaiseIfZero 1275 1276 wParam = MAKE_WPARAM(wParam) 1277 lParam = MAKE_LPARAM(lParam) 1278 _SendNotifyMessageW(hWnd, Msg, wParam, lParam)
1279 1280 SendNotifyMessage = GuessStringType(SendNotifyMessageA, SendNotifyMessageW)
1281 1282 # LRESULT SendDlgItemMessage( 1283 # HWND hDlg, 1284 # int nIDDlgItem, 1285 # UINT Msg, 1286 # WPARAM wParam, 1287 # LPARAM lParam 1288 # ); 1289 -def SendDlgItemMessageA(hDlg, nIDDlgItem, Msg, wParam = 0, lParam = 0):
1290 _SendDlgItemMessageA = windll.user32.SendDlgItemMessageA 1291 _SendDlgItemMessageA.argtypes = [HWND, ctypes.c_int, UINT, WPARAM, LPARAM] 1292 _SendDlgItemMessageA.restype = LRESULT 1293 1294 wParam = MAKE_WPARAM(wParam) 1295 lParam = MAKE_LPARAM(lParam) 1296 return _SendDlgItemMessageA(hDlg, nIDDlgItem, Msg, wParam, lParam)
1297
1298 -def SendDlgItemMessageW(hDlg, nIDDlgItem, Msg, wParam = 0, lParam = 0):
1299 _SendDlgItemMessageW = windll.user32.SendDlgItemMessageW 1300 _SendDlgItemMessageW.argtypes = [HWND, ctypes.c_int, UINT, WPARAM, LPARAM] 1301 _SendDlgItemMessageW.restype = LRESULT 1302 1303 wParam = MAKE_WPARAM(wParam) 1304 lParam = MAKE_LPARAM(lParam) 1305 return _SendDlgItemMessageW(hDlg, nIDDlgItem, Msg, wParam, lParam)
1306 1307 SendDlgItemMessage = GuessStringType(SendDlgItemMessageA, SendDlgItemMessageW)
1308 1309 # UINT RegisterWindowMessage( 1310 # LPCTSTR lpString 1311 # ); 1312 -def RegisterWindowMessageA(lpString):
1313 _RegisterWindowMessageA = windll.user32.RegisterWindowMessageA 1314 _RegisterWindowMessageA.argtypes = [LPSTR] 1315 _RegisterWindowMessageA.restype = UINT 1316 _RegisterWindowMessageA.errcheck = RaiseIfZero 1317 return _RegisterWindowMessageA(lpString)
1318
1319 -def RegisterWindowMessageW(lpString):
1320 _RegisterWindowMessageW = windll.user32.RegisterWindowMessageW 1321 _RegisterWindowMessageW.argtypes = [LPWSTR] 1322 _RegisterWindowMessageW.restype = UINT 1323 _RegisterWindowMessageW.errcheck = RaiseIfZero 1324 return _RegisterWindowMessageW(lpString)
1325 1326 RegisterWindowMessage = GuessStringType(RegisterWindowMessageA, RegisterWindowMessageW)
1327 1328 # UINT RegisterClipboardFormat( 1329 # LPCTSTR lpString 1330 # ); 1331 -def RegisterClipboardFormatA(lpString):
1332 _RegisterClipboardFormatA = windll.user32.RegisterClipboardFormatA 1333 _RegisterClipboardFormatA.argtypes = [LPSTR] 1334 _RegisterClipboardFormatA.restype = UINT 1335 _RegisterClipboardFormatA.errcheck = RaiseIfZero 1336 return _RegisterClipboardFormatA(lpString)
1337
1338 -def RegisterClipboardFormatW(lpString):
1339 _RegisterClipboardFormatW = windll.user32.RegisterClipboardFormatW 1340 _RegisterClipboardFormatW.argtypes = [LPWSTR] 1341 _RegisterClipboardFormatW.restype = UINT 1342 _RegisterClipboardFormatW.errcheck = RaiseIfZero 1343 return _RegisterClipboardFormatW(lpString)
1344 1345 RegisterClipboardFormat = GuessStringType(RegisterClipboardFormatA, RegisterClipboardFormatW)
1346 1347 # HANDLE WINAPI GetProp( 1348 # __in HWND hWnd, 1349 # __in LPCTSTR lpString 1350 # ); 1351 -def GetPropA(hWnd, lpString):
1352 _GetPropA = windll.user32.GetPropA 1353 _GetPropA.argtypes = [HWND, LPSTR] 1354 _GetPropA.restype = HANDLE 1355 return _GetPropA(lpString)
1356
1357 -def GetPropW(hWnd, lpString):
1358 _GetPropW = windll.user32.GetPropW 1359 _GetPropW.argtypes = [HWND, LPWSTR] 1360 _GetPropW.restype = HANDLE 1361 return _GetPropW(lpString)
1362 1363 GetProp = GuessStringType(GetPropA, GetPropW)
1364 1365 # BOOL WINAPI SetProp( 1366 # __in HWND hWnd, 1367 # __in LPCTSTR lpString, 1368 # __in_opt HANDLE hData 1369 # ); 1370 -def SetPropA(hWnd, lpString, hData):
1371 _SetPropA = windll.user32.SetPropA 1372 _SetPropA.argtypes = [HWND, LPSTR, HANDLE] 1373 _SetPropA.restype = BOOL 1374 _SetPropA.errcheck = RaiseIfZero 1375 return _SetPropA(lpString)
1376
1377 -def SetPropW(hWnd, lpString, hData):
1378 _SetPropW = windll.user32.SetPropW 1379 _SetPropW.argtypes = [HWND, LPWSTR, HANDLE] 1380 _SetPropW.restype = BOOL 1381 _SetPropW.errcheck = RaiseIfZero 1382 return _SetPropW(lpString)
1383 1384 SetProp = GuessStringType(SetPropA, SetPropW)
1385 1386 # HANDLE WINAPI RemoveProp( 1387 # __in HWND hWnd, 1388 # __in LPCTSTR lpString 1389 # ); 1390 -def RemovePropA(hWnd, lpString):
1391 _RemovePropA = windll.user32.RemovePropA 1392 _RemovePropA.argtypes = [HWND, LPSTR] 1393 _RemovePropA.restype = HANDLE 1394 return _RemovePropA(lpString)
1395
1396 -def RemovePropW(hWnd, lpString):
1397 _RemovePropW = windll.user32.RemovePropW 1398 _RemovePropW.argtypes = [HWND, LPWSTR] 1399 _RemovePropW.restype = HANDLE 1400 return _RemovePropW(lpString)
1401 1402 RemoveProp = GuessStringType(RemovePropA, RemovePropW) 1403