monoscout999 Posted June 26, 2011 Share Posted June 26, 2011 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 EndFuncI`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 More sharing options...
JohnOne Posted June 26, 2011 Share Posted June 26, 2011 Perhaps try adding a keyup message too. 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 More sharing options...
monoscout999 Posted June 26, 2011 Author Share Posted June 26, 2011 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 More sharing options...
AdmiralAlkex Posted June 26, 2011 Share Posted June 26, 2011 Did you try the easy way first? ControlSend() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
monoscout999 Posted June 26, 2011 Author Share Posted June 26, 2011 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 Link to comment Share on other sites More sharing options...
JohnOne Posted June 26, 2011 Share Posted June 26, 2011 I'm going to just have a guess at the lparam, but please I am usually wrong about these thingsOn the MSDN page you linked we see thisBits MeaningSo 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 More sharing options...
monoscout999 Posted June 27, 2011 Author Share Posted June 27, 2011 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 thingsOn the MSDN page you linked we see thisSo 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now