creeping Posted January 12, 2007 Share Posted January 12, 2007 Anyway to do this? line in question = ;hmmm???????????????? Want to call a function based on the ID stored in the array. eg. User clicks on but[5][0] I want to call the function But5() If not is there a work around? expandcollapse popup#include <GUIConstants.au3> Opt("WinWaitDelay", 800) #region global variables ;icon path $sIconPath = @ScriptDir & '\icons\' $iIconDim = 40 $iNumRows = 4 $iNumCols = 10 $iNumButs = $iNumRows * $iNumCols Dim $aBut[$iNumButs][2] Enum $E_BUT_ID, $E_BUT_TIP $iX = 0 $iY = 0 $aBut[0][$E_BUT_TIP] = 'Check all fixed disks on next reboot' $aBut[1][$E_BUT_TIP] = '' $aBut[2][$E_BUT_TIP] = '' $aBut[3][$E_BUT_TIP] = '' $aBut[4][$E_BUT_TIP] = '' $aBut[5][$E_BUT_TIP] = '' $aBut[6][$E_BUT_TIP] = '' $aBut[7][$E_BUT_TIP] = '' $aBut[8][$E_BUT_TIP] = '' $aBut[9][$E_BUT_TIP] = '' $aBut[10][$E_BUT_TIP] = '' $aBut[11][$E_BUT_TIP] = '' $aBut[12][$E_BUT_TIP] = '' $aBut[13][$E_BUT_TIP] = '' $aBut[14][$E_BUT_TIP] = '' $aBut[15][$E_BUT_TIP] = '' $aBut[16][$E_BUT_TIP] = '' $aBut[17][$E_BUT_TIP] = '' $aBut[18][$E_BUT_TIP] = '' $aBut[19][$E_BUT_TIP] = '' $aBut[20][$E_BUT_TIP] = '' $aBut[21][$E_BUT_TIP] = '' $aBut[22][$E_BUT_TIP] = '' $aBut[23][$E_BUT_TIP] = '' $aBut[24][$E_BUT_TIP] = '' $aBut[25][$E_BUT_TIP] = '' $aBut[26][$E_BUT_TIP] = '' $aBut[27][$E_BUT_TIP] = '' $aBut[28][$E_BUT_TIP] = '' $aBut[29][$E_BUT_TIP] = '' $aBut[30][$E_BUT_TIP] = '' $aBut[31][$E_BUT_TIP] = '' $aBut[32][$E_BUT_TIP] = '' $aBut[33][$E_BUT_TIP] = '' $aBut[34][$E_BUT_TIP] = '' $aBut[35][$E_BUT_TIP] = '' $aBut[36][$E_BUT_TIP] = '' $aBut[37][$E_BUT_TIP] = '' $aBut[38][$E_BUT_TIP] = '' $aBut[39][$E_BUT_TIP] = '' #endregion #region create GUI $GUI = GUICreate('', $iIconDim * $iNumCols, $iIconDim * $iNumRows) ;display buttons For $i = 0 To $iNumButs - 1 Step 1 If $aBut[$i][$E_BUT_TIP] <> '' Then $aBut[$i][0] = GUICtrlCreateButton('', $iX, $iY, $iIconDim, $iIconDim, $BS_ICON) GUICtrlSetImage(-1, $sIconPath & $i & '.ico') GUICtrlSetTip(-1, $aBut[$i][$E_BUT_TIP]) EndIf If mod($i, 10) = 9 Then $iY += $iIconDim $iX = 0 Else $iX += $iIconDim EndIf Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() For $i = 0 To $iNumButs - 1 Step 1 If $msg = $aBut[$i][0] Then ;hmmm???????????????? EndIf Next If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func But0() EndFunc Func But1() EndFunc Func But2() EndFunc Func But3() EndFunc Func But4() EndFunc Link to comment Share on other sites More sharing options...
Bert Posted January 12, 2007 Share Posted January 12, 2007 (edited) maybe Select $msg = GuiGetMsg() Select Case $msg = but[5][0] But0() Case Else ;;; EndSelect Edited January 12, 2007 by Volly The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
creeping Posted January 12, 2007 Author Share Posted January 12, 2007 Could do, didn't not really want to do that way as I wanted to make the script flexible as possible and not hard code that stuff in. Link to comment Share on other sites More sharing options...
Edgar Posted January 12, 2007 Share Posted January 12, 2007 Maybe : expandcollapse popup#include <GUIConstants.au3> Opt("WinWaitDelay", 800) #region global variables ;icon path $sIconPath = @ScriptDir & '\icons\' $iIconDim = 40 $iNumRows = 4 $iNumCols = 10 $iNumButs = $iNumRows * $iNumCols Dim $aBut[$iNumButs][2] Enum $E_BUT_ID, $E_BUT_TIP $iX = 0 $iY = 0 $aBut[0][$E_BUT_TIP] = 'Check all fixed disks on next reboot' $aBut[1][$E_BUT_TIP] = '' $aBut[2][$E_BUT_TIP] = '' $aBut[3][$E_BUT_TIP] = '' $aBut[4][$E_BUT_TIP] = '' $aBut[5][$E_BUT_TIP] = '' $aBut[6][$E_BUT_TIP] = '' $aBut[7][$E_BUT_TIP] = '' $aBut[8][$E_BUT_TIP] = '' $aBut[9][$E_BUT_TIP] = '' $aBut[10][$E_BUT_TIP] = '' $aBut[11][$E_BUT_TIP] = '' $aBut[12][$E_BUT_TIP] = '' $aBut[13][$E_BUT_TIP] = '' $aBut[14][$E_BUT_TIP] = '' $aBut[15][$E_BUT_TIP] = '' $aBut[16][$E_BUT_TIP] = '' $aBut[17][$E_BUT_TIP] = '' $aBut[18][$E_BUT_TIP] = '' $aBut[19][$E_BUT_TIP] = '' $aBut[20][$E_BUT_TIP] = '' $aBut[21][$E_BUT_TIP] = '' $aBut[22][$E_BUT_TIP] = '' $aBut[23][$E_BUT_TIP] = '' $aBut[24][$E_BUT_TIP] = '' $aBut[25][$E_BUT_TIP] = '' $aBut[26][$E_BUT_TIP] = '' $aBut[27][$E_BUT_TIP] = '' $aBut[28][$E_BUT_TIP] = '' $aBut[29][$E_BUT_TIP] = '' $aBut[30][$E_BUT_TIP] = '' $aBut[31][$E_BUT_TIP] = '' $aBut[32][$E_BUT_TIP] = '' $aBut[33][$E_BUT_TIP] = '' $aBut[34][$E_BUT_TIP] = '' $aBut[35][$E_BUT_TIP] = '' $aBut[36][$E_BUT_TIP] = '' $aBut[37][$E_BUT_TIP] = '' $aBut[38][$E_BUT_TIP] = '' $aBut[39][$E_BUT_TIP] = '' #endregion #region create GUI $GUI = GUICreate('', $iIconDim * $iNumCols, $iIconDim * $iNumRows) ;display buttons For $i = 0 To $iNumButs - 1 Step 1 If $aBut[$i][$E_BUT_TIP] <> '' Then $aBut[$i][0] = GUICtrlCreateButton('', $iX , $iY, $iIconDim, $iIconDim, $BS_ICON) GUICtrlSetImage(-1, $sIconPath & $i & '.ico') GUICtrlSetTip(-1, $aBut[$i][$E_BUT_TIP]) EndIf If mod($i, 10) = 9 Then $iY += $iIconDim $iX = 0 Else $iX += $iIconDim EndIf Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() For $i = 0 To $iNumButs - 1 Step 1 If $msg = $aBut[$i][0] Then Call("But" &$i) EndIf Next If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func But0() MsgBox(0,"TEST","TEST") EndFunc Func But1() EndFunc Func But2() EndFunc Func But3() EndFunc Func But4() EndFunc Link to comment Share on other sites More sharing options...
creeping Posted January 12, 2007 Author Share Posted January 12, 2007 Great So much easier and compact. Did not realize I could call a function using literal text. Thanks Link to comment Share on other sites More sharing options...
Danny35d Posted January 12, 2007 Share Posted January 12, 2007 (edited) You can use the function Call()expandcollapse popup#include <GUIConstants.au3> Opt("WinWaitDelay", 800) #region global variables ;icon path $sIconPath = @ScriptDir & '\icons\' $iIconDim = 40 $iNumRows = 4 $iNumCols = 10 $iNumButs = $iNumRows * $iNumCols Dim $aBut[$iNumButs][2] Enum $E_BUT_ID, $E_BUT_TIP $iX = 0 $iY = 0 $aBut[0][$E_BUT_TIP] = 'Check all fixed disks on next reboot' $aBut[1][$E_BUT_TIP] = 'Button 1' $aBut[2][$E_BUT_TIP] = 'Button 2' $aBut[3][$E_BUT_TIP] = 'Button 3' $aBut[4][$E_BUT_TIP] = 'Button 4' $aBut[5][$E_BUT_TIP] = '' $aBut[6][$E_BUT_TIP] = '' $aBut[7][$E_BUT_TIP] = '' $aBut[8][$E_BUT_TIP] = '' $aBut[9][$E_BUT_TIP] = '' $aBut[10][$E_BUT_TIP] = '' $aBut[11][$E_BUT_TIP] = '' $aBut[12][$E_BUT_TIP] = '' $aBut[13][$E_BUT_TIP] = '' $aBut[14][$E_BUT_TIP] = '' $aBut[15][$E_BUT_TIP] = '' $aBut[16][$E_BUT_TIP] = '' $aBut[17][$E_BUT_TIP] = '' $aBut[18][$E_BUT_TIP] = '' $aBut[19][$E_BUT_TIP] = '' $aBut[20][$E_BUT_TIP] = '' $aBut[21][$E_BUT_TIP] = '' $aBut[22][$E_BUT_TIP] = '' $aBut[23][$E_BUT_TIP] = '' $aBut[24][$E_BUT_TIP] = '' $aBut[25][$E_BUT_TIP] = '' $aBut[26][$E_BUT_TIP] = '' $aBut[27][$E_BUT_TIP] = '' $aBut[28][$E_BUT_TIP] = '' $aBut[29][$E_BUT_TIP] = '' $aBut[30][$E_BUT_TIP] = '' $aBut[31][$E_BUT_TIP] = '' $aBut[32][$E_BUT_TIP] = '' $aBut[33][$E_BUT_TIP] = '' $aBut[34][$E_BUT_TIP] = '' $aBut[35][$E_BUT_TIP] = '' $aBut[36][$E_BUT_TIP] = '' $aBut[37][$E_BUT_TIP] = '' $aBut[38][$E_BUT_TIP] = '' $aBut[39][$E_BUT_TIP] = '' #endregion #region create GUI $GUI = GUICreate('', $iIconDim * $iNumCols, $iIconDim * $iNumRows) ;display buttons For $i = 0 To UBound($aBut) - 1 If $aBut[$i][$E_BUT_TIP] <> '' Then $aBut[$i][0] = GUICtrlCreateButton('', $iX, $iY, $iIconDim, $iIconDim, $BS_ICON) GUICtrlSetImage(-1, $sIconPath & $i & '.ico') GUICtrlSetTip(-1, $aBut[$i][$E_BUT_TIP]) EndIf If mod($i, 10) = 9 Then $iY += $iIconDim $iX = 0 Else $iX += $iIconDim EndIf Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() For $i = 0 To UBound($aBut) - 1 If $msg = $aBut[$i][0] And $aBut[$i][0] <> '' Then Call('But' & $i) EndIf Next If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func But0() MsgBox(0, 'Button 0', 'You press button 0.') EndFunc Func But1() MsgBox(0, 'Button 1', 'You press button 1.') EndFunc Func But2() MsgBox(0, 'Button 2', 'You press button 2.') EndFunc Func But3() MsgBox(0, 'Button 3', 'You press button 3.') EndFunc Func But4() MsgBox(0, 'Button 4', 'You press button 4.') EndFuncEdit: I type too slooowww.... :"> Edited January 12, 2007 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line 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