Sign in to follow this  
Followers 0
loki1982

using a .dll

6 posts in this topic

I am just starting to get into using .dll files and need a little direction.

I started looking at the _ispressed function to try to learn how to use a dll

Ok I started looking at misc.au3 and found the function _ispressed. It makes a dllcall to user32.dll. I downloaded a .dll function viewer so that I could see all the available functions. I follow the code and see that the function used is getasynckeystate function. So far Im following it but then this is where I get confused. How do I know how to use the function? Is there a guide, or a program that shows me how to use the dll function? Or am I totally confused on what I am supposed to be doing?

For example if I want to use the function getactivewindow is user32.dll where would I begin?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am just starting to get into using .dll files and need a little direction.

I started looking at the _ispressed function to try to learn how to use a dll

Ok I started looking at misc.au3 and found the function _ispressed. It makes a dllcall to user32.dll. I downloaded a .dll function viewer so that I could see all the available functions. I follow the code and see that the function used is getasynckeystate function. So far Im following it but then this is where I get confused. How do I know how to use the function? Is there a guide, or a program that shows me how to use the dll function? Or am I totally confused on what I am supposed to be doing?

For example if I want to use the function getactivewindow is user32.dll where would I begin?

You need to lookup the reference to the function you are trying to call (whether it be a DLL from the Windows API or some other library). Here's a link to the documentation on the function you are trying to call:

http://msdn.microsoft.com/en-us/library/ms646292(VS.85).aspx

Func _GetActiveWindow()
    $nRet = DllCall("user32.dll", "HWND", "GetActiveWindow")
    return $nRet[0]
EndFunc

$hWnd = GUICreate("test", 640, 480)
GUISetState()

if ($hWnd == _GetActiveWindow()) Then
    MsgBox(0, "", "Hey, my main window is on top. Sweet.")
EndIf
Edited by cppman

Share this post


Link to post
Share on other sites

You need to lookup the reference to the function you are trying to call (whether it be a DLL from the Windows API or some other library). Here's a link to the documentation on the function you are trying to call:

http://msdn.microsoft.com/en-us/library/ms646292(VS.85).aspx

Func _GetActiveWindow()
    $nRet = DllCall("user32.dll", "HWND", "GetActiveWindow")
    return $nRet[0]
EndFunc

$hWnd = GUICreate("test", 640, 480)
GUISetState()

if ($hWnd == _GetActiveWindow()) Then
    MsgBox(0, "", "Hey, my main window is on top. Sweet.")
EndIf

Thanks. You helped me a bunch. I think I can get it figured out now. the msdn site is what I needed. Really appreciate it.

Share this post


Link to post
Share on other sites

Thanks. You helped me a bunch. I think I can get it figured out now. the msdn site is what I needed. Really appreciate it.

To get the active window you can also use: WinGetTitle("")

Share this post


Link to post
Share on other sites

To get the active window you can also use: WinGetTitle("")

Yeah I was just using that function as an example.

I know there is a mouse move function already but I wanted to try to make my own dll call as a test so I did the following

Func _MS($x,$y)
  $test = dllcall("user32.dll","int","SetCursorPos","int",$x,"int",$y)
return $test

_MS(200,200)

and it worked. Im so excited, feel like I have a whole new set of command to test out now ; )

Share this post


Link to post
Share on other sites

Yeah I was just using that function as an example.

I know there is a mouse move function already but I wanted to try to make my own dll call as a test so I did the following

Func _MS($x,$y)
   $test = dllcall("user32.dll","int","SetCursorPos","int",$x,"int",$y)
 return $test
 
 _MS(200,200)

and it worked. Im so excited, feel like I have a whole new set of command to test out now ; )

Yeah, but it gets boring pretty quickly. :P

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