AutoHotkey Community

It is currently May 27th, 2012, 11:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: gui combobox variable
PostPosted: August 14th, 2009, 6:49 pm 
Offline

Joined: August 26th, 2007, 12:23 am
Posts: 50
Location: USA
There is something that im not understanding about using variables.
I'm trying to make a gui with a combobox with names in it.
after you hit save the answer to the combobox gets put into an excel spreadsheet.
i think maybe problem #1 is ahk wont output into .xls directly?
So i would have to output to an ini file and then push over to excel?

anyway this is my script that isn't working.

Code:
;gui to colect operator name for excel sheet

Gui, Add, Text, x6 y10 w100 h30 +Center, Operator Name
Gui, Add, ComboBox, x6 y50 w100 h80 , |name1|name2|name3|name4|


Gui, Add, Button, x346 y330 Save
Gui, Add, Button, x136 y110 w60 h20 , Close

Gui, Show, x350 y350 h138 w204, Operator Name

ButtonClose:
ExitApp

Save:
GUi, Submit, NoHide
FileDelete, Operator.xls

Loop
{
   If !Combo%A_Index%
   Break
   Write, % Combo%A_Index%, Operator.xls, Combo%A_Index%, Combo
}
Return

GuiClose:
ExitApp


in the same directory there would be operator.xls
every time you click save the program operator.xls would get the answer but drop down a line the next time. so at the end of the week i would have operator.xls with a column with nothing but operator names

Any help at all would be nice i hope to lean from this so i can grow this idea into a full blown downtime tracker that will make my life at work MUCH easier.

_________________
~ B r () n c ()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2009, 7:05 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Use a CSV file instead of XLS, since it can be edited by both AHK and Excel. Here's an example.
Code:
Gui, Add, Text,,Operator Name
Gui, Add, ComboBox, vCB, name1|name2|name3|name4
Gui, Add, Button, Default, Save
Gui, Add, Button, x+10, Close

Gui, Show,,Operator Name
return
ButtonClose:
GuiClose:
ExitApp

ButtonSave:
Gui, Submit, NoHide
FileAppend, %CB%`n, operator.csv
return


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 18th, 2009, 4:16 pm 
Offline

Joined: August 26th, 2007, 12:23 am
Posts: 50
Location: USA
Is there a way to make the entries go left to right and not top to bottom?

This is the current script. Is there an easier way to do this but still keep it easy for my beginner eyes to follow the flow thru the script?

Code:
;gui to collect downtime data for excel sheet

Gui, Add, Text, x122 y0 w230 h20 , What is the sate of the machine?
; once mach down button is pressed start timer
Gui, Add, Button, x136 y20 w40 h30,red.bmp, Mach Down
; once mach up button is pressed end timer and record ttl time down.
Gui, Add, Button, x226 y20 w40 h30,green.bmp, Mach Up

Gui, Add, Text, x6 y70 w80 h20 , Operator
Gui, Add, ComboBox, voperator,x6 y110 w110 h250, |OPERATOR#1|OPERATOR#2|OPERATOR#3|OPERATOR#4|OPERATOR#5|OPERATOR#6|OPERATOR#7|OPERATOR#8|OPERATOR#9|OPERATOR#10|OPERATOR#11|OPERATOR#12|OPERATOR#13|OPERATOR#14|OPERATOR#15|OPERATOR#16|OPERATOR#17|OPERATOR#18|OPERATOR#19|OPERATOR#20|

Gui, Add, Text, x126 y70 w60 h30 , Is machine runable?
Gui, Add, CheckBox, x126 y100 w60 h30 , Yes
Gui, Add, CheckBox, x126 y130 w60 h30 , No

Gui, Add, Text, x216 y70 w250 h30 , What is the problem with the machine?
Gui, Add, ComboBox, vproblem, x216 y110 w250 h240 , |Jam In Stacker Section|Jam In Transport|Poor Print Quality|Broken Augger|Broken Beater|Broken Gate|Loud Noise|Broken Belt

Gui, Add, Text, x6 y220 w60 h20 , Tech Name
Gui, Add, DropDownList, vtech, x6 y250 w60 h100 +Center, |CLL|RB|DH|TC|BT|BE

Gui, Add, Text, x126 y180 w60 h30 , Is machine runable?
Gui, Add, CheckBox, x126 y210 w60 h30 , Yes
Gui, Add, CheckBox, x126 y240 w60 h30 , No

Gui, Add, Text, x216 y220 w250 h20 , What was done to fix the problem?
Gui, Add, ComboBox, vfix, x216 y250 w250 h110 , |Dirty Sensor|Cleaned Print Head|Replaced Augger|Replaced Beater|Gate was|Made new belt|replaced pully|

Gui, Add, Button, x346 y330 , Save
Gui, Add, Button, x216 y330 w100 h30 , Cancel

; Done with gui

Gui, Show, x131 y91 h374 w481, Downtime
Return


ButtonCancel:
ExitApp

ButtonSave:
Gui, Submit, NoHide
FileAppend, %operator%`n, operator.csv
FileAppend, %problem%`n, operator.csv
FileAppend, %tech%`n, operator.csv
FileAppend, %fix%`n, operator.csv
return


I have tried a couple of ways to get around my problems but i need help so i have posted my code and my problems to see if any1 has suggestions.

Problems
1. I see text in my drop down boxes example (x6 y110 w110 h250, )
2. Need the entries in operator.csv to go left to right not up and down.
3. After searching i still don't understand why my mach down and mach up buttons are not in red and green. in the directory i saved the colors red.bmp and green.bmp
4. At the end when i do my fileappends can i do them all in one line of code like
Code:
FileAppend, %operator%, %problem%, %tech%, %fix%`n, operator.csv


As always ty to all for reading and taking the time to help.

_________________
~ B r () n c ()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 19th, 2009, 11:45 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Here's what I came up with. See what you think.
Code:
;gui to collect downtime data for excel sheet

Gui, Add, Text, x122, What is the state of the machine?
Gui, Add, Radio, w75 gDown, DOWN       ;start timer
Gui, Add, Radio, x+10 gUp Section, UP  ;stop timer

Gui, Add, Text, xm y+50, Operator
Gui, Add, Text, xs yp, What is the problem with the machine?

Loop,20
 list .= "Operator#" A_Index "|"
Gui, Add, ComboBox, xm vOperator, %list%
Gui, Add, ComboBox, xs yp vProblem
, Jam In Stacker Section
 |Jam In Transport
 |Poor Print Quality
 |Broken Augger
 |Broken Beater
 |Broken Gate
 |Loud Noise
 |Broken Belt

Gui, Add, Text, xm, Is machine runable?
Gui, Add, Radio,,Yes
Gui, Add, Radio,,No

Gui, Add, Text, y+50, Tech Name
Gui, Add, Text, xs yp, What was done to fix the problem?

Gui, Add, DropDownList, xm vTech, CLL|RB|DH|TC|BT|BE
Gui, Add, ComboBox, xs yp vFix
, Dirty Sensor
 |Cleaned Print Head
 |Replaced Augger
 |Replaced Beater
 |Gate was
 |Made new belt
 |Replaced pully

Gui, Add, Text, xm, Is machine runable?
Gui, Add, Radio,,Yes
Gui, Add, Radio,,No

Gui, Add, Button, x122 w75, Save
Gui, Add, Button, x+10 wp, Cancel

Gui, Font, Bold
Gui, Add, StatusBar, -Theme vSB

Gui, Show,,DownTime
return               ;Done with gui
GuiClose:
ButtonCancel:
ExitApp

DOWN:
GuiControl, +BackgroundRed, SB
SB_SetText("Machine is DOWN")
start := A_Now
SetTimer, DownTime, 1000
return

UP:
SetTimer, DownTime, Off
GuiControl, +BackgroundGreen, SB
SB_SetText("Machine is UP " time)
return

DownTime:
T := 20000101000000, time := ""
time -= start, seconds
T += time, seconds
FormatTime, time, %T%, HH:mm:ss
SB_SetText("Machine is DOWN " time)
return

ButtonSave:
Gui, Submit, NoHide
FileAppend
 , %operator%`,%problem%`,%tech%`,%fix%`n
 , operator.csv
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject: almost done
PostPosted: August 21st, 2009, 7:14 pm 
Offline

Joined: August 26th, 2007, 12:23 am
Posts: 50
Location: USA
WOW just WOW
you helped me a ton and you did it in a way that made it easier for me to learn the code.

i made a couple of changes
Code:
;gui to collect downtime data for excel sheet

Gui, Add, Text, x122, What is the state of the machine?
Gui, Add, Radio, w75 gDown, DOWN       ;start timer
Gui, Add, Radio, x+10 gUp Section, UP  ;stop timer

Gui, Add, Text, xm y+50, Operator
Gui, Add, Text, xs yp, What is the problem with the machine?

Loop,20
 list .= "Operator#" A_Index "|"
Gui, Add, ComboBox, xm vOperator, %list%
Gui, Add, ComboBox, xs yp vProblem
, Jam In Stacker Section
 |Jam In Transport
 |Poor Print Quality
 |Broken Augger
 |Broken Beater
 |Broken Gate
 |Loud Noise
 |Broken Belt

Gui, Add, Text, xm, Is machine runable?
Gui, Add, Radio, vyes ,Yes
Gui, Add, Radio, vno ,No

Gui, Add, Text, y+50, Tech Name
Gui, Add, Text, xs yp, What was done to fix the problem?

Gui, Add, ComboBox, xm vTech, CLL|RB|DH|TC|BT|BE
Gui, Add, ComboBox, xs yp vFix
, Dirty Sensor
 |Cleaned Print Head
 |Replaced Augger
 |Replaced Beater
 |Gate was
 |Made new belt
 |Replaced pully


Gui, Add, Text, y+50, Type of Reapair.
Gui, Add, ComboBox, xs vType, DT|PM|UM|ST


Gui, Add, Button, x122 w75, Save
Gui, Add, Button, x+10 wp, Cancel

Gui, Font, Bold
Gui, Add, StatusBar, -Theme vSB

Gui, Show,,DownTime
return               ;Done with gui
GuiClose:
ButtonCancel:
ExitApp

DOWN:
GuiControl, +BackgroundRed, SB
SB_SetText("Machine is DOWN")
start := A_Now
SetTimer, DownTime, 1000
return

UP:
SetTimer, DownTime, Off
GuiControl, +BackgroundGreen, SB
SB_SetText("Machine is UP " time)
return

DownTime:
T := 20000101000000, time := ""
time -= start, seconds
T += time, seconds
FormatTime, time, %T%, HH:mm:ss
SB_SetText("Machine is DOWN " time)
return

ButtonSave:
Gui, Submit, NoHide
FileAppend
 , %type%`,%operator%`,%problem%`,%tech%`,%fix%`n
 , operator.csv
return


Only 2 problems that i can see still remain.

problems
1. any way to take the time answer and have it go to the csv?
Worse question than that is what if i start the form being filled out and the timer is running, but the fix is to reboot the pc? maybe i should have a combobox and just type the time in? option 2? Maybe record the time down and then time up and do the math? i believe for this project seeing the answer isn't as important as having the answer in the csv file, i think.

2. decided i didn't need the radios for is the machine runnable and replaced with type of repair and added the %type%`, command in the fileappend to pull data to the csv. Was having a problem deleting the 1st is the machine runnable radio's. All ready deleted the 2nd set to add my type.

(2nd set deleted fine)

_________________
~ B r () n c ()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2009, 9:46 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Here's an answer to the GUI problem, and I simply added the %time% variable to the spreadsheet. If you'd like to save the %time% somewhere else in case the PC is rebooted, and then add to it before putting it in the spreadsheet, that would work fine too.
Code:
;gui to collect downtime data for excel sheet

Gui, Add, Text, x122, What is the state of the machine?
Gui, Add, Radio, w75 gDown, DOWN       ;start timer
Gui, Add, Radio, x+10 gUp Section, UP  ;stop timer

Gui, Add, Text, xm y+50, Operator
Gui, Add, Text, xs yp, What is the problem with the machine?

Loop,20
 list .= "Operator#" A_Index "|"
Gui, Add, ComboBox, xm vOperator, %list%
Gui, Add, ComboBox, xs yp vProblem
, Jam In Stacker Section
 |Jam In Transport
 |Poor Print Quality
 |Broken Augger
 |Broken Beater
 |Broken Gate
 |Loud Noise
 |Broken Belt

Gui, Add, Text, xm y+50, Tech Name
Gui, Add, Text, xs yp, What was done to fix the problem?

Gui, Add, ComboBox, xm vTech, CLL|RB|DH|TC|BT|BE
Gui, Add, ComboBox, xs yp vFix
, Dirty Sensor
 |Cleaned Print Head
 |Replaced Augger
 |Replaced Beater
 |Gate was
 |Made new belt
 |Replaced pully

Gui, Add, Text,,Type of Repair?
Gui, Add, ComboBox, xs vType, DT|PM|UM|ST

Gui, Add, Button, x122 y+50 w75, Save
Gui, Add, Button, x+10 wp, Cancel

Gui, Font, Bold
Gui, Add, StatusBar, -Theme vSB

Gui, Show,,DownTime
return               ;Done with gui
GuiClose:
ButtonCancel:
ExitApp

DOWN:
GuiControl, +BackgroundRed, SB
SB_SetText("Machine is DOWN")
start := A_Now
SetTimer, DownTime, 1000
return

UP:
SetTimer, DownTime, Off
GuiControl, +BackgroundGreen, SB
SB_SetText("Machine is UP " time)
return

DownTime:
T := 20000101000000, time := ""
time -= start, seconds
T += time, seconds
FormatTime, time, %T%, HH:mm:ss
SB_SetText("Machine is DOWN " time)
return

ButtonSave:
Gui, Submit, NoHide
FileAppend
 , %type%`,%operator%`,%problem%`,%tech%`,%fix%`,%time%`n
 , operator.csv
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Ty
PostPosted: August 24th, 2009, 7:41 pm 
Offline

Joined: August 26th, 2007, 12:23 am
Posts: 50
Location: USA
How can i thank you!!!!

i took what i learned here and went on to my second project and had no problems at all.

Once again Thank you for taking the time to help out!

_________________
~ B r () n c ()


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group