Jump to content

Flowswitch - I Need Help To Finish This


vhanla

Recommended Posts

snap.jpg

FlowSwitch

Hi, this is what I'm trying to do, it's a Flow Taskbar and I also want to make it an ALT+TAB replacement.

What I did so far is (in Delphi 7)...

- I used CoverFrame unit from Sean Cross for CoverFlow effect

- I just Enumerated the Windows and filtered for chosing the Taskbar applications only, but some can't be winprinted (PrintWindow)

- Set a global hotkey for ALT+TAB, however I cannot figure out how to detect ALT keyup in order to switch to the selected task

- It flows with Alt+tab and Scrollwheel

- With a click I switch to the selected task

- It closes when focus is lost

- I can't find a way to hide it from taskbar at starting (after YES but I need it not to show in the taskbar)

At the moment it can be used as pseudo plugin for any Dock by launching the application :D

In the beginning I wanted to make it a plugin for XWindowsDock. However, it seems it will consume 20MB or more apart of the XWD and plugins existing.

Basically I need a guide about the correct way to PrintWindow applications (preferably not repeating windows) and AltTab procedure, and some suggestions :P.

You can download it HERE what I did so far, hope you like it...

Moved to a more appropriate area where some of the developers come and go - Thanks - mps69

Edited by vhanla
moved
Link to post

Wow men!

I certainly can't help you with coding or something, but you can bet that im downloading it right now and givin´u my feedback ASAP....

Let´s see....

Well...

So far, it´s not bad at all!

It will be kinda handy when you finish it; nice and smooth transitions; I know this is not finished yet, but, it will be nice if you can add a transition when you reach the window you wanna see,hope you get me....

Ok men, at the end this looks very promising, hope the other developers there can give you a hand with the things you need....

Greetings!

Link to post

- Set a global hotkey for ALT+TAB, however I cannot figure out how to detect ALT keyup in order to switch to the selected task

To detect if Alt key is up:

function IsAltKeyUp : Boolean;
begin
// I don't have Delphi here, maybe it is GetKeyAsycnState... search Win API
Result := (GetAsyncKeyState (VK_LALT) And $8000) = 0;
end;

- I can't find a way to hide it from taskbar at starting (after YES but I need it not to show in the taskbar)

There are some alternatives...

One is to put this into FormCreate event of main form: Application.ShowMainForm := False;

Another one is:

SetWindowLong (Application.Handle, GWL_EXSTYLE, (GetWindowLong (Application.Handle, GWL_EXSTYLE) And Not WS_EX_APPWINDOW) Or WS_EX_TOOLWINDOW);

I highly recommend the first one (ShowMainForm).

-

At least to my knowledge, there is not a "correct" way to PrintWindow applications. You can print windows in the background, with a Timer or similar, only one window at each TTimer.Timer event, scheduling older non-printed windows first (this is what I want to implement for WinExpose 2, if I ever write it).

Also you have the problem of frozen apps, which will in turn freeze you if you try to PrintWindow them.

There are two measures you can take to avoid this: (I'd recommend you use both)

1. TaskSwitchXP sends a message to the window, via SendMessageTimeout (the message must not cause any effect on app, for e.g. WM_GETICON is a good choice... remember to destroy the icons if the function succeeds!).

2. Launch a separate process (not a thread, but a process), receiving the window handle as parameter, and returning the screenshot to your app via SendMessage (WM_COPYDATA, ...). If your app finds the process doesn't return screenshot after 2 seconds of launching it, you can suppose it tried to screenshot a frozen app, and use TerminateProcess to kill the window printer process (and take note not to PrintWindow such app again for a while).

Link to post

Thanks a lot Matonga, I'll be researching more.

[20]

Ok, I managed to set global hotkeys for Windows XP only, and also used SendMessageTimeOut as you suggested. I tested with Free Extended Taks Manager which I used to freeze one running application and it works :D

I'm currently (happily) using Alt+Tab in WinXP. However, there seems that in Windows Vista/7 it doesn't work the Alt+Tab (Alt+Shift+Tab /Alt+Esc).

I'm using :

RegisterHotKey(Self.Handle,GlobalAddAtom('ALT_TAB'),MOD_ALT,VK_TAB);
RegisterHotKey(Self.Handle,GlobalAddAtom('ALT_SHIFT_TAB'),MOD_ALT+MOD_SHIFT,VK_TAB);
RegisterHotKey(Self.Handle,GlobalAddAtom('ALT_ESC'),MOD_ALT,$01b);

Hope there is a better way to do it. I don't know how to set the Global HotKey for Vista/7.

And also I can't find a good way to hide the program when lost focus. I'm using:

	procedure WMNCACTIVATE(var M: TWMNCACTIVATE); message WM_NCACTIVATE;

However, by doing form1.hide it Shows a warning message about violating OnShow and OnHide events.

I thought on activating a timer to hide after a 100/1000 second or less. But, hopefully there would be a better way :D

Anyone interested in trying and testing (suggesting too) can download from the first entry. It's still in its basic form.

Changelog:

- Some fixes done :o

- Alt+Tab switching barely works.

- Only one instance and if you launch the executable again, it will show the window instead. So you will be able to use it with any Dock.

This is how can I use this :P

vd.gif

Edited by vhanla
Link to post
And also I can't find a good way to hide the program when lost focus. I'm using:

	procedure WMNCACTIVATE(var M: TWMNCACTIVATE); message WM_NCACTIVATE;

However, by doing form1.hide it Shows a warning message about violating OnShow and OnHide events.

I thought on activating a timer to hide after a 100/1000 second or less. But, hopefully there would be a better way :D

I capture the WM_APPACTIVATE message, but maybe WM_NCACTIVATE works better for you. But this is not the solution.

The problem is: when you hide your window via form1.hide (because the user released the VK_LALT key), your window then deactivates and you try to form1.hide it again. Maybe adding this to WM_NCACTIVATE would work:

If Visible Then Hide;

So it shouldn't put an event violation in the way.

Maybe you'll have to use ShowWindow (form1.Handle, SW_SHOW {SW_HIDE} );

Link to post

Actually I'm kinda newbie at this. I just did a mashup.

And I don't know if it's possible to make an OpenGL window translucent.

Second that.

another suggestion: can minimized windows also be displayed instead of only a title bar.

On the other hand. I was trying to restore a window before taking the snapshot and restoring (minimizing again) after that.

It works, but in some way it interferes with correct switching to a selected window.

var
... {snaphost related e.g. BMP }
Placement: TWindowPlacement;
begin
Placement.length := SizeOf(TWindowPlacement);
GetWindowPlacement(H, @Placement);
if Placement.showCmd = SW_SHOWMINIMIZED then
begin
Placement.ShowCmd:=SW_ShowNormal;
SetWindowPlacement(H,@Placement);
{i take the snapshot after it i minimize again}
PrintWindow(the window handle,bmp);
Placement.ShowCmd:=SW_ShowMinimized;
SetWindowPlacement(H,@Placement);
end
else PrintWindow(the window handle, a bmp );

is it better to use SendMessage(wnd, WM_SYSCOMMAND, SC_RESTORE, 0) and SendMessage(wnd, WM_SYSCOMMAND, SC_MINIMIZE, 0) instead? Maybe I should use SendMessageTimeOut then...

I was also noticing that using OpenGL shows a flickering while I use XWindows Dock, but with RKLauncher, YzDock that doesn't happen. Is it because of OpenGL or just GLScene, which is what I'm using?.

Hopefully somebody would help. Thanks by advance.

Link to post
And I don't know if it's possible to make an OpenGL window translucent.

I was also noticing that using OpenGL shows a flickering while I use XWindows Dock, but with RKLauncher, YzDock that doesn't happen. Is it because of OpenGL or just GLScene, which is what I'm using?.

Flicker: I have that problem with RocketDock and OpenGL apps. Not sure if it is specific to XWD and RD but it surprises you tell YD and RKL doesn't have it... I haven't tried that.

For both flicker and translucency a solution would be to use pixel buffers instead of rendering to screen, then put the pixels into a bitmap and use UpdateLayeredWindow stuff.

The only problem is it would require a high end video board like ATI or nVidia no-more-than-about-two-year-old cards.

Link to post

Yeah, I've been reading about buffering, but it would be slower...

I definitely discarded the idea of using translucency, because I also tested with Lazarus GLScene's version and it flickers a lot while animating, unless I use buffering and painting on canvas (mmm I will test that).

Flicker: I meant that XWD makes my program to flicker (mostly the bottom part), and YD and RKL don't, but they do flicker instead (in their own areas).

In fact it is because of GLScene for Delphi. I also tested with Lazarus+GLScene, and that issue doesn't occur with XWD.

Changes:

- Full screen, or almost

- Background uses current wallpaper (stretched mode only) and updates if it's changed

- TrayIcon added with the following PopuMenu:

* Enable Alt+Tab (XP Only) - I couldn't find a way to registerhotkey on Vista/7

* Call with F9

* Hot Spots (check locations)

* Save Changes - to Config.ini

* Acerca de... (About)

* Exit (the most important part while it's in beta)

Currently it has this look:

FlowSwitch.gif

Download updated (refer first entry)

Edited by vhanla
Link to post
  • 2 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...