Jump to content

Including a line breaker in GUI title


Go to solution Solved by ioa747,

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Solution

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

Link to comment
Share on other sites

1 hour ago, CYCho said:

You seem to have come from a different world.

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

25 minutes ago, UEZ said:

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

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

Link to comment
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Posted (edited)

I should have selected this as my Solution. This makes Windows 10 to behave like Windows 11 as far as GUI title and taskbar thumbnail tooltip go. I incorporated this in the latest version of  my zPlayer. Hooray for your learning mind!

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