I have code that removes various window elements like title that I apply to an app's window on launch via Run an app, WinWait until it's window appears, then applying WinSetStyle (and then adjusting window size, position to match the old one)
However, this "flashes": you first see the window with the title, which then gets removed, and the window is repositioned
One workaround is to launch the app minimized, apply the styles, then restore it. But then some apps simply ignore this directive.
Is there a more reliable way to force the window to be created already with the adjusted styles? Maybe somehow hook into the window creation instead of waiting for the window to be created and changing the styles later?
(by the way, the MS docs mention that most of the styles can't be set after a window is created window-styles, though AHK can set them just find, what's up with that?)
Overriding other app's window style without a flash
- FanaticGuru
- Posts: 1907
- Joined: 30 Sep 2013, 22:25
Re: Overriding other app's window style without a flash
You can hook into a AHK window before it is displayed but not another application's window before it opens without using a separate custom DLL file.
It is the difference between using SetWinEventHook and SetWinEventHookEx if you want to do some research.
At least that is my understanding.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Overriding other app's window style without a flash
I see, then I guess I'd also need to implement all the logic inside that DLL file. Do you know whether it's actually possible, though, not to only apply styles, but update window size/position, and, crucially, do all that before a window is shown?
- FanaticGuru
- Posts: 1907
- Joined: 30 Sep 2013, 22:25
Re: Overriding other app's window style without a flash
Yes, the SetWinEventHookEx approach is doable, but the DLL needs to be written in a language other than AHK (C++ typically).
SetWinEventHook lets an application hook into its own windows to let that application handle the event. It runs code in the application which uses the same language as the application was written in. SetWinEventHookEx is a lower-level hook that basically runs a DLL on an event. The DLL needs to be in machine code so basically you need a true compiled language to get to that machine code.
You could probably create the DLL in C++ then use something like MCode in AHK to package and wrap it all in AHK. Because machine code is ready to go code, AHK can put it into memory and execute it. This is often done when you want the high level easy of using AHK but need speed, so you have AHK execute stuff like a machine code function. Although, it would be much easier to just have the DLL as a separate file for using SetWinEventHookEx.
At least that is my understanding, I am no expert only somewhat familiar.
Unless you are already pretty proficient in something like C++, I would look at trying to work out the kinks in the approach of running the application minimized, making changes, and then restoring the window.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Who is online
Users browsing this forum: wilkster and 37 guests