Jump to content

RepublicCommando

Members
  • Posts

    6
  • Joined

  • Last visited

RepublicCommando's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. Found this just yesterday, I've already implemented it into a project (Server of another app). I do have a problem though. Cin() blocks until something is sent to the console (Enter pressed). I am trying to use THIS AutoIt thread implementation to do the console stuff in a separate thread, and potentially separate client TCP stuff into threads as well, but it would be SO much easier just to allow Cin to return 0 if enter isn't pressed. I have Cin in a loop where I'm doing a lot of other networking stuff, but you can't do that if Cin is blocking everything until a command is entered..
  2. Just found this a couple days ago, I really like it! I have an example (heavily modified, though the display is close to the same, minus the progress bar and secondary window). This example is a great way to solve the inability to use GUIOnEventMode, and a great way to add more constantly updating code (like Network games, etc) in the future. This example has two scripts: Main.au3, and App.au3, where App.au3 is essentially the GUI code. Main.au3 has Three functions that get called automagicly for convenience and conservation sake: -OnStart(), which is invoked after the code is ready to roll -OnUpdate($FrameTime), which is invoked $UPDATESPERSECOND (a global constant) * Second, and supplies the time between frames, incase you need time sensitive code to adjust for lost time. -OnPreStop(), which is the function where you would put clean up code, all OnUpdate code is still valid in this function. -DoStop(), which causes the program to request stop immediately, obviously. App.au3 is the modified GUI code. Main.au3: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Jon/~RepComm Script Function: Main (Runs update clock, and exposes functions for application use) #ce ---------------------------------------------------------------------------- #include "App.au3" Opt ("MustDeclareVars", 1) Global Const $UPDATESPERSECOND = 30 Global $STATE = False ; Set to False when exiting from this script (Normally we just check _App_GetState() from App.au3) #Region =======Internal======== Init () Func Init() ; Called to initialize everything (Entry point) $STATE = True ;Global Const $UPDATESPERSECOND = 30 Global Const $TimeBetweenUpdates = 1000 / $UPDATESPERSECOND ; 1000 Millis = 1 second Global $IsRunning = true Global $oTimer = TimerInit() Global $nNowTime = 0 Global $nLastTime = 0 Global $nUpdateTime ; In OnUpdate(), this value can be used to get time the last frame took Global $nNowThenDifference ; Every frame cycle, this equals now - last OnStart() CauseUpdates() EndFunc Func CauseUpdates () ; Called to start the clock-invoked OnUpdate function While ($IsRunning) ; Constantly loop $nNowTime = TimerDiff($oTimer) ; Get difference from program startup to now $nNowThenDifference = $nNowTime - $nLastTime ; Difference from last time we updated to now If ($nNowThenDifference >= $TimeBetweenUpdates) Then ; If sufficient time has passed, Update If (_App_GetState() == False Or $STATE == False) Then ; Check if App.au3's code wants to stop Stop() ; Cause program to stop completely EndIf $nLastTime = $nNowTime ; Future use of vars $nUpdateTime = $nNowThenDifference ; $nUpdateTime is always the amount of time it took between frames (Second/Updates), NowThenDiff can potentially be any time inbetween OnUpdate($nUpdateTime) ; Invoke Update function $UPDATESPERSECOND * Second, supplying the time we took between frames (Useful for physics or time relative calculations) EndIf WEnd ; This function ends when the program ends EndFunc Func Stop () ; Call to stop program OnPreStop() ; All OnUpdate code is still valid for use in this function (Until IsRunning = False) $IsRunning = False ; Stops OnUpdate() From happening Exit ; Final stop EndFunc #EndRegion Func OnStart() ; Put initializing or startup code here ; Called after internal is already setup and ready to roll _App_Start() ; Tell App.au3's code to init its GUI 'n stuff EndFunc Func OnUpdate ($FrameTime) ; You can put constantly updating code here ; This function is called $UPDATESPERSECOND * Second ; $FrameTime is the time between this update, and the last one, in seconds. (Incase you have time-sensitive calculations to do) _App_Update($FrameTime) ; Update our GUI code in App.au3 EndFunc Func OnPreStop () ; You can put cleanup code here ; This function is called before the program actually does any cleaning, so all update code is still valid here _App_Stop() EndFunc Func DoStop() ; Call this function to request app stop immediately $STATE = False EndFunc App.au3: #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /rm /pe #AutoIt3Wrapper_Res_HiDpi=y #NoTrayIcon #include "MetroGUI-UDF\MetroGUI_UDF.au3" Global $STATE = False Global $nMsg Func _App_Start() $STATE = True _SetTheme("DarkAmber") _Metro_EnableHighDPIScaling() Global $hGUIMain = _Metro_CreateGUI("App", 720, 420, -1, -1, True) Global $Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True Global $GUI_CLOSE_BUTTON = $Control_Buttons[0] Global $GUI_MAXIMIZE_BUTTON = $Control_Buttons[1] Global $GUI_RESTORE_BUTTON = $Control_Buttons[2] Global $GUI_MINIMIZE_BUTTON = $Control_Buttons[3] Global $GUI_FULLSCREEN_BUTTON = $Control_Buttons[4] Global $GUI_FSRestore_BUTTON = $Control_Buttons[5] Global $GUI_MENU_BUTTON = $Control_Buttons[6] Global $Button1 = _Metro_CreateButton("Button Style 1", 105, 245, 130, 40) Global $Button2 = _Metro_CreateButtonEx("Button Style 2", 255, 245, 130, 40) Global $Checkbox1 = _Metro_CreateCheckbox("Checkbox 1", 30, 70, 125, 30) Global $Checkbox2 = _Metro_CreateCheckboxEx("Checkbox 2", 30, 107, 125, 30) _Metro_CheckboxCheck($Checkbox1) _Metro_CheckboxCheck($Checkbox2) Global $Radio1 = _Metro_CreateRadio("1", "Radio 1", 180, 70, 100, 30) Global $Radio2 = _Metro_CreateRadio("1", "Radio 2", 180, 110, 100, 30) _Metro_RadioCheck("1", $Radio1) Global $Toggle1 = _Metro_CreateToggle("Toggle 1", 320, 70, 130, 30) Global $Toggle2 = _Metro_CreateToggleEx("Toggle 2", 322, 107, 128, 30) Global $Toggle3 = _Metro_CreateOnOffToggle("Enabled", "Disabled", 320, 144, 130, 30) ;Create an Array containing menu button names Global $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"] GUICtrlSetResizing($Button1, 768 + 8) GUICtrlSetResizing($Button2, 768 + 8) GUICtrlSetResizing($Checkbox1, 768 + 2 + 32) GUICtrlSetResizing($Checkbox2, 768 + 2 + 32) GUICtrlSetResizing($Radio1, 768 + 2 + 32) GUICtrlSetResizing($Radio2, 768 + 2 + 32) GUICtrlSetResizing($Toggle1, 768 + 2 + 32) GUICtrlSetResizing($Toggle2, 768 + 2 + 32) GUICtrlSetResizing($Toggle3, 768 + 2 + 32) GUISetState(@SW_SHOW) EndFunc Func _App_Update ($FrameTime) ; Most of this code is staying the same, because _App_Update is in a constant loop (Main.au3's OnUpdate() function) _Metro_HoverCheck_Loop($hGUIMain) ; This was moved from a bland while() statement $nMsg = GUIGetMsg() Switch $nMsg ;=========================================Control-Buttons=========================================== Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON _Metro_GUIDelete($hGUIMain) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! _App_Stop() Case $GUI_MAXIMIZE_BUTTON GUISetState(@SW_MAXIMIZE) Case $GUI_RESTORE_BUTTON GUISetState(@SW_RESTORE) Case $GUI_MINIMIZE_BUTTON GUISetState(@SW_MINIMIZE) Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON _Metro_FullscreenToggle($hGUIMain, $Control_Buttons) ;=================================================================================================== Case $GUI_MENU_BUTTON Local $MenuSelect = _Metro_MenuStart($hGUIMain, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above. Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF) Case "1" ConsoleWrite("Returned 1 = About button clicked." & @CRLF) Case "2" ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF) Case "3" ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF) _Metro_GUIDelete($hGUIMain) ; This can stay here, or be moved to a cleanup function (fired by Main.au3's OnPreStop() function) _App_Stop() EndSwitch Case $Button2 _GUIDisable($hGUIMain, 0, 30) ;For better visibility of the MsgBox on top of the first GUI. _Metro_MsgBox(0, "Metro MsgBox Example", "Button 2 clicked. (Button with 3 secs timeout)", 400, 11, $hGUIMain, 3) ; with 3 secs timeout _GUIDisable($hGUIMain) Case $Toggle1 If _Metro_ToggleIsChecked($Toggle1) Then _Metro_ToggleUnCheck($Toggle1) ConsoleWrite("Toggle unchecked!" & @CRLF) Else _Metro_ToggleCheck($Toggle1) ConsoleWrite("Toggle checked!" & @CRLF) EndIf Case $Toggle2 If _Metro_ToggleIsChecked($Toggle2) Then _Metro_ToggleUnCheck($Toggle2) ConsoleWrite("Toggle unchecked!" & @CRLF) Else _Metro_ToggleCheck($Toggle2) ConsoleWrite("Toggle checked!" & @CRLF) EndIf Case $Toggle3 If _Metro_ToggleIsChecked($Toggle3) Then _Metro_ToggleUnCheck($Toggle3) ConsoleWrite("Disabled!" & @CRLF) Else _Metro_ToggleCheck($Toggle3) ConsoleWrite("Enabled!" & @CRLF) EndIf Case $Checkbox1 If _Metro_CheckboxIsChecked($Checkbox1) Then _Metro_CheckboxUnCheck($Checkbox1) ConsoleWrite("Checkbox unchecked!" & @CRLF) Else _Metro_CheckboxCheck($Checkbox1) ConsoleWrite("Checkbox checked!" & @CRLF) EndIf Case $Checkbox2 If _Metro_CheckboxIsChecked($Checkbox2) Then _Metro_CheckboxUnCheck($Checkbox2) ConsoleWrite("Checkbox unchecked!" & @CRLF) Else _Metro_CheckboxCheck($Checkbox2) ConsoleWrite("Checkbox checked!" & @CRLF) EndIf Case $Radio1 _Metro_RadioCheck(1, $Radio1) ConsoleWrite("Radio 1 selected!" & @CRLF) Case $Radio2 _Metro_RadioCheck(1, $Radio2) ConsoleWrite("Radio 2 selected = " & _Metro_RadioIsChecked(1, $Radio2) & @CRLF) EndSwitch EndFunc Func _App_Stop () ; Call this to tell Main.au3 to stop the program $STATE = False EndFunc Func _App_GetState () ; Main.au3 calls this in the update functions to see if we are still doing good Return $STATE EndFunc -- A side note, I was unable to change all the Theme for the window when using _SetTheme after initializations, etc. But the menu does change background color. A nice feature to look into (and I might just do this myself later), would be the ability to apply themes at runtime (since GDI plus doesn't care when you change brush colors, etc). You could just have a global variable that tells when SetTheme is used, and in the update loop, check it, and apply colors to the brushes that are used to draw the gui/controls, then draw them.
  3. Hi, I am trying to use This Json UDF to load a json file and display it in a _GUICtrlTreeView. The code is quite large, but I have separated it into GUI script, functionality script, file functions script. The first two working perfectly so far. Two functions in my file functions script are responsible for the loading of a json file and telling my functionality script to do something with it: Func _ltf_loadfile($fPath) Local $Object = Json_ObjCreate() ;Declare object properly. $Object = Json_Decode(FileRead($fPath)) ;Decode file into this object If Json_IsObject($Object) Then ;If the object is valid, we can use it. objLoop($Object) ;Handle information Else ;Object invalid? Tell user we can't load the file! MsgBox(0, "Error", "Json possibly has wrong syntax," & @CRLF & "Cannot open file.") EndIf EndFunc Func objLoop($hObj) Local $aItems = Json_ObjGetKeys($hObj) ;Get the keys of this object For $row=0 To UBound($aItems,1)-1 ;MsgBox(0, "Rows", "Rows " & $row+1 & " of " & UBound($aItems, 1)) $nObj = Json_ObjGet($hObj, $aItems[$row]) If Json_IsObject($nObj) Then For $column=0 to UBound($aItems,2)-1 _lt_AddChildItem($aItems[$row][$column]) MsgBox(0,"",$aItems[$row][$column]) ;Will display a Message Box with that Array's Cell content Next EndIf _lt_AddChildItem($aItems[$row]) Next ;_GUICtrlTreeView_SelectItem ($hLangTree, $nObj) ;_lt_AddChildItem($aItems[$i]) ;Function in another script that adds a GUI TreeView Item, with optional name. EndFuncbut I am having problems iterating past the first column. If need be I can post all my code, but I know it all works up until this point because of thorough testing. Here is an example JSON I've been using for testing: { "Game":{    "Name":"Game Title Goes Here",    "Interface":{       "MainMenu":{          "bOpts":"Options",          "bMp":"MultiPlayer",          "bSp":"SinglePlayer",          "bCreds":"Credits",          "bQuit":"Quit Game"       }    }    "Input":{       "inMouse":"Mouse",       "inJoy":"Joy Stick",       "inKeys":"KeyBoard"    } } "key2":"Key2 Text", "key3":"Key3 Text", "key4":"Key4 Text", "num":1024, "digits":{"1","2","3","4"} }I can stick _lt_AddChildItem() in the row for-loop and get items all day long, but I can't seem to get child objects or items from the first row. Doing so results in "Game|key2|key3|key4|num|digits" in vertical order on my _GUITreeView, just no child items or objects for "Game" object. Thank you for reading! edit- Corrected some syntax with the last item in an object having commas when the shouldn't.
  4. Aha, I found a solution: http://stackoverflow.com/questions/23816816/autoit-how-to-build-dynamic-array-and-loop-through-it This seems to solve the array issues, but I still can't get the boxes to render.. Any GDI geniuses out there? #include <EditConstants.au3> ;Should technically be included in GUIConstantsEx #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> ;For rendering graphs/charts and stuff #include "includes/AutoItObject.au3" ;AutoIt Object package #Region GUI $GUIMain = GUICreate("xBudget", 278, 332, 192, 124) $GUIMain_Menu_Budget = GUICtrlCreateMenu("Budget") $GUIMain_Menu_Budget_New = GUICtrlCreateMenuItem("New Budget", $GUIMain_Menu_Budget) $GUIMain_Menu_Budget_Load = GUICtrlCreateMenuItem("Load Budget", $GUIMain_Menu_Budget) $GUIMain_Menu_Budget_Save = GUICtrlCreateMenuItem("Save Budget"&@TAB&"Ctrl+S", $GUIMain_Menu_Budget) $GUIMain_Menu_Edit = GUICtrlCreateMenu("Edit") $GUIMain_Menu_Editor = GUICtrlCreateMenuItem("Editor", $GUIMain_Menu_Edit) $GUIMain_Menu_Data = GUICtrlCreateMenu("Data") $GUIMain_Menu_Data_Excel = GUICtrlCreateMenuItem("Excel", $GUIMain_Menu_Data) GUICtrlSetState(-1, $GUI_DISABLE) $GUIMain_Menu_Data_Txt = GUICtrlCreateMenuItem("Text", $GUIMain_Menu_Data) $GUIMain_BudgetSummary = GUICtrlCreateGroup("Budget Summary", 8, 8, 265, 257) $GUIMain_BudgetSum_Edit = GUICtrlCreateEdit("", 16, 24, 249, 209, BitOR($ES_WANTRETURN,$WS_VSCROLL), 0) GUICtrlSetData(-1, StringFormat("Name: No solution loaded...\r\nTotal Funds: N/A\r\n--\r\nTotal Input Funds: 0.0$\r\nTotal Input Members: 0\r\n--\r\nTotal Take-Away: 0.0$\r\nTotal Take-Away Members: 0\r\n--\r\nTotal Containers: 0\r\nContainers Intrest Input: 0.0$\r\nContainers Intrest Take-Away: 0.0$\r\nExtra Funds: 0.0$")) GUICtrlSetBkColor(-1, 0xE3E3E3) GUICtrlSetCursor (-1, 0) $GUIMain_SumCopy = GUICtrlCreateButton("Copy To Clipboard", 16, 240, 99, 17) $GUIMain_Calc = GUICtrlCreateButton("Recalculate", 120, 240, 75, 17) $GUIMain_Rprt = GUICtrlCreateButton("Report", 200, 240, 59, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $GUIMain_Editors = GUICtrlCreateButton("Editor", 8, 272, 123, 25) Dim $GUIMain_AccelTable[1][2] = [["^s", $GUIMain_Menu_Budget_Save]] GUISetAccelerators($GUIMain_AccelTable) GUISetState(@SW_SHOW, $GUIMain) #EndRegion End GUI #Region Editor GUI $GUI_Editor = GUICreate("Editor", 278, 332, 192, 124) $GUI_Editor_IsShown = False $GUI_Editor_Menu_New = GUICtrlCreateMenu("New") $GUI_Editor_Menu_New_Container = GUICtrlCreateMenuItem("Container",$GUI_Editor_Menu_New) $GUI_Editor_Menu_New_Pipe = GUICtrlCreateMenuItem("Pipe",$GUI_Editor_Menu_New) GUISetState(@SW_HIDE, $GUI_Editor) #EndRegion _AutoItObject_Startup() _GDIPlus_Startup() Global $aContainers = "" Global $gEditor = _GDIPlus_GraphicsCreateFromHWND($GUI_Editor) _GDIPlus_GraphicsSetSmoothingMode($gEditor, $GDIP_SMOOTHINGMODE_HIGHQUALITY) Global $gPen = _GDIPlus_PenCreate(0xFFA08080, 2) Func App_Exit() ;Free up resources _GDIPlus_GraphicsDispose($gEditor) _GDIPlus_PenDispose($gPen) _GDIPlus_Shutdown() _GDIPlus_GraphicsClear($gEditor) GUIDelete($GUI_Editor) GUIDelete($GUIMain) Exit EndFunc Func Container() Local $oClass = _AutoItObject_Class() With $oClass .AddMethod("AddPipe", "New_Pipe") .AddMethod("Simulate", "Simulate") .AddMethod("MoveXY", "Move_Container") .AddProperty("PositionX", $ELSCOPE_PUBLIC, 20) ;Position X on the Editor GUI .AddProperty("PositionY", $ELSCOPE_PUBLIC, 20) ;Position Y on the Editor GUI .AddProperty("Label", $ELSCOPE_PUBLIC, "Label") ;User defined label (e.x.: "My Wallet", "Bank Of America Account 1", "Employment Income", "Rent", etc) .AddProperty("InfiniteFunds", $ELSCOPE_PUBLIC, 0) ;0=N/A, 1=InfiniteOutput, 2=InfiniteInput (Employment would be 1, rent would be 2) .AddProperty("Funds", $ELSCOPE_PUBLIC, 0) ;Funds that this container contains (can be negative) .AddProperty("IntrestIn", $ELSCOPE_PUBLIC, 0) ;Amnt of intrest to gain per simulation (like a mutual fund) .AddProperty("IntrestOut", $ELSCOPE_PUBLIC, 0) ;Amnt of intrest take-away per simulation (like a loan) EndWith Return $oClass.Object ;Global $oContainer = Container() creates a new object EndFunc Func Move_Container($oSelf, $x, $y) With $oSelf .PositionX = $x .PositionY = $y EndWith EndFunc Func _New_Container() Local $oContainer = Container() If IsObj($oContainer) Then $aContainers = $aContainers & "|" & $oContainer ;Adds container to global array Return $oContainer Else Return 0 EndIf EndFunc Func New_Pipe() EndFunc Func Simulate() ;Simulates a turn of container flow EndFunc Func EditorUpdate() ;Updates editor graphics based on object data $aC = StringSplit($aContainers,"|") If IsArray($aC) Then $iMax = UBound($aC) For $i = 0 To $iMax - 1 If IsObj($aC[$i]) Then _GDIPlus_GraphicsDrawRect($gEditor,$aC[$i].PositionX,$aC[$i].PositionY,$aC[$i].PositionX + 40,$aC[$i].PositionY + 12) EndIf Next EndIf EndFunc While 1 $nMsg = GUIGetMsg() If $GUI_Editor_IsShown Then EditorUpdate() EndIf Switch $nMsg Case $GUI_EVENT_CLOSE App_Exit() Case $GUIMain_Menu_Editor If $GUI_Editor_IsShown Then GUISetState(@SW_HIDE, $GUI_Editor) $GUI_Editor_IsShown = False Else GUISetState(@SW_SHOW, $GUI_Editor) $GUI_Editor_IsShown = True EndIf Case $GUI_Editor_Menu_New_Container _New_Container() EndSwitch WEnd I wouldn't still be doing this if I didn't feel like I was really close to finishing successful. Technically, I should be doing this sort of thing in C#
  5. Thanks for the reply. I did that and still problems with the array: I wish there were another way to handle all of the objects without arrays, they are such a pain in the rear.. #include <EditConstants.au3> ;Should technically be included in GUIConstantsEx #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> ;For rendering graphs/charts and stuff #include "includes/AutoItObject.au3" ;AutoIt Object package #Region GUI $GUIMain = GUICreate("xBudget", 278, 332, 192, 124) $GUIMain_Menu_Budget = GUICtrlCreateMenu("Budget") $GUIMain_Menu_Budget_New = GUICtrlCreateMenuItem("New Budget", $GUIMain_Menu_Budget) $GUIMain_Menu_Budget_Load = GUICtrlCreateMenuItem("Load Budget", $GUIMain_Menu_Budget) $GUIMain_Menu_Budget_Save = GUICtrlCreateMenuItem("Save Budget"&@TAB&"Ctrl+S", $GUIMain_Menu_Budget) $GUIMain_Menu_Edit = GUICtrlCreateMenu("Edit") $GUIMain_Menu_Editor = GUICtrlCreateMenuItem("Editor", $GUIMain_Menu_Edit) $GUIMain_Menu_Data = GUICtrlCreateMenu("Data") $GUIMain_Menu_Data_Excel = GUICtrlCreateMenuItem("Excel", $GUIMain_Menu_Data) GUICtrlSetState(-1, $GUI_DISABLE) $GUIMain_Menu_Data_Txt = GUICtrlCreateMenuItem("Text", $GUIMain_Menu_Data) $GUIMain_BudgetSummary = GUICtrlCreateGroup("Budget Summary", 8, 8, 265, 257) $GUIMain_BudgetSum_Edit = GUICtrlCreateEdit("", 16, 24, 249, 209, BitOR($ES_WANTRETURN,$WS_VSCROLL), 0) GUICtrlSetData(-1, StringFormat("Name: No solution loaded...\r\nTotal Funds: N/A\r\n--\r\nTotal Input Funds: 0.0$\r\nTotal Input Members: 0\r\n--\r\nTotal Take-Away: 0.0$\r\nTotal Take-Away Members: 0\r\n--\r\nTotal Containers: 0\r\nContainers Intrest Input: 0.0$\r\nContainers Intrest Take-Away: 0.0$\r\nExtra Funds: 0.0$")) GUICtrlSetBkColor(-1, 0xE3E3E3) GUICtrlSetCursor (-1, 0) $GUIMain_SumCopy = GUICtrlCreateButton("Copy To Clipboard", 16, 240, 99, 17) $GUIMain_Calc = GUICtrlCreateButton("Recalculate", 120, 240, 75, 17) $GUIMain_Rprt = GUICtrlCreateButton("Report", 200, 240, 59, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $GUIMain_Editors = GUICtrlCreateButton("Editor", 8, 272, 123, 25) Dim $GUIMain_AccelTable[1][2] = [["^s", $GUIMain_Menu_Budget_Save]] GUISetAccelerators($GUIMain_AccelTable) GUISetState(@SW_SHOW, $GUIMain) #EndRegion End GUI #Region Editor GUI $GUI_Editor = GUICreate("Editor", 278, 332, 192, 124) $GUI_Editor_IsShown = False $GUI_Editor_Menu_New = GUICtrlCreateMenu("New") $GUI_Editor_Menu_New_Container = GUICtrlCreateMenuItem("Container",$GUI_Editor_Menu_New) $GUI_Editor_Menu_New_Pipe = GUICtrlCreateMenuItem("Pipe",$GUI_Editor_Menu_New) GUISetState(@SW_HIDE, $GUI_Editor) #EndRegion _AutoItObject_Startup() _GDIPlus_Startup() Global $aContainers Global $gEditor = _GDIPlus_GraphicsCreateFromHWND($GUI_Editor) _GDIPlus_GraphicsSetSmoothingMode($gEditor, $GDIP_SMOOTHINGMODE_HIGHQUALITY) Global $gPen = _GDIPlus_PenCreate(0xFFA08080, 2) Func _Budget_New() ;Create a new Budget EndFunc Func _Budget_Load() ;Load a Budget $fName = FileOpenDialog("Load", @ScriptDir, "All (*.*)|xBudget (*.xBdgt)") EndFunc Func _Budget_Save() ;Save a Budget EndFunc Func App_Exit() ;Free up resources _GDIPlus_GraphicsDispose($gEditor) _GDIPlus_PenDispose($gPen) _GDIPlus_Shutdown() _GDIPlus_GraphicsClear($gEditor) GUIDelete($GUI_Editor) GUIDelete($GUIMain) Exit EndFunc Func Container() Local $oClass = _AutoItObject_Class() With $oClass .AddMethod("AddPipe", "New_Pipe") .AddMethod("Simulate", "Simulate") .AddMethod("MoveXY", "Move_Container") .AddProperty("PositionX", $ELSCOPE_PUBLIC, 20) ;Position X on the Editor GUI .AddProperty("PositionY", $ELSCOPE_PUBLIC, 20) ;Position Y on the Editor GUI .AddProperty("Label", $ELSCOPE_PUBLIC, "Label") ;User defined label (e.x.: "My Wallet", "Bank Of America Account 1", "Employment Income", "Rent", etc) .AddProperty("InfiniteFunds", $ELSCOPE_PUBLIC, 0) ;0=N/A, 1=InfiniteOutput, 2=InfiniteInput (Employment would be 1, rent would be 2) .AddProperty("Funds", $ELSCOPE_PUBLIC, 0) ;Funds that this container contains (can be negative) .AddProperty("IntrestIn", $ELSCOPE_PUBLIC, 0) ;Amnt of intrest to gain per simulation (like a mutual fund) .AddProperty("IntrestOut", $ELSCOPE_PUBLIC, 0) ;Amnt of intrest take-away per simulation (like a loan) EndWith Return $oClass.Object ;Global $oContainer = Container() creates a new object EndFunc Func Move_Container($oSelf, $x, $y) With $oSelf .PositionX = $x .PositionY = $y EndWith EndFunc Func _New_Container() Local $oContainer = Container() Dim $aContainers[UBound($aContainers)+1] = [$oContainer] Return $oContainer EndFunc Func New_Pipe() EndFunc Func Simulate() ;Simulates a turn of container flow EndFunc Func EditorUpdate() ;Updates editor graphics based on object data ;_GDIPlus_GraphicsClear($gEditor, 0xFFFFFF) For $i = 0 To $i > UBound($aContainers) Step 1 _GDIPlus_GraphicsDrawRect($gEditor,$aContainers[$i].PositionX,$aContainers[$i].PositionY,$aContainers[$i].PositionX + 40,$aContainers[$i].PositionY + 12) Next EndFunc While 1 $nMsg = GUIGetMsg() If $GUI_Editor_IsShown Then EditorUpdate() EndIf Switch $nMsg Case $GUI_EVENT_CLOSE App_Exit() Case $GUIMain_Menu_Budget_Load _Budget_Load() Case $GUIMain_Menu_Editor If $GUI_Editor_IsShown Then GUISetState(@SW_HIDE, $GUI_Editor) $GUI_Editor_IsShown = False Else GUISetState(@SW_SHOW, $GUI_Editor) $GUI_Editor_IsShown = True EndIf Case $GUI_Editor_Menu_New_Container _New_Container() EndSwitch WEnd Maybe if someone could tell me how to add to the column size and add it's value (I've tried everything I can find). So far I'm not a huge fan of how little information is produced for me to debug my code.. It sounds like autoit is just saying "Uhh It doesn't work.."
  6. My code is at the bottom (didn't want to spam you initially ) GDIPlus works great, with the examples, but in my code I can't seem to get my Editor graphics rendering. The idea is that you -Create a container class object (AutoItObject). -Object is put in an array of container objects. -GDI Graphics update when "Editor" gui is shown. -Graphical representation of objects are drawn based on the container objects array. The Problem is that I cannot figure out why my graphics are not rendering on the child GUI("Editor"). I suspect that it's something about my array of container class objects (I dislike how arrays work in autoit greatly..), but I wouldn't know since I stink with them. I know the code is a bit messy, I'll worry about cleaning up stuff when I get this thing rendering and create some sort of collision system on the GDI graphics so the user can select objects/containers in real time. #include <EditConstants.au3> ;Should technically be included in GUIConstantsEx #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> ;For rendering graphs/charts and stuff #include "includes/AutoItObject.au3" ;AutoIt Object package #Region GUI $GUIMain = GUICreate("xBudget", 278, 332, 192, 124) $GUIMain_Menu_Budget = GUICtrlCreateMenu("Budget") $GUIMain_Menu_Budget_New = GUICtrlCreateMenuItem("New Budget", $GUIMain_Menu_Budget) $GUIMain_Menu_Budget_Load = GUICtrlCreateMenuItem("Load Budget", $GUIMain_Menu_Budget) $GUIMain_Menu_Budget_Save = GUICtrlCreateMenuItem("Save Budget"&@TAB&"Ctrl+S", $GUIMain_Menu_Budget) $GUIMain_Menu_Edit = GUICtrlCreateMenu("Edit") $GUIMain_Menu_Editor = GUICtrlCreateMenuItem("Editor", $GUIMain_Menu_Edit) $GUIMain_Menu_Data = GUICtrlCreateMenu("Data") $GUIMain_Menu_Data_Excel = GUICtrlCreateMenuItem("Excel", $GUIMain_Menu_Data) GUICtrlSetState(-1, $GUI_DISABLE) $GUIMain_Menu_Data_Txt = GUICtrlCreateMenuItem("Text", $GUIMain_Menu_Data) $GUIMain_BudgetSummary = GUICtrlCreateGroup("Budget Summary", 8, 8, 265, 257) $GUIMain_BudgetSum_Edit = GUICtrlCreateEdit("", 16, 24, 249, 209, BitOR($ES_WANTRETURN,$WS_VSCROLL), 0) GUICtrlSetData(-1, StringFormat("Name: No solution loaded...\r\nTotal Funds: N/A\r\n--\r\nTotal Input Funds: 0.0$\r\nTotal Input Members: 0\r\n--\r\nTotal Take-Away: 0.0$\r\nTotal Take-Away Members: 0\r\n--\r\nTotal Containers: 0\r\nContainers Intrest Input: 0.0$\r\nContainers Intrest Take-Away: 0.0$\r\nExtra Funds: 0.0$")) GUICtrlSetBkColor(-1, 0xE3E3E3) GUICtrlSetCursor (-1, 0) $GUIMain_SumCopy = GUICtrlCreateButton("Copy To Clipboard", 16, 240, 99, 17) $GUIMain_Calc = GUICtrlCreateButton("Recalculate", 120, 240, 75, 17) $GUIMain_Rprt = GUICtrlCreateButton("Report", 200, 240, 59, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $GUIMain_Editors = GUICtrlCreateButton("Editor", 8, 272, 123, 25) Dim $GUIMain_AccelTable[1][2] = [["^s", $GUIMain_Menu_Budget_Save]] GUISetAccelerators($GUIMain_AccelTable) GUISetState(@SW_SHOW, $GUIMain) #EndRegion End GUI #Region Editor GUI $GUI_Editor = GUICreate("Editor", 278, 332, 192, 124) $GUI_Editor_IsShown = False $GUI_Editor_Menu_New = GUICtrlCreateMenu("New") $GUI_Editor_Menu_New_Container = GUICtrlCreateMenuItem("Container",$GUI_Editor_Menu_New) $GUI_Editor_Menu_New_Pipe = GUICtrlCreateMenuItem("Pipe",$GUI_Editor_Menu_New) GUISetState(@SW_HIDE, $GUI_Editor) #EndRegion _AutoItObject_Startup() _GDIPlus_Startup() Global $aContainers[1] Local $gEditor = _GDIPlus_GraphicsCreateFromHWND($GUI_Editor) _GDIPlus_GraphicsSetSmoothingMode($gEditor, $GDIP_SMOOTHINGMODE_HIGHQUALITY) Local $gPen = _GDIPlus_PenCreate(0xFFA08080, 2) Func _Budget_New() ;Create a new Budget EndFunc Func _Budget_Load() ;Load a Budget $fName = FileOpenDialog("Load", @ScriptDir, "All (*.*)|xBudget (*.xBdgt)") EndFunc Func _Budget_Save() ;Save a Budget EndFunc Func App_Exit() ;Free up resources _GDIPlus_GraphicsDispose($gEditor) _GDIPlus_PenDispose($gPen) _GDIPlus_Shutdown() _GDIPlus_GraphicsClear($gEditor) GUIDelete($GUI_Editor) GUIDelete($GUIMain) Exit EndFunc Func Container() Local $oClass = _AutoItObject_Class() With $oClass .AddMethod("AddPipe", "New_Pipe") .AddMethod("Simulate", "Simulate") .AddMethod("MoveXY", "Move_Container") .AddProperty("PositionX", $ELSCOPE_PUBLIC, 20) ;Position X on the Editor GUI .AddProperty("PositionY", $ELSCOPE_PUBLIC, 20) ;Position Y on the Editor GUI .AddProperty("Label", $ELSCOPE_PUBLIC, "Label") ;User defined label (e.x.: "My Wallet", "Bank Of America Account 1", "Employment Income", "Rent", etc) .AddProperty("InfiniteFunds", $ELSCOPE_PUBLIC, 0) ;0=N/A, 1=InfiniteOutput, 2=InfiniteInput (Employment would be 1, rent would be 2) .AddProperty("Funds", $ELSCOPE_PUBLIC, 0) ;Funds that this container contains (can be negative) .AddProperty("IntrestIn", $ELSCOPE_PUBLIC, 0) ;Amnt of intrest to gain per simulation (like a mutual fund) .AddProperty("IntrestOut", $ELSCOPE_PUBLIC, 0) ;Amnt of intrest take-away per simulation (like a loan) EndWith Return $oClass.Object ;Global $oContainer = Container() creates a new object EndFunc Func Move_Container($oSelf, $x, $y) With $oSelf .PositionX = $x .PositionY = $y EndWith EndFunc Func _New_Container() Local $oContainer = Container() $aLen = UBound($aContainers) Dim $aContainers[$aLen+1] = [$oContainer] ;I suspect the problem is here, since I don't know how arrays work very well in autoit MsgBox(0,"New Container", String($aContainers[$aLen+1]) & "was created") EndFunc Func New_Pipe() EndFunc Func Simulate() ;Simulates a turn of container flow EndFunc Func EditorUpdate() ;Updates editor graphics based on object data ;_GDIPlus_GraphicsClear($gEditor, 0xFFFFFF) For $i=1 To $i > UBound($aContainers) Step 1 _GDIPlus_GraphicsDrawRect($gEditor,$aContainers[$i].PositionX,$aContainers[$i].PositionY,$aContainers[$i].X + 40,$aContainers[$i].X + 12) Next EndFunc While 1 $nMsg = GUIGetMsg() If $GUI_Editor_IsShown Then EditorUpdate() EndIf Switch $nMsg Case $GUI_EVENT_CLOSE App_Exit() Case $GUIMain_Menu_Budget_Load _Budget_Load() Case $GUIMain_Menu_Editor If $GUI_Editor_IsShown Then GUISetState(@SW_HIDE, $GUI_Editor) $GUI_Editor_IsShown = False Else GUISetState(@SW_SHOW, $GUI_Editor) $GUI_Editor_IsShown = True EndIf Case $GUI_Editor_Menu_New_Container _New_Container() EndSwitch WEnd Edit- There are no syntax errors btw, just no desired results.
×
×
  • Create New...