Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add document name to windows window title, for timetracking

2 REPLIES 2
Reply
Message 1 of 3
productbakery
185 Views, 2 Replies

Add document name to windows window title, for timetracking

I am using time tracking software, it captures the program title name. But unfortunately it cannot differentiate on which document/part I was working on inside fusion360.

Is there a way to enable the option to show the document name in the title property of windows?

Now it is showing 'Autodesk Fusion 360' would be nice to be able to cutomize it like for example:

'Fusion360 - partIamworkingon'  or (maybe) even better: 'Fusion360 - activeproject' 

 

Someone build a plugin for this for autocad, so I guess it should be possible for fusion360 also right?

Tags (2)
Labels (2)
2 REPLIES 2
Message 2 of 3
BrianEkins
in reply to: productbakery

I did a quick Google search and it shows some examples of using the Windows API from Python. There are Windows API functions to get the Hwnd of a window given the name of the window (FindWindow or FindWindowEx) and another to set the name of the windows (SetWindowText). I tried it for a few minutes because it looked like it might be easy, but I couldn't get it to work. It's probably something simple I'm doing wrong but I don't have more time to play with it. You can also listen to the documentActivated event and set the window text based on the currently active document.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

Thank you Brain for this usefull tip. I have been experimenting with this and am close to a working solution.
Amazing that such thing is even possible with python 😉

 

Below is the code I use for finding and changing the window title.

Funny thing is that it keeps on renaming the found window about 10 times because it finds the window over and over again.

I tried to add a flag so it only does it once, but then, for some strange reason the window title does not get changed.

It seems it need to do it at least 5 times to get it right... So I just keep the code as is now.

 

import ctypes

# Define the callback function to enumerate windows
def enum_windows_callback(hwnd, lParam):
    class_name = ctypes.create_string_buffer(256)
    title = ctypes.create_string_buffer(256)

    # Get the window class name
    ctypes.windll.user32.GetClassNameA(hwnd, class_name, 256)

    # Get the window title
    ctypes.windll.user32.GetWindowTextA(hwnd, title, 256)

    # Check if the window title contains the keyword "Fusion" or "F360"
    if b"F360" in title.value or b"Fusion" in title.value:
        # Change the window title to "F360 - projectname"
        ctypes.windll.user32.SetWindowTextA(hwnd, b"F360 - projectname")
        print("Window title changed successfully.")

    return True

# Enumerate all top-level windows and call the callback function
ctypes.windll.user32.EnumWindows(ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.c_int, ctypes.c_int)(enum_windows_callback), 0)

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report