ControlSend is sending keys everywhere

03/22/2015 16:56 WalrossGreat#1
Hi, I have problem with au3.
For example i have code like it:

ControlSend($game, "", "", "S")
Script is sending S, but when i open firefox, he is sending it to $game and to Firefox. After 5 minutes keyboard are getting bug. Keyboard is having press space/shift all the time etc. What is wrong? Is it au3 bug?

mfG Warloss.
03/22/2015 19:40 Moneypulation#2
You are not the only one. When I experimented with ControlClick, it was really weird as well. If you have any alternative, I would recommend you not to use ControlSend
03/22/2015 20:00 alpines#3
Try SendMessage, this should only click / send the window.
03/22/2015 20:46 WalrossGreat#4
Ok, I'm having

Code:
Local $hWnd = WinGetHandle("Notepad")
MsgBox("", "", $hWnd)
    If @error Then
        MsgBox("", "", "An error occurred when trying to retrieve the window handle of Notepad.")
        Exit
    EndIf
While 1
	_SendMessage($hWnd, 32)
	Sleep(300)
WEnd
But it is doing nothing after run script.
I found only it:
Code:
https://www.autoitscript.com/autoit3/docs/libfunctions/_SendMessage.htm
and the second parametr - $iMsg should be a number. It mean number of key, or what?
03/23/2015 00:03 alpines#5
No, it's the number of the message. w and l Param define the keys and position. There are plenty examples on the internet.
03/24/2015 17:51 fear-x#6
you should use Control Get Handle
Code:
;#Example
$Hwnd = WinGetHandle("[ACTIVE]","") ;click on active window
$Cwnd = ControlGetHandle($Hwnd, "", "")

controlsend($Cwnd, "", "", "")
just example. not correct code ofcourse.