当前位置:首页 / 文章测试 / AutoIt3_Win_API

AutoIt3_Win_API

开始打字练习

#include-once

#include "AutoItConstants.au3"

#include "FileConstants.au3"

#include "MsgBoxConstants.au3"

#include "Security.au3"

#include "SendMessage.au3"

#include "StringConstants.au3"

#include "StructureConstants.au3"

#include "WinAPIConstants.au3"

#include "WinAPIError.au3"

; #INDEX# =======================================================================================================================

; Title .........: Windows API

; AutoIt Version : 3.3.13.12

; Description ...: Windows API calls that have been translated to AutoIt functions.

; Author(s) .....: Paul Campbell (PaulIA), gafrost, Siao, Zedna, arcker, Prog@ndy, PsaltyDS, Raik, jpm

; Dll ...........: kernel32.dll, user32.dll, gdi32.dll, comdlg32.dll, shell32.dll, ole32.dll, winspool.drv

; ===============================================================================================================================

; #VARIABLES# ===================================================================================================================

Global $__g_aInProcess_WinAPI[64][2] = [[0, 0]]

Global $__g_aWinList_WinAPI[64][2] = [[0, 0]]

; ===============================================================================================================================

; #CONSTANTS# ===================================================================================================================

Global Const $__WINAPICONSTANT_WM_SETFONT = 0x0030

Global Const $__WINAPICONSTANT_FW_NORMAL = 400

Global Const $__WINAPICONSTANT_DEFAULT_CHARSET = 1

Global Const $__WINAPICONSTANT_OUT_DEFAULT_PRECIS = 0

Global Const $__WINAPICONSTANT_CLIP_DEFAULT_PRECIS = 0

Global Const $__WINAPICONSTANT_DEFAULT_QUALITY = 0

Global Const $__WINAPICONSTANT_LOGPIXELSX = 88

Global Const $__WINAPICONSTANT_LOGPIXELSY = 90

; ===============================================================================================================================

; #CURRENT# =====================================================================================================================

; _WinAPI_AttachConsole

; _WinAPI_AttachThreadInput

; _WinAPI_Beep

; _WinAPI_BitBlt

; _WinAPI_CallNextHookEx

; _WinAPI_CallWindowProc

; _WinAPI_ClientToScreen

; _WinAPI_CloseHandle

; _WinAPI_CombineRgn

; _WinAPI_CommDlgExtendedError

; _WinAPI_CopyIcon

; _WinAPI_CreateBitmap

; _WinAPI_CreateCompatibleBitmap

; _WinAPI_CreateCompatibleDC

; _WinAPI_CreateEvent

; _WinAPI_CreateFile

; _WinAPI_CreateFont

; _WinAPI_CreateFontIndirect

; _WinAPI_CreatePen

; _WinAPI_CreateProcess

; _WinAPI_CreateRectRgn

; _WinAPI_CreateRoundRectRgn

; _WinAPI_CreateSolidBitmap

; _WinAPI_CreateSolidBrush

; _WinAPI_CreateWindowEx

; _WinAPI_DefWindowProc

; _WinAPI_DeleteDC

; _WinAPI_DeleteObject

; _WinAPI_DestroyIcon

; _WinAPI_DestroyWindow

; _WinAPI_DrawEdge

; _WinAPI_DrawFrameControl

; _WinAPI_DrawIcon

; _WinAPI_DrawIconEx

; _WinAPI_DrawLine

; _WinAPI_DrawText

; _WinAPI_DuplicateHandle

; _WinAPI_EnableWindow

; _WinAPI_EnumDisplayDevices

; _WinAPI_EnumWindows

; _WinAPI_EnumWindowsPopup

; _WinAPI_EnumWindowsTop

; _WinAPI_ExpandEnvironmentStrings

; _WinAPI_ExtractIconEx

; _WinAPI_FatalAppExit

; _WinAPI_FillRect

; _WinAPI_FindExecutable

; _WinAPI_FindWindow

; _WinAPI_FlashWindow

; _WinAPI_FlashWindowEx

; _WinAPI_FloatToInt

; _WinAPI_FlushFileBuffers

; _WinAPI_FormatMessage

; _WinAPI_FrameRect

; _WinAPI_FreeLibrary

; _WinAPI_GetAncestor

; _WinAPI_GetAsyncKeyState

; _WinAPI_GetBkMode

; _WinAPI_GetClassName

; _WinAPI_GetClientHeight

; _WinAPI_GetClientWidth

; _WinAPI_GetClientRect

; _WinAPI_GetCurrentProcess

; _WinAPI_GetCurrentProcessID

; _WinAPI_GetCurrentThread

; _WinAPI_GetCurrentThreadId

; _WinAPI_GetCursorInfo

; _WinAPI_GetDC

; _WinAPI_GetDesktopWindow

; _WinAPI_GetDeviceCaps

; _WinAPI_GetDIBits

; _WinAPI_GetDlgCtrlID

; _WinAPI_GetDlgItem

; _WinAPI_GetFocus

; _WinAPI_GetForegroundWindow

; _WinAPI_GetGuiResources

; _WinAPI_GetIconInfo

; _WinAPI_GetFileSizeEx

; _WinAPI_GetLastErrorMessage

; _WinAPI_GetLayeredWindowAttributes

; _WinAPI_GetModuleHandle

; _WinAPI_GetMousePos

; _WinAPI_GetMousePosX

; _WinAPI_GetMousePosY

; _WinAPI_GetObject

; _WinAPI_GetOpenFileName

; _WinAPI_GetOverlappedResult

; _WinAPI_GetParent

; _WinAPI_GetProcAddress

; _WinAPI_GetProcessAffinityMask

; _WinAPI_GetSaveFileName

; _WinAPI_GetStockObject

; _WinAPI_GetStdHandle

; _WinAPI_GetSysColor

; _WinAPI_GetSysColorBrush

; _WinAPI_GetSystemMetrics

; _WinAPI_GetTextExtentPoint32

; _WinAPI_GetTextMetrics

; _WinAPI_GetWindow

; _WinAPI_GetWindowDC

; _WinAPI_GetWindowHeight

; _WinAPI_GetWindowLong

; _WinAPI_GetWindowPlacement

; _WinAPI_GetWindowRect

; _WinAPI_GetWindowRgn

; _WinAPI_GetWindowText

; _WinAPI_GetWindowThreadProcessId

; _WinAPI_GetWindowWidth

; _WinAPI_GetXYFromPoint

; _WinAPI_GlobalMemStatus

; _WinAPI_GUIDFromString

; _WinAPI_GUIDFromStringEx

; _WinAPI_HiWord

; _WinAPI_InProcess

; _WinAPI_IntToFloat

; _WinAPI_IsClassName

; _WinAPI_IsWindow

; _WinAPI_IsWindowVisible

; _WinAPI_InvalidateRect

; _WinAPI_LineTo

; _WinAPI_LoadBitmap

; _WinAPI_LoadImage

; _WinAPI_LoadLibrary

; _WinAPI_LoadLibraryEx

; _WinAPI_LoadShell32Icon

; _WinAPI_LoadString

; _WinAPI_LocalFree

; _WinAPI_LoWord

; _WinAPI_MAKELANGID

; _WinAPI_MAKELCID

; _WinAPI_MakeLong

; _WinAPI_MakeQWord

; _WinAPI_MessageBeep

; _WinAPI_Mouse_Event

; _WinAPI_MoveTo

; _WinAPI_MoveWindow

; _WinAPI_MsgBox

; _WinAPI_MulDiv

; _WinAPI_MultiByteToWideChar

; _WinAPI_MultiByteToWideCharEx

; _WinAPI_OpenProcess

; _WinAPI_PathFindOnPath

; _WinAPI_PointFromRect

; _WinAPI_PostMessage

; _WinAPI_PrimaryLangId

; _WinAPI_PtInRect

; _WinAPI_ReadFile

; _WinAPI_ReadProcessMemory

; _WinAPI_RectIsEmpty

; _WinAPI_RedrawWindow

; _WinAPI_RegisterWindowMessage

; _WinAPI_ReleaseCapture

; _WinAPI_ReleaseDC

; _WinAPI_ScreenToClient

; _WinAPI_SelectObject

; _WinAPI_SetBkColor

; _WinAPI_SetBkMode

; _WinAPI_SetCapture

; _WinAPI_SetCursor

; _WinAPI_SetDefaultPrinter

; _WinAPI_SetDIBits

; _WinAPI_SetEndOfFile

; _WinAPI_SetEvent

; _WinAPI_SetFilePointer

; _WinAPI_SetFocus

; _WinAPI_SetFont

; _WinAPI_SetHandleInformation

; _WinAPI_SetLayeredWindowAttributes

; _WinAPI_SetParent

; _WinAPI_SetProcessAffinityMask

; _WinAPI_SetSysColors

; _WinAPI_SetTextColor

; _WinAPI_SetWindowLong

; _WinAPI_SetWindowPlacement

; _WinAPI_SetWindowPos

; _WinAPI_SetWindowRgn

; _WinAPI_SetWindowsHookEx

; _WinAPI_SetWindowText

; _WinAPI_ShowCursor

; _WinAPI_ShowError

; _WinAPI_ShowMsg

; _WinAPI_ShowWindow

; _WinAPI_StringFromGUID

; _WinAPI_StringLenA

; _WinAPI_StringLenW

; _WinAPI_SubLangId

; _WinAPI_SystemParametersInfo

; _WinAPI_TwipsPerPixelX

; _WinAPI_TwipsPerPixelY

; _WinAPI_UnhookWindowsHookEx

; _WinAPI_UpdateLayeredWindow

; _WinAPI_UpdateWindow

; _WinAPI_WaitForInputIdle

; _WinAPI_WaitForMultipleObjects

; _WinAPI_WaitForSingleObject

; _WinAPI_WideCharToMultiByte

; _WinAPI_WindowFromPoint

; _WinAPI_WriteConsole

; _WinAPI_WriteFile

; _WinAPI_WriteProcessMemory

; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================

; $tagCURSORINFO

; $tagDISPLAY_DEVICE

; $tagFLASHWINFO

; $tagICONINFO

; $tagMEMORYSTATUSEX

; __WinAPI_EnumWindowsAdd

; __WinAPI_EnumWindowsChild

; __WinAPI_EnumWindowsInit

; __WinAPI_ParseFileDialogPath

; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================

; Name...........: $tagCURSORINFO

; Description ...: Contains global cursor information

; Fields ........: Size - Specifies the size, in bytes, of the structure

; Flags - Specifies the cursor state. This parameter can be one of the following values:

; |0 - The cursor is hidden

; |$CURSOR_SHOWING - The cursor is showing

; hCursor - Handle to the cursor

; X - X position of the cursor, in screen coordinates

; Y - Y position of the cursor, in screen coordinates

; Author ........: Paul Campbell (PaulIA)

; Remarks .......:

; ===============================================================================================================================

Global Const $tagCURSORINFO = "dword Size;dword Flags;handle hCursor;" & $tagPOINT

; #INTERNAL_USE_ONLY# ===========================================================================================================

; Name...........: $tagDISPLAY_DEVICE

; Description ...: Receives information about the display device

; Fields ........: Size - Specifies the size, in bytes, of the structure

; Name - Either the adapter device or the monitor device

; String - Either a description of the display adapter or of the display monitor

; Flags - Device state flags:

; |$DISPLAY_DEVICE_ATTACHED_TO_DESKTOP - The device is part of the desktop

; |$DISPLAY_DEVICE_MIRRORING_DRIVER - Represents a pseudo device used to mirror drawing for remoting or other

; +purposes. An invisible pseudo monitor is associated with this device.

; |$DISPLAY_DEVICE_MODESPRUNED - The device has more display modes than its output devices support

; |$DISPLAY_DEVICE_PRIMARY_DEVICE - The primary desktop is on the device

; |$DISPLAY_DEVICE_REMOVABLE - The device is removable; it cannot be the primary display

; |$DISPLAY_DEVICE_VGA_COMPATIBLE - The device is VGA compatible.

; ID - This is the Plug and Play identifier

; Key - Reserved

; Author ........: Paul Campbell (PaulIA)

; Remarks .......:

; ===============================================================================================================================

Global Const $tagDISPLAY_DEVICE = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"

; #INTERNAL_USE_ONLY# ===========================================================================================================

; Name...........: $tagFLASHWINFO

; Description ...: Contains the flash status for a window and the number of times the system should flash the window

; Fields ........: Size - The size of the structure, in bytes

; hWnd - A handle to the window to be flashed. The window can be either opened or minimized.

; Flags - The flash status. This parameter can be one or more of the following values:

; |$FLASHW_ALL - Flash both the window caption and taskbar button

; |$FLASHW_CAPTION - Flash the window caption

; |$FLASHW_STOP - Stop flashing

; |$FLASHW_TIMER - Flash continuously, until the $FLASHW_STOP flag is set

; |$FLASHW_TIMERNOFG - Flash continuously until the window comes to the foreground

; |$FLASHW_TRAY - Flash the taskbar button

; Count - The number of times to flash the window

; Timeout - The rate at which the window is to be flashed, in milliseconds

; Author ........: Paul Campbell (PaulIA)

; Remarks .......: Needs Constants.au3 for pre-defined constants

; ===============================================================================================================================

Global Const $tagFLASHWINFO = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"

; #INTERNAL_USE_ONLY# ===========================================================================================================

; Name...........: $tagICONINFO

; Description ...: Contains information about an icon or a cursor

; Fields ........: Icon - Specifies the contents of the structure:

; |True - Icon

; |False - Cursor

; XHotSpot - Specifies the x-coordinate of a cursor's hot spot

; YHotSpot - Specifies the y-coordinate of the cursor's hot spot

; hMask - Specifies the icon bitmask bitmap

; hColor - Handle to the icon color bitmap

; Author ........: Paul Campbell (PaulIA)

; Remarks .......:

; ===============================================================================================================================

Global Const $tagICONINFO = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"

; #INTERNAL_USE_ONLY# ===========================================================================================================

; Name...........: $tagMEMORYSTATUSEX

; Description ...: Contains information memory usage

; Fields ........: Length - size of the structure, must be set before calling GlobalMemoryStatusEx

; MemoryLoad -

; TotalPhys -

; AvailPhys -

; TotalPageFile -

; AvailPageFile -

; TotalVirtual -

; AvailVirtual -

; AvailExtendedVirtual - Reserved

; Author ........: jpm

; Remarks .......:

; ===============================================================================================================================

Global Const $tagMEMORYSTATUSEX = "dword Length;dword MemoryLoad;" & _

"uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & _

"uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_AttachConsole($iPID = -1)

Local $aResult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $iPID)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_AttachConsole

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_AttachThreadInput($iAttach, $iAttachTo, $bAttach)

Local $aResult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iAttach, "dword", $iAttachTo, "bool", $bAttach)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_AttachThreadInput

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_Beep($iFreq = 500, $iDuration = 1000)

Local $aResult = DllCall("kernel32.dll", "bool", "Beep", "dword", $iFreq, "dword", $iDuration)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_Beep

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_BitBlt($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iROP)

Local $aResult = DllCall("gdi32.dll", "bool", "BitBlt", "handle", $hDestDC, "int", $iXDest, "int", $iYDest, "int", $iWidth, _

"int", $iHeight, "handle", $hSrcDC, "int", $iXSrc, "int", $iYSrc, "dword", $iROP)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_BitBlt

; #FUNCTION# ====================================================================================================================

; Author ........: Gary Frost

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CallNextHookEx($hHk, $iCode, $wParam, $lParam)

Local $aResult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hHk, "int", $iCode, "wparam", $wParam, "lparam", $lParam)

If @error Then Return SetError(@error, @extended, -1)

Return $aResult[0]

EndFunc ;==>_WinAPI_CallNextHookEx

; #FUNCTION# ====================================================================================================================

; Author ........: Siao

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CallWindowProc($pPrevWndFunc, $hWnd, $iMsg, $wParam, $lParam)

Local $aResult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $pPrevWndFunc, "hwnd", $hWnd, "uint", $iMsg, _

"wparam", $wParam, "lparam", $lParam)

If @error Then Return SetError(@error, @extended, -1)

Return $aResult[0]

EndFunc ;==>_WinAPI_CallWindowProc

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......: JPM

; ===============================================================================================================================

Func _WinAPI_ClientToScreen($hWnd, ByRef $tPoint)

Local $aRet = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPoint)

If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0)

Return $tPoint

EndFunc ;==>_WinAPI_ClientToScreen

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CloseHandle($hObject)

Local $aResult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hObject)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_CloseHandle

; #FUNCTION# ====================================================================================================================

; Author ........: Zedna

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CombineRgn($hRgnDest, $hRgnSrc1, $hRgnSrc2, $iCombineMode)

Local $aResult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hRgnDest, "handle", $hRgnSrc1, "handle", $hRgnSrc2, _

"int", $iCombineMode)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CombineRgn

; #FUNCTION# ====================================================================================================================

; Author ........: Gary Frost

; Modified.......: JPM

; ===============================================================================================================================

Func _WinAPI_CommDlgExtendedError()

Local Const $CDERR_DIALOGFAILURE = 0xFFFF

Local Const $CDERR_FINDRESFAILURE = 0x06

Local Const $CDERR_INITIALIZATION = 0x02

Local Const $CDERR_LOADRESFAILURE = 0x07

Local Const $CDERR_LOADSTRFAILURE = 0x05

Local Const $CDERR_LOCKRESFAILURE = 0x08

Local Const $CDERR_MEMALLOCFAILURE = 0x09

Local Const $CDERR_MEMLOCKFAILURE = 0x0A

Local Const $CDERR_NOHINSTANCE = 0x04

Local Const $CDERR_NOHOOK = 0x0B

Local Const $CDERR_NOTEMPLATE = 0x03

Local Const $CDERR_REGISTERMSGFAIL = 0x0C

Local Const $CDERR_STRUCTSIZE = 0x01

Local Const $FNERR_BUFFERTOOSMALL = 0x3003

Local Const $FNERR_INVALIDFILENAME = 0x3002

Local Const $FNERR_SUBCLASSFAILURE = 0x3001

Local $aResult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")

If Not @error Then

Switch $aResult[0]

Case $CDERR_DIALOGFAILURE

Return SetError($aResult[0], 0, "The dialog box could not be created." & @LF & _

"The common dialog box function's call to the DialogBox function failed." & @LF & _

"For example, this error occurs if the common dialog box call specifies an invalid window handle.")

Case $CDERR_FINDRESFAILURE

Return SetError($aResult[0], 0, "The common dialog box function failed to find a specified resource.")

Case $CDERR_INITIALIZATION

Return SetError($aResult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")

Case $CDERR_LOADRESFAILURE

Return SetError($aResult[0], 0, "The common dialog box function failed to load a specified resource.")

Case $CDERR_LOADSTRFAILURE

Return SetError($aResult[0], 0, "The common dialog box function failed to load a specified string.")

Case $CDERR_LOCKRESFAILURE

Return SetError($aResult[0], 0, "The common dialog box function failed to lock a specified resource.")

Case $CDERR_MEMALLOCFAILURE

Return SetError($aResult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")

Case $CDERR_MEMLOCKFAILURE

Return SetError($aResult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")

Case $CDERR_NOHINSTANCE

Return SetError($aResult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & _

"but you failed to provide a corresponding instance handle.")

Case $CDERR_NOHOOK

Return SetError($aResult[0], 0, "The ENABLEHOOK flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & _

"but you failed to provide a pointer to a corresponding hook procedure.")

Case $CDERR_NOTEMPLATE

Return SetError($aResult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & _

"but you failed to provide a corresponding template.")

Case $CDERR_REGISTERMSGFAIL

Return SetError($aResult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")

Case $CDERR_STRUCTSIZE

Return SetError($aResult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")

Case $FNERR_BUFFERTOOSMALL

Return SetError($aResult[0], 0, "The buffer pointed to by the lpstrFile member of the OPENFILENAME structure is too small for the file name specified by the user." & @LF & _

"The first two bytes of the lpstrFile buffer contain an integer value specifying the size, in TCHARs, required to receive the full name.")

Case $FNERR_INVALIDFILENAME

Return SetError($aResult[0], 0, "A file name is invalid.")

Case $FNERR_SUBCLASSFAILURE

Return SetError($aResult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")

EndSwitch

EndIf

Return SetError(@error, @extended, '0x' & Hex($aResult[0]))

EndFunc ;==>_WinAPI_CommDlgExtendedError

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CopyIcon($hIcon)

Local $aResult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hIcon)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CopyIcon

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreateBitmap($iWidth, $iHeight, $iPlanes = 1, $iBitsPerPel = 1, $pBits = 0)

Local $aResult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iWidth, "int", $iHeight, "uint", $iPlanes, _

"uint", $iBitsPerPel, "ptr", $pBits)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateBitmap

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)

Local $aResult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hDC, "int", $iWidth, "int", $iHeight)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateCompatibleBitmap

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreateCompatibleDC($hDC)

Local $aResult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hDC)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateCompatibleDC

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......: jpm

; ===============================================================================================================================

Func _WinAPI_CreateEvent($pAttributes = 0, $bManualReset = True, $bInitialState = True, $sName = "")

Local $sNameType = "wstr"

If $sName = "" Then

$sName = 0

$sNameType = "ptr"

EndIf

Local $aResult = DllCall("kernel32.dll", "handle", "CreateEventW", "ptr", $pAttributes, "bool", $bManualReset, _

"bool", $bInitialState, $sNameType, $sName)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateEvent

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......: jpm

; ===============================================================================================================================

Func _WinAPI_CreateFile($sFileName, $iCreation, $iAccess = 4, $iShare = 0, $iAttributes = 0, $pSecurity = 0)

Local $iDA = 0, $iSM = 0, $iCD = 0, $iFA = 0

If BitAND($iAccess, 1) <> 0 Then $iDA = BitOR($iDA, $GENERIC_EXECUTE)

If BitAND($iAccess, 2) <> 0 Then $iDA = BitOR($iDA, $GENERIC_READ)

If BitAND($iAccess, 4) <> 0 Then $iDA = BitOR($iDA, $GENERIC_WRITE)

If BitAND($iShare, 1) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_DELETE)

If BitAND($iShare, 2) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_READ)

If BitAND($iShare, 4) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_WRITE)

Switch $iCreation

Case 0

$iCD = $CREATE_NEW

Case 1

$iCD = $CREATE_ALWAYS

Case 2

$iCD = $OPEN_EXISTING

Case 3

$iCD = $OPEN_ALWAYS

Case 4

$iCD = $TRUNCATE_EXISTING

EndSwitch

If BitAND($iAttributes, 1) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_ARCHIVE)

If BitAND($iAttributes, 2) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_HIDDEN)

If BitAND($iAttributes, 4) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_READONLY)

If BitAND($iAttributes, 8) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_SYSTEM)

Local $aResult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sFileName, "dword", $iDA, "dword", $iSM, _

"ptr", $pSecurity, "dword", $iCD, "dword", $iFA, "ptr", 0)

If @error Or ($aResult[0] = $INVALID_HANDLE_VALUE) Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateFile

; #FUNCTION# ====================================================================================================================

; Author ........: Gary Frost

; Modified.......: jpm

; ===============================================================================================================================

Func _WinAPI_CreateFont($iHeight, $iWidth, $iEscape = 0, $iOrientn = 0, $iWeight = $__WINAPICONSTANT_FW_NORMAL, $bItalic = False, $bUnderline = False, $bStrikeout = False, $iCharset = $__WINAPICONSTANT_DEFAULT_CHARSET, $iOutputPrec = $__WINAPICONSTANT_OUT_DEFAULT_PRECIS, $iClipPrec = $__WINAPICONSTANT_CLIP_DEFAULT_PRECIS, $iQuality = $__WINAPICONSTANT_DEFAULT_QUALITY, $iPitch = 0, $sFace = 'Arial')

Local $aResult = DllCall("gdi32.dll", "handle", "CreateFontW", "int", $iHeight, "int", $iWidth, "int", $iEscape, _

"int", $iOrientn, "int", $iWeight, "dword", $bItalic, "dword", $bUnderline, "dword", $bStrikeout, _

"dword", $iCharset, "dword", $iOutputPrec, "dword", $iClipPrec, "dword", $iQuality, "dword", $iPitch, "wstr", $sFace)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateFont

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreateFontIndirect($tLogFont)

Local $aResult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "struct*", $tLogFont)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateFontIndirect

; #FUNCTION# ====================================================================================================================

; Author ........: Zedna

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreatePen($iPenStyle, $iWidth, $nColor)

Local $aResult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $iPenStyle, "int", $iWidth, "INT", $nColor)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreatePen

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......: jpm

; ===============================================================================================================================

Func _WinAPI_CreateProcess($sAppName, $sCommand, $pSecurity, $pThread, $bInherit, $iFlags, $pEnviron, $sDir, $pStartupInfo, $pProcess)

Local $tCommand = 0

Local $sAppNameType = "wstr", $sDirType = "wstr"

If $sAppName = "" Then

$sAppNameType = "ptr"

$sAppName = 0

EndIf

If $sCommand <> "" Then

; must be MAX_PATH characters, can be updated by CreateProcessW

$tCommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")

DllStructSetData($tCommand, "Text", $sCommand)

EndIf

If $sDir = "" Then

$sDirType = "ptr"

$sDir = 0

EndIf

Local $aResult = DllCall("kernel32.dll", "bool", "CreateProcessW", $sAppNameType, $sAppName, "struct*", $tCommand, _

"ptr", $pSecurity, "ptr", $pThread, "bool", $bInherit, "dword", $iFlags, "ptr", $pEnviron, $sDirType, $sDir, _

"ptr", $pStartupInfo, "ptr", $pProcess)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateProcess

; #FUNCTION# ====================================================================================================================

; Author ........: Zedna

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreateRectRgn($iLeftRect, $iTopRect, $iRightRect, $iBottomRect)

Local $aResult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $iLeftRect, "int", $iTopRect, "int", $iRightRect, _

"int", $iBottomRect)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateRectRgn

; #FUNCTION# ====================================================================================================================

; Author ........: Zedna

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreateRoundRectRgn($iLeftRect, $iTopRect, $iRightRect, $iBottomRect, $iWidthEllipse, $iHeightEllipse)

Local $aResult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $iLeftRect, "int", $iTopRect, _

"int", $iRightRect, "int", $iBottomRect, "int", $iWidthEllipse, "int", $iHeightEllipse)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateRoundRectRgn

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......: Gary Frost (Release DC), Yashied (rewritten)

; ===============================================================================================================================

Func _WinAPI_CreateSolidBitmap($hWnd, $iColor, $iWidth, $iHeight, $bRGB = 1)

Local $hDC = _WinAPI_GetDC($hWnd)

Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)

Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)

Local $hOld = _WinAPI_SelectObject($hDestDC, $hBitmap)

Local $tRECT = DllStructCreate($tagRECT)

DllStructSetData($tRECT, 1, 0)

DllStructSetData($tRECT, 2, 0)

DllStructSetData($tRECT, 3, $iWidth)

DllStructSetData($tRECT, 4, $iHeight)

If $bRGB Then

$iColor = BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16))

EndIf

Local $hBrush = _WinAPI_CreateSolidBrush($iColor)

If Not _WinAPI_FillRect($hDestDC, $tRECT, $hBrush) Then

_WinAPI_DeleteObject($hBitmap)

$hBitmap = 0

EndIf

_WinAPI_DeleteObject($hBrush)

_WinAPI_ReleaseDC($hWnd, $hDC)

_WinAPI_SelectObject($hDestDC, $hOld)

_WinAPI_DeleteDC($hDestDC)

If Not $hBitmap Then Return SetError(1, 0, 0)

Return $hBitmap

EndFunc ;==>_WinAPI_CreateSolidBitmap

; #FUNCTION# ====================================================================================================================

; Author ........: Gary Frost

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_CreateSolidBrush($nColor)

Local $aResult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "INT", $nColor)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateSolidBrush

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......: jpm

; ===============================================================================================================================

Func _WinAPI_CreateWindowEx($iExStyle, $sClass, $sName, $iStyle, $iX, $iY, $iWidth, $iHeight, $hParent, $hMenu = 0, $hInstance = 0, $pParam = 0)

If $hInstance = 0 Then $hInstance = _WinAPI_GetModuleHandle("")

Local $aResult = DllCall("user32.dll", "hwnd", "CreateWindowExW", "dword", $iExStyle, "wstr", $sClass, "wstr", $sName, _

"dword", $iStyle, "int", $iX, "int", $iY, "int", $iWidth, "int", $iHeight, "hwnd", $hParent, "handle", $hMenu, _

"handle", $hInstance, "ptr", $pParam)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_CreateWindowEx

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam)

Local $aResult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $iwParam, _

"lparam", $ilParam)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_DefWindowProc

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DeleteDC($hDC)

Local $aResult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hDC)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DeleteDC

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DeleteObject($hObject)

Local $aResult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hObject)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DeleteObject

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DestroyIcon($hIcon)

Local $aResult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hIcon)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DestroyIcon

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DestroyWindow($hWnd)

Local $aResult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hWnd)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DestroyWindow

; #FUNCTION# ====================================================================================================================

; Author ........: Gary Frost

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DrawEdge($hDC, $pRect, $iEdgeType, $iFlags)

Local $aResult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hDC, "ptr", $pRect, "uint", $iEdgeType, _

"uint", $iFlags)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DrawEdge

; #FUNCTION# ====================================================================================================================

; Author ........: Gary Frost

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DrawFrameControl($hDC, $pRect, $iType, $iState)

Local $aResult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hDC, "ptr", $pRect, "uint", $iType, _

"uint", $iState)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DrawFrameControl

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DrawIcon($hDC, $iX, $iY, $hIcon)

Local $aResult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hDC, "int", $iX, "int", $iY, "handle", $hIcon)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DrawIcon

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DrawIconEx($hDC, $iX, $iY, $hIcon, $iWidth = 0, $iHeight = 0, $iStep = 0, $hBrush = 0, $iFlags = 3)

Local $iOptions

Switch $iFlags

Case 1

$iOptions = $DI_MASK

Case 2

$iOptions = $DI_IMAGE

Case 3

$iOptions = $DI_NORMAL

Case 4

$iOptions = $DI_COMPAT

Case 5

$iOptions = $DI_DEFAULTSIZE

Case Else

$iOptions = $DI_NOMIRROR

EndSwitch

Local $aResult = DllCall("user32.dll", "bool", "DrawIconEx", "handle", $hDC, "int", $iX, "int", $iY, "handle", $hIcon, _

"int", $iWidth, "int", $iHeight, "uint", $iStep, "handle", $hBrush, "uint", $iOptions)

If @error Then Return SetError(@error, @extended, False)

Return $aResult[0]

EndFunc ;==>_WinAPI_DrawIconEx

; #FUNCTION# ====================================================================================================================

; Author ........: Zedna

; Modified.......:

; ===============================================================================================================================

Func _WinAPI_DrawLine($hDC, $iX1, $iY1, $iX2, $iY2)

_WinAPI_MoveTo($hDC, $iX1, $iY1)

If @error Then Return SetError(@error, @extended, False)

_WinAPI_LineTo($hDC, $iX2, $iY2)

If @error Then Return SetError(@error + 10, @extended, False)

Return True

EndFunc ;==>_WinAPI_DrawLine

; #FUNCTION# ====================================================================================================================

; Author ........: Paul Campbell (PaulIA)

; Modified.......: jpm

; ===============================================================================================================================

Func _WinAPI_DrawText($hDC, $sText, ByRef $tRECT, $iFlags)

Local $aResult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sText, "int", -1, "struct*", $tRECT, _

"uint", $iFlags)

If @error Then Return SetError(@error, @extended, 0)

Return $aResult[0]

EndFunc ;==>_WinAPI_DrawText

; #FUNCTION# ====================================================================================================================

; Author ........: trancexx

; Modified.......:

Func _WinAPI_DuplicateHandle($hSourceProcessHandle, $hSourceHandle, $hTargetProcessHandle, $iDesiredAccess, $bInheritHandle, $iOptions)

Local $aResult = DllCall("kernel32.dll", "bool", "DuplicateHandle", _

"handle", $hSourceProcessHandle, _

"handle", $hSourceHandle, _

"handle", $hTargetProcessHandle, _

"handle*", 0, _

"dword", $iDesiredAccess, _

"bool", $bInheritHandle, _

"dword", $iOptions)

声明:以上文章均为用户自行发布,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。