Sign in to follow this  
Followers 0
TheCrimsonCrusader

Button Function Call Negating Drop Down Requests

5 posts in this topic

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

Share this post


Link to post
Share on other sites



*bump*

Share this post


Link to post
Share on other sites

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

Remove the line OPt("GuiOnEventMode",1) or set it to 0 instead of 1.

From the help

If 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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by TheCrimsonCrusader

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 Case

Case $msg = $test

TestButton();assuming you have some funjction that was working

;Depending on how it was written it might need some changes

Otherwise, 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 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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0