SUPPORTTI Posted January 18, 2023 Share Posted January 18, 2023 (edited) 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? expandcollapse popup#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 January 18, 2023 by SUPPORTTI Added translations Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 18, 2023 Moderators Share Posted January 18, 2023 SUPPORTTI, If I can use Google Translate to put your posts into English, so can you! Please do so in future. 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...
SUPPORTTI Posted January 18, 2023 Author Share Posted January 18, 2023 Hello, I did this but at the time of posting google chrome changed beforehand, and I didn't notice but I've been checking as much as possible to avoid failures Link to comment Share on other sites More sharing options...
Dan_555 Posted January 18, 2023 Share Posted January 18, 2023 your script code contains some characters that can not be run in autoit. can you repost it ? see "enquanto 1" ... should be "while" i guess. SUPPORTTI and Danp2 1 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted January 18, 2023 Share Posted January 18, 2023 (edited) You can check the checkbox with GUICtrlSetState ($go,$GUI_CHECKED) You can hide the IP box with GUICtrlSetState ($IPin,$GUI_HIDE) But i guess you would want to disable it GUICtrlSetState ($IPin,$GUI_DISABlE) Edited January 18, 2023 by Dan_555 SUPPORTTI 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 18, 2023 Moderators Share Posted January 18, 2023 Moved to the appropriate forum. Moderation Team 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...
Dan_555 Posted January 18, 2023 Share Posted January 18, 2023 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 SUPPORTTI 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Solution SUPPORTTI Posted January 18, 2023 Author Solution Share Posted January 18, 2023 I managed to do this by remaking another script the way I need to use it as a port knock, Follow the solution below expandcollapse popup#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 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