Jump to content
Sign in to follow this  

Problem using user32.dll

Recommended Posts

I am trying to remove a few buggy controlclicks from my application, and replace them with Enter-keypresses. The program runs on the background.

Somehow this code doesn't work.

The DllCalls give a @error = 0, so they should work. I also checked the handle code for the window, and its the right one.

I tried different Ascii codes, and I tried to use Asc($char).

Anyone know what could be wrong?

Global Const $WM_KEYDOWN = 0x0100
Global Const $WM_KEYUP = 0x0101
Global Const $WM_SETFOCUS = 0x0007
Global Const $WM_KILLFOCUS = 0x0008

WinWaitActive("Untitled - Notepad")
$hwnd = WinGetHandle("Untitled - Notepad")
DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd, "lparam", $WM_SETFOCUS, "wparam", 0, "lparam", 0)
DllCall("user32.dll", "int", "PostMessage", "hwnd", $hwnd, "lparam", $WM_KEYDOWN, "wparam", 13, "lparam", 0)
DllCall("user32.dll", "int", "PostMessage", "hwnd", $hwnd, "lparam", $WM_KEYUP, "wparam", 13, "lparam", 0)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd, "lparam", $WM_KILLFOCUS, "wparam", 0, "lparam", 0)
Edited by okdewit

Share this post

Link to post
Share on other sites

Thanks! That answers my question, and solves my problem.

I never knew there was a thing like ControlGetHandle()...

By the way, I'm new on this forum, so in case you were wondering:

I am an IT-consultant, and use Autoit for automating the "OOBE" process. We copy some files, change a few pictures, so the PC will leave with our logos and settings.

I want this automated process to run in the background, so I'm not bothered by it.

I also want to make a few silent-install scripts, and make some fixes for commonly encountered problems.


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  

  • Create New...