Page 1 of 1

ProgressBar mit Taste starten

Posted: 13 Nov 2016, 09:54
by Aso
Guten Tag,

ich habe für ein MMO Spiel folgende idee.
Ich möchte wenn ich zb die Taste F2 drücke das eine Fähigkeit aktiviert wird mit send, 2
und eine Progress bar startet die in 30 sekunden voll ist.
Nun habe ich folgendes gefunden, jedoch wenn ich zb F3 drücke startet die 2. Bar und die erste hört auf was gemäß code auch logisch ist aber wie kann ich das ändern?
Der erste balken soll ganz normal weiterlaufen unabhängig davon ob ich F3 drücke oder F2 drücke.

Code: Select all

Gui,1:Add,Progress,    x10  y10 w400 h20  vPRBAR cFF7200
Gui,1:Add,Text, cBlack x10  y10 w400 h20 +0x200 +Center +BackgroundTrans vText22,        ;here empty 
Gui,1:Add,Progress,    x10  y40 w400 h20  vPRBAR1 cFF7200
Gui,1:Add,Text, cBlack x10  y40 w400 h20 +0x200 +Center +BackgroundTrans vText33,        ;here empty 
Gui,1:Show, w400 h200 , 

F2::
GuiControl,, PRBAR, 0
loop, 100
{
 GuiControl,, PRBAR, +1
 GuiControl,1:,Text22,%A_Index%    ;to fill progressbar later
 sleep, 60
}

Return

F3::
GuiControl,, PRBAR1, 0
loop, 100
{
 GuiControl,, PRBAR1, +1
 GuiControl,1:,Text33,%A_Index%    ;to fill progressbar later
 sleep, 60
}

Return

Re: ProgressBar mit Taste starten

Posted: 22 Feb 2018, 20:42
by Aso
jemand eine idee?

Re: ProgressBar mit Taste starten

Posted: 23 Feb 2018, 02:38
by nnnik
Du müsstest SetTimer anstatt Loop verwenden.

Re: ProgressBar mit Taste starten

Posted: 23 Feb 2018, 05:26
by wolf_II
Versuch mal:

Code: Select all

#NoEnv
#SingleInstance, Force

    global Timer2 := Func("incrementBar").Bind(2)
    global Timer3 := Func("incrementBar").Bind(3)

    BarOptions = cFF7200 w400 h50
    TextOptions = xp yp wp hp Center BackgroundTrans 0x200 ; SS_CENTERIMAGE

    Gui, Add, Progress, vBarF2 %BarOptions%
    Gui, Add, Text,     vTxtF2 %TextOptions%
    Gui, Add, Progress, vBarF3 %BarOptions%
    Gui, Add, Text,     vTxtF3 %TextOptions%
    Gui, Show

Return

GuiClose:
ExitApp

F2:: startBar(2)
F3:: startBar(3)


;-------------------------------------------------------------------------------
startBar(n) { ; start bar number n
;-------------------------------------------------------------------------------
    GuiControl,, BarF%n%, 0
    SetTimer, % Timer%n%, 10
}


;-------------------------------------------------------------------------------
incrementBar(n) { ; increment bar number n
;-------------------------------------------------------------------------------
    GuiControl,, BarF%n%, +1
    GuiControlGet, Count,, BarF%n%
    GuiControl,, TxtF%n%, %Count%

    If (Count = 100)
        SetTimer, % Timer%n%, Off
}
Ich hoffe das hilft.

Re: ProgressBar mit Taste starten

Posted: 23 Feb 2018, 15:06
by Aso
wow wolf dankeschööön es funktioniert super! :D