antrikshcg Posted May 16, 2012 Share Posted May 16, 2012 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> test() Func test() Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $LoginForm = GUICreate("Login", 420, 283, 271, 205) $user_l = GUICtrlCreateLabel("Username", 56, 64, 76, 17) $pass_l = GUICtrlCreateLabel("Password", 56, 120, 76, 17) $reason_l = GUICtrlCreateLabel("Reason", 56, 176, 76, 17) $user_i = GUICtrlCreateInput("", 192, 64, 161, 21) $pass_i = GUICtrlCreateInput("", 192, 112, 161, 21) $reason_i = GUICtrlCreateInput("", 192, 168, 161, 21) $username=GUICtrlRead($user_i) $password=GUICtrlRead($pass_i) $reason=GUICtrlRead($reason_i) $login_b = GUICtrlCreateButton("Login", 144, 224, 75, 25) GUISetOnEvent($login_b,"loginfn") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd EndFunc Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit EndSelect EndFunc Func loginfn() Run("D:\Programfiles\PuTTYPortable\PuTTYPortable.exe") WinWaitActive("PuTTY Configuration") Sleep(3000) Send("Hostname") Sleep(4000) EndFunc This is my code. i just want that when i click the button login loginfn() will get called and if i close gui in between everything get terminated.Please help! Link to comment Share on other sites More sharing options...
JohnOne Posted May 16, 2012 Share Posted May 16, 2012 (edited) GUISetOnEvent($login_b,"loginfn") <> GUICtrlSetOnEvent($login_b,"loginfn") Edited May 16, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
qsek Posted May 16, 2012 Share Posted May 16, 2012 (edited) GUISetOnEvent is for Key/Mouse input events in your GUI.What you need is GUICtrlSetOnEventDarn JohnDoe, you were faster ^^ Edited May 16, 2012 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
buymeapc Posted May 16, 2012 Share Posted May 16, 2012 You're just missing a reference to clicking the button within your loop. The loop just runs while not looking for any events. This should work better for you: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> test() Func test() Opt("GUIOnEventMode", 1) $LoginForm = GUICreate("Login", 420, 283, 271, 205) $user_l = GUICtrlCreateLabel("Username", 56, 64, 76, 17) $pass_l = GUICtrlCreateLabel("Password", 56, 120, 76, 17) $reason_l = GUICtrlCreateLabel("Reason", 56, 176, 76, 17) $user_i = GUICtrlCreateInput("", 192, 64, 161, 21) $pass_i = GUICtrlCreateInput("", 192, 112, 161, 21) $reason_i = GUICtrlCreateInput("", 192, 168, 161, 21) $username=GUICtrlRead($user_i) $password=GUICtrlRead($pass_i) $reason=GUICtrlRead($reason_i) $login_b = GUICtrlCreateButton("Login", 144, 224, 75, 25) GUISetOnEvent($login_b,"loginfn") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $login_b Then loginfn() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd EndFunc Func loginfn() Run("D:\Programfiles\PuTTYPortable\PuTTYPortable.exe") WinWaitActive("PuTTY Configuration") Sleep(3000) Send("Hostname") Sleep(4000) EndFunc Link to comment Share on other sites More sharing options...
JohnOne Posted May 16, 2012 Share Posted May 16, 2012 buymeapc, the OP is working with event mode, rather than loop. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
qsek Posted May 16, 2012 Share Posted May 16, 2012 (edited) buymeapc, i think since his script contains Opt("GUIOnEventMode", 1) the OP wanted to use OnEvent Mode but its working either way so John your getting me mad Edited May 16, 2012 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
antrikshcg Posted May 16, 2012 Author Share Posted May 16, 2012 Ok .I got one problem solved. but one is still i m facing. wen i m closing the gui window program is not exiting. Link to comment Share on other sites More sharing options...
buymeapc Posted May 16, 2012 Share Posted May 16, 2012 Ahh...didn't notice that. Ya, the loop may not be the way to go then. Link to comment Share on other sites More sharing options...
qsek Posted May 16, 2012 Share Posted May 16, 2012 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> test() Func test() Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $LoginForm = GUICreate("Login", 420, 283, 271, 205) $user_l = GUICtrlCreateLabel("Username", 56, 64, 76, 17) $pass_l = GUICtrlCreateLabel("Password", 56, 120, 76, 17) $reason_l = GUICtrlCreateLabel("Reason", 56, 176, 76, 17) $user_i = GUICtrlCreateInput("", 192, 64, 161, 21) $pass_i = GUICtrlCreateInput("", 192, 112, 161, 21) $reason_i = GUICtrlCreateInput("", 192, 168, 161, 21) $username = GUICtrlRead($user_i) $password = GUICtrlRead($pass_i) $reason = GUICtrlRead($reason_i) $login_b = GUICtrlCreateButton("Login", 144, 224, 75, 25) GUIctrlSetOnEvent($login_b, "loginfn") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd EndFunc ;==>test Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit EndSelect EndFunc ;==>SpecialEvents Func loginfn() ConsoleWrite("run" & @CRLF) Run("D:ProgramfilesPuTTYPortablePuTTYPortable.exe") WinWaitActive("PuTTY Configuration") Sleep(3000) Send("Hostname") Sleep(4000) EndFunc ;==>loginfn Func CLOSEClicked() Exit EndFunc Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
antrikshcg Posted May 16, 2012 Author Share Posted May 16, 2012 ConsoleWrite("run" & @CRLF) what this line does? btw code is working.many thanks for help. Link to comment Share on other sites More sharing options...
JohnOne Posted May 16, 2012 Share Posted May 16, 2012 John your getting me mad For me, when I'm typing a reply, if someone else replies I get a notification on screen and the option to view it.You don't get that? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
qsek Posted May 16, 2012 Share Posted May 16, 2012 ConsoleWrite("run" & @CRLF) what this line does? btw code is working.many thanks for help.This writes "run" to the scite output pane if you click login.It was part of finding the problem.Since i dont have putty installed, i wanted an action be visible weather the function was called or not.For me, when I'm typing a reply, if someone else replies I get a notification on screen and the option to view it.You don't get that?Sometimes i dont get it, maybe i dont pay enogh attention though. Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 16, 2012 Moderators Share Posted May 16, 2012 JohnOne, qsek,Personally I have found the "New Reply" feature about as much use a chocolate fireguard - when I do see it it is several minutes too late to be of use. After the crappy "updowngraded" post editor, it is probably the least useful thing in the last update. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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