SOLVED: GuiControl only when clicked?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Dylan87
Posts: 9
Joined: 03 Nov 2015, 11:17

SOLVED: GuiControl only when clicked?

03 Nov 2015, 11:29

First post!

I'm an automation engineer at a factory and I've made a few AHK GUI's to collect user input for some of my processes. For some reason, this GUI is acting strangely. The purpose is to read the "status" of a process by pulling keywords from a "status.txt" file. The GUI then updates the picture "PicData" according to what step it is in the process.

My problem is the picture will only update when I click on the picture. I expected GuiControl,, StatusPic, %PicData% to update the picture even when the GUI was inactive. I've tried forcing the GUI to be "+AlwaysOnTop" or trying to activate the GUI with WINACTIVATE but still no luck. I still have to click the image to see if there were any changes. Does the Picture being controlled need to have focus for the changes to be seen? That's what i'm currently thinking, but not sure the best method to do this.

Anyways, here is my code:

Code: Select all

;3D SCAN STATUS

#NoEnv
#singleinstance force

StatusDirectory = F:\Shared\GEOMAGIC\System\status.txt			;Update the status via the status text file
PictureDirectory = F:\Shared\GEOMAGIC\Layout Pictures			;Update the corresponding image to the status
ReportDirectory = F:\Shared\GEOMAGIC\Reports					;Location to retrieve Geomagic Report
status1 = scan											;Scan will always be the first word, sets loop variable

timerm := "00"
timers := "00"
stopped := "0"

Start:
Gui,+AlwaysOnTop
Gui, Color, white
Gui, Font, s48 bold, Calibri
Gui, Add, Picture, X10 Y10  vStatusPic gUpdate,
Gui, Add, Text, x500 y500 w160 h120 vTText, %timerm%:%timers%
;~ Gui, Add, Text, vStatusText, blank
Gui, Font,
Settimer, Stopwatch, 1000
GuiControl +BackgroundTrans, TText
Gui, Show, h800 w1150, 3D SCAN STATUS

Update:
FileReadLine, status, %StatusDirectory%, 1
GUIControl,, StatusText, %status%
PicData = %PictureDirectory%\%status%.png
GUIControl,, StatusPic, %PicData%
IfNotEqual, status, %status1%
{
	status1 = %status%
	IfEqual, status, error
	{
		Settimer, Stopwatch, off 
	}
	else
	{
		sleep, 10
	}
	Gui, Submit, NoHide
	;~ Goto, Start
}
else
{
	sleep, 1000
}


Stopwatch:
timers += 1
if(timers > 59)
{
	timerm += 1
	timers := "0"
	GuiControl, , TText ,  %timerm%:%timers%
}
if(timers < 10)
{
	GuiControl, , TText ,  %timerm%:0%timers%
}
else
{
	GuiControl, , TText ,  %timerm%:%timers%
}
return

GuiClose:
GuiEscape:
ExitApp
return
Last edited by Dylan87 on 03 Nov 2015, 11:46, edited 1 time in total.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: GuiControl only when clicked?

03 Nov 2015, 11:39

As far as I can see the only command which will update the picture control belongs to the Update: label which is called only if you click on the control (and also once when the script starts).
Dylan87
Posts: 9
Joined: 03 Nov 2015, 11:17

Re: GuiControl only when clicked?

03 Nov 2015, 11:44

That was it, I replaced "Update:" with a loop. I tried so many things, but I guess not that. Thanks just me.
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: GuiControl only when clicked?

03 Nov 2015, 11:50

it depends when you want the change to occur, add this line "gosub, Update" at that position line in the Stopwatch timer
EDIT: it seems you have fixed the problem, seconds before my post.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: hedehede81 and 273 guests