Jump to content

The bumper thread of missing winapi examples.


JohnOne
 Share

Recommended Posts

_WinAPI_GetSystemMetrics 

#include <WindowsConstants.au3>
#include <WinAPI.au3>

ConsoleWrite(_WinAPI_GetSystemMetrics ( $SM_CXSCREEN ) & @LF)

;All constants defined in WindowsConstants.au3

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GetSystemTimes

#include <WinAPISys.au3>
#include <Array.au3>

$aSystemTimes = _WinAPI_GetSystemTimes()
If @error Then
    Exit MsgBox(0, "Failure", "_WinAPI_GetSystemTimes")
EndIf

_ArrayDisplay($aSystemTimes)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GetSystemWow64Directory

#include <APIErrors.au3>
#include <WinAPISys.au3>

$sWow64Directory = _WinAPI_GetSystemWow64Directory ( )

$iError = @error
If @extended = $ERROR_CALL_NOT_IMPLEMENTED Then
    Exit MsgBox(0, "Error", "32 bit OS")
EndIf

If $iError Then
    Exit MsgBox(0, "Failure", "_WinAPI_GetSystemWow64Directory")
EndIf

ConsoleWrite($sWow64Directory & @LF)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GetTempFileName

#include <WinAPIFiles.au3>

$sTempFileName = _WinAPI_GetTempFileName (@ScriptDir)

If @error Then
    Exit MsgBox(0, "Failure", "_WinAPI_GetTempFileName")
EndIf

ConsoleWrite($sTempFileName & @LF)
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GetVersionEx

#include <WinAPISys.au3>

$tOSVERSIONINFOEX = _WinAPI_GetVersionEx ( )
If @error Then
    Exit MsgBox (0, "failure", "_WinAPI_GetVersionEx")
EndIf

For $i = 1 To 11
    ConsoleWrite(DllStructGetData($tOSVERSIONINFOEX, $i) & @LF)
Next

; What these OSVERSIONINFOEX values are can be seen at this link (correct at time of post)
;http://msdn.microsoft.com/en-gb/library/windows/desktop/ms724833(v=vs.85).aspx

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GetWindowDC

#include <WinAPI.au3>

$DesktopDC = _WinAPI_GetWindowDC ( WinGetHandle("Program Manager") )

If Not $DesktopDC Then
    Exit MsgBox(0, "Failure", "_WinAPI_GetWindowDC")
EndIf

ConsoleWrite($DesktopDC  & @LF)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GetWindowFileName

#include <WinAPIProc.au3>

$PID = Run("notepad.exe")
ProcessWait($PID)

$sWindowFileName = _WinAPI_GetWindowFileName ( WinGetHandle("Untitled - Notepad") )
If @error Then
    ProcessClose($PID)
    Exit MsgBox(0, "Failure", "_WinAPI_GetWindowFileName")
EndIf

ProcessClose($PID)
ConsoleWrite($sWindowFileName & @LF)
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GetWindowHeight

_WinAPI_GetWindowWidth

#include <WinAPI.au3>

$PID = Run("notepad.exe")
ProcessWait($PID)

$hWnd =  WinGetHandle("Untitled - Notepad")

$Height = _WinAPI_GetWindowHeight($hWnd)
If @error Then
    ProcessClose($PID)
    Exit MsgBox(0, "Failure", "_WinAPI_GetWindowHeight")
EndIf

$Width = _WinAPI_GetWindowWidth($hWnd)
If @error Then
    ProcessClose($PID)
    Exit MsgBox(0, "Failure", "_WinAPI_GetWindowWidth")
EndIf

ProcessClose($PID)
ConsoleWrite($Width & @LF)
ConsoleWrite($Height & @LF)
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_GlobalMemoryStatus

#include <WinAPI.au3>
#include <Array.au3>

$MemoryStatus = _WinAPI_GlobalMemoryStatus()
If @error Then
    Exit MsgBox(0, "Failure", "_WinAPI_GlobalMemoryStatus")
EndIf

_ArrayDisplay($MemoryStatus)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_LoByte

_WinAPI_HiByte

#include <WinAPIMisc.au3>

$dsShort = DllStructCreate("short")
DllStructSetData($dsShort, 1, 12345)

$hiByte = _WinAPI_HiByte(DllStructGetData($dsShort, 1))
$loByte = _WinAPI_LoByte(DllStructGetData($dsShort, 1))

ConsoleWrite($hiByte & @LF & $loByte & @LF)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_InflateRect

#include <WinAPIGdi.au3>

$tRect = DllStructCreate($tagRECT)

DllStructSetData($tRect, "Left", 100)
DllStructSetData($tRect, "Top", 100)
DllStructSetData($tRect, "Right", 100)
DllStructSetData($tRect, "Bottom", 100)

ConsoleWrite("Struct before" & @LF)
For $i = 1 To 4
    ConsoleWrite(DllStructGetData($tRect, $i) & @LF)
Next

_WinAPI_InflateRect($tRect, 20, 20)

ConsoleWrite("Struct after" & @LF)
For $i = 1 To 4
    ConsoleWrite(DllStructGetData($tRect, $i) & @LF)
Next

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_IsChild

#include <WinAPISys.au3>

$AutWin = WinGetHandle(AutoItWinGetTitle())

$GUI = GUICreate("GUI")

GUICtrlCreateButton("button", 10, 10)

$hButton = ControlGetHandle($GUI, "", "[CLASS:Button; INSTANCE:1]")

If _WinAPI_IsChild($GUI, $AutWin) Then ; test our gui against autoit hidden window
    ConsoleWrite("True" & @LF)
Else
    ConsoleWrite("False" & @LF)
EndIf

If _WinAPI_IsChild($hButton, $GUI) Then ; Test our button against our gui
    ConsoleWrite("True" & @LF)
Else
    ConsoleWrite("False" & @LF)
EndIf
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

_WinAPI_IsClassName

#include <WinAPI.au3>

$GUI = GUICreate("GUI")

GUICtrlCreateButton("button", 10, 10)

$hButton = ControlGetHandle($GUI, "", "[CLASS:Button; INSTANCE:1]")

If _WinAPI_IsClassName($hButton, "Edit") Then
    ConsoleWrite("True" & @LF)
Else
    ConsoleWrite("False" & @LF)
EndIf

If _WinAPI_IsClassName($hButton, "Button") Then
    ConsoleWrite("True" & @LF)
Else
    ConsoleWrite("False" & @LF)
EndIf

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • 2 years later...

_WinAPI_AbortPath

#include <WinAPIGdi.au3>

$hDC = _WinAPI_GetDC(Null)

ConsoleWrite(_WinAPI_AbortPath($hDC) & @LF)

Function does not return true or false as stated in help file, it returns 1 or 0

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...