Jump to content

DllCall() Function Help


Recommended Posts

Hi, I'm trying to write a small script that will send "3" to a few applications that their titles are the same lets say "app".

By using their handles I made the script to send "3" to each of them in turn.

Now my problem is I don't exactly understand how DllCall() works so I'll show you what I wrote and maybe you guys could guide me and correct me if I have something wrong with the script.

So here it is:

HotKeySet("+x","Terminate")
Func Terminate ()
    Exit 0      
EndFunc

Const $WMKEYDOWN = 0x100
Const $key = 0x33
$hwnd=WinList("app")
    While 1
        For $i=1 To $hwnd [0][0]
        DllCall("ggbp.dll","int","PostMessageA","HWnd",$hwnd [$i][1],"long",$WMKEYDOWN,"long",$key,"long")
        Next
    WEnd

ggbp.dll is a dll that by what I was told bypasses a block that a certain program has on PostMessage, which disables the use of Send() and ControlSend() to the app.

Using ggbp.dll and DllCall() is supposed to send the key "3" using the bypassed from of PostMessage which is PostMessageA.

I don't really know how does PostMessage works if someone would be kind enough to show me the correct way to write it or at least explain what I'm doing wrong.

Thanks.

Edited by Its2l82die
Link to comment
Share on other sites

Ok, got that now i started reading the the MSDN in microsofts website and now a lot is clear to me.

Do I have to add an lparam at the end of my first DllCall()or is it unnecessary?

And if I won't add a WM_KEYUP message it will act as if the key is still being pressed?

Thanks for you replies

EDIT:for some reason it doesn't work even with a Notepad.

Where should I put my Dll, at the same location where the script is or where the autoit3.exe is?

Edited by Its2l82die
Link to comment
Share on other sites

ok so this is how it looks after the revision but still it won't even send to the Notepad I don't know whats wrong with it =\

Thats how the new script looks like:

HotKeySet("+x","Terminate")
Func Terminate ()
    Exit 0      
EndFunc

Const $WMKEYDOWN = 0x100
Const $WMKEYUP = 0x101
Const $key = 0x33 
Const $lparam = 0
$hwnd=WinList("New Text Document - Notepad")
    While 1
        For $i=1 To $hwnd [0][0]
        $ggbp = DllOpen("ggbp.dll")
        DllCall($ggbp,"int","ggPMA","hwnd",$hwnd [$i][1],"long",$WMKEYDOWN,"long",$key,"long",$lparam,"long")
        DllCall($ggbp,"int","ggPMA","hwnd",$hwnd [$i][1],"long",$WMKEYUP,"long",$key,"long",$lparam,"long")
        $ggbp = DllClose("ggbp.dll")
        Next
    WEnd

Hope you can help.

EDIT: No result even with user32.dll its not different in Windows 7 X64 right?

Edited by Its2l82die
Link to comment
Share on other sites

DllCall($ggbp,"int","ggPMA","hwnd",$hwnd [$i][1],"long",$WMKEYDOWN,"long",$key,"long",$lparam,"long")
DllCall($ggbp,"int","ggPMA","hwnd",$hwnd [$i][1],"long",$WMKEYUP,"long",$key,"long",$lparam,"long")

Should be

DllCall($ggbp,"int","ggPMA","hwnd",$hwnd [$i][1],"long",$WMKEYDOWN,"long",$key,"long",$lparam,"long", 0)
DllCall($ggbp,"int","ggPMA","hwnd",$hwnd [$i][1],"long",$WMKEYUP,"long",$key,"long",$lparam,"long", 0)
Link to comment
Share on other sites

Thanks for the reply well now it did work but it sends just one character and thats it, while its in a endless loop strange.

maybe I should set the $lparam to something else?

And for some reason I get this >Exit code: -1073741819

Edited by Its2l82die
Link to comment
Share on other sites

Ok, well its not that the app is too slow I gave it a Sleep(200) still it sends only one character.

Do you know by any change what is what is the exit code -1073741819

EDIT: Never mind I found my problem. the Iparam was unnecessary for some reason.

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