Jump to content

Ventana de Ping Flotante - (Moved)


Recommended Posts

Buenas soy nuevo con Autoit mi proyecto es crear una venta de Ping Flotante que este transparente solo el fondo y que el Ping permanezca completamente Visible la intención es crear una venta Fija y que solo varié el Ping sin que parpadee la Vetana completa.

Ok realice dos pruebas que seria 

Hi, I am new with Autoit. My project is to create a Floating Ping GUI that has a transparent background and that the Ping remains completely visible. The intention is to create a fixed window and that only the Ping changes without blinking the entire GUI.

Ok. I have made two tests that would be:

HotKeySet("{ESC}", "Terminate")

While 1
    WinSetTrans("Medidor", "", 100)
    Local $iPing = Ping("www.google.es", "")
    SplashTextOn("Medidor", $iPing & "ms." , 80, 40, 422, 17, 1+2+16,"Comic Sans MS","10")
    WinSetTrans("Medidor", "", 100)
    Sleep(100)
 WEnd


Func Terminate()
    Exit 0
EndFunc

Y este otro que es con Ventanas GUI para fijar la ventana y darle transparencia pero aun no consigo colocar el texto en este caso el ping es dicha coordenada

And this other one that uses a Windows GUI to fix the window and give it transparency but I still can't put the text. In this case the ping is at a given coordinate

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "Terminate")

WinSetTrans("Conexion", "", 100)
    GUICreate("Conexion", 80, 40, 422, 17, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0xE0FFFF)
    Local $idPic = GUICtrlCreatePic("..\GUI\mslogo.jpg", 80, 40, 422, 17)
WinSetTrans("Conexion", "", 100)
    GUISetState(@SW_SHOW)


While 1
    Local $iPing = Ping("www.google.es", "")
    Sleep(100)
 WEnd

Func Terminate()
    Exit 0
EndFunc

Muchas gracias por la ayudar.

Thanks a lot for any help

Edited by Melba23
Added translation and code tags
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

  • Moderators

Hemrry,

Welcome to the AutoIt forums. But we speak English here and although I think I can understand your request (although a bit more punctuation would help!) not everyone else will. Please use Google Translate or similar in future. Thanks in advance for your cooperation.

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

Hello Hemrry(I speak Spanish ☺️) Nice to see Spanish user.

Here an example to play with. (Aqui te dejo un ejemplo con el que puedes jugar/modificar)

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
HotKeySet("{ESC}", "Terminate")
Global $hGUI = 0, $hGraphics = 0, $hBrush = 0, $hFormat = 0, $hFamily = 0, $hFont = 0, $tLayout = 0
$hGUI = GUICreate("MyGUI", 250, 50, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED))
GUISetBkColor(0x000000)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0x000000)
GUISetState(@SW_SHOW, $hGUI)
_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 17, 1)
$tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)


While Sleep(100)
    Local $iPing = Ping("www.google.es")
    If $iPing Then
        _GDIPlus_GraphicsClear($hGraphics)
        _GDIPlus_GraphicsDrawStringEx($hGraphics, $iPing & " ms.", $hFont, $tLayout, $hFormat, $hBrush)
     EndIf
WEnd

Func Terminate()
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit 0
EndFunc   ;==>Terminate

 

Saludos

Link to comment
Share on other sites

Using @Chimp suggestion, you can combine both solutions into a single approach :

#include <Constants.au3>
#include <GUIConstants.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>

HotKeySet("{ESC}", "Terminate")
Local $hGUI = GUICreate("MyGUI", 250, 50, -1, -1, $WS_POPUP, $WS_EX_TOPMOST+$WS_EX_LAYERED)
GUISetBkColor(0x000000)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0x000000)
Local $idLabel = GUICtrlCreateLabel ("", 0, 0,250, 50, $SS_CENTER+$SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor (-1,0x101010)
GUICtrlSetFont (-1, 17, $FW_SEMIBOLD)
GUISetState(@SW_SHOW, $hGUI)

Local $iPing, $iPrev

While Sleep(100)
  $iPing = Ping("www.google.ca")
  If $iPing <> $iPrev Then
    GUICtrlSetData ($idLabel, $iPing & " ms.")
    $iPrev = $iPing
  EndIf
WEnd

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Link to comment
Share on other sites

Muchas gracias por el aporte. Funcionó muy bien. Te lo agradezco.
Inserté la función para poder moverla por toda la pantalla y que el bucle se ejecute constantemente para que no se conecte a Internet


 

#include <Constants.au3>
#include <GUIConstants.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>
#include <WinAPISysWin.au3>

HotKeySet("^{SPACE}", "Terminate")
Local $hGUI = GUICreate("MyGUI",80 , 34, 1700, 2, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED))
GUISetBkColor(0x000000)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0x000000)
Local $idLabel = GUICtrlCreateLabel ("", 0, 0,80, 40, $SS_CENTER+$SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor (-1,0x34eb41)
GUICtrlSetFont (-1, 13, $FW_NORMAL, $GUI_FONTNORMAL, "Comic Sans MS")
GUISetState(@SW_SHOW, $hGUI)

Local $iPing

While Sleep(90)

$iPing = Ping("www.google.es", "")
GUICtrlSetData ($idLabel, $iPing & " ms")

WEnd

Func Terminate()
    Exit
 EndFunc   ;==>Terminate

 

Link to comment
Share on other sites

  • Developers
3 hours ago, Hemrry said:

Muchas gracias por el aporte. Funcionó muy bien. Te lo agradezco.

Please use English only as requested! 

Thanks,
Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Good afternoon, I am adjusting the latest modifications but I am having problems with the conditions or the variables, I am not sure yet, because when applying the variable, it limits the ping to drop below the amount I place, I explain.

If I put that when it is below 100 it turns green and when it is above 100 it turns red.

Even if you have a ping of 40 or 80, this bone red always remains static.
Could you please help me.

#include <Constants.au3>
#include <GUIConstants.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>
#include <WinAPISysWin.au3>

HotKeySet("^{SPACE}", "Terminate")
Local $hGUI = GUICreate("MyGUI",100 , 35, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED))
GUISetBkColor(0x000000)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0x000000)

Local $idLabel = GUICtrlCreateLabel ("", 0, 0,100, 35, $SS_CENTER+$SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor (-1,0x34eb41)
GUICtrlSetFont (-1, 14, $FW_NORMAL, $GUI_FONTNORMAL, "Comic Sans MS")
GUISetState(@SW_SHOW, $hGUI)

Local $2idLabel = GUICtrlCreateLabel ("", 0, 0,100, 35, $SS_CENTER+$SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor (-1,0xfa0707)
GUICtrlSetFont (-1, 14, $FW_NORMAL, $GUI_FONTNORMAL, "Comic Sans MS")
GUISetState(@SW_SHOW, $hGUI)



While 1
Local $iPing
Local $var
$iPing = Ping("www.google.es", "")
$var = 100
If $iPing < $var  Then
GUICtrlSetData ($idLabel, $iPing & " ms")
ElseIf $iPing > $var Then
GUICtrlSetData ($2idLabel, $iPing & " ms")
EndIf

WEnd

Func Terminate()
    Exit
 EndFunc   ;==>Terminate

 

Link to comment
Share on other sites

Here's an over-simplified example that shows you some basic concepts involved in achieving your goal: (Press ESC to Exit)

Change the threshold value to meet your needs.  For me, the ping value is around 6ms.  That allows me to see it turn red every once in a while when it exceeds 6ms.

I didn't take into account any of the transparency stuff, just the pinging and changing the color of the value when the threshold is exceeded. :)

 

Global $frmMain = GUICreate("Ping Test", 196, 96, -1, -1)
Global $Label1 = GUICtrlCreateLabel("Ping (ms):", 8, 16, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $lblPingTime = GUICtrlCreateLabel("", 72, 16, 68, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $Label2 = GUICtrlCreateLabel("ESC to QUIT", 8, 60, 150, 17)


Global Const $PING_THRESHOLD_MS = 7 ;<== Change threshhold to meet needs

Global $iPingMs = 0

HotKeySet("{esc}", terminate)

GUISetState(@SW_SHOW)
While 1
    ;Ping host
    $iPingMs = Ping("www.google.es")
    If @error Then
        ConsoleWrite("Ping error - @error = " & @error & @CRLF)
        ExitLoop
    EndIf

    ;Update ping label
    GUICtrlSetData($lblPingTime, $iPingMs)

    ;Set label color based on whether threshhold is exceeded
    If $iPingMs > $PING_THRESHOLD_MS Then
        GUICtrlSetColor($lblPingTime, 0xFF0000) ;Red
    Else
        GUICtrlSetColor($lblPingTime, 0x06722E) ;Dark Green
    EndIf

    ;Wait a bit before next loop
    Sleep(500)
WEnd

Func terminate()
    Exit
EndFunc

 

Edited by TheXman
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...