프로그래밍언어/Python

(Ctypes)winAPI_user32

부산딸랑이 2014. 11. 6. 11:17
  1. # GUI Application automation and testing library
  2. # Copyright (C) 2006 Mark Mc Mahon
  3. #
  4. # This library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public License
  6. # as published by the Free Software Foundation; either version 2.1
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. # See the GNU Lesser General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Lesser General Public
  15. # License along with this library; if not, write to the
  16. # Free Software Foundation, Inc.,
  17. # 59 Temple Place,
  18. # Suite 330,
  19. # Boston, MA 02111-1307 USA
  20. "Defines Windows(tm) functions"
  21.  
  22. __revision__ = "$Revision: 186 $"
  23.  
  24. import ctypes
  25.  
  26. CreateBrushIndirect = ctypes.windll.gdi32.CreateBrushIndirect
  27. CreateDC = ctypes.windll.gdi32.CreateDCW
  28. CreateFontIndirect = ctypes.windll.gdi32.CreateFontIndirectW
  29. CreatePen = ctypes.windll.gdi32.CreatePen
  30. DeleteDC = ctypes.windll.gdi32.DeleteDC
  31. DeleteObject = ctypes.windll.gdi32.DeleteObject
  32. DrawText = ctypes.windll.user32.DrawTextW
  33. TextOut = ctypes.windll.gdi32.TextOutW
  34. EnableWindow = ctypes.windll.user32.EnableWindow
  35. EnumChildWindows = ctypes.windll.user32.EnumChildWindows
  36. EnumDesktopWindows = ctypes.windll.user32.EnumDesktopWindows
  37. EnumWindows = ctypes.windll.user32.EnumWindows
  38. GetClassName = ctypes.windll.user32.GetClassNameW
  39. GetClientRect = ctypes.windll.user32.GetClientRect
  40. GetDC = ctypes.windll.user32.GetDC
  41. GetDesktopWindow = ctypes.windll.user32.GetDesktopWindow
  42.  
  43. # menu functions
  44. DrawMenuBar = ctypes.windll.user32.DrawMenuBar
  45. GetMenu = ctypes.windll.user32.GetMenu
  46. GetMenuBarInfo = ctypes.windll.user32.GetMenuBarInfo
  47. GetMenuItemCount = ctypes.windll.user32.GetMenuItemCount
  48. GetMenuItemInfo = ctypes.windll.user32.GetMenuItemInfoW
  49. GetMenuItemRect = ctypes.windll.user32.GetMenuItemRect
  50. GetMenuState = ctypes.windll.user32.GetMenuState
  51. GetSystemMenu = ctypes.windll.user32.GetSystemMenu
  52. HiliteMenuItem = ctypes.windll.user32.HiliteMenuItem
  53. IsMenu = ctypes.windll.user32.IsMenu
  54. MenuItemFromPoint = ctypes.windll.user32.MenuItemFromPoint
  55.  
  56.  
  57. GetObject = ctypes.windll.gdi32.GetObjectW
  58. GetParent = ctypes.windll.user32.GetParent
  59. GetStockObject = ctypes.windll.gdi32.GetStockObject
  60. GetSystemMetrics = ctypes.windll.user32.GetSystemMetrics
  61. GetTextMetrics = ctypes.windll.gdi32.GetTextMetricsW
  62. GetVersion = ctypes.windll.kernel32.GetVersion
  63. GetWindow = ctypes.windll.user32.GetWindow
  64. ShowWindow = ctypes.windll.user32.ShowWindow
  65. GetWindowContextHelpId = ctypes.windll.user32.GetWindowContextHelpId
  66. GetWindowLong = ctypes.windll.user32.GetWindowLongW
  67. GetWindowRect = ctypes.windll.user32.GetWindowRect
  68. GetWindowText = ctypes.windll.user32.GetWindowTextW
  69. GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
  70. GetCurrentThreadId = ctypes.windll.Kernel32.GetCurrentThreadId
  71. GetWindowThreadProcessId = ctypes.windll.user32.GetWindowThreadProcessId
  72. AttachThreadInput = ctypes.windll.user32.AttachThreadInput
  73. IsChild = ctypes.windll.user32.IsChild
  74. IsWindow = ctypes.windll.user32.IsWindow
  75. IsWindowUnicode = ctypes.windll.user32.IsWindowUnicode
  76. IsWindowVisible = ctypes.windll.user32.IsWindowVisible
  77. IsWindowEnabled = ctypes.windll.user32.IsWindowEnabled
  78. MapVirtualKey = ctypes.windll.user32.MapVirtualKeyW
  79. OpenProcess = ctypes.windll.kernel32.OpenProcess
  80. ReadProcessMemory = ctypes.windll.kernel32.ReadProcessMemory
  81. Rectangle = ctypes.windll.gdi32.Rectangle
  82. SelectObject = ctypes.windll.gdi32.SelectObject
  83. SendMessage = ctypes.windll.user32.SendMessageW
  84. SendMessageA = ctypes.windll.user32.SendMessageA
  85. PostMessage = ctypes.windll.user32.PostMessageW
  86. SetActiveWindow = ctypes.windll.user32.SetActiveWindow
  87. GetFocus = ctypes.windll.user32.GetFocus
  88. SetFocus = ctypes.windll.user32.SetFocus
  89. SetForegroundWindow = ctypes.windll.user32.SetForegroundWindow
  90. GetForegroundWindow = ctypes.windll.user32.GetForegroundWindow
  91. SetWindowLong = ctypes.windll.user32.SetWindowLongW
  92. SystemParametersInfo = ctypes.windll.user32.SystemParametersInfoW
  93. VirtualAllocEx = ctypes.windll.kernel32.VirtualAllocEx
  94. VirtualFreeEx = ctypes.windll.kernel32.VirtualFreeEx
  95. VkKeyScan = ctypes.windll.user32.VkKeyScanW
  96. WriteProcessMemory = ctypes.windll.kernel32.WriteProcessMemory
  97. GetActiveWindow = ctypes.windll.user32.GetActiveWindow
  98. GetLastActivePopup = ctypes.windll.user32.GetLastActivePopup
  99. FindWindow = ctypes.windll.user32.FindWindowW
  100. GetTopWindow = ctypes.windll.user32.GetTopWindow
  101.  
  102. SetCapture = ctypes.windll.user32.SetCapture
  103. ReleaseCapture = ctypes.windll.user32.ReleaseCapture
  104.  
  105. GetGUIThreadInfo = ctypes.windll.user32.GetGUIThreadInfo
  106. ShowOwnedPopups = ctypes.windll.user32.ShowOwnedPopups
  107. WindowFromPoint = ctypes.windll.user32.WindowFromPoint
  108. GetMessage = ctypes.windll.user32.GetMessageW
  109. SendMessageTimeout = ctypes.windll.user32.SendMessageTimeoutW
  110.  
  111. WideCharToMultiByte = ctypes.windll.kernel32.WideCharToMultiByte
  112. GetACP = ctypes.windll.kernel32.GetACP
  113.  
  114. CreateProcess = ctypes.windll.kernel32.CreateProcessW
  115. TerminateProcess = ctypes.windll.kernel32.TerminateProcess
  116. ExitProcess = ctypes.windll.kernel32.ExitProcess
  117.  
  118. WaitForSingleObject = ctypes.windll.kernel32.WaitForSingleObject
  119. WaitForInputIdle = ctypes.windll.user32.WaitForInputIdle
  120.  
  121. GetWindowThreadProcessId = ctypes.windll.user32.GetWindowThreadProcessId
  122. OpenProcess = ctypes.windll.kernel32.OpenProcess
  123. GetModuleFileNameEx = ctypes.windll.psapi.GetModuleFileNameExW
  124.  
  125. GetClipboardData = ctypes.windll.user32.GetClipboardData
  126. OpenClipboard = ctypes.windll.user32.OpenClipboard
  127. CountClipboardFormats = ctypes.windll.user32.CountClipboardFormats
  128. EnumClipboardFormats = ctypes.windll.user32.EnumClipboardFormats
  129. CloseClipboard = ctypes.windll.user32.CloseClipboard
  130.  
  131. GlobalAlloc = ctypes.windll.kernel32.GlobalAlloc
  132. GlobalLock = ctypes.windll.kernel32.GlobalLock
  133. GlobalUnlock = ctypes.windll.kernel32.GlobalUnlock
  134.  
  135.  
  136. #====================================================================
  137. def MakeLong(low, high):
  138. "Pack high into the high word of a long and low into the low word"
  139. return (high << 16) |
  140. low# GUI Application automation and testing library
  141. # Copyright (C) 2006 Mark Mc Mahon
  142. #
  143. # This library is free software; you can redistribute it and/or
  144. # modify it under the terms of the GNU Lesser General Public License
  145. # as published by the Free Software Foundation; either version 2.1
  146. # of the License, or (at your option) any later version.
  147. #
  148. # This library is distributed in the hope that it will be useful,
  149. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  150. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  151. # See the GNU Lesser General Public License for more details.
  152. #
  153. # You should have received a copy of the GNU Lesser General Public
  154. # License along with this library; if not, write to the
  155. # Free Software Foundation, Inc.,
  156. # 59 Temple Place,
  157. # Suite 330,
  158. # Boston, MA 02111-1307 USA
  159. "Defines Windows(tm) functions"
  160.  
  161. __revision__ = "$Revision: 186 $"
  162.  
  163. import ctypes
  164.  
  165. CreateBrushIndirect = ctypes.windll.gdi32.CreateBrushIndirect
  166. CreateDC = ctypes.windll.gdi32.CreateDCW
  167. CreateFontIndirect = ctypes.windll.gdi32.CreateFontIndirectW
  168. CreatePen = ctypes.windll.gdi32.CreatePen
  169. DeleteDC = ctypes.windll.gdi32.DeleteDC
  170. DeleteObject = ctypes.windll.gdi32.DeleteObject
  171. DrawText = ctypes.windll.user32.DrawTextW
  172. TextOut = ctypes.windll.gdi32.TextOutW
  173. EnableWindow = ctypes.windll.user32.EnableWindow
  174. EnumChildWindows = ctypes.windll.user32.EnumChildWindows
  175. EnumDesktopWindows = ctypes.windll.user32.EnumDesktopWindows
  176. EnumWindows = ctypes.windll.user32.EnumWindows
  177. GetClassName = ctypes.windll.user32.GetClassNameW
  178. GetClientRect = ctypes.windll.user32.GetClientRect
  179. GetDC = ctypes.windll.user32.GetDC
  180. GetDesktopWindow = ctypes.windll.user32.GetDesktopWindow
  181.  
  182. # menu functions
  183. DrawMenuBar = ctypes.windll.user32.DrawMenuBar
  184. GetMenu = ctypes.windll.user32.GetMenu
  185. GetMenuBarInfo = ctypes.windll.user32.GetMenuBarInfo
  186. GetMenuItemCount = ctypes.windll.user32.GetMenuItemCount
  187. GetMenuItemInfo = ctypes.windll.user32.GetMenuItemInfoW
  188. GetMenuItemRect = ctypes.windll.user32.GetMenuItemRect
  189. GetMenuState = ctypes.windll.user32.GetMenuState
  190. GetSystemMenu = ctypes.windll.user32.GetSystemMenu
  191. HiliteMenuItem = ctypes.windll.user32.HiliteMenuItem
  192. IsMenu = ctypes.windll.user32.IsMenu
  193. MenuItemFromPoint = ctypes.windll.user32.MenuItemFromPoint
  194.  
  195.  
  196. GetObject = ctypes.windll.gdi32.GetObjectW
  197. GetParent = ctypes.windll.user32.GetParent
  198. GetStockObject = ctypes.windll.gdi32.GetStockObject
  199. GetSystemMetrics = ctypes.windll.user32.GetSystemMetrics
  200. GetTextMetrics = ctypes.windll.gdi32.GetTextMetricsW
  201. GetVersion = ctypes.windll.kernel32.GetVersion
  202. GetWindow = ctypes.windll.user32.GetWindow
  203. ShowWindow = ctypes.windll.user32.ShowWindow
  204. GetWindowContextHelpId = ctypes.windll.user32.GetWindowContextHelpId
  205. GetWindowLong = ctypes.windll.user32.GetWindowLongW
  206. GetWindowRect = ctypes.windll.user32.GetWindowRect
  207. GetWindowText = ctypes.windll.user32.GetWindowTextW
  208. GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
  209. GetCurrentThreadId = ctypes.windll.Kernel32.GetCurrentThreadId
  210. GetWindowThreadProcessId = ctypes.windll.user32.GetWindowThreadProcessId
  211. AttachThreadInput = ctypes.windll.user32.AttachThreadInput
  212. IsChild = ctypes.windll.user32.IsChild
  213. IsWindow = ctypes.windll.user32.IsWindow
  214. IsWindowUnicode = ctypes.windll.user32.IsWindowUnicode
  215. IsWindowVisible = ctypes.windll.user32.IsWindowVisible
  216. IsWindowEnabled = ctypes.windll.user32.IsWindowEnabled
  217. MapVirtualKey = ctypes.windll.user32.MapVirtualKeyW
  218. OpenProcess = ctypes.windll.kernel32.OpenProcess
  219. ReadProcessMemory = ctypes.windll.kernel32.ReadProcessMemory
  220. Rectangle = ctypes.windll.gdi32.Rectangle
  221. SelectObject = ctypes.windll.gdi32.SelectObject
  222. SendMessage = ctypes.windll.user32.SendMessageW
  223. SendMessageA = ctypes.windll.user32.SendMessageA
  224. PostMessage = ctypes.windll.user32.PostMessageW
  225. SetActiveWindow = ctypes.windll.user32.SetActiveWindow
  226. GetFocus = ctypes.windll.user32.GetFocus
  227. SetFocus = ctypes.windll.user32.SetFocus
  228. SetForegroundWindow = ctypes.windll.user32.SetForegroundWindow
  229. GetForegroundWindow = ctypes.windll.user32.GetForegroundWindow
  230. SetWindowLong = ctypes.windll.user32.SetWindowLongW
  231. SystemParametersInfo = ctypes.windll.user32.SystemParametersInfoW
  232. VirtualAllocEx = ctypes.windll.kernel32.VirtualAllocEx
  233. VirtualFreeEx = ctypes.windll.kernel32.VirtualFreeEx
  234. VkKeyScan = ctypes.windll.user32.VkKeyScanW
  235. WriteProcessMemory = ctypes.windll.kernel32.WriteProcessMemory
  236. GetActiveWindow = ctypes.windll.user32.GetActiveWindow
  237. GetLastActivePopup = ctypes.windll.user32.GetLastActivePopup
  238. FindWindow = ctypes.windll.user32.FindWindowW
  239. GetTopWindow = ctypes.windll.user32.GetTopWindow
  240.  
  241. SetCapture = ctypes.windll.user32.SetCapture
  242. ReleaseCapture = ctypes.windll.user32.ReleaseCapture
  243.  
  244. GetGUIThreadInfo = ctypes.windll.user32.GetGUIThreadInfo
  245. ShowOwnedPopups = ctypes.windll.user32.ShowOwnedPopups
  246. WindowFromPoint = ctypes.windll.user32.WindowFromPoint
  247. GetMessage = ctypes.windll.user32.GetMessageW
  248. SendMessageTimeout = ctypes.windll.user32.SendMessageTimeoutW
  249.  
  250. WideCharToMultiByte = ctypes.windll.kernel32.WideCharToMultiByte
  251. GetACP = ctypes.windll.kernel32.GetACP
  252.  
  253. CreateProcess = ctypes.windll.kernel32.CreateProcessW
  254. TerminateProcess = ctypes.windll.kernel32.TerminateProcess
  255. ExitProcess = ctypes.windll.kernel32.ExitProcess
  256.  
  257. WaitForSingleObject = ctypes.windll.kernel32.WaitForSingleObject
  258. WaitForInputIdle = ctypes.windll.user32.WaitForInputIdle
  259.  
  260. GetWindowThreadProcessId = ctypes.windll.user32.GetWindowThreadProcessId
  261. OpenProcess = ctypes.windll.kernel32.OpenProcess
  262. GetModuleFileNameEx = ctypes.windll.psapi.GetModuleFileNameExW
  263.  
  264. GetClipboardData = ctypes.windll.user32.GetClipboardData
  265. OpenClipboard = ctypes.windll.user32.OpenClipboard
  266. CountClipboardFormats = ctypes.windll.user32.CountClipboardFormats
  267. EnumClipboardFormats = ctypes.windll.user32.EnumClipboardFormats
  268. CloseClipboard = ctypes.windll.user32.CloseClipboard
  269.  
  270. GlobalAlloc = ctypes.windll.kernel32.GlobalAlloc
  271. GlobalLock = ctypes.windll.kernel32.GlobalLock
  272. GlobalUnlock = ctypes.windll.kernel32.GlobalUnlock
  273.  
  274.  
  275. #====================================================================
  276. def MakeLong(low, high):
  277. "Pack high into the high word of a long and low into the low word"
  278. return (high << 16) | low


'프로그래밍언어 > Python' 카테고리의 다른 글

Python)계산기 SendMessage예제 Ctypes  (0) 2014.11.06
Python) 메모장에 텍스트보내기 파이썬3내장 ctypes  (0) 2014.11.06
프로세스종료  (0) 2014.10.29
SendMessage  (0) 2014.10.29
이미지 to Base64  (0) 2014.10.28