GUI New Tab Not Working

Get help with using AutoHotkey and its commands and hotkeys
Vaklev
Posts: 47
Joined: 04 Mar 2019, 13:58

GUI New Tab Not Working

Post by Vaklev » 11 Jun 2019, 13:21

Hi guys, I have a GUI that adds a +1 to my count every time it picks up an image, but my code is glitching out please help, I want tab 1 to show just the total reports completed, tab 2 to show reports completed during each hour, but I do not know how to link a label according to the time, also my text seems to be glitched out and it is not showing please help!

Code: Select all


^p::
Counter = 0000  ; Start counter at zero
Gui, Add, Text, vText, Completed Reports: %Counter%
Gui, Add, UpDown, Range0-1000, 0
Gui, Show, w300 h500, Report Counter  ; Show Gui
Gui, Add, Tab, 2
Gui, Add, Text, vText1,  9:30am-10:30am = %Counter%
Gui, Add, Text, vText2, 10:30am-11:30am = %Counter%
Gui, Add, Text, vText3, 11:30am-12:30pm = %Counter%
Gui, Add, Text, vText4, 12:30pm- 1:30pm = %Counter%
Gui, Add, Text, vText5,  1:30pm- 2:30pm = %Counter%
Gui, Add, Text, vText6,  2:30pm- 3:30pm = %Counter%
Gui, Add, Text, vText7,  3:30pm- 4:30pm = %Counter%
Gui, Add, Text, vText8,  4:30pm- 5:30pm = %Counter%
return

~^e::
loop
{
    sleep 200
    ImageSearch FoundX,FoundY, 345,300, 900,700, complete.png
    If ErrorLevel = 0
    break
}
Count:  ; Label
	Counter++  ; Increase counter by +1
	GuiControl,, Text, Completed Reports: %Counter%  ; Update Text control with new value
return



colt
Posts: 176
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: GUI New Tab Not Working

Post by colt » 11 Jun 2019, 18:26

How is this?

Code: Select all

hr := 8

counters:={}
timeSlots := 8
startTime := 930

;build array to store times and counts for each hour
loop % timeSlots 
{
	counters[A_Index,"st"] := startTime
	counters[A_Index,"et"] := startTime + 100
 	counters[A_Index,"count"] := 0	
	startTime += 100 	
}

Counter = 0000  ; Start counter at zero
Gui, Add, Tab,h250,Tab1 | Tab2 ||
Gui, Add, Text, vText, Completed Reports: %Counter%
Gui, Add, UpDown, Range0-1000, 0

Gui, Tab, 2
Gui, Add, Text, vText1 hwndText1Hwnd,  9:30am-10:30am = %Counter%
Gui, Add, Text, vText2 hwndText2Hwnd, 10:30am-11:30am = %Counter%
Gui, Add, Text, vText3 hwndText3Hwnd, 11:30am-12:30pm = %Counter%
Gui, Add, Text, vText4 hwndText4Hwnd, 12:30pm- 1:30pm = %Counter%
Gui, Add, Text, vText5 hwndText5Hwnd,  1:30pm- 2:30pm = %Counter%
Gui, Add, Text, vText6 hwndText6Hwnd,  2:30pm- 3:30pm = %Counter%
Gui, Add, Text, vText7 hwndText7Hwnd,  3:30pm- 4:30pm = %Counter%
Gui, Add, Text, vText8 hwndText8Hwnd,  4:30pm- 5:30pm = %Counter%
Gui, Show,, Report Counter  ; Show Gui

return

^d::
	;loop
	;{
	;    sleep 200
	;    ImageSearch FoundX,FoundY, 345,300, 900,700, complete.png
	;    If ErrorLevel = 0
	;    break
	;}	 
	
	;loop over time slots
	for slot in counters
	{
		;check if current time is inside time slot
		if(timeOfDay>counters[slot].st && timeOfDay<=counters[slot].et)
		{
			;found correct slot so update slot counter and update text
			counters[slot].count ++
			
			hwnd := Text%slot%Hwnd			
			GuiControlGet, currentText, ,%hwnd%,		
			currentText := substr(currentText,1,strLen(currentText)-strLen(counters[slot].count)) . format("{:d}",counters[slot].count)		
			GuiControl,, Text%slot%, %currentText%  ; Update Text control with new value			
			break
		}
	}
	;update global counter
	Counter++ 
	GuiControl,, Text, Completed Reports: %Counter% 
return

^i::
	;simulate increase hour of day

	; to get real time of day
/*
	timeOfDay := A_now 
	FormatTime, timeOfDay , timeOfDay , HHMM
	tooltip % timeOfDay 
*/

	hr++
	if(hr>23)
	{
		hr := 0
	}
	random,min,0,59 ;set to random min
	dispHr := mod(hr,12)
	if(dispHr == 0)
	{
		dispHr := 12
	}
	timeOfDay := format("{:02d}",hr) . format("{:02d}",min)
	tooltip % "Current Time: " . format("{:02d}",dispHr) . ":" . format("{:02d}",min) . "`n" . hr

return



Post Reply

Return to “Ask For Help”