Jump to content

Simple DllCall question


Jex
 Share

Recommended Posts

Link to comment
Share on other sites

Windows Datatype = DllCall Type

BOOL = "int"

COLORREF = "int"

DWORD = "int"

HANDLE = "ptr"

HDC = "ptr"

HFILE = "int"

HFONT = "ptr"

HICON = "ptr"

HINSTANCE = "ptr"

HKEY = "ptr"

HMENU = "ptr"

HMODILE = "ptr"

HWND = "hwnd"

INT = "int"

LONG = "long"

LPARAM = "long"

LPCTSTR = "str" ("wstr" if a UNICODE function)

LPINT = "int_ptr"

LPLONG = "long_ptr"

UINT = "int"

ULONG = "long"

WPARAM = "int"

$hwnd = GUICreate ("Tester")

GUISetState ()
Sleep (1000)
MsgBox (0, "", "GUI Should Close after this message")
$Test = DllCall("user32.dll", "int", "CloseWindow", "hwnd", $hwnd)
MsgBox("", "", $Test[0])
Link to comment
Share on other sites

I'm trying learn DllCall function but i can't manage to use that simple function : http://msdn2.microsoft.com/en-us/library/ms632678.aspx

Which type i need use for "BOOL" ?

$hwnd = "AutoIt"
$Test = DllCall("user32.dll", "", "CloseWindow", "hwnd", $hwnd)
MsgBox("", "", $Test)ƒoÝŠ÷ Ù8Z¶z-ŠäØ­º¹oÝ÷ Øyè·
+ú®¢×ºÚ"µÍÌÍÚÓHÚ[Ù][J ][ÝÉÌL
NÉÌL
ÍÎÉÌL
ÎNÉÌLNNÉÌL
ÉÌLLÎÉÌL
NÉÌL
NÉÌLNNÉÌLNÉ][ÝÊBØ[
    ][ÝÝÙÌ  ][ÝË  ][ÝÛÛI][ÝË ][ÝÐÛÜÙUÚ[ÝÉ][ÝË  ][ÝÚÛ    ][ÝË  ÌÍÚÓ
Link to comment
Share on other sites

$hwnd = GUICreate ("Test")
GUISetState()
Sleep(1000)
DllCall("user32.dll", "int", "MoveWindow", "hwnd", $hwnd, "int", "300", "int", "250", "int", "550", "int", "500", "int", "")
Sleep(3000)

Working ;)

But showing second window :P ?

Posted Image

By the way reason is why my first post script not work, I'm not used "WinGetHandle". ( Thanks Rasim )

Edited by Jex
Link to comment
Share on other sites

DragDetect Function

The DragDetect function captures the mouse and tracks its movement until the user releases the left button, presses the ESC key, or moves the mouse outside the drag rectangle around the specified point. The width and height of the drag rectangle are specified by the SM_CXDRAG and SM_CYDRAG values returned by the GetSystemMetrics function.

Syntax

BOOL DragDetect(

HWND hwnd,

POINT pt

);

Parameters

hwnd

[in] Handle to the window receiving mouse input.

pt

[in] Initial position of the mouse, in screen coordinates. The function determines the coordinates of the drag rectangle by using this point.

Return Value

If the user moved the mouse outside of the drag rectangle while holding down the left button, the return value is nonzero.

If the user did not move the mouse outside of the drag rectangle while holding down the left button, the return value is zero.

$Test = GUICreate("Test")
GUISetState()
Do
    $Pos = MouseGetPos()
    $Test = DllCall("user32.dll", "int", "DragDetect", "hwnd", $Test, "int", $Pos)
Until $Test <> 0

What i need write for POINT and pt ?

I think im writed completely wrong that script :P

Edited by Jex
Link to comment
Share on other sites

  • 1 month later...

$hwnd = GUICreate ("Test")
GUISetState()
Sleep(1000)
DllCall("user32.dll", "int", "MoveWindow", "hwnd", $hwnd, "int", "300", "int", "250", "int", "550", "int", "500", "int",True)
Sleep(3000)

is this OK for you?

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

I'm opened this topic 47 days ago but still thanks.

well I'm havong a problem like yours and I was searching the forum for answers and I found your topic and searched for answers for it in the msdn

and found that your missing parameter is only the [True] parameter, so I tried it and it worked

now my problem is that I want to move the GUI using the Dll function

just like using the WinMove() function in autoit

until now I'm getting the [MoveWindow] in the user32.dll , it ok but without animating the window

I want to slide the window with a sense of animation.

anyway if you have any ideas please don't be shy.

hope that your script is OK now.

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

The return is alway in an array:

$PID = Run("notepad.exe")
WinWait("Untitled - Notepad")
$hWin = WinGetHandle("Untitled - Notepad")
Sleep(2000)

$Test = DllCall("user32.dll", "int", "MoveWindow", "hwnd", $hWin, "int", 200, "int", 200, "int", 200, "int", 200, "int", True)
MsgBox(64, "Result", "$Test = " & $Test[0])
Sleep(2000)

$Test = DllCall("user32.dll", "int", "MoveWindow", "hwnd", $hWin, "int", 400, "int", 400, "int", 400, "int", 400, "int", True)
MsgBox(64, "Result", "$Test = " & $Test[0])
Sleep(2000)

$Test = DllCall("user32.dll", "int", "CloseWindow", "hwnd", $hWin)
MsgBox(64, "Result", "$Test = " & $Test[0])

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 months later...

Technically you did hi-jack it. This topic was about the question from Jex. Not you. So take the advice. Create a new topic.

Gah!

:)

Edited by Bert
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...