Jump to content

[Is Possible?] _SendMessage - VM_KEYDOWN


Recommended Posts

Hi i come with this doubt from the spanish Autoit forum, i need to send keys (F1 and F3) to a window in a sequence of time in seconds, that part is solved, now what i want to know. Is possible send keys to an inactive window trough the _sendMessage Function?

I havent found an examplo of this type of use of the sendmessage function.. this is my test script...

I attempt to open the notepad help, sending the F1 key to the notepad window. so far i can`t

#include <SendMessage.au3>
#include <Array.au3>
_Main()

Func _Main()
    Local Const $WM_KEYDOWN = 0x0100
    Local Const $VK_F1 = 0x70
    Opt("WinTitleMatchMode", 4)
    $hwnd = WinGetHandle('classname=Notepad')
    $ret = _SendMessage($hWnd, $WM_KEYDOWN, $VK_F1, 0,-1)
    If @error Then
        MsgBox(0,"", "_SendMessage Error: " & @error)
        Exit
    Else
         _arraydisplay($ret)
         Exit
    EndIf
EndFunc

I`m getting the info from here MSDN Link i have problems to understand how to set the lParam of the message.

Link to comment
Share on other sites

I try this but doesn`t work... :S i cant understand the what, why and how of the lparam... or maybe this is not possible.

#include <SendMessage.au3>
#include <Array.au3>
_Main()

Func _Main()
    Local Const $Off = 2, $On = -1
    Local Const $WM_KEYDOWN = 0x0100
    Local Const $WM_KEYUP = 0x0101
    Local Const $VK_F1 = 0x70
    Opt("WinTitleMatchMode", 4)
    $hwnd = WinGetHandle('classname=Notepad')
    $ret = _SendMessage($hwnd, $WM_KEYDOWN, $VK_F1, 0, -1)
    If @error Then
        MsgBox(0, "", "_SendMessage Error: " & @error)
        Exit
    Else
;~       _arraydisplay($ret)
    EndIf
    $ret = _SendMessage($hwnd, $WM_KEYUP, $VK_F1, 0, -1)
    If @error Then
        MsgBox(0, "", "_SendMessage Error: " & @error)
    Else
        _ArrayDisplay($ret)
    EndIf
EndFunc   ;==>_Main
Link to comment
Share on other sites

I'm going to just have a guess at the lparam, but please I am usually wrong about these things

On the MSDN page you linked we see this

Bits Meaning

So maybe its a BitOR() or BitAnd() you need to pass :)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

It works with controlsend() thanks AdmiralAlkex.

About this...

because i still want to learn if windows can do this by message system...

I'm going to just have a guess at the lparam, but please I am usually wrong about these things

On the MSDN page you linked we see this

So maybe its a BitOR() or BitAnd() you need to pass :)

I`m not fully understand how to use it, i think i´m gonna keep searching for some example in VB or something that showsme the way of use it.
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...