Anatoly 0 Posted Tuesday at 10:47 AM Hello. I'm looking for a way to set the background color, text color, size font in ToolTip. Json.au3 Spoiler Quote #include "Json.au3" ; (by @AspirinJunkie) #include <Misc.au3> Global $sRead1 = "" Global $sRead_mem = "" ; ------------ Function : --------------- Func _GoogleAPITranslate($sMytext, $sFrom, $sTo) Local $sUrl, $oHTTP, $sResponse, $JSONData, $sOutput = "", $aData $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $sUrl, False) $oHTTP.Send() $sResponse = $oHTTP.ResponseText $JSONData = _JSON_Parse($sResponse) If VarGetType($JSONData) = 'Array' Then $aData = $JSONData[0] If VarGetType($aData) = 'Array' Then For $i = 0 To UBound($aData) -1 Step 1 $sOutput &= ($aData[$i])[0] ;*** & @CRLF Next EndIf EndIf Return $sOutput EndFunc ;==>_GoogleAPITranslate While 1 Sleep(200) ToolTip("") ConsoleWrite(5) While _IsPressed("11") ConsoleWrite("C") Sleep(200) WEnd While _IsPressed("01") Send("^c") $sRead_mem = ClipGet() Sleep(200) if $sRead1==$sRead_mem Then Sleep(100) ConsoleWrite("Ш") Else ConsoleWrite(0) $sRead1 = ClipGet() ToolTip(_GoogleAPITranslate($sRead1, "en", "ru"), Default, Default, "", 0, 1) Sleep(200) EndIf WEnd WEnd Share this post Link to post Share on other sites
Jos 2,207 Posted Tuesday at 10:57 AM Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team 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. Share this post Link to post Share on other sites
Musashi 329 Posted Tuesday at 11:33 AM 43 minutes ago, Anatoly said: I'm looking for a way to set the background color, text color, size font in ToolTip. Then you might want to take a look at the help : _GUIToolTip_SetTipTextColor , _GUIToolTip_SetTipBkColor "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Share this post Link to post Share on other sites
Anatoly 0 Posted Tuesday at 11:48 AM I try do it this way, but i don't have gui Share this post Link to post Share on other sites
Nine 992 Posted Tuesday at 02:01 PM You do not need to create a GUI : #include <GUIToolTip.au3> #include <WinAPITheme.au3> HotKeySet("{ESC}", _Exit) Example() Func Example() ToolTip("Tooltip Test", 300, 300) Local $hWnd = WinWait("Tooltip Test") ConsoleWrite ($hWnd & @CRLF) _WinAPI_SetWindowTheme($hWnd, "0", "0") _GUIToolTip_SetTipTextColor($hWnd, 0xFF) _GUIToolTip_SetTipBkColor($hWnd,0xFF0000) While Sleep(100) WEnd EndFunc ;==>Example Func _Exit() Exit EndFunc Remember that color are expressed in COLORREF (BGR) Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Multi-keyboards HotKeySet Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites
Anatoly 0 Posted 22 hours ago expandcollapse popup#include <GUIToolTip.au3> #include <WinAPITheme.au3> #include "Json.au3" ; (by @AspirinJunkie) #include <Misc.au3> Global $sRead1 = "" Global $sRead_mem = "" ; ------------ Function : --------------- Func _GoogleAPITranslate($sMytext, $sFrom, $sTo) Local $sUrl, $oHTTP, $sResponse, $JSONData, $sOutput = "", $aData $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $sUrl, False) $oHTTP.Send() $sResponse = $oHTTP.ResponseText $JSONData = _JSON_Parse($sResponse) If VarGetType($JSONData) = 'Array' Then $aData = $JSONData[0] If VarGetType($aData) = 'Array' Then For $i = 0 To UBound($aData) -1 Step 1 $sOutput &= ($aData[$i])[0] ;*** & @CRLF Next EndIf EndIf Return $sOutput EndFunc ;==>_GoogleAPITranslate Func Prepare_text($clip_get='') $v = StringLeft($clip_get, 1000) $v = StringRegExpReplace($v, '([^a-zA-Z]+)', ' ') If $v==' ' Then $v = '' return $v EndFunc Func Tool_tip_draw($v='') ToolTip($v, Default, Default, Default, 0, 1) _WinAPI_SetWindowTheme(WinGetHandle($v), "0", "0") _GUIToolTip_SetTipTextColor(WinGetHandle($v), 0xFFFFFF) _GUIToolTip_SetTipBkColor(WinGetHandle($v),0x000000) _GUIToolTip_SetMaxTipWidth(WinGetHandle($v), 500) EndFunc Func mouse_event() Do $x_mouse_pos = MouseGetPos(0) $y_mouse_pos = MouseGetPos(1) Sleep(350) Until Abs($x_mouse_pos-MouseGetPos(0)) < 2 and Abs($y_mouse_pos-MouseGetPos(1)) < 2 Return True EndFunc While 1 $trans = 0 $trans_text = "" Sleep(50) While _IsPressed('11') ToolTip("") ConsoleWrite(@CRLF) Sleep(100) WEnd While _IsPressed('01') and mouse_event() Sleep(100) Send("^{INSERT}") $time = TimerInit() While _IsPressed('01') ;~ ConsoleWrite(Int(StringLen(Prepare_text(ClipGet())))) If $trans == 0 and Int(StringLen(Prepare_text(ClipGet()))) > 1 Then Beep(700, 40) ConsoleWrite('G') $trans_text = _GoogleAPITranslate(Prepare_text(ClipGet()), "en", "ru") $time = TimerInit() $trans = 1 EndIf Tool_tip_draw($trans_text) Sleep(50) WEnd Sleep(50) WEnd ToolTip('') Sleep(50) WEnd Json.au3 Here is my idea. I would like to increase the font size in ToolTip. Thank you all Share this post Link to post Share on other sites
Nine 992 Posted 19 hours ago I did not find a way to modify font with built-in tooltip but I made it work witn UDF : #include <GUIToolTip.au3> #include <WinAPITheme.au3> #include <SendMessage.au3> #include <WinAPIGdiDC.au3> #include <FontConstants.au3> #include <WindowsConstants.au3> Global $bShow = True HotKeySet("{ESC}", _Exit) Local $hToolTip = _GUIToolTip_Create(0) Local $hDC = _WinAPI_GetDC(0) _WinAPI_SetWindowTheme($hToolTip, "0", "0") _GUIToolTip_SetTipTextColor($hToolTip, 0xFF) _GUIToolTip_SetTipBkColor($hToolTip,0xFF0000) Local $hFont = _WinAPI_CreateFont(32, 0, 0, 0, 800, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma') _WinAPI_SelectObject($hDC, $hFont) _SendMessage($hToolTip, $WM_SETFONT, $hFont, True) _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip Test", 0, 0, 0, 0, 0, BitOR($TTF_TRACK, $TTF_ABSOLUTE)) _GUIToolTip_TrackActivate($hToolTip) While $bShow Sleep(10) _GUIToolTip_TrackPosition($hToolTip,MouseGetPos(0), MouseGetPos(1)) WEnd _GUIToolTip_Destroy($hToolTip) _WinAPI_DeleteObject($hFont) _WinAPI_ReleaseDC(0, $hDC) Func _Exit() $bShow = False EndFunc 1 argumentum reacted to this Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Multi-keyboards HotKeySet Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites
pixelsearch 221 Posted 13 hours ago (edited) Hi everybody I tried what follows to change the font of a built-in tooltip, it seems to work : #include <FontConstants.au3> #include <GUIToolTip.au3> #include <WinAPITheme.au3> #include <WinAPIGdiInternals.au3> HotKeySet("{ESC}", _Exit) Local $iToolFontSize = 25 Global $hFont = _WinAPI_CreateFont($iToolFontSize, 0, 0, 0, 400, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma') Example() Func Example() ToolTip("Tooltip Test", 300, 300) Local $hWnd = WinWait("Tooltip Test") ; look at the 2 alternative scripts below _WinAPI_SetWindowTheme($hWnd, "0", "0") _GUIToolTip_SetTipTextColor($hWnd, 0xFF) _GUIToolTip_SetTipBkColor($hWnd,0xFF0000) _WinAPI_SetFont($hWnd, $hFont) While Sleep(100) WEnd EndFunc ;==>Example Func _Exit() _WinAPI_DeleteObject($hFont) Exit EndFunc Due to Winwait, there is a little moment (250ms) showing the initial tooltip (normal colors & font) then the final tooltip (new colors & new font). If these 250ms are a problem for the user, then the 1st alternative script below should display the final tooltip much quicker : expandcollapse popup#include <FontConstants.au3> #include <GUIToolTip.au3> #include <WinAPITheme.au3> #include <WinAPIGdiInternals.au3> HotKeySet("{ESC}", _Exit) Local $iToolFontSize = 25 Global $hFont = _WinAPI_CreateFont($iToolFontSize, 0, 0, 0, 400, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma') Example() Func Example() ToolTip("Tooltip Test", 300, 300) Local $hWnd = 0, $aToolTip = WinList("[CLASS:tooltips_class32]") If IsArray($aToolTip) And $aToolTip[0][0] <> 0 Then For $i = 1 To $aToolTip[0][0] If $aToolTip[$i][0] = "Tooltip Test" Then $hWnd = $aToolTip[$i][1] ExitLoop EndIf Next EndIf If $hWnd = 0 Then $hWnd = WinWait("Tooltip Test") _WinAPI_SetWindowTheme($hWnd, "0", "0") _GUIToolTip_SetTipTextColor($hWnd, 0xFF) _GUIToolTip_SetTipBkColor($hWnd,0xFF0000) _WinAPI_SetFont($hWnd, $hFont) While Sleep(100) WEnd EndFunc ;==>Example Func _Exit() _WinAPI_DeleteObject($hFont) Exit EndFunc And the 2nd alternative script below should display the tooltip even faster : #include <FontConstants.au3> #include <GUIToolTip.au3> #include <WinAPITheme.au3> #include <WinAPIGdiInternals.au3> HotKeySet("{ESC}", _Exit) Local $iToolFontSize = 25 Global $hFont = _WinAPI_CreateFont($iToolFontSize, 0, 0, 0, 400, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma') Example() Func Example() ToolTip("Tooltip Test", 300, 300) Local $hWnd = 0, $aToolTip = WinList("[TITLE:Tooltip Test; CLASS:tooltips_class32]") If IsArray($aToolTip) And $aToolTip[0][0] = 1 Then $hWnd = $aToolTip[1][1] Else $hWnd = WinWait("Tooltip Test") EndIf _WinAPI_SetWindowTheme($hWnd, "0", "0") _GUIToolTip_SetTipTextColor($hWnd, 0xFF) _GUIToolTip_SetTipBkColor($hWnd,0xFF0000) _WinAPI_SetFont($hWnd, $hFont) While Sleep(100) WEnd EndFunc ;==>Example Func _Exit() _WinAPI_DeleteObject($hFont) Exit EndFunc Edited 12 hours ago by pixelsearch added a 2nd alternative Share this post Link to post Share on other sites
Nine 992 Posted 11 hours ago (edited) It doesn't seem to work on Win7. The tooltip appears normal for a fraction of a sec, and then disappears. That is what I was experimenting in my first attempts. @pixelsearch There is a way to reduce delay of WinWait : Opt("WinWaitDelay", 10) Or in case anyone would be interested... Edited 2 hours ago by Nine Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Multi-keyboards HotKeySet Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites