Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/04/2019 in all areas

  1. Maybe this is what you asked. $baum = 'tree' _translate() Func _translate() Send("^c"); Send(Eval(ClipGet())) EndFunc
    2 points
  2. LAST VERSION - 1.1 18-May-12 Control Viewer (CV) is a replacement of AutoIt Window Info with a number of advantages. I tried to stick to the interface of the last, so you almost do not have to be retrained. During testing, I never managed to find any controls that could not be identified by CV (on the contrary, shows a lot of hidden controls, especially for the system windows). The all program settings are stored in the following registry key: HKEY_CURRENT_USERSoftwareY'sControl Viewer The main differences CV from AWI Shows the complete list of all existing controls for the window that are interested (visible, hidden and deleted controls are displayed with different colors that can be changed to any other).Dynamically changing information during search for the windows and their controls.Ability to quickly switch between controls in the list.Ability to show/hide any controls from the list (useful for the overlaping controls).Information for the Style and ExStyle parameters shown in the form of hexadecimal values​​, and as its flags.Added the PID and Path parameters in the Window tab and ability to quickly open a folder that containing the process file.Added the coordinate system relative to the selected control.Shows a color of the selected pixel in RGB and BGR formats.Shows an example fill of the selected color.Ability to select the text encoding (affects the Text parameter in the Control tab).The complete change the appearance of pop-up frame for the selected controls.Simple and convenient tool to get a screenshot of the part screen of interest for publication on the forum (Capture tab).Create a report in the clipboard or a text file for subsequent publication on the forum.Search all running AutoIt scripts and their windows in the system (AutoIt tab).User-friendly interface. Used shortcuts Ctrl+Alt+T - Enable/Disable "Always On Top" mode (also available from the menu). Ctrl+Alt+H - Enable/Disable highlight selected controls (also available from the menu). Ctrl+A - Select all text (works in any input field). Ctrl - Hold down when moving the mouse to scroll the screenshot (Capture tab). Shift - Hold down when stretching/compression of the contour frame for an equilateral resizing screenshots (Capture tab). DoubleClick (on the screenshot) - Save the image to a file (Capture tab). DoubleClick (on any list item) - Open a folder with the file of the process or AutoIt script (AutoIt tab). Del (on any list item) - Close process (AutoIt tab). F5 - Updating the list (AutoIt tab). If anyone have any questions or comments about CV, please post it in this thread. I will be glad to any feedback and suggestions. Files to download Binary (x86 and x64) Redirection to CV_bin.zip, 1.14 MB CV_bin.html Source Redirection to CV_source.zip, 691 KB CV_source.html
    1 point
  3. For me, the boxes don't show up using either method. This is likely due to the browser version used by the embedded control. See this post for a way to update the registry to specify a newer version --
    1 point
  4. To start you up : Local $oShellApplication = ObjCreate("Shell.Application") Local $oShellFolder = $oShellApplication.NameSpace(0x11) Local $oShellFolderItems = $oShellFolder.Items() For $oFolder in $oShellFolderItems ; ConsoleWrite ($oFolder.name & @CRLF) If $oFolder.name = "Moto G Play" Then ExitLoop Next Local $oRoot = $oFolder.GetFolder Local $oRootItems = $oRoot.Items() For $oSource in $oRootItems ; ConsoleWrite ($oSource.name & @CRLF) If $oSource.name = "Stockage interne partagé" Then ExitLoop Next $oRoot = $oSource.GetFolder $oRootItems = $oRoot.Items() For $oSource in $oRootItems ConsoleWrite ($oSource.name & "/" & $oSource.IsFolder & @CRLF) Next That accesses internal data.
    1 point
  5. I've no idea. Maybe compressed content or a picture or ... who knows? Browsers know how to handle that but only web gurus can tell.
    1 point
  6. Something like this? Mark Haus or Uhr and then hit ALT+SHIFT+d. $myDict = _ObjDictCreate(1) _ObjDictAdd($myDict, 'Baum', 'tree') _ObjDictAdd($myDict, 'Uhr', 'clock') _ObjDictAdd($myDict, 'Haus', 'house') HotKeySet("+!d", "_translate") ; Shift-Alt-d While 1 Sleep(100) WEnd Func _translate() Send("^c"); ConsoleWrite(ClipGet() & @CRLF) Send(_ObjDictGetValue($myDict, ClipGet())) EndFunc #cs ============================= OBJEKT 'Scripting.Dictionary' ======================================= *** Funktionssammlung *** _ObjDictCreate(Modus) Erzeugt ein Dictionary Objekt im Binär- (default) oder Textmodus Gibt das Handle des Objektes zurück _ObjDictAdd(Objekt, Schlüssel, Wert) Fügt einem Dictionary Objekt ein Schlüssel-Wert Paar hinzu _ObjDictGetValue(Objekt, Schlüssel) Liest den Wert für einen Schlüssel aus _ObjDictSetValue(Objekt, Schlüssel) Setzt einen neuen Wert für einen Schlüssel _ObjDictCount(Objekt) Gibt die Anzahl der Schlüssel-Wert Paare zurück _ObjDictSearch(Objekt, Schlüssel) Prüft ob der Schlüssel existiert, liefert 'TRUE' wenn gefunden _ObjDictDeleteKey(Objekt, Schlüssel) Löscht den angegebenen Schlüssel (und dessen Wert) Wird statt eines Schlüsselnamens '' übergeben, werden alle Schlüssel gelöscht (Standard) _ObjDictList(Objekt) Eine GUI mit einem ListView zeigt alle Schlüssel-Wert Paare _IniReadSectionToObjDict(Objekt, INI-Pfad, Sektion) Liest die angegebene INI-Sektion in das Objekt Gibt die Anzahl der gelesenen Schlüssel-Wert Paare zurück _IniWriteSectionFromObjDict(Objekt, INI-Pfad, Sektion) Schreibt die Schlüssel-Wert Paare des Objekts in die angegebene Sektion der INI-Datei Gibt die Anzahl der geschriebenen Schlüssel-Wert Paare zurück _FileReadToObjDict(Objekt, TextDatei-Pfad, Seperator) Liest aus einer Textdatei alle Schlüssel-Wert Paare zeilenweise ein (1 Paar/Zeile) Standard-Seperator ist '|', kann hier angepaßt werden Gibt die Anzahl der gelesenen Schlüssel-Wert Paare zurück _FileWriteFromObjDict(Objekt, TextDatei-Pfad, Seperator, Overwrite) Schreibt die Schlüssel-Wert Paare des Objekts in die angegebene Datei (1 Paar/Zeile). Mit Overwrite='TRUE' (Standard) wird die angegebene Datei, falls sie bereits existiert, überschrieben. Mit 'FALSE' wird an eine bestehende Datei angehängt. Standard-Seperator ist '|', kann hier angepaßt werden. Gibt die Anzahl der geschriebenen Schlüssel-Wert Paare zurück Autor: BugFix ( bugfix@autoit.de ) =================================================================================================== #ce #include <GuiConstants.au3> #include <GuiListView.au3> ;================================================================================================== ; Parameter: $MODE ; 0 Binär (default) ; 1 Text ; Return: Objekt Handle ;================================================================================================== Func _ObjDictCreate($MODE=0) $oDICT = ObjCreate('Scripting.Dictionary') If $MODE <> 0 Then $oDICT.CompareMode = 1 Return $oDICT EndFunc ;==>_ObjDictCreate ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $KEY - Schlüssel ; $VALUE - Wert ; Return: Erfolg: 0 ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 2 Schlüssel ohne Inhalt übergeben ; 3 Wert hat keinen Inhalt ; 4 Schlüssel bereits vorhanden ;================================================================================================== Func _ObjDictAdd(ByRef $oDICT, $KEY, $VALUE) If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf $KEY = '' Then SetError(2) Return -1 ElseIf $VALUE = '' Then SetError(3) Return -1 ElseIf $oDICT.Exists($KEY) Then SetError(4) Return -1 EndIf $oDICT.Add($KEY, $VALUE) Return 0 EndFunc ;==>_ObjDictAdd ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $KEY - Schlüssel ; Return: Erfolg: Wert des Schlüssels ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 2 Schlüssel ohne Inhalt übergeben ; 5 Schlüssel nicht vorhanden ;================================================================================================== Func _ObjDictGetValue(ByRef $oDICT, $KEY) If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf $KEY = '' Then SetError(2) Return -1 ElseIf Not $oDICT.Exists($KEY) Then SetError(5) Return -1 EndIf Return $oDICT.Item($KEY) EndFunc ;==>_ObjDictGetValue ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $KEY - Schlüssel ; $VALUE - Wert ; Return: Erfolg: 0 ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 2 Schlüssel ohne Inhalt übergeben ; 3 Wert hat keinen Inhalt ; 5 Schlüssel nicht vorhanden ;================================================================================================== Func _ObjDictSetValue(ByRef $oDICT, $KEY, $VALUE) If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf $KEY = '' Then SetError(2) Return -1 ElseIf $VALUE = '' Then SetError(3) Return -1 ElseIf Not $oDICT.Exists($KEY) Then SetError(5) Return -1 EndIf $oDICT.Item($KEY) = $VALUE Return 0 EndFunc ;==>_ObjDictSetValue ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; Return: Erfolg: Anzahl der Schlüssel-Wert Paare ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ;================================================================================================== Func _ObjDictCount(ByRef $oDICT) If Not IsObj($oDICT) Then SetError(1) Return -1 EndIf Return $oDICT.Count EndFunc ;==>_ObjDictCount ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $KEY - Schlüssel ; Return: Erfolg: TRUE Schlüssel vorhanden ; FALSE Schlüssel nicht vorhanden ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 2 Schlüssel ohne Inhalt übergeben ;================================================================================================== Func _ObjDictSearch(ByRef $oDICT, $KEY) If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf $KEY = '' Then SetError(2) Return -1 ElseIf Not $oDICT.Exists($KEY) Then Return False Else Return True EndIf EndFunc ;==>_ObjDictSearch ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $KEY - Schlüssel (default='') ; mit $KEY = '' werden alle Schlüssel gelöscht ; Return: Erfolg: 0 ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ;================================================================================================== Func _ObjDictDeleteKey(ByRef $oDICT, $KEY='') If Not IsObj($oDICT) Then SetError(1) Return -1 EndIf If $KEY = '' Then $oDICT.RemoveAll Return 0 ElseIf Not $oDICT.Exists($KEY) Then SetError(5) Return -1 EndIf $oDICT.Remove($KEY) Return 0 EndFunc ;==>_ObjDictDeleteKey ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $TITLE - Fenstertitel (optional) ; Return: Erfolg: GUI mit ListView ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; Requirements: #include <GuiConstants.au3> ; #include <GuiListView.au3> ;================================================================================================== Func _ObjDictList(ByRef $oDICT, $TITLE='Elemente: Objekt Dictionary') If Not IsObj($oDICT) Then SetError(1) Return -1 EndIf Local $count = $oDICT.Count Local $SaveMode = Opt("GUIOnEventMode",0), $ListGUI, $oDictLV, $btnClose, $msg $ListGUI = GUICreate($TITLE, 600, 400, (@DesktopWidth - 600)/2, (@DesktopHeight - 400)/2) $btnClose = GUICtrlCreateButton('&Ende', 40, 360, 70, 22) GUICtrlSetResizing($btnClose, BitOR($GUI_DockRight, $GUI_DockBottom, $GUI_DockSize)) GUICtrlDelete($oDictLV) $oDictLV = GUICtrlCreateListView('Schlüssel|Wert', 10, 10, 580, 340, BitOR($LVS_SHOWSELALWAYS, _ $LVS_EDITLABELS), BitOR($LVS_EX_GRIDLINES, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_REGIONAL)) If $count > 0 Then Local $strKey, $colKeys = $oDICT.Keys For $strKey In $colKeys GUICtrlCreateListViewItem($strKey & '|' & $oDICT.Item($strKey), $oDictLV) Next Else WinSetTitle($ListGUI, '', 'Das Objekt Dictionary enthält keine Elemente!') EndIf GUISetState(@SW_SHOW, $ListGUI) While 1 $msg = GUIGetMsg(1) If $msg[1] = $ListGUI And _ ($msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $btnClose) Then ExitLoop WEnd GUIDelete($ListGUI) Opt("GUIOnEventMode",$SaveMode) EndFunc ;==>ObjDictList ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $PathINI - Pfad der INI-Datei ; $SECTION - Sektion die gelesen werden soll ; Return: Erfolg: Anzahl der eingelesenen Schlüssel-Wert Paare ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 6 INI-Pfad nicht vorhanden ; 7 kein Sektionsname ; 8 INI-Sektion konnte nicht gelesen werden oder leer ;================================================================================================== Func _IniReadSectionToObjDict(ByRef $oDICT, $PathINI, $SECTION) If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf Not FileExists($PathINI) Then SetError(6) Return -1 ElseIf $SECTION = '' Then SetError(7) Return -1 EndIf Local $arSECTION = IniReadSection($PathINI, $SECTION) If Not IsArray($arSECTION) Then SetError(8) Return -1 EndIf For $i = 1 To $arSECTION[0][0] $oDICT.Add($arSECTION[$i][0], $arSECTION[$i][1]) Next Return $arSECTION[0][0] EndFunc ;==>_IniReadSectionToObjDict ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $PathINI - Pfad der INI-Datei ; $SECTION - Sektion die gelesen werden soll ; Return: Erfolg: Anzahl der geschriebenen Schlüssel-Wert Paare ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 7 kein Sektionsname ; 9 INI-Sektion konnte nicht geschrieben werden ;================================================================================================== Func _IniWriteSectionFromObjDict(ByRef $oDICT, $PathINI, $SECTION) If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf $SECTION = '' Then SetError(7) Return -1 EndIf Local $arSECTION[$oDICT.Count][2], $i = 0 Local $strKey, $colKeys = $oDICT.Keys For $strKey In $colKeys $arSECTION[$i][0] = $strKey $arSECTION[$i][1] = $oDICT.Item($strKey) $i += 1 Next If IniWriteSection($PathINI, $SECTION, $arSECTION, 0) = 1 Then Return $oDICT.Count Else SetError(9) Return -1 EndIf EndFunc ;==>_IniWriteSectionFromObjDict ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $PathFile - Pfad der Datei ; $SEPERATOR - Trennzeichen zwischen Wert u. Schlüssel, Standard: '|' ; Return: Erfolg: Anzahl der eingelesenen Schlüssel-Wert Paare ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 6 Datei-Pfad nicht vorhanden ; 7 Leerstring als Seperator übergeben ; 8 Datei konnte nicht gelesen werden ;================================================================================================== Func _FileReadToObjDict(ByRef $oDICT, $PathFile, $SEPERATOR='|') If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf Not FileExists($PathFile) Then SetError(6) Return -1 ElseIf $SEPERATOR = '' Then SetError(7) Return -1 EndIf Local $fh = FileOpen($PathFile, 0), $line Local $val If $fh = -1 Then SetError(8) Return -1 EndIf While 1 $line = FileReadLine($fh) If @error = -1 Then ExitLoop $val = StringSplit($line, $SEPERATOR) If $val[0] > 1 Then $oDICT.Add($val[1], $val[2]) EndIf Wend FileClose($fh) Return $oDICT.Count EndFunc ;==>_FileReadToObjDict ;================================================================================================== ; Parameter: $oDICT - Handle des Dictionary-Objektes ; $PathFile - Pfad der Datei ; $SEPERATOR - Trennzeichen zwischen Wert u. Schlüssel, Standard: '|' ; $OVERWRITE - Falls Datei existiert, wird sie überschrieben (Standard). ; Mit 'FALSE' wird an bestehende Datei angehängt. ; Return: Erfolg: Anzahl der geschriebenen Schlüssel-Wert Paare ; Fehler: -1 ; Fehlerwert: 1 Objekt existiert nicht ; 7 Leerstring als Seperator übergeben ; 8 Datei konnte nicht geschrieben werden ;================================================================================================== Func _FileWriteFromObjDict(ByRef $oDICT, $PathFile, $SEPERATOR='|', $OVERWRITE=True) If Not IsObj($oDICT) Then SetError(1) Return -1 ElseIf $SEPERATOR = '' Then SetError(7) Return -1 EndIf If $OVERWRITE Then Local $fh = FileOpen($PathFile, 34) Else Local $fh = FileOpen($PathFile, 33) EndIf Local $strKey, $colKeys = $oDICT.Keys For $strKey In $colKeys FileWriteLine($fh, $strKey & $SEPERATOR & $oDICT.Item($strKey)) If @error Then SetError(8) Return -1 EndIf Next FileClose($fh) Return $oDICT.Count EndFunc ;==>_FileWriteFromObjDict
    1 point
  7. Nine

    Controls with same ID

    Great, glad it worked. Also you should use the handle of the window like this : #include <WinAPISysWin.au3> ; put those 2 lines on top of your script #include <Array.au3> Local $hWnd = WinGetHandle ("Set Measurement Channels") Local $aArr = _WinAPI_EnumChildWindows ($hWnd) ControlSetText($hWnd, "", $aArr[12][0] , "333" )
    1 point
  8. I have started a section in the wiki for the UDF: https://www.autoitscript.com/wiki/TaskScheduler
    1 point
  9. Hi @CYCho, Anyway, I have finished my code followed your suggestion, thanks so much!
    1 point
  10. I made some changes to the TCP source code of @mlukac89 posted above to monitor multiple ports (spacebar delimiter) To monitor multiple ports, just input e.g 80 800 8000 into inputbox #include <GUIConstantsEx.au3> #include <StringConstants.au3> $sock = "" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("TCP", 328, 447, 193, 125) $IPin = GUICtrlCreateInput("", 50, 0, 121, 21) GUICtrlCreateLabel("IP/Host:", 0, 0, 50, 17) $History = GUICtrlCreateEdit("", 2, 82, 321, 361) $Go = GUICtrlCreateCheckbox("Start", 250, -2, 75, 25, 0) GUICtrlSetBkColor(-1, 0x009933) GUICtrlCreateLabel("Port", 178, 2, 23, 17) $Portin = GUICtrlCreateInput("", 204, 0, 45, 21) GUICtrlCreateLabel("History", 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() ;118.70.78.54:80 8000 3116 3389 While 1 $msgb = GUIGetMsg() Switch $msgb Case $GUI_EVENT_CLOSE TCPCloseSocket($sock) TCPShutdown() Exit Case BitAND(GUICtrlRead($Go), $GUI_CHECKED) Case BitAND(GUICtrlRead($Go), $GUI_UNCHECKED) $ip = GUICtrlRead($IPin, 1) $port = GUICtrlRead($Portin, 1) If $ip = "" Or $port = "" Then Else $aPort = StringSplit($port, " ", $STR_NOCOUNT) For $p In $aPort PingPort($ip, $p) Next EndIf EndSwitch WEnd Func PingPort($ip, $port) $ip = TCPNameToIP($ip) Sleep(1000) $start = TimerInit() $sock = TCPConnect($ip, $port) If @error = 1 Then MsgBox(0, "Error", "Invalid IP entered!") GUICtrlSetState($Go, $GUI_UNCHECKED) ElseIf @error = 2 Then MsgBox(0, "Error", "Invalid/closed Port entered!") GUICtrlSetState($Go, $GUI_UNCHECKED) ElseIf $sock = -1 Then GUICtrlSetData($Gstatus, "OFFLINE!") GUICtrlSetFont($Gstatus, 26) GUICtrlSetColor($Gstatus, 0xFF0093) GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] OFFLINE, " & $ip & ":" & $port & @CRLF, GUICtrlRead($History)) Else $Stop = Round(TimerDiff($start), 2) GUICtrlSetData($Gstatus, "ONLINE!") GUICtrlSetFont($Gstatus, 26) GUICtrlSetColor($Gstatus, 0x009933) GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] ONLINE, " & $ip & ":" & $port & " ms:" & $Stop & @CRLF, GUICtrlRead($History)) TCPCloseSocket($sock) EndIf EndFunc ;==>PingPort Result is like this
    1 point
  11. Werty

    Send() is not working

    Qwidgets are a pain to automate, read this thread about qwidgets, not a solution as the zip in the example is missing, but will give you an idea of what you are up against...
    1 point
  12. Nine

    Send() is not working

    WinActivate doesn't have a 3rd parameter. So it is impossible that you could run that script. What are you up to ?
    1 point
  13. seadoggie01

    FileInstall Issues

    Like this... If @ScriptDir = @DesktopDir Then ; "Do nothing, keep going" Else FileCopy(@ScriptFullPath, @DesktopDir & '\' & @ScriptName) Run(@DesktopDir & '\' & @ScriptName) Exit EndIf If the script isn't on the desktop, copy to the desktop, and run it. You could even have a check at the end of your script (if you were feeling fancy) to automatically delete itself if it was on the desktop. Edit: Would probably be better to use @AppDataDir instead of @DesktopDir so the user never sees it
    1 point
  14. The PLC you may have from Siemens requires Modbus TCP, and not just straight TCP. Which means, you can have one IP address with more than 10 registers speaking at the same time. That you know, however since you have an application that speaks to the PLC, the best thing to do is convert the C# program into AutoIt version. If the information on that C# program is to sensitive, then I suggest stripping pieces of it and posting it here... I assume in that program there should be something like: IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; IPEndPoint remoteEP = new IPEndPoint(ipAddress,11000); Let us know, there are plenty of C# GURU's out here in AutoIt land.
    1 point
  15. @dinodod Every PLC, even if they are from the same "manufacturer", communicate with different protocols. If you could know at least the model of the PLC, and what you are trying to achieve from your script, then it would be a good point where to start from
    1 point
  16. mlukac89

    Ping a specific port

    Here i found this on this forum, try run 1 by 1 UDP #include<GUIConstantsEx.au3> $sock = "" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("UDP", 328, 447, 193, 125) $IPin = GUICtrlCreateInput("", 50, 0, 121, 21) GUICtrlCreateLabel("IP/Host:", 0, 0, 50, 17) $History = GUICtrlCreateEdit("", 2, 82, 321, 361) $Go = GUICtrlCreateCheckbox("Start", 250, -2, 75, 25, 0) GUICtrlSetBkColor(-1, 0x009933) GUICtrlCreateLabel("Port", 178, 2, 23, 17) $Portin = GUICtrlCreateInput("", 204, 0, 45, 21) GUICtrlCreateLabel("History", 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= UDPStartup() While 1 $msgb = GUIGetMsg() Switch $msgb Case $GUI_EVENT_CLOSE UDPCloseSocket($sock) UDPShutdown() Exit Case BitAND(GUICtrlRead($go),$GUI_CHECKED) Case BitAND(GUICtrlRead($go),$GUI_UNCHECKED) $ip = GUICtrlRead($IPin, 1) $port = GUICtrlRead($Portin, 1) If $ip = "" Or $port = "" Then Else $ip = TCPNameToIP($ip) Sleep(1000) $start = TimerInit() $sock = UDPBind($ip, $port) If @error = 1 Then MsgBox(0, "Error", "Invalid IP entered!") GUICtrlSetState($go, $GUI_UNCHECKED) ElseIf @error = 2 Then MsgBox(0, "Error", "Invalid/closed Port entered!") GUICtrlSetState($go, $GUI_UNCHECKED) ElseIf $sock = -1 Then GUICtrlSetData($Gstatus, "OFFLINE!") GUICtrlSetFont($gstatus, 26) GUICtrlSetColor($gstatus, 0xFF0093) GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] OFFLINE, "&$ip&":"&$port & @CRLF, GUICtrlRead($History)) Else $Stop = Round(TimerDiff($start), 2) GUICtrlSetData($Gstatus, "ONLINE!") GUICtrlSetFont($gstatus, 26) GUICtrlSetColor($gstatus, 0x009933) GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] ONLINE, "&$ip&":"&$port&" ms:" & $Stop & @CRLF, GUICtrlRead($History)) UDPCloseSocket($sock) EndIf EndIf EndSwitch WEnd And TCP #include<GUIConstantsEx.au3> $sock = "" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("TCP", 328, 447, 193, 125) $IPin = GUICtrlCreateInput("", 50, 0, 121, 21) GUICtrlCreateLabel("IP/Host:", 0, 0, 50, 17) $History = GUICtrlCreateEdit("", 2, 82, 321, 361) $Go = GUICtrlCreateCheckbox("Start", 250, -2, 75, 25, 0) GUICtrlSetBkColor(-1, 0x009933) GUICtrlCreateLabel("Port", 178, 2, 23, 17) $Portin = GUICtrlCreateInput("", 204, 0, 45, 21) GUICtrlCreateLabel("History", 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() While 1 $msgb = GUIGetMsg() Switch $msgb Case $GUI_EVENT_CLOSE TCPCloseSocket($sock) TCPShutdown() Exit Case BitAND(GUICtrlRead($go),$GUI_CHECKED) Case BitAND(GUICtrlRead($go),$GUI_UNCHECKED) $ip = GUICtrlRead($IPin, 1) $port = GUICtrlRead($Portin, 1) If $ip = "" Or $port = "" Then Else $ip = TCPNameToIP($ip) Sleep(1000) $start = TimerInit() $sock = TCPConnect($ip, $port) If @error = 1 Then MsgBox(0, "Error", "Invalid IP entered!") GUICtrlSetState($go, $GUI_UNCHECKED) ElseIf @error = 2 Then MsgBox(0, "Error", "Invalid/closed Port entered!") GUICtrlSetState($go, $GUI_UNCHECKED) ElseIf $sock = -1 Then GUICtrlSetData($Gstatus, "OFFLINE!") GUICtrlSetFont($gstatus, 26) GUICtrlSetColor($gstatus, 0xFF0093) GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] OFFLINE, "&$ip&":"&$port & @CRLF, GUICtrlRead($History)) Else $Stop = Round(TimerDiff($start), 2) GUICtrlSetData($Gstatus, "ONLINE!") GUICtrlSetFont($gstatus, 26) GUICtrlSetColor($gstatus, 0x009933) GUICtrlSetData($History, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] ONLINE, "&$ip&":"&$port&" ms:" & $Stop & @CRLF, GUICtrlRead($History)) TCPCloseSocket($sock) EndIf EndIf EndSwitch WEnd
    1 point
×
×
  • Create New...