JustinReno Posted April 2, 2008 Share Posted April 2, 2008 (edited) I got bored (Yet again) for a last couple of late (11 >) nights, and created an Inventory program. Its fairly simple, but it gets the job done.Features:1. Includes Name, ID Number, Category, Condition, Date Purchased, and a Picture.2. Able to search items with the (Random) ID number.3. When viewing an item, (If it has a picture), you can click on the picture to make is bigger (640x480)Notes:1. IF you select a picture when you add an item, it copies the picture into the script directory!Screenshot:No EXE, but here is the script:expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author : JustinReno (Jardenix) Script Function: Inventory Software created by Justin Reno 2008. Credit is expected were due. #CE ---------------------------------------------------------------------------- #NoTrayIcon #Include <GUIListBox.au3> Global $Ini = @ScriptDir & "\Inventory.ini" Global $GetInventory Global $Picture $GUI = GUICreate("Inventory", 307, 450) GUICtrlCreateLabel("Items:", 0, 0, 32, 17) $Items = GUICtrlCreateList("", 0, 16, 121, 383) $Add_Item = GUICtrlCreateButton("Add Item", 120, 16, 75, 25, 0) $Delete_Item = GUICtrlCreateButton("Delete Item", 200, 16, 75, 25, 0) GUICtrlCreateLabel("Item Properties:", 120, 48, 77, 17) GUICtrlCreateLabel("Name:", 120, 64, 35, 17) $Name = GUICtrlCreateInput("", 120, 80, 121, 21) GUICtrlCreateLabel("ID Number:", 120, 104, 58, 17) $ID_Number = GUICtrlCreateInput("", 120, 120, 121, 21) GUICtrlCreateLabel("Category:", 120, 144, 49, 17) $Category = GUICtrlCreateInput("", 120, 160, 121, 21) GUICtrlCreateLabel("Condition:", 120, 184, 51, 17) $Condition = GUICtrlCreateInput("", 120, 200, 121, 21) GUICtrlCreateLabel("Date Purchased:", 120, 224, 84, 17) $Date_Purchased = GUICtrlCreateInput("", 120, 240, 186, 21) GUICtrlCreateLabel("Picture:", 120, 264, 40, 17) $Picture = GUICtrlCreatePic("", 120, 280, 185, 168) $Search_Input = GUICtrlCreateInput("", 0, 400, 121, 21) $Search = GUICtrlCreateButton("Search ID Numbers", 0, 424, 122, 25, 0) If IniReadSectionNames($Ini) <> @error Then _GetInventory() GUISetState(@SW_SHOW, $GUI) If IniReadSectionNames($Ini) <> @error Then WinSetTitle($GUI, "", "Inventory - " & $GetInventory[0] & " items") While 1 Switch GUIGetMsg() Case - 3 Exit Case $Add_Item _AddItem() Case $Delete_Item IniDelete($Ini, GUICtrlRead($Items)) GUICtrlSetData($Items, StringReplace(GUICtrlRead($Items), GUICtrlRead($Items), "")) Case $Search If GUICtrlRead($Search_Input) <> 0 And StringIsDigit(GUICtrlRead($Search_Input)) Then $GetItems = IniReadSectionNames($Ini) For $I = 1 To $GetItems[0] If IniRead($Ini, $GetItems[$I], "ID Number", "") = GUICtrlRead($Search_Input) Then $Found = $GetItems[$I] ExitLoop EndIf Next _GUICtrlListBox_SetCurSel ($Items, _GUICtrlListBox_FindString ($Items, $Found)) EndIf Case $Items GUICtrlSetData($Name, IniRead($Ini, GUICtrlRead($Items), "Name", "")) GUICtrlSetData($ID_Number, IniRead($Ini, GUICtrlRead($Items), "ID Number", "")) GUICtrlSetData($Category, IniRead($Ini, GUICtrlRead($Items), "Category", "")) GUICtrlSetData($Condition, IniRead($Ini, GUICtrlRead($Items), "Condition", "")) GUICtrlSetData($Date_Purchased, IniRead($Ini, GUICtrlRead($Items), "Date Purchased", "")) If IniRead($Ini, GUICtrlRead($Items), "Picture", "") <> Default Then GUICtrlSetImage($Picture, @ScriptDir & "\" & IniRead($Ini, GUICtrlRead($Items), "Picture", "")) Case $Picture _OpenPicture() EndSwitch WEnd Func _AddItem() Dim $GetPicture MsgBox(64, "Add Item", "Press EXIT to save the item!") $GUI = GUICreate("Add Item", 125, 341, -1, -1, -1, 0x00000080) GUICtrlCreateLabel("Item Name:", 0, 0, 58, 17) $Item_Name = GUICtrlCreateInput("", 0, 16, 121, 21) GUICtrlCreateLabel("ID Number:", 0, 40, 58, 17) $ID_Number = GUICtrlCreateInput(Round(Random(100, 999, 1)), 0, 56, 121, 21) GUICtrlCreateLabel("Category:", 0, 80, 49, 17) $Category = GUICtrlCreateCombo("", 0, 96, 121, 25) GUICtrlSetData($Category, "Furniture|Electronics|Animal|Office|Health") GUICtrlCreateLabel("Condition:", 0, 120, 51, 17) $Condition = GUICtrlCreateCombo("", 0, 136, 121, 25) GUICtrlSetData($Condition, "Excellent|Good|Ok|Poor") GUICtrlCreateLabel("Date Purchased:", 0, 160, 84, 17) $Date_Purchased = GUICtrlCreateInput("", 0, 176, 121, 21) GUICtrlCreateLabel("Picture:", 0, 200, 40, 17) $Add_Picture = GUICtrlCreateButton("Add Picture", 0, 216, 123, 25, 0) $Picture = GUICtrlCreatePic("", 0, 240, 124, 100) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case - 3 IniWrite($Ini, GUICtrlRead($Item_Name), "Name", GUICtrlRead($Item_Name)) IniWrite($Ini, GUICtrlRead($Item_Name), "ID Number", GUICtrlRead($ID_Number)) IniWrite($Ini, GUICtrlRead($Item_Name), "Category", GUICtrlRead($Category)) IniWrite($Ini, GUICtrlRead($Item_Name), "Condition", GUICtrlRead($Condition)) IniWrite($Ini, GUICtrlRead($Item_Name), "Date Purchased", GUICtrlRead($Date_Purchased)) If $GetPicture <> "" Then $PictureName = StringSplit($GetPicture, "\") FileCopy($GetPicture, @ScriptDir & "\" & $PictureName[$PictureName[0]]) IniWrite($Ini, GUICtrlRead($Item_Name), "Picture", $PictureName[$PictureName[0]]) EndIf GUIDelete($GUI) If @Compiled = 0 Then Run(@AutoItExe & " " & FileGetShortName(@ScriptFullPath)) If @Compiled = 1 Then Run(@ScriptFullPath) Exit Case $Add_Picture $GetPicture = FileOpenDialog("Add Item", @ScriptDir, "Pictures(*.jpg; *.bmp; *.png)") GUICtrlSetImage($Picture, $GetPicture) EndSwitch WEnd EndFunc ;==>_AddItem Func _OpenPicture() $GUI = GUICreate(GUICtrlRead($Items), 640, 480) $PictureBig = GUICtrlCreatePic(@ScriptDir & "\" & IniRead($Ini, GUICtrlRead($Items), "Picture", ""), 0, 0, 640, 480) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case - 3 GUIDelete($GUI) ExitLoop EndSwitch WEnd EndFunc ;==>_OpenPicture Func _GetInventory() $GetInventory = IniReadSectionNames($Ini) For $I = 1 To $GetInventory[0] GUICtrlSetData($Items, $GetInventory[$I]) Next EndFunc ;==>_GetInventoryPlease leave comments, and feel free to modify it. Just give original author credit (Justin Reno 2008). Edited April 2, 2008 by JustinReno Link to comment Share on other sites More sharing options...
kuzotare Posted April 2, 2008 Share Posted April 2, 2008 hi, i tried to compile your scritp , but i receive this error : "Subscript used with non-Array variable" Link to comment Share on other sites More sharing options...
JamesDover Posted April 2, 2008 Share Posted April 2, 2008 I got the same error. It would be great if this would dump to a sql data base. Cheers Link to comment Share on other sites More sharing options...
eazee Posted April 2, 2008 Share Posted April 2, 2008 Had the same error, so I changed line 14 with the declaration of the variable into Global $GetInventory[100] Now it works, should have place for 99 entries?! Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 2, 2008 Share Posted April 2, 2008 Hi, there are some more problems. :-) If you just hit serach ID Numbers it also erros out. Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
gseller Posted April 2, 2008 Share Posted April 2, 2008 I had the same problem, to get it to work you have to add the ini file to the script directory and add at least one ini section[Electronics]... Link to comment Share on other sites More sharing options...
JustinReno Posted April 2, 2008 Author Share Posted April 2, 2008 (edited) Do you guys have AutoIt 3.2.10.0?Edit: I'm reposting the code now, The top line of the script does not have to be a variable. It was the line that sets the window title.Clarification: The top line doesn't have to be a variable because, if you have inventory already there (Like I did), I didn't recieve the error because $GetInventory[0] was already declared (When it read the inventory into the ListBox). If you don't have any inventory, it didn't declare $GetInventory[0]. Edit again: If you follow Gesller's advice, it would a inventory item called Electronics (And if INIRead crashed AutoIt because of an error (Like most functions) you would recieve many errors!) Edited April 2, 2008 by JustinReno Link to comment Share on other sites More sharing options...
Swift Posted April 2, 2008 Share Posted April 2, 2008 Yes, that's what im using, and it errors out, at before the script starts, if you fix that and try to search, it errors out.... Link to comment Share on other sites More sharing options...
JustinReno Posted April 2, 2008 Author Share Posted April 2, 2008 I just fixed the bug in the search function, thanks. Updated above. Link to comment Share on other sites More sharing options...
JustinReno Posted April 4, 2008 Author Share Posted April 4, 2008 Anyone? Link to comment Share on other sites More sharing options...
Swift Posted April 4, 2008 Share Posted April 4, 2008 I don't really think it's useful. Too, well, A bussiness wouldn't use it. It would be more useful, if you made it better looking with more features. Link to comment Share on other sites More sharing options...
JustinReno Posted April 4, 2008 Author Share Posted April 4, 2008 What features? Link to comment Share on other sites More sharing options...
Swift Posted April 4, 2008 Share Posted April 4, 2008 (edited) SQLite, to save everything there, instead of a ini. Full size GUI, with a context menu, and a menu. Colors. Pictures. Nicer GUI to imput new stuff. Tray tips. Resizable. ListBox &/Or ListView Stuff Like That! Edited April 4, 2008 by R6V2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now