Sign in to follow this  
Followers 0
magician13134

DLL question

40 posts in this topic

How do you know the functions inside of a DLL? IS there a program to view them like the COM/OLE viewer? Like in this:

DllCall("user32.dll", "int", "ShowCursor", "int", 0)

This hides the cursor. Now I know CyberSlug is a genius, but he didn't just guess that "ShowCursor" was in user32. How do you find these? Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Looking at the windows header files for declared functions is one way. Another way is to go on MSDN and simply look at the win32api.

Win32API:

http://msdn.microsoft.com/library/default....i_reference.asp

ShowCursor function:

http://msdn2.microsoft.com/en-us/library/ms648396.aspx

- The Kandie Man ;-)

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ok... well... I'm having trouble figuring out how to use them... For instance I found one in user32.dll called GetCursorPos, and I know this is like MouseGetPos(), but how would I actually use the dll? can someone give me an example?

Edited by magician13134

Share this post


Link to post
Share on other sites

Ok... well... I'm having trouble figuring out how to use them... For instance I found one in user32.dll called GetCursorPos, and I know this is like MouseGetPos(), but how would I actually use the dll? can someone give me an example?

$tPoint = DllStructCreate("int X; int Y")
DllCall("User32.dll", "int", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
ConsoleWrite("Cursor X position: " & DllStructGetData($tPoint, "X") & @CR)
ConsoleWrite("Cursor Y position: " & DllStructGetData($tPoint, "Y") & @CR)

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

$tPoint = DllStructCreate("int X; int Y")
DllCall("User32.dll", "int", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
ConsoleWrite("Cursor X position: " & DllStructGetData($tPoint, "X") & @CR)
ConsoleWrite("Cursor Y position: " & DllStructGetData($tPoint, "Y") & @CR)

Hmmm.... I just get this no matter what:

Cursor X position: 0

Cursor Y position: 0

Share this post


Link to post
Share on other sites

Hmmm.... I just get this no matter what:

Cursor X position: 0

Cursor Y position: 0

Need latest version of AutoIt and make sure your mouse isn't in upper left hand corner of the screen. :)

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

I do and it's not... oh well, I found a couple other example on the forums

If you're not getting the right results from these 4 lines of code, one of the following is true:

1. You don't have the latest production version of AutoIt

2. You mangled the original script when you copied it

3. You're mouse is in the upper left hand corner of your screen

4. Some other really n00b thing that I haven't thought of yet

You pick. :)


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

If you're not getting the right results from these 4 lines of code, one of the following is true:

1. You don't have the latest production version of AutoIt

2. You mangled the original script when you copied it

3. You're mouse is in the upper left hand corner of your screen

4. Some other really n00b thing that I haven't thought of yet

You pick. :)

Uhhhh... NUMBER 1! I PICK NUMBER 1! Ok... sorry about that. It works... now can someone explain why? What exactly it all does?

Share this post


Link to post
Share on other sites

Uhhhh... NUMBER 1! I PICK NUMBER 1! Ok... sorry about that. It works... now can someone explain why? What exactly it all does?

NP. :) The MSDN link for GetCursorPos looks like this:

BOOL GetCursorPos(LPPOINT lpPoint);

So we know that the function returns a BOOL value (which is just an integer), takes a pointer to a POINT structure as input and is defined in User32.dll. If you look on MSDN, a POINT structure looks like this:

struct tagPOINT { 
  LONG x; 
  LONG y; 
}

So, back to the code that I gave you:

$tPoint = DllStructCreate("int X; int Y")
DllCall("User32.dll", "int", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
ConsoleWrite("Cursor X position: " & DllStructGetData($tPoint, "X") & @CR)
ConsoleWrite("Cursor Y position: " & DllStructGetData($tPoint, "Y") & @CR)

So, after using DllStructCreate to build a POINT structure, we call DllCall with the following:

1. The Dll where GetCursorPos is defined (User32.dll)

2. The return type expected (BOOL = "int")

3. The name of the Dll function (GetCursorPos)

4. A pointer to our POINT structure

When called, GetCursorPos get's the global cursor position and places it in our POINT structure, using the pointer that we passed. On return, we use DllStructGetData to extract the X and Y positions. Simple right? :)


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Uhhhh... NUMBER 1! I PICK NUMBER 1! Ok... sorry about that. It works... now can someone explain why? What exactly it all does?

Not a DLL-type myself, but I'll take a shot at it for the educational value:

$tPoint = DllStructCreate("int X; int Y")
DllCall("User32.dll", "int", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
ConsoleWrite("Cursor X position: " & DllStructGetData($tPoint, "X") & @CR)
ConsoleWrite("Cursor Y position: " & DllStructGetData($tPoint, "Y") & @CR)

First you reserve some space in memory for various values. This will be the "structure". It can contain lots of different type of values, but in this case simply reserves memory space for two integers to be called "X" and "Y". The pointer to their memory space is saved as $tPoint.

Next you call the User32.dll and pass it parameters as specified by it's code (completely different from dll to dll).

Of the parameters, the first is most confusing to me. Integer is obviously meant by "int", but what is that for, return code?

The second parameter is easy. "GetCursorPos" is a pretty plain-language verb telling the .dll what to do.

Third one seems to only tell what type the fourth is - it's a pointer ("ptr") to the memory structure we want the answer put in.

And fourthly, the actual pointer that tells it where in memory to put our answer.

The two lines after that that take advantage of the names given our structure elements "X" and "Y" to read out their values.

I just expended everything I know about .dll's, and I know it aint much, but we can keep learning from there... :)

Edit: PaulIA! Where's the fun in us dummies figuring it out if you smart people are just going to give away the answers like that! :)

Edited by PsaltyDS

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

Share this post


Link to post
Share on other sites

Not a DLL-type myself, but I'll take a shot at it for the educational value:

$tPoint = DllStructCreate("int X; int Y")
DllCall("User32.dll", "int", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
ConsoleWrite("Cursor X position: " & DllStructGetData($tPoint, "X") & @CR)
ConsoleWrite("Cursor Y position: " & DllStructGetData($tPoint, "Y") & @CR)

First you reserve some space in memory for various values. This will be the "structure". It can contain lots of different type of values, but in this case simply reserves memory space for two integers to be called "X" and "Y". The pointer to their memory space is saved as $tPoint.

Next you call the User32.dll and pass it parameters as specified by it's code (completely different from dll to dll).

Of the parameters, the first is most confusing to me. Integer is obviously meant by "int", but what is that for, return code?

The second parameter is easy. "GetCursorPos" is a pretty plain-language verb telling the .dll what to do.

Third one seems to only tell what type the fourth is - it's a pointer ("ptr") to the memory structure we want the answer put in.

And fourthly, the actual pointer that tells it where in memory to put our answer.

The two lines after that that take advantage of the names given our structure elements "X" and "Y" to read out their values.

I just expended everything I know about .dll's, and I know it aint much, but we can keep learning from there... :)

Edit: PaulIA! Where's the fun in us dummies figuring it out if you smart people are just going to give away the answers like that! :)

Dlls? Fun? What are YOU drinking (and where do I get some)? :)

"GetCursorPos" a verb? Well, more like the name of a function inside the Dll itself. It's like calling a UDF in AutoIt. Each one has it's own name, return type and parameter list. When you use DllCall, it loads the Dll, finds the function entry point, calls the function with the parameters that you supply and then returns the results. Yes, Jon is a genius. :P


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Dlls? Fun? What are YOU drinking (and where do I get some)? :)

"GetCursorPos" a verb? Well, more like the name of a function inside the Dll itself. It's like calling a UDF in AutoIt. Each one has it's own name, return type and parameter list. When you use DllCall, it loads the Dll, finds the function entry point, calls the function with the parameters that you supply and then returns the results. Yes, Jon is a genius. :)

Did the BOOL (= "int") return go anywhere? Or would that be captured by:

$iRetCode = DllCall("User32.dll", "int", ...)

:)


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

Share this post


Link to post
Share on other sites

Did the BOOL (= "int") return go anywhere? Or would that be captured by:

$iRetCode = DllCall("User32.dll", "int", ...)oÝ÷ Ù¹bOêº^!ò0jÉ÷öÛ(¬ò#]«Þ¸­µéâ·­è¥êëzË¥µÈ^rH§«­¢+ØÀÌØíÑA½¥¹Ðô±±MÑÉÕÑ
ÉÑ ÅÕ½Ðí¥¹Ð`쥹ÐdÅÕ½Ðì¤(ÀÌØíIÍÕ±Ðô±±
±° ÅÕ½ÐíUÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑ
ÕÉͽÉA½ÌÅÕ½Ðì°ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØíÑA½¥¹Ð¤¤)
½¹Í½±]É¥Ñ ÅÕ½ÐíIÑÕɸÉÍձи¸¸èÅÕ½ÐìµÀìÀÌØíIÍÕ±ÑlÁtµÀì
H¤)
½¹Í½±]É¥Ñ ÅÕ½Ðí
ÕÉͽÈ`Á½Í¥Ñ¥½¸èÅÕ½ÐìµÀì±±MÑÉÕÑÑÑ ÀÌØíÑA½¥¹Ð°ÅÕ½Ðí`ÅÕ½Ð줵Àì
H¤)
½¹Í½±]É¥Ñ ÅÕ½Ðí
ÕÉͽÈdÁ½Í¥Ñ¥½¸èÅÕ½ÐìµÀì±±MÑÉÕÑÑÑ ÀÌØíÑA½¥¹Ð°ÅÕ½ÐídÅÕ½Ð줵Àì
H¤

A 1 means it worked and a 0 means you did something really bad. :)


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Thanks! :)

I used 'ta couldn't spell DLL, now I own 'em. Thanks to PaulIA!

:)


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

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Hey, can I ask for help with one more issue? I want to user user32's GetWindowRect... any idea how? I've tried using the help file and searching the forums... this is what I've got, but it always returns 0, so I know it's wrong...

$win = WinGetHandle("")
$str        = "int;ubyte;uint;char"
$a          = DllStructCreate($str)
$dll = DllCall("user32.dll", DllStructGetPtr($a), "GetWindowRect", "hwnd", $win)
MsgBox(0, "", $int)
Edited by magician13134

Share this post


Link to post
Share on other sites

Hey, can I ask for help with one more issue? I want to user user32's GetWindowRect... any idea how? I've tried using the help file and searching the forums... this is what I've got, but it always returns 0, so I know it's wrong...

$win = WinGetHandle("")
$str        = "int;ubyte;uint;char"
$a          = DllStructCreate($str)
$dll = DllCall("user32.dll", DllStructGetPtr($a), "GetWindowRect", "hwnd", $win)
MsgBox(0, "", $int)
Defined in the A3LWinAPI.au3 module of Auto3Lib. Download a copy and save yourself a lot of grief. :)

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

I've tried that and it doesn't work. I get errors for 99% of them... I have the LATEST installed and I did everything just as it said... but it just doesn't work... (I'm talking about Auto3Lib)

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