Nezoic Posted August 30, 2005 Share Posted August 30, 2005 Alright basically its looking for the right branch which is only comming out as a variable or something that isn't the correct value and seems to be constantly updating the GUIctrlSetState without actually looking at the case. I think I understand why its doing this, but I'm not sure of the best way to go about fixing it other than some makeshift dumpfile used to create the correct variables and values I need to call. I attempted to make arrays and see if they would call it correctly from a IF or Case but they dont, and I'm more confused. Anyhow if this makes any sense... my brain hurts and I think I'm useing too many arrays :-\ expandcollapse popupGlobal $xPos, $yPos dim $KeyData, $ValData #include <GUIConstants.au3> #Include <Constants.au3> #include <array.au3> ;===================================> GUI <======================================= GUICreate("Macro v1.0", 400, 430) $filemenu = GUICtrlCreateMenu ("File") $optionsmenu = GUICtrlCreateMenu ("Options") $helpmenu = GUICtrlCreateMenu ("?") $Fileitem = GUICtrlCreateMenuitem ("New",$filemenu) $Fileitem = GUICtrlCreateMenuitem ("Open",$filemenu) $Fileitem = GUICtrlCreateMenuitem ("Save",$filemenu) $Fileitem = GUICtrlCreateMenuitem ("Exit",$filemenu) $optionsitem = GUICtrlCreateMenuitem ("Even Window", $optionsmenu) $eventsgroup = GUICtrlCreateGroup ("Events",170,5,135,275) $xPosLocked = GUICtrlCreateInput ( 0, 175, 220, 40, 20) $yPosLocked = GUICtrlCreateInput ( 0, 240, 220, 40, 20) $xPos = GUICtrlCreateInput ( 0, 175, 255, 40, 20) $yPos = GUICtrlCreateInput ( 0, 240, 255, 40, 20) $btnNew = GUICtrlCreateButton("New", 335, 15, 60) $btnSave = GUICtrlCreateButton("Save", 335, 45, 60) $btnLoad = GUICtrlCreateButton("Load", 335, 75, 60) $btnPlay = GUICtrlCreateButton("Play", 335, 115, 50) $btnStop = GUICtrlCreateButton("Stop", 335, 145, 50) $btnPause = GUICtrlCreateButton("Pause", 335, 175, 50) ;$KeyValue = GUICtrlCreateLabel ("This little scripts demonstates the using of a treeview-control.",190,70,100,60) $treeview = GUICtrlCreateTreeView(6, 20, 150, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge) $sections = IniReadSectionNames("testmacrolist.ini") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else $KeyData = _ArrayCreate("") $ValData = _ArrayCreate("") For $i = 1 To $sections[0] $keys = IniReadSection("testmacrolist.ini", $sections[$i]) $item = GUICtrlCreateTreeViewItem($sections[$i], $treeview) For $x = 1 To $keys[0][0] _ArrayAdd($KeyData, $Keys[$x][0]) _ArrayAdd($ValData, $Keys[$x][1]) GUICtrlCreateTreeViewItem($keys[$x][0], $item) Next Next EndIf GUISetState() ;================================> End GUI <====================================== While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop $pos = MouseGetPos() GUICtrlSetData($xPos, $pos[0]) GUICtrlSetData($yPos, $pos[1]) If _IsPressed('02') = 1 Then PosLock() GUISetState() Select Case $msg = -3 Or $msg = -1 ExitLoop ;=============================================== ; Note : ; $KeyData[1] needs to equal something like: ; $aboutitem = GUICtrlCreateTreeViewItem ("About",$maintree) ; But currently just = Event1 ;=============================================== Case $msg = $KeyData[1] GUIctrlSetState ($eventsgroup,$GUI_SHOW) GUIctrlSetState ($xPos,$GUI_SHOW) GUIctrlSetState ($yPos,$GUI_SHOW) GUIctrlSetState ($xPosLocked,$GUI_HIDE) GUIctrlSetState ($yPosLocked,$GUI_HIDE) Case $msg = $KeyData[2] GUIctrlSetState ($eventsgroup,$GUI_HIDE) GUIctrlSetState ($xPos,$GUI_SHOW) GUIctrlSetState ($yPos,$GUI_SHOW) GUIctrlSetState ($xPosLocked,$GUI_SHOW) GUIctrlSetState ($yPosLocked,$GUI_SHOW) sleep(10) EndSelect sleep(10) WEnd GUIDelete() Exit Func PosLock() GUICtrlSetData($xPosLocked, $pos[0]) GUICtrlSetData($yPosLocked, $pos[1]) ; $colur = PixelGetColor( $pos[0] , $pos[1] ) ; GUICtrlSetData($ColorOne, $colur) EndFunc Func _IsPressed($hexKey) Local $aR, $bO $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then $bO = 1 Else $bO = 0 EndIf Return $bO EndFunc testmacrolist.ini looks like [Macro1] Event1=lala, 2223 Event2=222 Event3=111 [Macro2] Event1a= Event2a= Event3a= Link to comment Share on other sites More sharing options...
Nezoic Posted August 30, 2005 Author Share Posted August 30, 2005 If anyone cares I did come up with one solution, altho not the best I'm sure, but it works. Basically just wrote the variables to a .au3 file. Kinda made a porta menu =D expandcollapse popupGlobal $xPos, $yPos dim $sectData, $KeyData, $ValData, $tempData #include <GUIConstants.au3> #Include <Constants.au3> #include <array.au3> ;If WinExists("Macro v1.0") Then winclose("Macro v1.0") ;===================================> GUI <======================================= GUICreate("Macro v1.0", 400, 430) $filemenu = GUICtrlCreateMenu ("File") $optionsmenu = GUICtrlCreateMenu ("Options") $helpmenu = GUICtrlCreateMenu ("?") $Fileitem = GUICtrlCreateMenuitem ("New",$filemenu) $Fileitem = GUICtrlCreateMenuitem ("Open",$filemenu) $Fileitem = GUICtrlCreateMenuitem ("Save",$filemenu) $Fileitem = GUICtrlCreateMenuitem ("Exit",$filemenu) $optionsitem = GUICtrlCreateMenuitem ("Even Window", $optionsmenu) $eventsgroup = GUICtrlCreateGroup ("Events",170,5,135,275) GUICtrlCreateLabel ( "Color", 218, 170, 40, 20) $Color = GUICtrlCreateInput ( 0, 210, 185, 50, 20) GUICtrlCreateLabel ( "Locked", 215, 205, 40, 20) $xPosLocked = GUICtrlCreateInput ( 0, 195, 220, 40, 20) $yPosLocked = GUICtrlCreateInput ( 0, 240, 220, 40, 20) GUICtrlCreateLabel ( "Current", 215, 240, 40, 20) $xPos = GUICtrlCreateInput ( 0, 195, 255, 40, 20) $yPos = GUICtrlCreateInput ( 0, 240, 255, 40, 20) $btnNew = GUICtrlCreateButton("New", 335, 15, 60) $btnSave = GUICtrlCreateButton("Save", 335, 45, 60) $btnLoad = GUICtrlCreateButton("Load", 335, 75, 60) $btnPlay = GUICtrlCreateButton("Play", 335, 115, 50) $btnStop = GUICtrlCreateButton("Stop", 335, 145, 50) $btnPause = GUICtrlCreateButton("Pause", 335, 175, 50) $treeview = GUICtrlCreateTreeView(6, 20, 150, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge) $sections = IniReadSectionNames("testmacrolist.ini") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else $SectData = _ArrayCreate("") $KeyData = _ArrayCreate("") $ValData = _ArrayCreate("") $tempData = _ArrayCreate("") For $i = 1 To $sections[0] _ArrayAdd($SectData, $sections[$i]) $keys = IniReadSection("testmacrolist.ini", $sections[$i]) ;$item = GUICtrlCreateTreeViewItem($sections[$i], $treeview) _ArrayAdd($tempData, "$" & $sectData[$i] & " = GUICtrlCreateTreeViewItem(" & '"' & $sectData[$i] & '"' & ", " & "$treeview)") For $x = 1 To $keys[0][0] _ArrayAdd($KeyData, $Keys[$x][0]) _ArrayAdd($ValData, $Keys[$x][1]) _ArrayAdd($tempData, "$" & $keys[$x][0] & " = GUICtrlCreateTreeViewItem(" & '"' & $keys[$x][0] & '"' & ", " & "$" & $sectData[$i] & ")") ;GUICtrlCreateTreeViewItem($keys[$x][0], $item) Next Next EndIf $file = FileOpen("vardata.au3", 2) if $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $f = 0 to UBound($tempData, 1) - 1 FileWrite($file, $tempData[$f] & @CRLF) next FileClose($file) GUISetState() ;================================> End GUI <====================================== #include<Vardata.au3> While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop $pos = MouseGetPos() GUICtrlSetData($xPos, $pos[0]) GUICtrlSetData($yPos, $pos[1]) If _IsPressed('02') = 1 Then PosLock() GUISetState() Select Case $msg = -3 Or $msg = -1 ExitLoop Case $msg = $Event1 GUIctrlSetState ($eventsgroup,$GUI_SHOW) GUIctrlSetState ($xPos,$GUI_SHOW) GUIctrlSetState ($yPos,$GUI_SHOW) GUIctrlSetState ($xPosLocked,$GUI_HIDE) GUIctrlSetState ($yPosLocked,$GUI_HIDE) Case $msg = $Event2 GUIctrlSetState ($eventsgroup,$GUI_HIDE) GUIctrlSetState ($xPos,$GUI_SHOW) GUIctrlSetState ($yPos,$GUI_SHOW) GUIctrlSetState ($xPosLocked,$GUI_SHOW) GUIctrlSetState ($yPosLocked,$GUI_SHOW) sleep(10) EndSelect sleep(10) WEnd GUIDelete() Exit Func PosLock() GUICtrlSetData($xPosLocked, $pos[0]) GUICtrlSetData($yPosLocked, $pos[1]) $colur = PixelGetColor( $pos[0] , $pos[1]) $colur = Hex($colur, 6) GUICtrlSetData ($Color, $colur) $bkcolur = '0x' & $colur GUICtrlSetBkColor ($treeview, $bkcolur) EndFunc Func _IsPressed($hexKey) Local $aR, $bO $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then $bO = 1 Else $bO = 0 EndIf Return $bO EndFunc If anyone has a better solution for this, I'm definitly open to suggestions as writing a whole array of junk to a file instead of scrapping it out of memory seems like a waste. Link to comment Share on other sites More sharing options...
quick_sliver007 Posted August 31, 2005 Share Posted August 31, 2005 (edited) How does this work for you. Click on the events. expandcollapse popupGlobal $xpos, $ypos Dim $keydata, $valdata #include <GUIConstants.au3> #Include <Constants.au3> #include <array.au3> ;===================================> GUI <======================================= GUICreate("Macro v1.0", 400, 430) $filemenu = GUICtrlCreateMenu("File") $optionsmenu = GUICtrlCreateMenu("Options") $helpmenu = GUICtrlCreateMenu("?") $fileitem = GUICtrlCreateMenuItem("New", $filemenu) $fileitem = GUICtrlCreateMenuItem("Open", $filemenu) $fileitem = GUICtrlCreateMenuItem("Save", $filemenu) $fileitem = GUICtrlCreateMenuItem("Exit", $filemenu) $optionsitem = GUICtrlCreateMenuItem("Even Window", $optionsmenu) $eventsgroup = GUICtrlCreateGroup("Events", 170, 5, 135, 275) $xposlocked = GUICtrlCreateInput(0, 175, 220, 40, 20) $yposlocked = GUICtrlCreateInput(0, 240, 220, 40, 20) $xpos = GUICtrlCreateInput(0, 175, 255, 40, 20) $ypos = GUICtrlCreateInput(0, 240, 255, 40, 20) $btnnew = GUICtrlCreateButton("New", 335, 15, 60) $btnsave = GUICtrlCreateButton("Save", 335, 45, 60) $btnload = GUICtrlCreateButton("Load", 335, 75, 60) $btnplay = GUICtrlCreateButton("Play", 335, 115, 50) $btnstop = GUICtrlCreateButton("Stop", 335, 145, 50) $btnpause = GUICtrlCreateButton("Pause", 335, 175, 50) ;$KeyValue = GUICtrlCreateLabel ("This little scripts demonstates the using of a treeview-control.",190,70,100,60) $treeview = GUICtrlCreateTreeView(6, 20, 150, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge) $sections = IniReadSectionNames("testmacrolist.ini") ;;;;;;;;;;;;;;;;;;added;;;;;;;;;;;; If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") EndIf $maxevents = 1 Dim $events[$sections[0]][$maxevents] For $i = 1 To $sections[0] $keys = IniReadSection("testmacrolist.ini", $sections[$i]) If $keys[0][0] > $maxevents Then $maxevents = $keys[0][0] ReDim $events[$sections[0]][$maxevents] EndIf Next ;;;;;;;;;;;;;;;;;;;;;;; For $i = 1 To $sections[0] $keys = IniReadSection("testmacrolist.ini", $sections[$i]) $item = GUICtrlCreateTreeViewItem($sections[$i], $treeview) For $x = 1 To $keys[0][0] $events[$i - 1][$x - 1] = GUICtrlCreateTreeViewItem($keys[$x][0], $item) Next Next GUISetState() ;================================> End GUI <====================================== While 1 $msg = GUIGetMsg() If $msg = $gui_event_close Then ExitLoop $pos = MouseGetPos() GUICtrlSetData($xpos, $pos[0]) GUICtrlSetData($ypos, $pos[1]) If _IsPressed('02') = 1 Then PosLock() GUISetState() ;;;;;;;;;;;;;added here For $i = 1 To $sections[0] For $x = 1 To $keys[0][0] If $msg = $events[$i - 1][$x - 1] Then MsgBox(0, "", $i & " " & $x) EndIf Next Next ;;;;;;;;;;;;;;;;;;;;;;;;;; Select Case $msg = -3 Or $msg = -1 ExitLoop ;=============================================== ; Note : ; $KeyData[1] needs to equal something like: ; $aboutitem = GUICtrlCreateTreeViewItem ("About",$maintree) ; But currently just = Event1 ;=============================================== EndSelect Sleep(10) WEnd GUIDelete() Exit Func PosLock() GUICtrlSetData($xposlocked, $pos[0]) GUICtrlSetData($yposlocked, $pos[1]) ; $colur = PixelGetColor( $pos[0] , $pos[1] ) ; GUICtrlSetData($ColorOne, $colur) EndFunc ;==>PosLock Func _IsPressed($hexkey) Local $ar, $bo $hexkey = '0x' & $hexkey $ar = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexkey) If Not @error And BitAND($ar[0], 0x8000) = 0x8000 Then $bo = 1 Else $bo = 0 EndIf Return $bo EndFunc ;==>_IsPressed Edited August 31, 2005 by quick_sliver007 . Link to comment Share on other sites More sharing options...
Nezoic Posted September 1, 2005 Author Share Posted September 1, 2005 Alright that is smooth, I dont understand 1/2 of it at first glance but it does put me back on the right path! Thank you. Link to comment Share on other sites More sharing options...
quick_sliver007 Posted September 1, 2005 Share Posted September 1, 2005 Alright that is smooth, I dont understand 1/2 of it at first glance but it does put me back on the right path!Thank you.<{POST_SNAPBACK}>Your welcome. . 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