Progress

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Progress

05 Sep 2017, 10:28

Moin,
ich eiere aktuell an einer fortschrittsanzeige herum. Deren vorbild läuft auf meinem Sony Bravia.
Links wird die startzeit der laufenden sendung angezeigt, rechts die endzeit.

Zwischen beiden zeitangaben liegt eine zeitachse, welche aus vier gleich langen abschnitten besteht.
Die drei jeweiligen "lücken" dieser zeitachse stehen für 25%/50%/75% der verstrichenen gesamtlaufzeit.
Oberhalb der zeitachse läuft der zeiger (ähnlich einer nabla, einem auf dem kopf stehenden dreieck), dessen position die aktuelle/verstrichene zeit auf der zeitachse in bezug auf die gesamtlaufzeit anzeigt.
Hier stellvertretend durch die vertikale linie dargestellt

12:30 ___|___ ___ ___ 13:15 (es wären hier 25% der 45min gesamtlaufzeit verstrichen)

Als bekennender logik-legastheniker stelle ich mir vor, das die laufzeit (in sekunden) gegen die fixe länge des fortschrittsbalkens (in pixeln) zu rechnen ist.
Daraus sollte sich bei langer laufzeit eine verzögerte, bei kurzer laufzeit eine beschleunigte schrittfolge auf der zeitachse ergeben.
Bekomme den zeiger via SetTimer und GuiControl, Move ... bewegt, allerdings nicht wirklich synchron zur tatsächlich verstrichenen zeit.
Ich halluziniere bereits zw mehrwertsteuerformel und pixelbreite des zeigers herum ... :silent:

Die lösende formel bringt, wie üblich, dem geneigten supporter, sowie deren/dessen ahnen und nachkommen immerwährende dankbarkeit !! :shifty:
baldimkino
Posts: 4
Joined: 19 Aug 2017, 14:15

Re: Progress

05 Sep 2017, 10:53

start+(end-start)*percent/100
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

05 Sep 2017, 12:30

baldimkino wrote:start+(end-start)*percent/100
Merci schon mal für die antwort :thumbup:

Die prozentangabe entspräche der position des zeigers auf der zeitachse. IMHO müsste ich nun die aktuelle zeit gegen die einzelnen, den prozentwerten zugeordneten zeiten vergleichen. Das gelingt mir aktuell nicht. Die ausgabe der formel ergibt werte/zeiten wie 20170905126740 (12:67:40), welche bei der übergabe an FormatTime eine leere ausgabe ergeben... :|

:?:
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Progress

05 Sep 2017, 12:40

Zeitgeist.

Code: Select all

q:: ;works for HH:mm or mm:ss
vStart := "12:30" ;HH:mm
vEnd := "13:15" ;HH:mm
vPct := 25
;vPct := 75
oStart := StrSplit(vStart, ":")
oEnd := StrSplit(vEnd, ":")
vStartSec := oStart.1 * 60 + oStart.2
vEndSec := oEnd.1 * 60 + oEnd.2
vElapsedSec := Round((vPct/100) * (vEndSec-vStartSec))
vRemainingSec := Round(((100-vPct)/100) * (vEndSec-vStartSec))
MsgBox, % "elapsed: " Format("{:02}:{:02}", vElapsedSec//60, Mod(vElapsedSec,60))
MsgBox, % "remaining: " Format("{:02}:{:02}", vRemainingSec//60, Mod(vRemainingSec,60))
return

w:: ;works for HH:mm or mm:ss (but must specify format)
vFormat := "HH:mm"
;vFormat := "mm:ss"
vStart := "12:30" ;HH:mm
vEnd := "13:15" ;HH:mm
vPct := 25
;vPct := 75
if (vFormat := "HH:mm")
{
	vStart := "19990101" StrReplace(vStart, ":") "00"
	vEnd := "19990101" StrReplace(vEnd, ":") "00"
}
else if (vFormat := "mm:ss")
{
	vStart := "1999010100" StrReplace(vStart, ":")
	vEnd := "1999010100" StrReplace(vEnd, ":")
}
vSec := vEnd
EnvSub, vSec, % vStart, S
vElapsedSec := Round((vPct/100) * vSec)
vRemainingSec := Round(((100-vPct)/100) * vSec)
vElapsed := 19990101000000
vRemaining := 19990101000000
EnvAdd, vElapsed, % vElapsedSec, S
EnvAdd, vRemaining, % vRemainingSec, S
FormatTime, vElapsed, % vElapsed, % vFormat
FormatTime, vRemaining, % vRemaining, % vFormat
MsgBox, % "elapsed: " vElapsed
MsgBox, % "remaining: " vRemaining
return
Last edited by jeeswg on 05 Sep 2017, 16:12, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
baldimkino
Posts: 4
Joined: 19 Aug 2017, 14:15

Re: Progress

05 Sep 2017, 12:49

Code: Select all

; untested
EnvSub, end, %start%, S
EnvSub, cur, %start%, S
percent := 100*cur/end
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Progress

05 Sep 2017, 15:07

ActiveX mit vlc.exe , progressbar , Bsp time-25% , played-time Bsp 00:05:20, totallenght Bsp 00:20:22

EDIT : added button-Snapshot and removed 'gosubtimecalc'

Image


Achtung : erstellt (in a_scriptdir) = wget.exe / creates NOS_TV_Logfile.txt / nos-journaal.html /modify Wave to 8%

Code: Select all

;=================================================================
;- modified=20170906
;- created =20170124
;-         = show last news from NOS-TV netherlands
;=================================================================
; downloads in a_scriptdir = wget.exe / creates NOS_TV_Logfile.txt / nos-journaal.html /modify Wave to 8%

#NoEnv
SendMode,Input
SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode 2
SetBatchLines, -1

filename1=Nederland_NOS-TV
c1=%a_programfiles%\videolan\vlc\vlc.exe
logfile=%a_scriptdir%\NOS_TV_Logfile.txt

c1=%a_programfiles%\videolan\vlc\vlc.exe
  wget1=%a_scriptdir%\wget.exe
  ifnotexist,%wget1%
    {
    if A_Is64bitOS
      x1=https://eternallybored.org/misc/wget/current/wget64.exe
    else
      x1=https://eternallybored.org/misc/wget/current/wget.exe
    urldownloadtofile,%x1%,wget.exe
    }

 loop,%wget1%                                                ;- create shortpath
   SP1= %A_loopFileShortPath%

SM4=8                          ; set volume level
soundset,0,WAVE,mute           ; WAVE ON
SoundSet,%SM4%,WAVE            ; WAVE

;Gui,2: +AlwaysOnTop
Gui,2: Color, 000000
Gui,2:Font,  S10 CDefault , FixedSys

;xxa=Shell.Explorer
xxa=Mozilla.Browser

ifexist,%c1%
   Gui,2:Add,ActiveX, x10 y10 w1460 h900 vVlcx, VideoLAN.VLCPlugin.2
else
   {
   Gui,2:Add,ActiveX, x10 y10 w1460 h880 vWB1 ,%xxa%
   WB1.Silent := True
   ComObjError(false)
   }

Gui,2:Add, Slider  , x1490  y100  w40  h190     altsubmit    vVOL11a gVOL11 Range0-100  Vertical invert thick25 cGray left line10,%sm4%
Gui,2:add, Button  , x10    y940  w100 h25   gLastNews,LastNews
Gui,2:add, Button  , x120   y940  w100 h25   gNOS_Live, NOS_Live
ifexist,%c1%
  Gui,2:add, Button  , x240   y940  w100 h25   gSnapshot vSnapshot1, SNAPSHOT

Gui,2:Add, Progress,  x140  y914 w1200 h18 vPRBAR backgroundGray range0-100
Gui,2:Add,Text,       x5    y914 w40    vT1 cYellow   ;- procent
Gui,2:Add,Text,       x50   y914 w80    vT2 cYellow   ;- played time actual
Gui,2:Add,Text,       x1370 y914 w80    vT3 cYellow   ;- total lenght from video
Gui,2:Add,Text,       x1470 y914 w80    vT5 cYellow   ;- vlc state

Gui,2: Show,x0 y0 w1550 h970,%filename1%
ifexist,%c1%
  {
  settimer,aas1,1000
  settimer,aas1,off
  }
gosub,lastnews
return
;-------------------------
2Guiclose:
exitapp

nos_live:
run,https://nos.nl/livestream/npo-nieuws.html
return

SNAPSHOT:
ifexist,%c1%
  vlcx.video.takeSnapshot()
return

;--------check NOS-TV nieuws -----------------
LastNews:
gosub,clearall
 fd  =%a_scriptdir%
 refx=https://nos.nl
 fxx =nos-journaal.html
 url =https://nos.nl/uitzending/%fxx%
 all =%fd%\%fxx%
 ifexist,%all%
    filedelete,%all%
 RunWait,%COMSPEC% /c %sp1% --no-parent --directory-prefix="%fd%" --referer=%refx% %url%,,hide
 fileread,aacc,%all%
;msgbox,%aacc%
;<source src="https://download.omroep.nl/nos/content/mp4/web01/2017/08/09/26688/mp4_web01_backup.mp4"

A:="https"                                                 ;- begin
Extensions1 := "mp3,m4a,wav,wma,flv,vob,mp4,mpg,wmv,avi"   ;- end
stringlen,L1,A

T=
Loop,parse,aacc,`n,`r
   {
   T=%A_LoopField%
   Loop Parse,t,`"      ;- split for `"
     {
     StringLeft r,A_LoopField,L1
     If (r=A)
        {
        SplitPath,A_LoopField, name, dir, ext, name_no_ext, drive
        if ext in %Extensions1%
           {
           e .= A_LoopField "`n"
           Last=%A_LoopField%
           }
        }
     }
   }
;------------------------------------
stringsplit,h,e,`n
;msgbox,%e%`n`nH1=%h1%`nH2=%h2%`nH3=%h3%`nLAST=`n%last%
;h1=320M
;h2= 48M
;h3=155M
e=
xxs=%h3%
;RunWait,%COMSPEC% /k %sp1% -nc --no-parent --directory-prefix="%fd%" --referer=%refx% %xxs%
;return

stringmid,date,a_now,1,10
fileappend,%date%_%xxs%`r`n,%logfile%

ifexist,%c1%
    {
    vlcx.playlist.stop()
    vlcx.playlist.items.clear()
    vlcx.playlist.add(xxs,"","""""")
    vlcx.playlist.next()
    settimer,aas1,on
    }
   else
     WB1.Navigate(xxs)
return
;-------------------------------------------------------------------

;----- volumex -------------------------------
VOL11:
GuiControlGet, VOL11a
SoundSet,%vol11a%,WAVE
return


;=========== settimer progressbar ==================
aas1:
gui,2:submit,nohide
bc:=vlcx.input.length
ac:=vlcx.input.time
acc:=(ac//1000)
bcx:=(bc//1000)
if (acc=0 or bcx=0)
   return
;msgbox, 262208, ,acc=%acc%`nbcx=%bcx% , 1
SetFormat, float, 02
hours1   := (acc//3600)
minutes1 := (acc - hours1 * 3600)// 60
seconds1 := (acc - hours1 * 3600 - minutes1 * 60)
hours1  +=0.00
minutes1+=0.00
seconds1+=0.00
acc=%hours1%:%minutes1%:%seconds1%
;------- played-time ---------------

hours   := (bcx//3600)
minutes := (bcx - hours * 3600)// 60
seconds := (bcx - hours * 3600 - minutes * 60)
hours  +=0.00
minutes+=0.00
seconds+=0.00
bcx=%hours%:%minutes%:%seconds%
;----- total-time ----------------
ay:=vlcx.input.state
if (ay=0)
   cy=Idle
if (ay=1)
   cy=Opening
if (ay=2)
   cy=Buffering
if (ay=3)
   cy=Playing
if (ay=4)
   cy=Paused
if (ay=5)
   cy=Stopped
if (ay=7)
   cy=Error
if (ay=6)
   {
   cy=Ended
   GuiControl,2:Text,T5,%cy%
   settimer,aas1,off
   GuiControl,2:,PRBAR,100
   GuiControl,2:Text,Procentx   ,100`%
   return
   }

;GuiControl,2:Text,T4,AY=%ay%
GuiControl,2:Text,T5,%cy%

    RES1:=Round((100*AC)/BC)
    GuiControl,2:,PRBAR ,%res1%
GuiControl,2:Text,T1    ,%res1%`%   ;- procent
GuiControl,2:Text,T2    ,%acc%      ;- PlayedTime
GuiControl,2:Text,T3    ,%bcx%      ;- Lenght
return

;========== CLEAR ===================
clearall:
  GuiControl,2:Text,T1,
  GuiControl,2:Text,T2,
  GuiControl,2:Text,T3,
  Guicontrol,2:text,T5
  Guicontrol,2:text,prbar
  GuiControl,2:,PRBAR,0
  GuiControl,2:Text,Procentx   ,0`%
return
;-------------------------------------
;======== END SCRIPT =======================================
Last edited by garry on 06 Sep 2017, 07:07, edited 1 time in total.
just me
Posts: 9450
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Progress

06 Sep 2017, 05:01

Moin BoBo,
Bekomme den zeiger via SetTimer und GuiControl, Move ... bewegt, allerdings nicht wirklich synchron zur tatsächlich verstrichenen zeit.
Das hört sich so an, als ob Du Dir selbst eine Fortschrittsanzeige gebastelt hast. Kannst Du das und auch die Werte für den Start und das Ende der Sendung im Originalformat vor Bearbeitung mal zeigen?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

06 Sep 2017, 06:16

A very warm welcome to just me :mrgreen:

Code: Select all

	Pos		:=	50														; startposition auf dem fortschrittsbalken
	pBarLen	:=	100														; endpostion ...
	sTime	:=	"20:45"													; startzeit (wird angezeigt)
	eTime	:=	"20:46"													; endzeit ...
;	rTime 	:= RunTime(sTime,eTime,"s")									; ermittlung der laufzeit aus start und endzeit
	rTime	:=	60 
	pTime	:= Round(pBarLen/rTime,4)*1000								; ermittlung der verzögerung zwischen den anzeigeschritten


Gui, -Caption
Gui, Add, Text, x10		y12		w40			h24			,% sTime		; anzeige der startzeit
Gui, Font, Bold s8 cBlue
Gui, Add, Text, xp40	yp-2	w%pBarLen%	h14			, __ __ __ __	; anzeige fortschrittsbalken
Gui, Font, s8 cRed
Gui, Add, Text, x%Pos%	yp2		w1			h9 vProgr	,|				; anzeige forschrittszeiger 
																		; alternativen wären: • ° ®
																		; oder ...
																		; % Chr(0x21D3) 
																		; ... wobei:
																		; 0x2207	= nabla (bevorzugt)
																		; 0x2228	= oder
																		; 0x25CA	= raute
																		; 0x3BD		= ny klein
																		; 0x2666	= karo
																		; 0x21D3	= doppelpfeil unten
Gui, Font,
Gui, Add, Text, xp80	y12		w40			h24			,% eTime		; anzeige der endzeit	
Gui, Show, w170 h36, `t

												
; SetTimer, Progress, On
SetTimer, Progress,% pTime													; start der fortschrittsanzeige

Progress:
	Pos++																	; neue position des forschrittszeigers festlegen
	If (Pos = pBarLen) {													; ... doch, sobald ende des fortschrittsbalkens erreicht ...
		SoundBeep															; ... krawall!
		SetTimer, Progress, Off												; forschrittszeiger abschalten
		Sleep,% 500															; gedenksekundenteil
		Gui, Destroy														; Schluß.
		ExitApp
		}
	GuiControl, Move, Progr, x%Pos% y12 w2 h9								; ... ansonsten, forschrittszeiger um eine position bewegen.
	Return
Die "formel" für die variable p(rogress)Time, sowie die umsetzung unter Progress: ist der knackpunkt, womit der zeiger aktuell unsynchron zur verstreichenden zeit läuft. Zumindest als anschauungsobjekt ist's OK :)
Die start-/endzeit resultiert aus der [hier] gezeigten gui.
Danke fürs draufschaun :thumbsup:

Slightly of topic. Es ist mir nicht gelungen den gesamten codeblock in einer funktion unterzubringen, da a) die Gui-variable als static/global angemahnt wird, und b) der Return der SetTimer-routine die funktion beendet und damit die Gui sofort wieder ausblendet (zumindest interpretiere ich es so).
Doch das wäre ein separates topic.
Last edited by BoBo on 06 Sep 2017, 08:15, edited 3 times in total.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

06 Sep 2017, 06:24

jeeswg wrote:Zeitgeist.

Code: Select all

q:: ;works for HH:mm or mm:ss
vStart := "12:30" ;HH:mm
vEnd := "13:15" ;HH:mm
vPct := 25
;vPct := 75
oStart := StrSplit(vStart, ":")
oEnd := StrSplit(vEnd, ":")
vStartSec := oStart.1 * 60 + oStart.2
vEndSec := oEnd.1 * 60 + oEnd.2
vElapsedSec := Round((vPct/100) * (vEndSec-vStartSec))
vRemainingSec := Round(((100-vPct)/100) * (vEndSec-vStartSec))
MsgBox, % "elapsed: " Format("{:02}:{:02}", vElapsedSec//60, Mod(vElapsedSec,60))
MsgBox, % "remaining: " Format("{:02}:{:02}", vRemainingSec//60, Mod(vRemainingSec,60))
return

w:: ;works for HH:mm or mm:ss (but must specify format)
vFormat := "HH:mm"
;vFormat := "mm:ss"
vStart := "12:30" ;HH:mm
vEnd := "13:15" ;HH:mm
vPct := 25
;vPct := 75
if (vFormat := "HH:mm")
{
	vStart := "19990101" StrReplace(vStart, ":") "00"
	vEnd := "19990101" StrReplace(vEnd, ":") "00"
}
else if (vFormat := "mm:ss")
{
	vStart := "1999010100" StrReplace(vStart, ":")
	vEnd := "1999010100" StrReplace(vEnd, ":")
}
vSec := vEnd
EnvSub, vSec, % vStart, S
vElapsedSec := Round((vPct/100) * vSec)
vRemainingSec := Round(((100-vPct)/100) * vSec)
vElapsed := 19990101000000
vRemaining := 19990101000000
EnvAdd, vElapsed, % vElapsedSec, S
EnvAdd, vRemaining, % vRemainingSec, S
FormatTime, vElapsed, % vElapsed, % vFormat
FormatTime, vRemaining, % vRemaining, % vFormat
MsgBox, % "elapsed: " vElapsed
MsgBox, % "remaining: " vRemaining
return
StrReplace("The ghost in the machine !","ghost","Zeitgeist") :clap:
Well, but not exactly what I've tried to accomplish (correct me if I'm wrong!) - but definitely worth to be kept for further things to come.
Thx a lot jeeswg :thumbup:
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

06 Sep 2017, 06:38

garry wrote:
Spoiler
Moin garry 8-)
Ich habe bereits einen EPG gebastelt um VLC damit anzusteuern (siehe screenshot). Die hier besprochene fortschrittsanzeige sollte zukünftig in der gui oben rechts ihren platz finden. Welchen teil in deinem script habe ich übersehen, welcher hierfür hilfreich wäre?? :)

Screenshot1
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Progress

06 Sep 2017, 07:16

danke BoBo
script oben angepasst mit Bemerkungen , gosub-timecalc entfernt , ein Button SnapShot angefügt
schau auf den Teil AAS1 und beim GUI die Text-Variablen T1=prozent T2=Zeit aktuell T3=Total-Länge
im Teil Lastnews :

Code: Select all

;xxs ist die gefundene URL ( 3 URL's verfügbar)
;xxs=https://download.omroep.nl/nos/content/mp4/web03/2017/09/06/27292/mp4_web03.mp4
; when vlc exists
ifexist,%c1%
    {
    vlcx.playlist.stop()
    vlcx.playlist.items.clear()
    vlcx.playlist.add(xxs,"","""""")
    vlcx.playlist.next()
    settimer,aas1,on
    }
   else
     WB1.Navigate(xxs)
return
just me
Posts: 9450
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Progress

06 Sep 2017, 09:31

Hallo BoBo,

eine kurze Frage zwischendurch. In Deinem CEPG GUI gibt es ja bereits eine RunTime [sec]. Kannst Du die als Laufzeit für das 'Progress' Control übernehmen? Man müsste dann nicht neu berechnen.

Außerdem glaube ich, dass sich Textfelder nur bedingt für eine genaue Positionierung eignen. Mit Bitmaps bzw. einem Icon für den Slider wäre das einfacher.

Zu Slightly of topic:

Code: Select all

#NoEnv
GuiFunc()
ExitApp

GuiFunc() {
   I := 0
   Gui, FuncGui:New, +LastFound +LabelFuncGui
   Gui, Show, w400 h400, Test
   SetTimer, FuncGuiTimer, 1000
   WinWaitClose ; last-found window !!!
   Return
   FuncGuiClose:
   SetTimer, FuncGuiTimer, Off
   ;
   ToolTip
   Gui, Destroy
   Return
   ;
   FuncGuiTimer:
   I += 1 ; der Timer kann auch auf lokale Variablen 'von oben' zugreifen, solange die Funktion nicht beendet ist
   If (I > 10)
      Gui, FuncGui: Destroy
   Else
      ToolTip, I = %I%
   Return
}
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

06 Sep 2017, 10:18

just me wrote:Hallo BoBo,

eine kurze Frage zwischendurch. In Deinem CEPG GUI gibt es ja bereits eine RunTime [sec]. Kannst Du die als Laufzeit für das 'Progress' Control übernehmen? Man müsste dann nicht neu berechnen.

Außerdem glaube ich, dass sich Textfelder nur bedingt für eine genaue Positionierung eignen. Mit Bitmaps bzw. einem Icon für den Slider wäre das einfacher.
Spoiler
Zur laufzeit (rTime) - alles was hilft, hilft. Ich errechne die laufzeit auch nur deshalb nochmals, da ich es nicht hinbekommen habe die fortschrittsanzeige in eine lauffähige funktion zu kapseln. Dieser hätte ich die laufzeit schlicht als parameter übergeben.

Anbei noch ein bild des original "Sony Bravia" progressbar. Danke für das SOT beispiel :)

Screenshot02.png
just me
Posts: 9450
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Progress

06 Sep 2017, 11:06

Dann sieht es für mich so aus:
Du brauchst eine Bitmap mit einem blauen Dreieck auf passendem oder transparentem Hintergrund und den Versatz der unteren Spitze zur linken Ecke.
Dann wäre noch eine Bitmap (oder zwei verschiedenfarbige Bitmaps, wenn sie ausgetauscht werden sollen) für die einzelnen 'Abschnitte' der 'Positionslinie' gut.
Wenn man das dann exakt positioniert, sollte es kein echtes Problem mehr sein.

Ich bin nicht so gut im 'Bitmaps erstellen'. Aber ich werde mal versuchen, eine einfache Lösung zu basteln, die das Prinzip zeigt:
- Schrittweite = Gesamtlänge der 'Posititionslinie' / Gesamtlaufzeit in Sekunden
- Aktuelle Position = X-Position der 'Positionslinie + (aktuelle Laufzeit in Sekunden * Schritttweite) - Versatz der Dreiecksspitze zur linken Ecke des Dreiecks
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

06 Sep 2017, 12:08

just me wrote:Dann sieht es für mich so aus:
Du brauchst eine Bitmap mit einem blauen Dreieck auf passendem oder transparentem Hintergrund und den Versatz der unteren Spitze zur linken Ecke.
Dann wäre noch eine Bitmap (oder zwei verschiedenfarbige Bitmaps, wenn sie ausgetauscht werden sollen) für die einzelnen 'Abschnitte' der 'Positionslinie' gut.
Wenn man das dann exakt positioniert, sollte es kein echtes Problem mehr sein.

Ich bin nicht so gut im 'Bitmaps erstellen'. Aber ich werde mal versuchen, eine einfache Lösung zu basteln, die das Prinzip zeigt:
- Schrittweite = Gesamtlänge der 'Posititionslinie' / Gesamtlaufzeit in Sekunden
- Aktuelle Position = X-Position der 'Positionslinie + (aktuelle Laufzeit in Sekunden * Schritttweite) - Versatz der Dreiecksspitze zur linken Ecke des Dreiecks
Alles beside der reinen funktionalität wäre "nice2have". Zum zeiger/dreieck, wäre evtl der nabla-character bereits ausreichend (als grafik evtl noch nachträglich 'gefüllt')?

http://www.fileformat.info/info/unicode ... /index.htm
http://www.fileformat.info/info/unicode ... ertest.htm
http://www.fileformat.info/info/unicode ... /nabla.svg
http://www.fileformat.info/info/unicode ... upport.htm

... probiert:

Code: Select all

MsgBox % Chr(0x2207)
; 0x2207	= nabla
; 0x2228	= oder
; 0x25CA	= raute
; 0x2666	= karo
; 0x21D3	= doppelpfeil unten
... zeigt (auf Win7), ein 'dreieck' (was der grund war, warum ich zuerst text statt grafik in die engere wahl zog) :thumbup:

Gerade noch einen satz dreiecke mit paint beackert. Leider nimmt das forum keine bmp's, und irgendwie nicht mehr als 3 dateien (habe sieben versch.).
Jetzt sind es GIF's.

PS. die GIF's haben aktuell noch einen weißen hintergrund.
Ist schon etwas her das ich bilder bearbeitet habe.
Evtl bekomme ich die transparenz noch gebacken.
Attachments
img03.gif
(881 Bytes) Downloaded 168 times
img02.gif
(892 Bytes) Downloaded 168 times
img01.gif
(865 Bytes) Downloaded 168 times
just me
Posts: 9450
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Progress

06 Sep 2017, 15:20

OK, gib mir etwas Zeit.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

07 Sep 2017, 03:27

just me wrote:OK, gib mir etwas Zeit.
Yo, sowieso. Gut ding will weile haben :thumbup:
just me
Posts: 9450
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Progress

07 Sep 2017, 05:09

Gut, guckst Du. Das ist eine recht einfach aufgebaute Variante. Man könnte das noch 'verfeinern'. Es kommt allerdings auch darauf an, was außer dem 'Progress' gezeigt werden soll:

Code: Select all

#NoEnv
SetBatchLines, -1

StartTime := "23:15"
EndTime := "23:17"
Today := A_YYYY . A_MM . A_DD
S := Today . StrReplace(StartTime, ":")
E := Today . StrReplace(EndTime, ":")
If (EndTime < StartTime)
   E += 1, D
RunTime := E
RunTime -= S, S

Triangle := []
Triangle.Push([0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0
             , 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x000000])
Triangle.Push([0x000000, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0
             , 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x000000, 0x000000])
Triangle.Push([0x000000, 0x000000, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0
             , 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x000000, 0x000000, 0x000000])
Triangle.Push([0x000000, 0x000000, 0x000000, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0
             , 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0, 0x000000, 0x000000, 0x000000, 0x000000])
Triangle.Push([0x000000, 0x000000, 0x000000, 0x000000, 0x6090D0, 0x6090D0, 0x6090D0, 0x6090D0
             , 0x6090D0, 0x6090D0, 0x6090D0, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000])
Triangle.Push([0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x6090D0, 0x6090D0, 0x6090D0
             , 0x6090D0, 0x6090D0, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000])
Triangle.Push([0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x6090D0, 0x6090D0
             , 0x6090D0, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000])
Triangle.Push([0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x6090D0
             , 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000])
HBMT := DIB_CreateFromArray(Triangle, 1, 1)  ; triangal bitmap
HBML := DIB_CreateUC(0x6090D0)               ; line bitmap

Gui, Color, Black
Gui, Margin, 20, 20
Gui, Font, s16
Gui, Add, Text, xm ym cWhite vT1, %StartTime%
GuiControlGet, T1, Pos
LineHeight := 2 ; height of the base line
Y := T1Y + (T1H // 2) - (LineHeight // 2)
Gui, Add, Pic, x+10 y%Y% w28 h%LineHeight% vP1, HBITMAP:*%HBML%
GuiControlGet, P1, Pos
Gui, Add, Pic, x+3 yp wp hp, HBITMAP:*%HBML%
Gui, Add, Pic, x+3 yp wp hp, HBITMAP:*%HBML%
Gui, Add, Pic, x+3 yp wp hp vP4, HBITMAP:%HBML%
GuiControlGet, P4, Pos
Gui, Add, Text, x+10 y%T1Y% cWhite vT2, %EndTime%
X := P1X - 7 ; 7 = Versatz der Spitze zur linken Ecke
Y := P1Y - 14
Gui, Add, Pic, x%X% y%Y% w16 h12 vPB, % "HBITMAP:" . HBMT
GuiControlGet, PB, Pos
Gui, Show, , Progress - %RunTime% Sekunden

LineLength := P4X + P4W - P1X
ProgressDelta := LineLength / RunTime
StartTC := A_TickCount
ProgressTime := 0
SetTimer, UpdProgress, 10
Return

GuiClose:
ExitApp

UpdProgress:
CurrentSecs := (A_TickCount - StartTC) // 1000
If (CurrentSecs >= RunTime) {
   SetTimer, UpdProgress, Off
   MsgBox, 0, Finished!, %CurrentSecs% Sekunden
   Return
}
If (CurrentSecs <> ProgressTime) {
   X := Round(PBX + (CurrentSecs * ProgressDelta))
   GuiControl, Move, PB, x%X%
   ProgressTime := CurrentSecs
}
Return

; ================================================================================================================================
; Modified versions of CreateDIB() by SKAN, 01-Apr-2014, autohotkey.com/boards/viewtopic.php?t=3203
; Colors       -  RGB integer values (0xRRGGBB)
; Direction    -  H (default)       -  horizontal
;                 Any other value   -  vertical
; ================================================================================================================================
; Creates an uni-colored DIB (1x1 pixels).
; ================================================================================================================================
DIB_CreateUC(Color) {
   Static W := 1, H := 1, Size := W * H * 4
   HBM := DllCall("CreateBitmap", "Int", W, "Int", H, "UInt", 1, "UInt", 32, "Ptr", 0, "UPtr")
   , HBM := DllCall("CopyImage", "Ptr", HBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "UPtr")
   , VarSetCapacity(BMBITS, Size, 0)
   , Numput(Color, BMBITS, "UInt")
   , DllCall("SetBitmapBits", "Ptr", HBM, "UInt", Size, "Ptr", &BMBITS)
   Return HBM
}
; ================================================================================================================================
; Creates DIB from a color array.
; ColorArray   -  2-dimensional array of colors.
; ================================================================================================================================
DIB_CreateFromArray(ColorArray, ScaleX := 1, ScaleY := 1) {
   If !(H := ColorArray.Length()) || !(W := ColorArray.1.Length())
      Return 0
   Size := W * ScaleX * H * ScaleY * 4
   HBM := DllCall("CreateBitmap", "Int", W * ScaleX, "Int", H * ScaleY, "UInt", 1, "UInt", 32, "Ptr", 0, "UPtr")
   HBM := DllCall("CopyImage", "Ptr", HBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "UPtr")
   VarSetCapacity(BMBITS, Size, 0)
   Addr := &BMBITS
   Loop, %ScaleY%
      For Each, Row In ColorArray
         Loop, %ScaleX%
            For Each, Color In Row
               Addr := NumPut(Color, Addr + 0, "UInt")
   DllCall("SetBitmapBits", "Ptr", HBM, "UInt", Size, "Ptr", &BMBITS)
   Return HBM
}
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

07 Sep 2017, 06:17

just me wrote:Gut, guckst Du. Das ist eine recht einfach aufgebaute Variante. Man könnte das noch 'verfeinern'. Es kommt allerdings auch darauf an, was außer dem 'Progress' gezeigt werden soll:
[...]
Du siehst mich beeindruckt :o ... :clap: :thumbup: :clap:


PS.
Das mit "eine recht einfach aufgebaute Variante" hat soeben die goldene astgabel für die untertreibung der woche gewonnen.
Gratulation auch dazu
:clap: ;)
PPS. ... und natürlich sollte diese scriptische großtat auch einzug in der sektion Skripte & Funktionen finden :!:
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Progress

07 Sep 2017, 08:35

Frage: läßt sich das triangel ggf skalieren? Nach meiner interpretation wird dieses mittels des colorarrays gebaut?? Das daraus resultierende pic über den GUI weite/-höhe-parameter zu skalieren, ergibt bei entsprechender verkleinerung unschöne treppeneffekte. IMHO wird dabei das pic lediglich nach gutdünken des OS zerrechnet/gequetscht (bei der linie ist dies scheints vernachläßigbar). Ich hab da mal die hoffnung, das sich dies bereits im vorfeld über das array vermeiden ließe?!!

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 45 guests