Romm Posted September 25, 2009 Share Posted September 25, 2009 Func OKButton() $file = FileOpen("ID.txt", 1) FileWrite($file, "eewre") FileWrite($file, @CRLF) EndFunc And nothing... Without Func all works fine. WTF? Link to comment Share on other sites More sharing options...
martin Posted September 25, 2009 Share Posted September 25, 2009 Func OKButton() $file = FileOpen("ID.txt", 1) FileWrite($file, "eewre") FileWrite($file, @CRLF) EndFunc And nothing... Without Func all works fine. WTF? I have no doubt you have a problem but without more explanation than you have given I have no idea what it is, apart from the fact that you have no error checking in the code you've shown. A sample script which we can run which shows the problem is worth doing for 2 reasons; you will get more help and by making the sample you might well see your own solution. Have you even tried adding a consolewrite line at the start of the function to check that the function is actually getting called? 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...
Romm Posted September 25, 2009 Author Share Posted September 25, 2009 I edited script. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #Include <string.au3> #include <array.au3> $mainwindow = GUICreate("Test", 850, 580, 1, 1, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlSetImage(-1, "shell32.dll", 38) GUISetState() Opt("GUIOnEventMode", 1) ; Change to OnEvent mode GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $okbutton = GUICtrlCreateButton("Push to write into file", 130, 450, 180) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISwitch($mainwindow) GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func OKButton() MsgBox(1, "", "Trying to write into file") $file = FileOpen("ID.txt", 1) FileWrite($file, "Test") EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow If @GUI_WINHANDLE = $mainwindow Then MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...") Exit EndIf EndFunc Link to comment Share on other sites More sharing options...
Inverted Posted September 25, 2009 Share Posted September 25, 2009 While 1 Sleep(1000) ; Idle around WEnd First of all, that Wend is in the wrong place Link to comment Share on other sites More sharing options...
Casablanca Posted September 26, 2009 Share Posted September 26, 2009 I edited script. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #Include <string.au3> #include <array.au3> $mainwindow = GUICreate("Test", 850, 580, 1, 1, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlSetImage(-1, "shell32.dll", 38) GUISetState() Opt("GUIOnEventMode", 1) ; Change to OnEvent mode GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $okbutton = GUICtrlCreateButton("Push to write into file", 130, 450, 180) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISwitch($mainwindow) GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func OKButton() MsgBox(1, "", "Trying to write into file") $file = FileOpen("ID.txt", 1) FileWrite($file, "Test") EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow If @GUI_WINHANDLE = $mainwindow Then MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...") Exit EndIf EndFunc GUICtrlSetImage(-1, "shell32.dll", 38) GUISetState() Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Im getting confused the way you 'edit' the script, multiple stuff on the same line doesnt work well for me when i try your code. $mainwindow = GUICreate("Test", 850, 580, 1, 1, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) This needs some work i belive. GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $okbutton = GUICtrlCreateButton("Push to write into file", 130, 450, 180) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") Im no expert, but is GUISetOnEvent() needed on 2 places ? and theres the multiline-thingy again. While 1 Sleep(1000) ; Idle around WEnd Do we need to explain this ? What are you trying to accomplish with 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