MrChris Posted July 9, 2006 Share Posted July 9, 2006 What am I missing in order to make this sample GUI button work. Right now it does noting. It shoudl open up notepad. #include <GuiConstants.au3> GuiCreate("Sample GUI", 296, 120,-1, -1 ) $Group_1 = GuiCtrlCreateGroup("Sample GUI", 10, 10, 280, 100) $Button_2 = GuiCtrlCreateButton("Open Notepad", 20, 30, 80, 40) GUICtrlSetOnEvent(-1, "notepad") Func notepad() RunWait(@SystemDir & '\notepad.exe') EndFunc GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Thanks, MrChris Link to comment Share on other sites More sharing options...
gamepin126 Posted July 9, 2006 Share Posted July 9, 2006 (edited) Run("Notepad.exe") If you can type it in the start>run then you can use Run(). Edited July 9, 2006 by gamepin126 Link to comment Share on other sites More sharing options...
MrChris Posted July 9, 2006 Author Share Posted July 9, 2006 I have RunWait(@SystemDir & '\notepad.exe') in there. I changed it with your code and nothing still. Link to comment Share on other sites More sharing options...
gamepin126 Posted July 9, 2006 Share Posted July 9, 2006 You need to make a new case for that button. #include <GuiConstants.au3> GuiCreate("Sample GUI", 296, 120,-1, -1 ) $Group_1 = GuiCtrlCreateGroup("Sample GUI", 10, 10, 280, 100) $Button_2 = GuiCtrlCreateButton("Open Notepad", 20, 30, 80, 40) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $Button_2 Run("Notepad.exe") Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
Uten Posted July 9, 2006 Share Posted July 9, 2006 Search for OnEvent mode in the help file. Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Uten Posted July 9, 2006 Share Posted July 9, 2006 (edited) gamepin came with the other solution "not to use events" so a more elaborate OnEvent sample would be: #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode GuiCreate("Sample GUI", 296, 120,-1, -1 ) $Group_1 = GuiCtrlCreateGroup("Sample GUI", 10, 10, 280, 100) $Button_2 = GuiCtrlCreateButton("Open Notepad", 20, 30, 80, 40) GUICtrlSetOnEvent(-1, "notepad") Func notepad() RunWait(@SystemDir & '\notepad.exe') EndFunc GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE sleep(1000) ;Relax the process, save cpu WEnd Exit I have not tested this code so I could have typos EDIT: Damn typos! Edited July 9, 2006 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
MrChris Posted July 9, 2006 Author Share Posted July 9, 2006 @ Uten Ahh yes that was it. Thanks a ton. MrChris 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