Sign in to follow this  
Followers 0
mblunk

Newegg computer builder - almost done...

7 posts in this topic

Ok, so my newegg computer builder, which you guys thought impossible, is nearing completion. I'm having a problem though, when I add more parts, instead of making the group bigger, it simply moves the group down.

combuild.au3

CODE

;newegg computer builder

;all code by aric blunk

;http://secure.newegg.com/NewVersion/shopping/AddtoCart.asp?Submit=ADD&itemList=N82E16813157108%7C1,N82E16827101131%7C1,N82E16811119068%7C1,N82E16819103747%7C1,N82E16820231098%7C1,N82E16822136062%7C1,N82E16817153023%7C1,N82E16814102079%7C1&preitemList=

#cs

* means space

^ joins segments of parts

space seperates parts

#ce

#include <GuiConstants.au3> ;Include GUI functions

#include <File.au3> ;Include file handling funcs

$casegrp = ""

$mobogrp = ""

$cpugrp = ""

$ramgrp = ""

$gpugrp = ""

$hddgrp = ""

$psugrp = ""

$opdgrp = ""

$mscgrp = ""

Func AddCase($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$casegrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddCase

Func AddMobo($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$mobogrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddMobo

Func AddCPU($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$cpugrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddCPU

Func AddRAM($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$ramgrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddRAM

Func AddGPU($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$gpugrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddGPU

Func AddHDD($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$hddgrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddHDD

Func AddPSU($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$psugrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddPSU

Func AddOpticalDrive($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$opdgrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddOpticalDrive

Func AddMisc($name, $price, $url, $count)

$_name = StringReplace($name, " ", "*")

$mscgrp &= " " & $_name & "^" & $price & "^" & $url & "^" & $count

EndFunc ;==>AddMisc

$partslist = @ScriptDir & "\parts.txt"

$partslistlines = _FileCountLines($partslist)

For $i = 1 To $partslistlines

$curline = FileReadLine($partslist, $i)

Execute($curline)

Next

$numcases = StringCountOccurances($casegrp, " ")

$nummobos = StringCountOccurances($mobogrp, " ")

$numcpus = StringCountOccurances($cpugrp, " ")

$numrams = StringCountOccurances($ramgrp, " ")

$numgpus = StringCountOccurances($gpugrp, " ")

$numhdds = StringCountOccurances($hddgrp, " ")

$numpsus = StringCountOccurances($psugrp, " ")

$numopds = StringCountOccurances($opdgrp, " ")

$nummiscs = StringCountOccurances($mscgrp, " ")

$numparts = $numcases + $nummobos + $numcpus + $numrams + $numgpus + $numhdds + $numpsus + $numopds + $nummiscs

$costcase = GetPrice($casegrp, 0, $numcases)

$costmobo = GetPrice($mobogrp, 0, $nummobos)

$costcpu = GetPrice($cpugrp, 0, $numcpus)

$costram = GetPrice($ramgrp, 0, $numrams)

$costgpu = GetPrice($gpugrp, 0, $numgpus)

$costhdd = GetPrice($hddgrp, 0, $numhdds)

$costpsu = GetPrice($psugrp, 0, $numpsus)

$costopd = GetPrice($opdgrp, 0, $numopds)

$costmisc = GetPrice($mscgrp, 0, $nummiscs)

#cs

getpice - find the price of an entire group or item

(item = 0 for whole group, 1 for specific item)

numitems should be the number of items in the group for whole group cost, or the item in the group for specific item cost

#ce

Func GetPrice($group, $item, $numitems)

$price = 0

If $item = 0 Then

$searchchar = 0 ;the character we're checking

For $i = 1 To $numitems ;do this for each product in the group

$searchchar += 1

$foundprice = 0 ;have we found any seperators?

While $foundprice = 0 ;no seperators found yet

$curchar = StringLeft($group, $searchchar) ;copy the group up until this character

$curchar = StringRight($curchar, 1) ;copy only the last character

If $curchar = "^" Then ;if we've struck a seperator

$pos1 = $searchchar ;where the first seperator is

$foundprice = 1 ;now to find the next

Else ;haven't found it (yet)

$searchchar += 1 ;look at the next character in the group

EndIf

WEnd

$searchchar += 1 ;now to find next seperator (to isolate the price)

While $foundprice = 1 ;we've found the first seperator, now to find the next

$curchar = StringLeft($group, $searchchar)

$curchar = StringRight($curchar, 1)

If $curchar = "^" Then

$pos2 = $searchchar

$foundprice = 2

Else

$searchchar += 1

EndIf

WEnd

$pricechars = $pos2 - $pos1 ;how many chars long is the price

$thisprice = Number(StringMid($group, $pos1, $pricechars)) ;get the price

$price += $thisprice ;add this item's price to the total

Next

Else

$founditemstart = 0

$curitem = 0

While $founditemstart = 0 ;no seperators found yet

$curchar = StringLeft($group, $searchchar) ;copy the group up until this character

$curchar = StringRight($curchar, 1) ;copy only the last character

If $curchar = " " Then ;if we've struck a seperator

$curitem += 1

If $curitem = $numitems Then

$itemcode = StringRight($group, StringInStr($searchchar, "") - $searchchar) ;store the item's code

$founditemstart = 1 ;found the item

EndIf

Else ;haven't found it (yet)

$searchchar += 1 ;look at the next character in the group

EndIf

WEnd

$searchchar = 1 ;the character we're checking

$foundprice = 0 ;have we found any seperators?

While $foundprice = 0 ;no seperators found yet

$curchar = StringLeft($itemcode, $searchchar) ;copy the group up until this character

$curchar = StringRight($curchar, 1) ;copy only the last character

If $curchar = "^" Then ;if we've struck a seperator

$pos1 = $searchchar ;where the first seperator is

$foundprice = 1 ;now to find the next

Else ;haven't found it (yet)

$searchchar += 1 ;look at the next character in the group

EndIf

WEnd

$searchchar += 1 ;now to find next seperator (to isolate the price)

While $foundprice = 1 ;we've found the first seperator, now to find the next

$curchar = StringLeft($itemcode, $searchchar)

$curchar = StringRight($curchar, 1)

If $curchar = "^" Then

$pos2 = $searchchar

$foundprice = 2

Else

$searchchar += 1

EndIf

WEnd

$pricechars = $pos2 - $pos1 ;how many chars long is the price

$thisprice = Number(StringMid($group, $pos1, $pricechars)) ;get the price

$price += $thisprice ;add this item's price to the total

EndIf

Return $price

EndFunc ;==>GetPrice

Func StringCountOccurances($basestring, $substring)

StringReplace($basestring, $substring, $substring)

$occurances = @extended

Return $occurances

EndFunc ;==>StringCountOccurances

;MsgBox(0, "", "Cases:" & $casegrp & @CR & "Mobos:" & $mobogrp & @CR & "CPUs:" & $cpugrp & @CR & "RAM:" & $ramgrp & @CR & "GPUs:" & $gpugrp & @CR & "HDDs:" & $hddgrp & @CR & "PSUs:" & $psugrp & @CR & "OPDs:" & $opdgrp & @CR & "Misc:" & $mscgrp)

;format the gui

$addtotop = 0 ;extra room at top

$addtobottom = 0 ;extra room at bottom

$guiheight = ($numparts * 20) ;allocate 20 pixels per part

$guiheight += ((9 * 10) * 2) ;allocate 10 pixels for the top and bottom of each group

$guiheight_final = $guiheight + $addtotop ;room for other stuff

$guiwidth = 500 ;how wide the gui should be

;how much room we should allocate per group

$casespace = $numcases * 20

$mobospace = $nummobos * 20

$cpuspace = $numcpus * 20

$ramspace = $numrams * 20

$gpuspace = $numgpus * 20

$hddspace = $numhdds * 20

$psuspace = $numpsus * 20

$opdspace = $numopds * 20

$miscspace = $nummiscs * 20

$_casespace = $casespace + 20

$_mobospace = $mobospace + 20

$_cpuspace = $cpuspace + 20

$_ramspace = $ramspace + 20

$_gpuspace = $gpuspace + 20

$_hddspace = $hddspace + 20

$_psuspace = $psuspace + 20

$_opdspace = $opdspace + 20

$_miscspace = $miscspace + 20

;calculate how much room is left under each group

$room_under_top = $guiheight

$room_under_case = $guiheight - $_casespace

$room_under_mobo = $guiheight - $_casespace - $_mobospace

$room_under_cpu = $guiheight - $_casespace - $_mobospace - $_cpuspace

$room_under_ram = $guiheight - $_casespace - $_mobospace - $_cpuspace - $_ramspace

$room_under_gpu = $guiheight - $_casespace - $_mobospace - $_cpuspace - $_ramspace - $_gpuspace

$room_under_hdd = $guiheight - $_casespace - $_mobospace - $_cpuspace - $_ramspace - $_gpuspace - $_hddspace

$room_under_psu = $guiheight - $_casespace - $_mobospace - $_cpuspace - $_ramspace - $_gpuspace - $_hddspace - $_psuspace

$room_under_opd = $guiheight - $_casespace - $_mobospace - $_cpuspace - $_ramspace - $_gpuspace - $_hddspace - $_psuspace - $_opdspace

$room_under_misc = $guiheight - $_casespace - $_mobospace - $_cpuspace - $_ramspace - $_gpuspace - $_hddspace - $_psuspace - $_opdspace - $_miscspace

;re-order them

$pos_case = $guiheight_final - $room_under_case - 20

$pos_mobo = $guiheight_final - $room_under_mobo - 20

$pos_cpu = $guiheight_final - $room_under_cpu - 20

$pos_ram = $guiheight_final - $room_under_ram - 20

$pos_gpu = $guiheight_final - $room_under_gpu - 20

$pos_hdd = $guiheight_final - $room_under_hdd - 20

$pos_psu = $guiheight_final - $room_under_psu - 20

$pos_opd = $guiheight_final - $room_under_opd - 20

$pos_misc = $guiheight_final - $room_under_misc - 20

;#cs

$adjusterthingy = 20

If $numcases = 0 Then

$pos_case += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $nummobos = 0 Then

$pos_mobo += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $numcpus = 0 Then

$pos_cpu += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $numrams = 0 Then

$pos_ram += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $numgpus = 0 Then

$pos_gpu += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $numhdds = 0 Then

$pos_hdd += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $numpsus = 0 Then

$pos_psu += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $numopds = 0 Then

$pos_opd += $adjusterthingy

$guiheight_final += $adjusterthingy

ElseIf $nummiscs = 0 Then

$pos_misc += $adjusterthingy

$guiheight_final += $adjusterthingy

EndIf

;#ce

;MsgBox(0, "", $room_under_top & @CR & $room_under_case & @CR & $room_under_mobo & @CR & $room_under_cpu & @CR & $room_under_ram & @CR & $room_under_gpu & @CR & $room_under_hdd & @CR & $room_under_psu & @CR & $room_under_opd & @CR & $room_under_misc)

;MsgBox(0, "", $_miscspace)

GUICreate("Newegg computer builder", $guiwidth, $guiheight_final+$addtobottom+15)

GUICtrlCreateGroup("Cases", 5, $pos_case, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("Motherboards", 5, $pos_mobo, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("CPUs", 5, $pos_cpu, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("Memory", 5, $pos_ram, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("Graphics cards", 5, $pos_gpu, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("Hard drives", 5, $pos_hdd, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("Power supplies", 5, $pos_psu, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("Optical drives", 5, $pos_opd, $guiwidth - 10, $_casespace)

GUICtrlCreateGroup("Misc. items", 5, $pos_misc, $guiwidth - 10, $_casespace)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case Else

;incase we do something

EndSelect

WEnd

parts.txt

CODE

;newegg computer builder parts list

;Add parts by using the following functions:

;AddCase()

;AddMobo()

;AddCPU()

;AddRAM()

;AddGPU()

;AddHDD()

;AddPSU()

;AddOpticalDrive()

;AddMisc()

;in the (), put "name of item", "price", "newegg url extension", "number of these to buy"

;"price" should be the combined cost for all multiple items, ex. two 29.99 sticks of memory should be 59.98 with the two at the end of the add function

;example parts list:

;AddCase("ExCase", "29.99", "CASEURL", "1")

;AddMobo("ExMobo", "149.99", "MOBOURL", "1")

;AddCPU("ExCPU", "249.99", "CPUURL", "1")

;AddRAM("ExRAM", "49.99", "RAMURL", "2")

;AddGPU("ExGPU", "349.99", "GPUURL", "1")

;AddHDD("ExHDD", "49.99", "HDDURL", "1")

;AddPSU("ExPSU", "49.99", "PSUURL", "1")

;AddOpticalDrive("ExOPD", "149.99", "OPDURL", "1")

;AddMisc("ExMisc", "149.99", "MISCURL", "1")

; add parts below this line

AddCase("Aplus Monolith", "119.99", "N82E16811294006", "1")

AddMobo("Gigabyte x38", "349.99", "N82E16813128068", "1")

AddCPU("Q6600", "277.99", "N82E16819115017", "1")

AddRAM("Kingston 533mhz", "109.98", "N82E16820144157", "2")

AddGPU("EVGA 8800gts 640mb", "384.99", "N82E16814130071", "1")

AddHDD("WD 7200rpm 16mb cache 250gb", "69.99", "N82E16822144701", "1")

AddPSU("Coolmax 700w", "139.99", "N82E16817159058", "1")

;AddOpticalDrive("None", "0", "OPDURL", "0")

AddMisc("Zalman 9700 cpu cooler", "59.99", "N82E16835118020", "1")

AddMisc("Arctic silver 5 thermal grease", "5.99", "N82E16835100007", "1")

AddMisc("Arctic silver 5 thermal grease", "5.99", "N82E16835100007", "1")

AddMisc("Arctic silver 5 thermal grease", "5.99", "N82E16835100007", "1")

AddMisc("Arctic silver 5 thermal grease", "5.99", "N82E16835100007", "1")

Share this post


Link to post
Share on other sites

can you elaborate or make a demo of the problem?

what does the part.txt file do?

the script you posted doesn't seem to have any functionality other than showing a GUI...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

His part.txt is his pseudo database of NewEgg's huge database. I pointed out to him before that unless he has access to the NewEgg database, he has to update his partslist manually...which apparently what he wants to do. :/

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

His part.txt is his pseudo database of NewEgg's huge database. I pointed out to him before that unless he has access to the NewEgg database, he has to update his partslist manually...which apparently what he wants to do. :/

Yes. That way, you just have to pick out the parts you're considering getting. Kinda like an off-line compare feature, but for an entire computer.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ok, so we're suposed to load that list into the program?

In my mind your question is why the groups in you GUI dont expand if you add to much text to them(instead the text just flows over?)....is that the case?

Edited by evilertoaster

Share this post


Link to post
Share on other sites

Ok, so we're suposed to load that list into the program?

In my mind your question is why the groups in you GUI dont expand if you add to much text to them(instead the text just flows over?)....is that the case?

The problem is that when I add more parts, that group is supposed to expand and make more room. Instead, the group simply moves down the window. I'm trying to find out how I can make the group get bigger instead of simply move down.

Share this post


Link to post
Share on other sites

how do you add parts? What do i have to do in order to get the problem you are describing to happen? Currently a run the program and it shows a a screen like the sccreenshot attached. What do I from here?

post-5131-1192649145_thumb.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0