TheCrimsonCrusader Posted March 9, 2008 Share Posted March 9, 2008 I have a button function call(Test Button, which is located at the top left) to the notepad executable and that works fine. However, because I have this in place, the combo box I have created doesn't work in terms of when I select an item and click on the 'Add' button, it should write the request of the selected entry to a text file(c:\test.txt), but it doesn't. I assume I need something between the 'EndFunc' and 'While 1' or I need to use an entirely different routine for how the combo box works, but I am not sure what that would be. Any ideas would be greatly appreciated! Thanks in advance! CODE#include <GuiConstants.au3> Opt ("GUIOnEventMode", 1) $Form1 = GUICreate("Test Form", 681, 480, -1, -1) $Tab1 = GUICtrlCreateTab(0, 0, 681, 481) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Test Tab") $apps = GUICtrlCreateCombo("", 520, 40, 140, 150) GUICtrlSetData(-1, "Entry 1|Entry 2|Entry 3", "Entry 1") $Add = GUICtrlCreateButton("Add", 520, 80, 60, 30) GUISetState() $Test = GUICtrlCreateButton("Test Button", 20, 40, 120, 20) GUICtrlSetOnEvent($Test, "TestButton") Func TestButton() Run("notepad.exe") EndFunc ;==>TestButton While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Add $file = FileOpen("c:\test.txt", 1) If GUICtrlRead($apps) == "Entry 1" Then FileWriteLine($file, "Entry1") FileClose($file) EndIf If GUICtrlRead($apps) == "Entry 2" Then FileWriteLine($file, "Entry2") FileClose($file) EndIf If GUICtrlRead($apps) == "Entry 3" Then FileWriteLine($file, "Entry3") FileClose($file) EndIf EndSelect WEnd Link to comment Share on other sites More sharing options...
TheCrimsonCrusader Posted March 9, 2008 Author Share Posted March 9, 2008 *bump* Link to comment Share on other sites More sharing options...
martin Posted March 9, 2008 Share Posted March 9, 2008 I have a button function call(Test Button, which is located at the top left) to the notepad executable and that works fine. However, because I have this in place, the combo box I have created doesn't work in terms of when I select an item and click on the 'Add' button, it should write the request of the selected entry to a text file(c:\test.txt), but it doesn't. I assume I need something between the 'EndFunc' and 'While 1' or I need to use an entirely different routine for how the combo box works, but I am not sure what that would be. Any ideas would be greatly appreciated! Thanks in advance!CODE#include <GuiConstants.au3>Opt ("GUIOnEventMode", 1)$Form1 = GUICreate("Test Form", 681, 480, -1, -1)$Tab1 = GUICtrlCreateTab(0, 0, 681, 481)GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)$TabSheet1 = GUICtrlCreateTabItem("Test Tab")$apps = GUICtrlCreateCombo("", 520, 40, 140, 150)GUICtrlSetData(-1, "Entry 1|Entry 2|Entry 3", "Entry 1")$Add = GUICtrlCreateButton("Add", 520, 80, 60, 30)GUISetState()$Test = GUICtrlCreateButton("Test Button", 20, 40, 120, 20)GUICtrlSetOnEvent($Test, "TestButton")Func TestButton() Run("notepad.exe")EndFunc ;==>TestButtonWhile 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Add $file = FileOpen("c:\test.txt", 1) If GUICtrlRead($apps) == "Entry 1" Then FileWriteLine($file, "Entry1") FileClose($file) EndIf If GUICtrlRead($apps) == "Entry 2" Then FileWriteLine($file, "Entry2") FileClose($file) EndIf If GUICtrlRead($apps) == "Entry 3" Then FileWriteLine($file, "Entry3") FileClose($file) EndIf EndSelectWEnd Remove the line OPt("GuiOnEventMode",1) or set it to 0 instead of 1.From the helpIf the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1. 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...
TheCrimsonCrusader Posted March 9, 2008 Author Share Posted March 9, 2008 (edited) Thanks, but when I change the value to '0' or remove the line entirely, the drop-down list calls now work, but now the 'Test' button won't work . Strange, but that's because I don't know what I am doing. Edited March 9, 2008 by TheCrimsonCrusader Link to comment Share on other sites More sharing options...
martin Posted March 9, 2008 Share Posted March 9, 2008 (edited) Thanks, but when I change the value to '0' or remove the line entirely, the drop-down list calls now work, but now the 'Test' button won't work . Strange, but that's because I don't know what I am doing. You need to remove the line GuiCtrlSetOnEvenet($Test,"TestButton"), and add a new CaseCase $msg = $test TestButton();assuming you have some funjction that was working ;Depending on how it was written it might need some changesOtherwise, keep the on event mode and then you need GuiSetOnEvent for $GUI_EVENT_CLOSE and $Add. If you use OnEventMode then everything control has to trigger an OnEvent function, otherwise nothing will trigger the on event functions. Edited March 9, 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...
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