Jump to content

Recommended Posts

Posted (edited)

So I've taken bits and pieces of information from all over the place and put them together. It does what I want it to do for the most part. There are just a few issues that have me wondering.

Here's the code:

WinSetTitle ("game","","game 2")
WinWaitActive("game")


HotKeySet("{PAUSE}", "Start")
HotKeySet("!{PAUSE}","Quit")

TogglePause()

func Start()
HotKeySet("{PAUSE}")
HotKeySet("{PAUSE}", "TogglePause")
ToolTip('SendSpace started.',0,0)
While 1
ControlSend("game", "", "", "{SPACE}")
ControlSend("game 2", "", "", "{SPACE}")
Sleep(Random(120000,240000))
WEnd
EndFunc

Func TogglePause()
ToolTip('SendSpace Stopped.',0,0)
HotKeySet("{PAUSE}")
HotKeySet("{PAUSE}", "Start")
While 1
sleep(100)
WEnd
EndFunc

func Quit()
Exit
EndFunc

So here's my situation. I have two instances of the game open. I changed one of the instance's title to game 2 to differentiate between the two windows. Now when I run the script it successfully manages to send "Space" to both windows when they're inactive only when game was the last one to be active. However, if game 2 was the last window to be active the script only successfully sends "Space" to game 2 and not game.

I was wondering how I could fix the code such that the script successfully sends "Space" regardless of which window, game or game 2, I had active last.

I'm new to AutoIt and any clarification would be greatly appreciated.

Edited by sillyfool
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...