Sign in to follow this  
Followers 0
Arez

Have Program Only Work When In A Diablo Ii Game

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You didn't like the answers given in your other thread on this same topic?

http://www.autoitscript.com/forum/index.ph...showtopic=24237

Edit: What is your current script doing that you do not like?

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
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..

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
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.

Share this post


Link to post
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.

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

[center]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.[/center]

Share this post


Link to post
Share on other sites

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

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

Share this post


Link to post
Share on other sites

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: :(

[center]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.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0