billthecreator Posted December 8, 2010 Posted December 8, 2010 I'm really stuck here.. I have 6 pictures, that change like on/off. Almost like a checkbox, basically. Is there a way to make it so that if the picture is click, it would change conditionally, like if the picture had a $GUI_CHECKED property. I've been using java for the last 3 months, and the only thing that comes to mind is classes and objects, that would be easy. Maybe there's a way, but after searching this forum, I'm not sure what to do. Thank you all. Basically this is what I am imagining... if $button_1.Status()= 1 then ;change picture $button_1.Status(0) endif [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap
PsaltyDS Posted December 8, 2010 Posted December 8, 2010 GUICtrlSetImage() #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> Global $idButton, $iImg = 1 GUICreate("My GUI", 300, 300) ; will create a dialog box that when displayed is centered $idLabel = GUICtrlCreateLabel("Image = " & $iImg, 20, 20, 260, 20) $idButton = GUICtrlCreateButton("my picture button", 20, 120, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", $iImg) GUISetState() ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton $iImg += 1 If $iImg > 48 Then $iImg = 1 GUICtrlSetData($idLabel, "Image = " & $iImg) GUICtrlSetImage($idButton, "shell32.dll", $iImg) EndSwitch WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
billthecreator Posted December 8, 2010 Author Posted December 8, 2010 thats not actually what i was looking for, but after thnking i think i found the best way to create an array, subscript 1 would be the handle, 2 the status, and so forth. [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap
Malkey Posted December 10, 2010 Posted December 10, 2010 An example. #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> local $hGUI, $idButton[6], $iImg = 274 $hGUI = GUICreate("My GUI", 300, 300,300,300) For $i = 0 To 5 GUICtrlCreateLabel("", 110, 30 + ($i * 42), 100, 20) $idButton[$i] = GUICtrlCreateButton("", 110, 20 + ($i * 42), 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", $iImg) GUICtrlSetState(-1, $GUI_DISABLE) $iImg += 1 Next GUICtrlSetState($idButton[0], $GUI_ENABLE) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit ; All buttons are disabled, except for the button which was last pressed via its invisible covering label. Case $idButton[0] - 1 To $idButton[UBound($idButton) - 1] For $i = 0 To 5 GUICtrlSetState($idButton[$i], $GUI_DISABLE) Next GUICtrlSetState($idButton[($iMsg + 1 - $idButton[0]) / 2], $GUI_ENABLE) MsgBox(0, "", "Button " & 1 + ($iMsg + 1 - $idButton[0]) / 2 & " pushed.", 1, $hGUI) EndSwitch WEnd
ivan Posted March 26, 2011 Posted March 26, 2011 (edited) Just for the sake of completeness, shouldn't you close the User32.dll, i.e, add a function: Func _PropList_Destroy($phwnd) GUIDelete($phwnd) DllClose($User32) EndFunc So after you leave the main loop in the example _PropList_Destroy($Gui) Edited March 26, 2011 by ivan Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3
PsaltyDS Posted March 30, 2011 Posted March 30, 2011 You can if it makes you feel better, but AutoIt closes all open handles on exit anyway. Not actually required. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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