Jump to content

Recommended Posts

Posted

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.

Posted

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
Posted

Did you try the easy way first? ControlSend()

no.... i forget of that, because i never use it before...

This is not for me is for another user of the spanish forum, so i gonna ask him and come back with and answer... thanks

Posted

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.

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
×
×
  • Create New...