Jump to content

Including a line breaker in GUI title


Go to solution Solved by ioa747,

Recommended Posts

Posted (edited)

The following code works as I intended in Windows 11:  the resulting GUI title shows only the first line and the task bar tooltip shows both lines. If I run the same code in Windows 10, however, the task bar tooltip is the same but the GUI title shows concatenation of two lines. How can I make the code to behave the same way in Windows 10 as in Windows 11? Thank you in advance for your help.
 

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("AutoIt v3" & @CRLF & "A BASIC-like scripting language" , 400, 100)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

GUIDelete($hGUI)

image.png.0122f399dd2ac2a8a0f4e8789bb193a8.png image.png.eb9dbe4c5ff09506e602f3b50433a799.png

Edited by CYCho
Posted (edited)
#include <GUIConstantsEx.au3>
#include <String.au3>

If @OSVersion = "WIN_11" Then
    $sTitle = "AutoIt v3" & @CRLF & "A BASIC-like scripting language"
Else
    $sTitle = "AutoIt v3" & _StringRepeat(" ", 45) & @CRLF & "A BASIC-like scripting language"
EndIf
$hGUI = GUICreate($sTitle, 400, 100)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

GUIDelete($hGUI)

This is not a perfect solution, but I can live with it. In Windows 10, the GUI title shows 3 dots(ellipses) at the end of title box, which is not so offensive to my eyes. The number in _StringRepeat() function should be adjusted to suit the GUI width. You can increase or decrease this number and see how the GUI title and taskbar tooltip change.

Edited by CYCho
  • Solution
Posted

here is my attempt
Testet in Win10

#include <AutoItObject.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>

Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")

$hGUI = GUICreate("AutoIt v3", 400, 100)
GUISetState()

_SetThumbnailTooltip($hGUI, "AutoIt v3" & @CRLF & "A BASIC-like scripting language")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

GUIDelete($hGUI)

;--------------------------------------------------------------------------------------------------------------------------------
Func _SetThumbnailTooltip($hWnd, $sText)

    ; Initialize AutoItObject
    _AutoItObject_StartUp()

    ; Get CLSID and IID for ITaskbarList3
    Local $CLSID_TaskBarlist = _AutoItObject_CLSIDFromString("{56FDF344-FD6D-11D0-958A-006097C9A090}")
    Local $IID_ITaskbarList3 = _AutoItObject_CLSIDFromString("{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}")

    ; Create the ITaskbarList3 interface instance
    Local $pTB3
    _AutoItObject_CoCreateInstance(DllStructGetPtr($CLSID_TaskBarlist), 0, 1, DllStructGetPtr($IID_ITaskbarList3), $pTB3)
    If Not $pTB3 Then
        MsgBox(16, "Error", "Failed to create ITaskbarList3 interface, exiting.")
        _AutoItObject_Shutdown()
        Exit
    EndIf

    Local $tagInterface = _
            "QueryInterface long(ptr;ptr;ptr);" & _
            "AddRef ulong();" & _
            "Release ulong();" & _
            "HrInit long();" & _
            "AddTab long(hwnd);" & _
            "DeleteTab long(hwnd);" & _
            "ActivateTab long(hwnd);" & _
            "SetActiveAlt long(hwnd);" & _
            "MarkFullscreenWindow long(hwnd;int);" & _
            "SetProgressValue long(hwnd;uint64;uint64);" & _
            "SetProgressState long(hwnd;int);" & _
            "RegisterTab long(hwnd;hwnd);" & _
            "UnregisterTab long(hwnd);" & _
            "SetTabOrder long(hwnd;hwnd);" & _
            "SetTabActive long(hwnd;hwnd;dword);" & _
            "ThumbBarAddButtons long(hwnd;uint;ptr);" & _
            "ThumbBarUpdateButtons long(hwnd;uint;ptr);" & _
            "ThumbBarSetImageList long(hwnd;ptr);" & _
            "SetOverlayIcon long(hwnd;ptr;wstr);" & _
            "SetThumbnailTooltip long(hwnd;wstr);" & _
            "SetThumbnailClip long(hwnd;ptr);"

    ; Create the AutoItObject wrapper for the interface
    Local $oTaskBar = _AutoItObject_WrapperCreate($pTB3, $tagInterface)
    If Not IsObj($oTaskBar) Then
        MsgBox(16, "Error", "Failed to create AutoItObject wrapper.")
        _AutoItObject_Shutdown()
        Exit
    EndIf

    ; Initialize the ITaskbarList3 interface
    $oTaskBar.HrInit()

    ; Set the tooltip for the taskbar thumbnail
    $oTaskBar.SetThumbnailTooltip($hWnd, $sText)

    ; Release the COM object
    $oTaskBar = 0
    _AutoItObject_Shutdown()
EndFunc   ;==>_SetThumbnailTooltip
;--------------------------------------------------------------------------------------------------------------------------------
Func _ErrFunc()
    ConsoleWrite("! COM Error !  Number: 0x" & Hex($oError.number, 8) & "   ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF)
    Return
EndFunc   ;==>_ErrFunc

 

I know that I know nothing

Posted
  On 8/26/2024 at 11:49 AM, CYCho said:

You seem to have come from a different world.

Expand  

After all, he is Merlin ;)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 8/26/2024 at 2:30 PM, UEZ said:

Why not simply replace any CRLF char with "space"?

Expand  

He's looking to see a caption of the 1st line and a "ThumbnailTooltip" of multiple lines, for the reason of his reasons.

In my Win11 (23H2), it works as expected :)

image.png.7b7a0d1567336da52a488d4e80e46c8c.png    image.png.86e8c44f050086f3948160fdf382f664.png

 

Edited by argumentum
added pic

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

I misread the question but you can cut the string from CRLF

#include <GUIConstantsEx.au3>

$sTitle = "AutoIt v3" & @CRLF & "A BASIC-like scripting language" & @CRLF & "Blah"
$sNew = StringRegExp($sTitle, "(.+)\r\n", 3)
$hGUI = GUICreate(IsArray($sNew) ? $sNew[0] : $sTitle, 400, 100)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

GUIDelete($hGUI)

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...