Sign in to follow this  
Followers 0
JohnD

Dllcall & Sendmessage

10 posts in this topic

Hi everyone. I am not able to get dllcall to work with send message.

$result = DllCall("user32.dll", "int", "Sendmessage", "hwnd", $Edithwnd, "ULONG", $WM_SETTEXT, "WPARAM", 0, "LPARAM", "Hello World.")

Anyone know what I am missing here? This is for a control not in my application.

Thanks.

-JD

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

"ULONG" should be "UINT" and the return value isn't and integer, it's an lresult (not quite sure what that is in DllCall() though)

http://msdn.microsoft.com/en-us/library/ms644950%28VS.85%29.aspx

EDIT: Oh hey 500

Edited by Minikori

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

What is @error returned by DllCall? I'll bet it's '3 "function" not found in the DLL file'. DllCall function names are case sensitive.

Share this post


Link to post
Share on other sites

What is @error returned by DllCall? I'll bet it's '3 "function" not found in the DLL file'. DllCall function names are case sensitive.

Actually, the return value is 0, indicating success. I changed ULONG to UINT but it still doesn't place the text. The constant is declared along with there being a valid window handle, so I don't know what else it could be.

$result = DllCall("user32.dll", "int", "Sendmessage", "hwnd", $Edithwnd, "UINT", $WM_SETTEXT, "WPARAM", 0, "LPARAM", "Hello World.")

Share this post


Link to post
Share on other sites

wraithdu was talking about the value of @error.

Also, when DllCall returns 0, that's an indicator of error. DllCall returns an array on a successful call.

Share this post


Link to post
Share on other sites

Sorry, that wasn't clear. It is @error returning 0, not 3.

Share this post


Link to post
Share on other sites

Sorry, that wasn't clear. It is @error returning 0, not 3.

...sure it is

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

There is no function called "Sendmessage" in that dll. There's no way @error says 0.

Share this post


Link to post
Share on other sites

Look at SendMessage.au3 in your include folder for some information. Perhaps just include SendMessage.au3 and use that. :mellow:

Syntax

_SendMessage($hWnd, $iMsg[, $wParam = 0[, $lParam = 0[, $iReturn = 0[, $wParamType = "wparam"[, $lParamType = "lparam"[, $sReturnType = "lresult"]]]]]])

Function in SendMessage.au3

Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
    Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
    If @error Then Return SetError(@error, @extended, "")
    If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
    Return $aResult
EndFunc   ;==>_SendMessage

Include it

#include <SendMessage.au3>

Share this post


Link to post
Share on other sites

Look at SendMessage.au3 in your include folder for some information. Perhaps just include SendMessage.au3 and use that. :mellow:

Syntax

_SendMessage($hWnd, $iMsg[, $wParam = 0[, $lParam = 0[, $iReturn = 0[, $wParamType = "wparam"[, $lParamType = "lparam"[, $sReturnType = "lresult"]]]]]])

Function in SendMessage.au3

Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
    Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
    If @error Then Return SetError(@error, @extended, "")
    If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
    Return $aResult
EndFunc   ;==>_SendMessage

Include it

#include <SendMessage.au3>

Thanks MHz! It took a little tinkering bc I am new to this language but I got it working. I appreciate the help.

Share this post


Link to post
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
Sign in to follow this  
Followers 0