just to make shure, you don´t use your keybord to push that bad-button
Code:
Gui +LastFoundExist
MyGuiHWND := WinExist("A")
Gui, Add, Button, x75 y120 w75 h20 -Theme HwndMyButton1HWND, AutoHotkey
Gui, Add, Button, x+5 w75 h20 -Theme vAI HwndMyButton2HWND, AutoIt3
Gui, Show,w306 h150, Which is your Favourite Software ?
OnMessage( 0x200, "M" )
OnMessage( 0x102, "F" )
OnMessage( 0x101, "F" )
Return
M() {
MouseGetPos,,,, CID
If ( CID = "Button2" ) {
Random,x,5,230
Random,y,5,130
GuiControl, Movedraw, AI, x%x% y%y%
}}
F()
{
global
GuiThreadInfoSize = 48
VarSetCapacity(GuiThreadInfo, GuiThreadInfoSize)
NumPut(GuiThreadInfoSize, GuiThreadInfo, 0)
if not DllCall("GetGUIThreadInfo", uint, 0, str, GuiThreadInfo)
{
Errorlevel = 1
return
}
CurrentFocus := NumGet(GuiThreadInfo, 12)
if !ErrorLevel
{
if (CurrentFocus = MyButton2HWND)
ControlFocus , , ahk_id %MyButton1HWND%
}
return
}