Jump to content

Beginner: On clicking button nothing is happening?


Recommended Posts

#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

GUISetOnEvent is for Key/Mouse input events in your GUI.

What you need is GUICtrlSetOnEvent

Darn JohnDoe, you were faster ^^

Edited 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

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

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

#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

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...