steliyan Posted November 30, 2008 Share Posted November 30, 2008 (edited) So here's the deal. I have an array of control ids: for $i = 0 to $rows-1 for $j = 0 to $cols-1 $hImage[$i][$j] = GUICtrlCreatePic("00.bmp", $j*$size, $offset+($i*$size), $size, $size) next next Everything is working OK, but I want to catch the message when any of these images is clicked. For a single one is easy: Case $hImage[0][0] GUICtrlSetImage($hImage[0][0], "01.bmp") I'm new to AutoIt, so I'm wondering if there's an easier way to do the trick for all of them. Edited November 30, 2008 by steliyan Link to comment Share on other sites More sharing options...
Paulie Posted November 30, 2008 Share Posted November 30, 2008 Check out OnEvent Mode. It would make this way easier Link to comment Share on other sites More sharing options...
martin Posted November 30, 2008 Share Posted November 30, 2008 (edited) Maybe (not tested) Switch $Msg Case $hImage[0][0] to $hImage[ $rows][$cols] $id = 0 for $i = 0 to $rows-1 for $j = 0 to $cols-1 $id += 1 if $hImage[$i][$j] = $msg then ExitLoop 2 next next GUICtrlSetImage($msg, StringFormat("%02d.bmp",$id)) Edited November 30, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Andreik Posted November 30, 2008 Share Posted November 30, 2008 Or like this: $MSG = GUIGetMsg() For $INDEX1 = 0 to $ROWS-1 For $INDEX2 = 0 to $COLS-1 If $MSG = $hImage[$INDEX1][$INDEX2] Then MsgBox(0,"CLICK",$INDEX1 & @CRLF & $INDEX2) EndIf Next Next but Paulie method is more good. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
steliyan Posted December 1, 2008 Author Share Posted December 1, 2008 I've done it using event. I catch the message of left button up event, then get the coordinates and calculate the image. Another question about array, is there a way to set a value for all the elements of the array without going through them? Like in C++ (int array[5] = {0})? 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