Jump to content

Recommended Posts

Posted (edited)

So I had this Idea of creating a tooltip which shows me my ping.

That itself was made quickly and I thought too add a couple features.

I want the tooltip background to be a different color depending on the ping. (good ping is green, medium ping is yellow,...)

So how do I color in a tooltip? google brought me to this: 

 

where in the comments I found this:

$s = "LOW"
ToolTip($s, 0, 0, "Battery Information");, $icon)
$H_TOOLTIP1 = WinGetHandle($s)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "")
DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 2552550, "int", 0)
Sleep(1000)

Which I then used in my code with different color codes... Trial and Error brought me these that I wanted to use:

Quote

;2550255 yellow
;00255 red
;0255255 green
;000 black

 

The Problem is if I loop through my code it only sets the color for the 1st loop and then sticks to it.

The real problem is tho that I don't exactly understand the dllcalls... And I guess that's why it isn't working

So if someone would be so awesome to explain to me how they work, or at least can give me a list of these parameters then I would really appreciate that and learn something new :)

Obviously a solution to my problem is awesome aswell ^^

I run this under Windows 8.1

There is my code in a paste.

https://pastebin.com/q525f7mS

Edited by astrionn
added OS
Posted

The calls are fine, your real problem is how you are evaluating each if statement. You can't do "1 <= $ping < 250" in AutoIt. This is how it should be done:

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

pingpong()

Func pingpong()
   While True
      $ping=ping("8.8.8.8",3000)
      $s = string($ping)

      If $ping = 0 Then
         ToolTip("N/A",0,0)
         $H_TOOLTIP1 = WinGetHandle($s)
         DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "")
         DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 000, "int", 0)
      ElseIf $ping >= 1 And $ping < 250 Then
         ToolTip($s&" ms",0,0)
         $H_TOOLTIP1 = WinGetHandle($s)
         DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "")
         DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 0255255, "int", 0)
      ElseIf $ping >= 250 And $ping < 750 Then
         ToolTip($s&" ms",0,0)
         $H_TOOLTIP1 = WinGetHandle($s)
         DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "")
         DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 2550255, "int", 0)
      ElseIf $ping >= 750 Then
         ToolTip($s&" ms",0,0)
         $H_TOOLTIP1 = WinGetHandle($s)
         DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "")
         DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 00255, "int", 0)
      EndIf
      Sleep(500)
   WEnd
EndFunc

Func close()
    Exit
EndFunc

 

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

  • 2 weeks later...
Posted

Nice job, but this code creates a new Tooltip at every ping, and changes it color - even if nothing changed.

Is it possible to update the Tooltip text/title with a DLLCall too?

Posted

There is a ToolTip UDF included with AutoIt, look in the help file for the _GUIToolTip* functions.

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

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
×
×
  • Create New...