Jump to content

User32.au3


Kip
 Share

Recommended Posts

Title says enough.

I created it with an automatic MSDN page downloader, so some of the datatypes can be wrong.

Let me know if you see any.

Anyway:

User32.au3

I hope you like it.

None of the functions have any descriptions. Just use MSDN for that.

Edited by Kip
Link to comment
Share on other sites

Heh, cool, some are not correct. For example, _User32_WindowFromPoint() is not correct. When you see a structure specified as a parameter as opposed to a handle or pointer to this structure, it means pushing all it's members (in the case of union it's the greatest sized members) on the stack and calling it. So it should be:

DllCall('user32.dll',"hwnd","WindowFromPoint","int", 100, "int", 200)

...for example.

Link to comment
Share on other sites

Looks like good work!

Here are my recommendations:

- you can also make UDF for kernel32.dll, gdi32.dll, shell32.dll

- you can quite easily add also generated function header (look at WinAPI.au3)

- after each dllcall() add this: If @error Then Return SetError(@error, 0, 0)

- remove from your final UDF functions which are already in standard includes (WinAPI)

Edited by Zedna
Link to comment
Share on other sites

Good, but unfortunately, most of these functions does not help the user work.

$Result = _User32_...(...)

vs

$Result = DllCall('user32.dll', ...)

$Result = $Result[0]

Usefulness is questionable. It would be better adapt to AutoIt with the user interests.

For example (from WinAPIEx.au3):

Func _WinAPI_GetKeyboardLayoutList()

    Local $Ret

    $Ret = DllCall('user32.dll', 'int', 'GetKeyboardLayoutList', 'int', 0, 'ptr', 0)
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf

    Local $tData = DllStructCreate('ptr[' & $Ret[0] & ']')

    $Ret = DllCall('user32.dll', 'int', 'GetKeyboardLayoutList', 'int', $Ret[0], 'ptr', DllStructGetPtr($tData))
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    
    Local $List[$Ret[0] + 1] = [$Ret[0]]
    
    For $i = 1 To $List[0]
        $List[$i] = BitAND(DllStructGetData($tData, 1, $i), 0xFFFF)
    Next
    Return $List
EndFunc   ;==>_WinAPI_GetKeyboardLayoutList

Your function:

func _User32_GetKeyboardLayoutList(  $nBuff, $lpList  )
    local $vRetVal = DllCall($User32,"UINT","GetKeyboardLayoutList","int",$nBuff,"hwnd*",$lpList)
    return $vRetVal[0]
EndFunc

Just for thought...

Link to comment
Share on other sites

Good, but unfortunately, most of these functions does not help the user work.

$Result = _User32_...(...)

vs

$Result = DllCall('user32.dll', ...)

$Result = $Result[0]

Usefulness is questionable

Well, you don't have to know the data types.

I really prefer:

$iResult = _User32_IsChild(  $hWndParent, $hWnd  )

over

$iResult = DllCall($User32,"int","IsChild","hwnd",$hWndParent,"hwnd",$hWnd)
$iResult = $iResult[0]

Heh, cool, some are not correct. For example, _User32_WindowFromPoint() is not correct. When you see a structure specified as a parameter as opposed to a handle or pointer to this structure, it means pushing all it's members (in the case of union it's the greatest sized members) on the stack and calling it. So it should be:

Eerm, huh? Edited by Kip
Link to comment
Share on other sites

  • 1 month later...

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...