Jump to content

Sleep time left in GUI


Recommended Posts

Hi I made a script for Diablo II that make game then wait to 'perm' this game. It simply wait untill you are in the lobby and then make a game and wait $time.

I want it displays the time remaining in a msgbox or something else.

There is a preview of my script.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.11.12 (beta)
 Author:         josnaker

 Script Function:
    Perm game in D2.

#ce ----------------------------------------------------------------------------

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>

HotKeySet("{ESC}","close")
HotKeySet("{HOME}","about")

#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
$title = GUICreate("GamePermer", 260, 150, 193, 125)
$gamelabel = GUICtrlCreateLabel("Nom de la Partie :", 16, 18, 88, 17)
$game = GUICtrlCreateInput("", 112, 15, 121, 21)
$passlabel = GUICtrlCreateLabel("Mot de passe :", 16, 52, 79, 17)
$pass = GUICtrlCreateInput("", 112, 48, 121, 21)
$OK = GUICtrlCreateButton("OK", 88, 115, 75, 25, 0)
$timelabel = GUICtrlCreateLabel("Secondes :", 16, 84, 79, 17)
$time = GuiCtrlCreateInput("5000",112, 80, 121, 21, $ES_NUMBER)
GUICtrlSetOnEvent($OK, "OK")
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func OK()
WinActivate("Diablo II")
If WinExists("Diablo II") = 0 Then MsgBox(0,"GamePermer","Veuillez lancer Diablo II et vous assurez que le titre est bien 'Diablo II'" & @LF & @LF & "Ensuite relancez GamePermer.")
If WinExists("Diablo II") = 0 Then Exit
WinActivate("Diablo II")
If WinActive("Diablo II") = 0 Then MsgBox(0,"GamePermer","Un problème est survenue pendant l'activation de la fenêtre de Diablo II." & @LF & @LF & "Veuillez relancez GamePermer.")
WinWaitActive("Diablo II")
WinMove("Diablo II","",0,0)
If PixelGetColor(154, 133) <> 263172 Then MsgBox(0,"GamePermer","Vous devez être dans le lobby avant de lancer GamePermer." & @LF & @LF & "Allez au lobby et relancez GamePermer.")
If PixelGetColor(154, 133) <> 263172 Then Exit
Sleep(500)
MouseClick("Left",715, 486)
Sleep(200)
MouseClick("Left",603, 494)
Sleep(600)
Send(GUICtrlRead($game))
Sleep(300)
Send("{TAB}")
Sleep(500)
Send(GUICtrlRead($pass))
MouseClick("Left",684, 445)
Sleep($time)    ;<<< The time remaining I want to be displayed.
MsgBox(0,"GamePermer","Votre partie est permer de " & $time & " secondes")
Exit
EndFunc

Func about()
    MsgBox(0,"GamePermer","GamePermer est un programme en AutoIt V3 et à été créé par SiRiUs[WoH] @ USWest." & @LF & "GamePermer 1.0" & @LF & "josnaker@hotmail.com")
EndFunc
Func close()
    Exit
EndFunc

It's in french but i think you can get the point.

Can anyone tell me how ?

Link to comment
Share on other sites

try now:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.11.12 (beta)
 Author:         josnaker

 Script Function:
    Perm game in D2.

#ce ----------------------------------------------------------------------------

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>

HotKeySet("{ESC}","close")
HotKeySet("{HOME}","about")

Global $timer1 = False
Global $timer

#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
$title = GUICreate("GamePermer", 260, 150, 193, 125)
$gamelabel = GUICtrlCreateLabel("Nom de la Partie :", 16, 18, 88, 17)
$game = GUICtrlCreateInput("", 112, 15, 121, 21)
$passlabel = GUICtrlCreateLabel("Mot de passe :", 16, 52, 79, 17)
$pass = GUICtrlCreateInput("", 112, 48, 121, 21)
$OK = GUICtrlCreateButton("OK", 88, 115, 75, 25, 0)
$timelabel = GUICtrlCreateLabel("Secondes :", 16, 84, 79, 17)
$time = GuiCtrlCreateInput("5000",112, 80, 121, 21, $ES_NUMBER)
GUICtrlSetOnEvent($OK, "OK")
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    if $timer1 = true Then
        $Read_time = GUICtrlRead($time)
        $passed_time = TimerDiff($timer)
        $Count_Down = Round(($Read_time-$passed_time)/1000, 0)
        TrayTip("", "Time left: " & $Count_Down, 10, 1)
        if $Count_Down <= 0 then
            TrayTip("", "", 10)
            $timer1 = False
        EndIf
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func OK()
WinActivate("Diablo II")
If WinExists("Diablo II") = 0 Then MsgBox(0,"GamePermer","Veuillez lancer Diablo II et vous assurez que le titre est bien 'Diablo II'" & @LF & @LF & "Ensuite relancez GamePermer.")
If WinExists("Diablo II") = 0 Then Exit
WinActivate("Diablo II")
If WinActive("Diablo II") = 0 Then MsgBox(0,"GamePermer","Un problème est survenue pendant l'activation de la fenêtre de Diablo II." & @LF & @LF & "Veuillez relancez GamePermer.")
WinWaitActive("Diablo II")
WinMove("Diablo II","",0,0)
If PixelGetColor(154, 133) <> 263172 Then MsgBox(0,"GamePermer","Vous devez être dans le lobby avant de lancer GamePermer." & @LF & @LF & "Allez au lobby et relancez GamePermer.")
If PixelGetColor(154, 133) <> 263172 Then Exit
Sleep(500)
MouseClick("Left",715, 486)
Sleep(200)
MouseClick("Left",603, 494)
Sleep(600)
Send(GUICtrlRead($game))
Sleep(300)
Send("{TAB}")
Sleep(500)
Send(GUICtrlRead($pass))
MouseClick("Left",684, 445)
$timer = TimerInit()
$timer1 = true
Sleep($time)    ;<<< The time remaining I want to be displayed.
MsgBox(0,"GamePermer","Votre partie est permer de " & $time & " secondes")
Exit
EndFunc

Func about()
    MsgBox(0,"GamePermer","GamePermer est un programme en AutoIt V3 et à été créé par SiRiUs[WoH] @ USWest." & @LF & "GamePermer 1.0" & @LF & "josnaker@hotmail.com")
EndFunc
Func close()
    Exit
EndFunc
Link to comment
Share on other sites

Thanks sandin for the answer but I tried and it send the msgbox when it make a game with 9 second

I.E.

Votre partie est permer de 9 secondes.

I think thats almost this and i'll try to fix it but if someone have an idea that would be nice

Thanks again sandin.

Edit : What I want it to do is simply display the time left before the time in the $time variable is at 0 (zero)

I don't know if you understand what I mean.

Edited by josnaker
Link to comment
Share on other sites

basicly this is the only thing I've changed:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}","close")
HotKeySet("{HOME}","about")
Global $timer1 = False
Global $timer
Opt("GUIOnEventMode", 1)
$title = GUICreate("GamePermer", 260, 150, 193, 125)
$gamelabel = GUICtrlCreateLabel("Nom de la Partie :", 16, 18, 88, 17)
$game = GUICtrlCreateInput("", 112, 15, 121, 21)
$passlabel = GUICtrlCreateLabel("Mot de passe :", 16, 52, 79, 17)
$pass = GUICtrlCreateInput("", 112, 48, 121, 21)
$OK = GUICtrlCreateButton("OK", 88, 115, 75, 25, 0)
$timelabel = GUICtrlCreateLabel("Secondes :", 16, 84, 79, 17)
$time = GuiCtrlCreateInput("5000",112, 80, 121, 21, $ES_NUMBER)
GUICtrlSetOnEvent($OK, "OK")
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState(@SW_SHOW)
While 1
    if $timer1 = true Then
        $Read_time = GUICtrlRead($time)
        $passed_time = TimerDiff($timer)
        $Count_Down = Round(($Read_time-$passed_time)/1000, 0)
        TrayTip("", "Time left: " & $Count_Down, 10, 1)
        if $Count_Down <= 0 then
            TrayTip("", "", 10)
            $timer1 = False
        EndIf
    EndIf
    Sleep(10)
WEnd
Func OK()
    $timer = TimerInit()
    $timer1 = true
    Sleep($time)    ;<<< The time remaining I want to be displayed.
EndFunc
Func about()
    MsgBox(0,"GamePermer","GamePermer est un programme en AutoIt V3 et à été créé par SiRiUs[WoH] @ USWest." & @LF & "GamePermer 1.0" & @LF & "josnaker@hotmail.com")
EndFunc
Func close()
    Exit
EndFunc
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...