LDraw.org Discussion Forums

Full Version: [LDCad] Addon
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello!

I've been doing some experiments and Roland suggested I shared them in this forum.

I've done some icons and themes in the past for LDCad. They are usually flat design themes, from several colors, with clear monochromatic icons

[Image: Blue-Theme.png]

But I also wanted to be able to change the color of the titlebar of LDCad window from white, in the example above, to match the color of the menubar. I asked Roland about it but unfortunately that option was not available through the regular configuration files. But his reply about objects and windows class put me in the right track! I research a little and found out Autohotkey, a scripting language for Windows. 

And what started as a pure cosmetic change turned out into a little addon that creates 4 extra buttons on the menubar, some additional hotkeys and the possibility to toggle on/off completely the window titlebar. 

[Image: Dark-Theme.png]
Only works in windows unfortunately

You can see a small video of the addon in action here: https://youtu.be/sDCpDDpfEWY

Here is a brief technical explanation. Autohotkey script grabs LDcad class window and creates an overlay GUI, an extension of the menubar, at a certain position. It creates the extra buttons and show/hides them as necessary. Then registers the mouse clicks and position to change images, cursor and run actions. Pressing the new menubar button will maximize the window, remove titlebar and show additional window control buttons on the menubar (min, restore, close window). It will also register new hotkeys to enable/disable the titlebar, show/hide the menubar, reload script, etc. The autohotkey script is called by a new autorun.lua script also included. So once LDCad loads and finishes updating the PartBin, you'll see a CMD window flash briefly (due to limitations of the io.popen function in the lua script) and the new button will appear on the menubar. Feel free to open the autohotkey script and look around.

Features:
1. New Hotkeys 
- CTRL+T to toggle titlebar
- F11 to toggle menubar (have to config LDCad hotkey show/hide menubar to F10)
- Left Double Click on menubar will maximize/restore window

Requirements:

1. Install Autohotkey
2. Download Addon
3. Download themes (optional)
Blue
Dark
Gray

Instructions:
1. Unzip files inside Titlebar Addon.zip to your LDCad instalation folder
2. Copy autorun.lua to your profile LDCad global script folder i.e %appdata%\Roaming\LDCad\scripts\default\global
3. Edit autorun.lua and change path to your LDCad.exe accordingly
4. Depending on your buttons of the menu bar, you might have to adjust the origin of the new complement menubar.
- Open autorun.ahk with a text editor
- Find line 21, code "MenuPos = 1338"
- Change value "1338" for what suits you best. Increasing the number will move origin to the right. Decreasing will move to the left
 

Let me know if you need extra help in setting this up.

Hope you enjoy!
(2019-09-19, 11:37)Miguel Reizinho Wrote: [ -> ]Hello!

I've been doing some experiments and Roland suggested I shared them in this forum.

I've done some icons and themes in the past for LDCad. They are usually flat design themes, from several colors, with clear monochromatic icons

[Image: Blue-Theme.png]

But I also wanted to be able to change the color of the titlebar of LDCad window from white, in the example above, to match the color of the menubar. I asked Roland about it but unfortunately that option was not available through the regular configuration files. But his reply about objects and windows class put me in the right track! I research a little and found out Autohotkey, a scripting language for Windows. 

And what started as a pure cosmetic change turned out into a little addon that creates 4 extra buttons on the menubar, some additional hotkeys and the possibility to toggle on/off completely the window titlebar. 

[Image: Dark-Theme.png]
Only works in windows unfortunately

You can see a small video of the addon in action here: https://youtu.be/sDCpDDpfEWY

Here is a brief technical explanation. Autohotkey script grabs LDcad class window and creates an overlay GUI, an extension of the menubar, at a certain position. It creates the extra buttons and show/hides them as necessary. Then registers the mouse clicks and position to change images, cursor and run actions. Pressing the new menubar button will maximize the window, remove titlebar and show additional window control buttons on the menubar (min, restore, close window). It will also register new hotkeys to enable/disable the titlebar, show/hide the menubar, reload script, etc. The autohotkey script is called by a new autorun.lua script also included. So once LDCad loads and finishes updating the PartBin, you'll see a CMD window flash briefly (due to limitations of the io.popen function in the lua script) and the new button will appear on the menubar. Feel free to open the autohotkey script and look around.

Features:
1. New Hotkeys 
- CTRL+T to toggle titlebar
- F11 to toggle menubar (have to config LDCad hotkey show/hide menubar to F10)
- Left Double Click on menubar will maximize/restore window

Requirements:

1. Install Autohotkey
2. Download Addon
3. Download themes (optional)
Blue
Dark
Gray

Instructions:
1. Unzip files inside Titlebar Addon.zip to your LDCad instalation folder
2. Copy autorun.lua to your profile LDCad global script folder i.e %appdata%\Roaming\LDCad\scripts\default\global
3. Edit autorun.lua and change path to your LDCad.exe accordingly
4. Depending on your buttons of the menu bar, you might have to adjust the origin of the new complement menubar.
- Open autorun.ahk with a text editor
- Find line 21, code "MenuPos = 1338"
- Change value "1338" for what suits you best. Increasing the number will move origin to the right. Decreasing will move to the left
 

Let me know if you need extra help in setting this up.

Hope you enjoy!


Those look AWESOME! Would it be possible to put this as tutorial on the wiki? Drop me a line if you have problems with setting up an account.

Obviously it would be best if LDCad would ship with the possibility to select those skins from within the prog with no need to do all those hacking ... don't listen to me just dreaming aloud ;-)

w.
(2019-09-19, 15:41)Willy Tschager Wrote: [ -> ]Those look AWESOME! Would it be possible to put this as tutorial on the wiki? Drop me a line if you have problems with setting up an account.

Obviously it would be best if LDCad would ship with the possibility to select those skins from within the prog with no need to do all those hacking ... don't listen to me just dreaming aloud ;-)

w.

Thank you!  

There are really just two things that can be considered "hacking", even if it's only editing two text files ;-)

1. Editing the autorun.lua to change your LDCad path
2. Editing the autorun.ahk to change your starting X position of the new GUI

All the rest is just copying the files to the right place or folders as documented in LDCad tutorials. Themes to the "gui" folder and scripts to the "global" folder. 

After doing that the themes and titlebar macro become available through LDCad menus:
[Image: Themes.png]    [Image: Scripts.png]

But back to the "hacking"...

For item 1., editing autorun.lua script, perhaps Roland can help. Hopefully there is a Path System Variable available that can be used instead of having to write it on the file for each user.

For item 2., about the X positioning of the new GUI, I'm already thinking of an updated version. The new version would add the new button in the menubar and check the screen resolution to display it ALIGNED TO THE RIGHT of the LDCad window. Once clicked, this button would be replaced by the window controls (min, max/restore, close). Because I just realized: having the restore button or the toggle titlebar button is redundant since they both will have the same effect if clicked.
(2019-09-19, 16:38)Miguel Reizinho Wrote: [ -> ]After doing that the themes and titlebar macro become available through LDCad menus:
[Image: Themes.png]    [Image: Scripts.png]
Yes, theming is supported in current LDCad version... I use Miguel's dark theme for a while Wink
And it's done! Version 2.0. No more "hacking" needed. Just copy the files to the LDCad folder and the lua script to the global scripts folder.

New version can be downloaded from HERE.

This version will detect the screen resolution and insert a new button (Toggle Titlebar) on the menubar at the rightmost position. When you click that button, LDCad window is maximized,  titlebar is removed and the new button will be replaced by the window control box (min, restore, close).

When LDCad window is restored, titlebar is also restored and window control box is hidden.

Also changed hotkey config. Now you just press F11 to Show/Hide the titlebar. CTRL+F11 will Show/Hide LDCad menubar completely. You must configure LDCad Hotkey Show/Hide Menubar to F10 for this to work. Also be sure that you don't have any other LDCad hotkeys configured to F11.
Ain't workin:

[attachment=4051]


w.
(2019-09-23, 14:37)Willy Tschager Wrote: [ -> ]Ain't workin:




w.

Sorry for the late reply. I've just returned from the Skaerbaek Fan Weekend.

I think you're not copying the file autorun.ahk to your LDCad.exe folder...

From the ReadMe.txt file:

Quote:- Copy "Images" folder and "autorun.ahk" to the same folder where LDCad.exe is located (installation folder)
[attachment=4069]

Did I tell you that I work with the 32 bit version?

w.
(2019-10-01, 10:47)Miguel Reizinho Wrote: [ -> ]Sorry for the late reply. I've just returned from the Skaerbaek Fan Weekend.

I think you're not copying the file autorun.ahk to your LDCad.exe folder...

From the ReadMe.txt file:

Looking at the autorun.lua script, there seems to be a hard coded path "C:\\Dropbox\\LDraw\\LDCad\\Launcher.ahk" that may be the issue.
(2019-10-02, 14:01)Orion Pobursky Wrote: [ -> ]Looking at the autorun.lua script, there seems to be a hard coded path "C:\\Dropbox\\LDraw\\LDCad\\Launcher.ahk" that may be the issue.

Nope. That line is commented out. 

Quote:--os.execute("C:\\Progra~1\\AutoHo~1\\AutoHotkey.exe C:\\Dropbox\\LDraw\\LDCad\\Launcher.ahk")

os.execute function is not supported in LDCad
Pages: 1 2