Jump to content

Leave the checkbox checked - (Moved)


Go to solution Solved by SUPPORTTI,

Recommended Posts

I need to leave the checkbox always checked so that when starting the script it automatically runs the ping/port test,

Is there any way to also not show the port IP box?

#include <GUIConstantsEx.au3>
#include <StringConstants.au3>
$meia = ""
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TCP", 328, 447, 193, 125)
$IPin = GUICtrlCreateInput("172.16.16.1", 50, 0, 121, 21)
GUICtrlCreateLabel("IP/Host:", 0, 0, 50, 17)
$História = GUICtrlCreateEdit("", 2, 82, 321, 361)
$Go = GUICtrlCreateCheckbox("Iniciar", 250, -2, 75, 25, 0)
GUICtrlSetBkColor(-1, 0x009933)
GUICtrlCreateLabel("Porta", 178, 2, 23, 17)
$Portin = GUICtrlCreateInput("3389", 204, 0, 45, 21)
GUICtrlCreateLabel("Histórico", 2, 62, 36, 17)
$Gstatus = GUICtrlCreateLabel("", 74, 30, 196, 41)
GUICtrlSetFont(-1, 26, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=
TCPStartup()

enquanto 1
    $msgb = GUIGetMsg()
    Alternar $msgb
        Caso $GUI_EVENT_CLOSE
            TCPCloseSocket($sock)
            TCPShutdown()
            Saída

        Caso BitAND(GUICtrlRead($Go), $GUI_CHECKED)

        Caso BitAND(GUICtrlRead($Go), $GUI_UNCHECKED)
            $ip = GUICtrlRead($IPin, 1)
            $port = GUICtrlRead($Portin, 1)
            Se $ip = "" Ou $port = "" Então
            Outro
                $aPorta = StringSplit($porta, " ", $STR_NOCOUNT)
                Para $p Em $aPort
                    PingPort($ip, $p)
                Próximo
            Fim se
    EndSwitch
Fim


Função PingPort($ip, $port)
    $ip = TCPNameToIP($ip)
    Sono(1000)
    $início = TimerInit()
    $sock = TCPConnect($ip, $porta)
    Se @erro = 1 Então
        MsgBox(0, "Erro", "IP inválido digitado!")
        GUICtrlSetState($Go, $GUI_UNCHECKED)
    ElseIf @error = 2 Então
        MsgBox(0, "Erro", "Porta inválida/fechada digitada!")
        GUICtrlSetState($Go, $GUI_UNCHECKED)
    ElseIf $ meia = -1 Então
        GUICtrlSetData($Gstatus, "OFFLINE!")
        GUICtrlSetFont($Gstatus, 26)
        GUICtrlSetColor($Gstatus, 0xFF0093)
        GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] OFFLINE, " & $ip & ":" & $port & @CRLF, GUICtrlRead($History) )
    Outro
        $Parada = Round(TimerDiff($inicio), 2)
        GUICtrlSetData($Gstatus, "ONLINE!")
        GUICtrlSetFont($Gstatus, 26)
        GUICtrlSetColor($Gstatus, 0x009933)
        GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] ONLINE, " & $ip & ":" & $port & " ms:" & $Stop & @CRLF, GUICtrlRead($História))
        TCPCloseSocket($sock)
    Fim se
EndFunc ;==>PingPort
Mandar ("!")
Enviar ("{f4}")
Thanks to anyone who helps I've been trying since yesterday but being a beginner it's complicated.
Edited by SUPPORTTI
Added translations
Link to comment
Share on other sites

  • Moderators

SUPPORTTI,

If I can use Google Translate to put your posts into English, so can you! Please do so in future.

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

  • Moderators

Moved to the appropriate forum.

Moderation Team

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

To automatically run the ping on start (or by pressing a button) you have to run the code before the main loop.
here are 2 functions which can be useful with checkboxes:

 

Func _IsChecked($idControlID)
    ;Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED     ;Returns true or false (oneliner)
    ;The lines below convert true and false to numbers - 1 and 0
    local $x=BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
    If $x = True Then Return 1
    Return 0
EndFunc   ;==>_IsChecked

Func _CheckUncheck($id, $nr)
    If $nr = 0 Then
        GUICtrlSetState($id, $GUI_UNCHECKED)
    Else
        GUICtrlSetState($id, $GUI_CHECKED)
    EndIf
EndFunc   ;==>_CheckUncheck

 

Some of my script sourcecode

Link to comment
Share on other sites

  • Solution
I managed to do this by remaking another script the way I need to use it as a port knock,

Follow the solution below
#include <File.au3>
#include <Misc.au3>


Local $Server1 = Ping("$host","$port")
Local $Server2 = PingPort("172.16.16.100", 0000)  ;<== digite aqui o  IP e Porta 
Local $Server3 = PingPort("172.16.16.100", 0001)
Local $Server4 = PingPort("172.16.16.100", 0002)
Local $SServer1 = 0
Local $SServer2 = 0
Local $SServer3 = 0
Local $SServer4 = 0

Func PingPort($ip, $port)
     $ip = TCPNameToIP($ip)
     Sleep(1000)
        $start = TimerInit()
        $sock = TCPConnect($ip, $port)
    if ($sock <= -1) Then return -1

    ; Fill up 32 bytes
    $sBytes = ""
    For $i = 1 to 32
        $sBytes &= " "
    Next
    
    $nSent = TCPSend($sock, $sBytes)
    if (@error or $nSent <= 0) then Return -1

    $nTimerDiff = TimerDiff($start)

    TCPCloseSocket($Sock)

    Return $nTimerDiff
EndFunc

If $Server1 = -1 Then
    $SServer1 = "BLOQUEADO"
Else
    $SServer1 = "OK"
EndIf

If $Server2 = -1 Then
    $SServer2 = "BLOQUEADO"
Else
    $SServer2 = "LIBERADO"
EndIf

If $Server3 = -1 Then
    $SServer3 = "BLOQUEADO"
Else
    $SServer3 = "LIBERADO"
EndIf

If $Server4 = -1 Then
    $SServer4 = "BLOQUEADO"
Else
    $SServer4 = "LIBERADO"
EndIf

MsgBox(-1, "     CONEXAO CLIENTE", "SERVICO   | " & $SServer1 & @CRLF & "CONEXAO | " & $SServer2 & @CRLF & "CONEXAO | " & $SServer3& @CRLF & "CONEXAO | " & $SServer4)
scprit tested and working anything just call
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...