highway61ie Posted March 23, 2014 Posted March 23, 2014 Hi Folks ..new to Autoit here and having serious trouble getting my head around the basics :-( I'm try to create a script that will create an array of nine buttons .1 to 9 . that when clicked will open an image file in a movable window . I have the nine buttons from example scripts but can only get the buttons to open one image .i.e no matter which button I press I get the same image . SO what I can't work out is what part of this is controlling which button ... any help appreciated :-) guisetstate() While 0 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aButtons[0] to $aButtons[ubound($aButtons)-1] GUICreate("", 700, 700, Default, Default,$WS_EX_ACCEPTFILES) GUICtrlCreatePic("Your.jpg", 0, 0, 600, 600) GUISetState() EndSwitch WEnd i This is the full script I have so far ... #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiButton.au3> #include <array.au3> #AutoIt3Wrapper_Add_Constants=n local $gui010 = guicreate('') local $aSize = wingetclientsize($gui010) local $lbl010 = guictrlcreatelabel('Some meaningful text',0,20,$aSize[0],20,bitor($ss_sunken, $SS_CENTER)) local $aButtons[9], $idx = 0 for $1 = 1 to 3 for $2 = 1 to 3 $aButtons[$idx] = guictrlcreatebutton('#' & $idx+1,$2*55,$1*55,35,35) $idx += 1 Next next guisetstate() While 0 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aButtons[0] to $aButtons[ubound($aButtons)-1] GUICreate("", 700, 700, Default, Default,$WS_EX_ACCEPTFILES) GUICtrlCreatePic("Your.jpg", 0, 0, 600, 600) GUISetState() EndSwitch WEnd guisetstate() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aButtons[2] to $aButtons[ubound($aButtons)-2] GUICreate("", 700, 700, Default, Default,$WS_EX_ACCEPTFILES) GUICtrlCreatePic("pic2", 0, 0, 600, 600) GUISetState() EndSwitch WEnd
JohnOne Posted March 23, 2014 Posted March 23, 2014 Case $aButtons[0] GUICreate("", 700, 700, Default, Default, $WS_EX_ACCEPTFILES) GUICtrlCreatePic("0.jpg", 0, 0, 600, 600) Case $aButtons[1] GUICreate("", 700, 700, Default, Default, $WS_EX_ACCEPTFILES) GUICtrlCreatePic("1.jpg", 0, 0, 600, 600) ;...... Case $aButtons[8] GUICreate("", 700, 700, Default, Default, $WS_EX_ACCEPTFILES) GUICtrlCreatePic("8.jpg", 0, 0, 600, 600) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
DatMCEyeBall Posted March 23, 2014 Posted March 23, 2014 '?do=embed' frameborder='0' data-embedContent>> "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation
mikell Posted March 23, 2014 Posted March 23, 2014 expandcollapse popup#include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiButton.au3> #include <array.au3> #AutoIt3Wrapper_Add_Constants=n local $gui010 = guicreate('') local $aSize = wingetclientsize($gui010) local $lbl010 = guictrlcreatelabel('Some meaningful text',0,20,$aSize[0],20,bitor($ss_sunken, $SS_CENTER)) Global $aButtons[9], $idx = 0 Global $aImg[9] = ["img 1", "img 2", "img 3", "img 4", "img 5", "img 6", "img 7", "img 8"] for $1 = 1 to 3 for $2 = 1 to 3 $aButtons[$idx] = guictrlcreatebutton('#' & $idx+1,$2*55,$1*55,35,35) $idx += 1 Next next guisetstate() $gui2 = GUICreate("", 700, 700, Default, Default, -1, $WS_EX_ACCEPTFILES) $label = GUICtrlCreateLabel("", 0, 0, 600, 600) ; $pic = GUICtrlCreatePic("", 0, 0, 600, 600) GUISetState(@SW_HIDE, $gui2) While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE Switch $msg[1] Case $gui010 Exit Case $gui2 GUISetState(@SW_HIDE, $gui2) EndSwitch EndSwitch For $k = 0 to 8 Switch $msg[0] Case $aButtons[$k] GuiCtrlSetData($label, $aImg[$k]) ; GuiCtrlSetImage($pic, $aImg[$k]) GUISetState(@SW_SHOW, $gui2) EndSwitch Next WEnd
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