Sign in to follow this  
Followers 0
Kaiva

WinActivate Problems

3 posts in this topic

Hey, I'm having a problem with WinActivate. I'm trying to create a script for a game I play, however I've hit a snag. This is my code thus far:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

Global $Mana = 197
Global $Dir = "Up"
Global $Steps = 0
Global $Battle = 0


$hGUI = GUICreate("AutoIt V3- Example GUI", 400, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGUI") 
$hButton = GUICtrlCreateButton("Initialize!", 320, 260, 70, 25)
GUICtrlSetOnEvent($hButton, "StartProg") ; The button's function

GUISetState(@SW_SHOW)



While 1
    Sleep(10)
WEnd


Func StartProg()          ;My Function
    If $Dir == "Up" Then
        WinActivate("[CLASS:#32770]")
        WinWaitActive("[CLASS:#32770]","","3")
        Send("{UP}")
    Else
        MsgBox(0, "Test", "Something's wrong")
    EndIf
EndFunc


Func ExitGui ()
    Exit 
EndFunc

When I call my StartProg() function, it brings the window to the front, however it does not have focus (it's still semi-transparent). Therefore they keystroke does not get sent to it. How can I sort this?

Share this post


Link to post
Share on other sites



I did overlook that, yes; first rule too...

Nonetheless, the problem still remains.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0