JustinReno Posted November 9, 2007 Share Posted November 9, 2007 (edited) I'm creating a slideshow creator for my friend. I need to use GuiCtrlSetOnEvent for my functions. Well, I was looking around, and GuiCtrlSetOnEvent adds the () at the end of the function. That causes a problem, my functions have parameters and it doesn't work. Maybe its just me but is there anyother way? Here is some test code: #Include <GuiConstants.au3> $Gui = GuiCreate("Testing GUICtrlSetOnevent", 500, 500) $Button_One = GUICtrlCreateButton("Click", 0, 0) $Button_Two = GUICtrlCreateButton("Click_2", 0, 20) GUISetState() GUICtrlSetOnEvent($Button_One, "Message(""1"")") GUICtrlSetOnEvent($Button_Two, "Message(""1"")") While 1 Sleep(10) WEnd Func Message($Param1) If $Param1 = "1" Then MsgBox(0, "Testing GuiCtrlSetOnEvent", "Button_One clicked") If $Param1 = "2" Then MsgBox(0, "Testing GuiCtrlSetOnEvent", "Button_Two clicked") EndFunc Edit: And this is the only way I can code the function. Edited November 9, 2007 by JustinReno Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 9, 2007 Moderators Share Posted November 9, 2007 I'm sure you don't "need" OnEvent. GUIGetMsg() used properly will work for you I'm sure. But the short answer is "no" you can't use parameters with OnEvent as you are wanting. But you could set up some type of manager function to do what you need I'm sure, only problem is, you'll be playing with unnecessary globals then. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted November 9, 2007 Share Posted November 9, 2007 Like this... #Include <GuiConstants.au3> Opt("GUIOnEventMode", 1) $Gui = GuiCreate("Testing GUICtrlSetOnevent", 500, 500) $Button_One = GUICtrlCreateButton("Click_1", 0, 0) $Button_Two = GUICtrlCreateButton("Click_2", 0, 30) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUICtrlSetOnEvent($Button_One, "Send_Message") GUICtrlSetOnEvent($Button_Two, "Send_Message") While 1 Sleep(10) WEnd Func Send_Message() $info = @GUI_CtrlId -2 Message($info) EndFunc Func SpecialEvents() Exit EndFunc Func Message($Param1) If $Param1 = "1" Then MsgBox(0, "Testing GuiCtrlSetOnEvent", "Button_One clicked") If $Param1 = "2" Then MsgBox(0, "Testing GuiCtrlSetOnEvent", "Button_Two clicked") EndFunc 8) Link to comment Share on other sites More sharing options...
martin Posted November 9, 2007 Share Posted November 9, 2007 (edited) #Include <GuiConstants.au3> Opt("GUIOnEventMode",1) $Gui = GuiCreate("Testing GUICtrlSetOnevent", 500, 500) $Button_One = GUICtrlCreateButton("Click", 0, 0) $Button_Two = GUICtrlCreateButton("Click_2", 0, 30) GUISetState() GUICtrlSetOnEvent($Button_One, "Message") GUICtrlSetOnEvent($Button_Two, "Message") While 1 Sleep(10) WEnd Func Message() switch @GUI_CTRLID Case $Button_One MsgBox(0, "Testing GuiCtrlSetOnEvent", "Button_One clicked") Case $Button_Two MsgBox(0, "Testing GuiCtrlSetOnEvent", "Button_Two clicked") EndSwitch EndFunc Whoops, sorry Valuater, didn't see your reply. Edited November 9, 2007 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...
Valuater Posted November 9, 2007 Share Posted November 9, 2007 (edited) Whoops, sorry Valuater, didn't see your reply. lol, yours actually looks cleaner! 8) BTW, it might "look" nicer if you use [ autoit] tags Edited November 9, 2007 by Valuater Link to comment Share on other sites More sharing options...
JustinReno Posted November 9, 2007 Author Share Posted November 9, 2007 Thanks! @Smoke_N: This is the only way I could code the function. GUIGetMsg will NOT work. Its a multitasker and won't work with GUIGetMsg. 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