Jump to content

Have Program Only Work When In A Diablo Ii Game


Recommended Posts

Here is the code I have so far:

If WinExists ("Diablo II") Then
WinActivate ("Diablo II")
WinWaitActive ("Diablo II")
$WinPos = WinGetPos ("Diablo II")

Sleep(595)
Opt("SendKeyDelay", 0)
Sleep(0)

Send("{ENTER}")
Send("Test Message")
Send("{ENTER}")
Send("{ENTER}")
Send("Testing")
Send("{ENTER}")

Else
MsgBox(64, "Information", "Need to have DII Loaded.")
Exit
EndIf

Func Close()

EndFunc

How would I transform the MsgBox part to make it so that the program would only perform its functions in a game?

Edited by Arez
Link to comment
Share on other sites

If WinExists ("Diablo II") Then
WinActivate ("Diablo II")
WinWaitActive ("Diablo II")
$WinPos = WinGetPos ("Diablo II")

Sleep(595)
Opt("SendKeyDelay", 0)

Send("{ENTER}")
Send("Test Message")
Send("{ENTER}")
Send("{ENTER}")
Send("Testing")
Send("{ENTER}")

Else
MsgBox(64, "Information", "Need to have DII Loaded.")
Exit
EndIf

That should be all you need... But then again, i dont really understand your question that well..

Link to comment
Share on other sites

The code at the bottom will not execute if Diablo II is not open. But, if it is open anywhere else, such as pre-game lobby, or basically anywhere it will still execute.

I was wondering if there was a way to only have all of the code execute in game, and if they were anywhere else but in a game it'd come up with an error message saying "You must be in game to use this program".

Just thought maybe there was something to use.

Link to comment
Share on other sites

  • Moderators

You could always use the "exact title" Opt('WinTitleMatchMode', 3)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The Diablo II window never changes title, so any of that won't work. What you should do is check certain pixel places for colors that are only there if you're in-game (but have lots in case things are different). Or, you can just run the script when you're in a game, and you won't have to deal with any issues.

Link to comment
Share on other sites

  • Moderators

The Diablo II window never changes title, so any of that won't work. What you should do is check certain pixel places for colors that are only there if you're in-game (but have lots in case things are different). Or, you can just run the script when you're in a game, and you won't have to deal with any issues.

If it's a different window, even though it has the same title, wouldn't it have a different handle?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

It keeps the same window with the same title for the entire time. Nothing changes except the graphics inside.

Ahh, that explains a tad more... Guess I should play games :think: :Nah: :(

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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