Jump to content



Photo

Windows 8 Start Menu Modifier


  • Please log in to reply
66 replies to this topic

#1 svnO.o

svnO.o

    Programmer & Web Developer

  • Joined: 24-March 08
  • Location: Washington State

Posted 08 September 2012 - 21:40

Hello everyone, I thought I'd play around with some C# in Windows 8 and came up with the idea for an app. With this you can choose which screen the start menu should appear and allows you to dock it in top or bottom configuration non-full screen on any monitor. You can toggle between full screen and docked states with the press of a button and force your start menu to appear on a certain screen if you wish (moving a metro app to another screen will push the start menu to that screen as well but using the hotkey will force it back to the screen of choice).

Also if anyone knows how to simulate the keystroke or bring up the start menu via code let me know. I tried this using a keyboard event but it didn't bring up the start menu and did the ^{ESC} send keys trick but it doesn't seen to work in Windows 8. Would be cool to allow the hot key to bring up the start menu as well.

Screenshots are attached to the post.

Download: http://www.diablocra...MModifier1b.zip

Attached Images

  • top.png
  • bottom.jpg
  • hk.jpg



#2 +devHead

devHead

    Get Off The Bandwagon, Put Down The Handbook

  • Tech Issues Solved: 1
  • Joined: 08-August 01
  • Location: Arizona... Among The Trees
  • OS: Windows 8.1 Pro
  • Phone: Nokia Lumia 521

Posted 08 September 2012 - 21:57

Wow. Now this looks pretty cool. So, the Start menu slides down after clicking an app shortcut or moving away from it?

#3 phailyoor

phailyoor

    Neowinian

  • Joined: 02-September 12
  • OS: Windows 7/8 + OSX + Android
  • Phone: Samsung Galaxy Note SGH-i717

Posted 08 September 2012 - 22:05

	    private static void ShowStartMenu()
	    {
		    // key down event:
		    const byte keyControl = 0x11;
		    const byte keyEscape = 0x1B;
		    keybd_event(keyControl, 0, 0, UIntPtr.Zero);
		    keybd_event(keyEscape, 0, 0, UIntPtr.Zero);
		    // key up event:
		    const uint KEYEVENTF_KEYUP = 0x02;
		    keybd_event(keyControl, 0, KEYEVENTF_KEYUP, UIntPtr.Zero);
		    keybd_event(keyEscape, 0, KEYEVENTF_KEYUP, UIntPtr.Zero);
	    }
	    [DllImport("user32.dll")]
	    static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
		   UIntPtr dwExtraInfo);

Also, awesome idea. I really want to know how it works. Would you mind posting some snippets or source?

#4 OP svnO.o

svnO.o

    Programmer & Web Developer

  • Joined: 24-March 08
  • Location: Washington State

Posted 08 September 2012 - 23:00

Wow. Now this looks pretty cool. So, the Start menu slides down after clicking an app shortcut or moving away from it?


Yeah, if you click off the start screen it goes away just like if you were launching an app from the start menu. You can also toggle it and see it resize for a second when the start menu is up (so it'd be possible to do an animation/fade on the window if someone wanted to code it in, though not sure how it'd actually work in practice).

		private static void ShowStartMenu()
		{
			// key down event:
			const byte keyControl = 0x11;
			const byte keyEscape = 0x1B;
			keybd_event(keyControl, 0, 0, UIntPtr.Zero);
			keybd_event(keyEscape, 0, 0, UIntPtr.Zero);
			// key up event:
			const uint KEYEVENTF_KEYUP = 0x02;
			keybd_event(keyControl, 0, KEYEVENTF_KEYUP, UIntPtr.Zero);
			keybd_event(keyEscape, 0, KEYEVENTF_KEYUP, UIntPtr.Zero);
		}
		[DllImport("user32.dll")]
		static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
		   UIntPtr dwExtraInfo);

Also, awesome idea. I really want to know how it works. Would you mind posting some snippets or source?


Thanks, I used Spy++ to get the window handle of the start menu (had it right next to it on second monitor then toggled it and dragged really fast). From there I just played with some windows APIs to see what types of things I could do with the start menu and this is what I came up with.

I'll also try that code soon and see if I can get it implemented so people can bring up the start menu simultaneously if they are using this.

As for some of the code it's pretty simple (could probably leave flags null) -

UInt32 flags = SWP_SHOWWINDOW;
IntPtr hwnd = FindWindow("ImmersiveLauncher", null);
SetWindowPos(hwnd, HWND_TOP, x, y, width, height, flags);

Imports:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetWindowPos(IntPtr hWnd,
  IntPtr hWndInsertAfter,
  int x,
  int y,
  int cx,
  int cy,
  UInt32 uFlags);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);



I tried getting the class name/handle of the search bar too and got "DirectUIHWND" but can't seem to adjust or resize that just yet. The search bar will appear on the last window a metro-style app was launched. Also if you're interested the class name for the metro band (the divider between a metro app/desktop) is called "ImmersiveGutter" with "Application Arrangement Bar" as the window title. Just by having the class names/handles to these windows you can do quite a bit of manipulation. Most of the code involved in this app is taskbar positioning/screen size calculations and settings-related stuff.

#5 phailyoor

phailyoor

    Neowinian

  • Joined: 02-September 12
  • OS: Windows 7/8 + OSX + Android
  • Phone: Samsung Galaxy Note SGH-i717

Posted 08 September 2012 - 23:13

That's pretty cool. I tried to do the same, but I guess I'm just not fast enough with spy++ to do it all....can you also use this to reposition metro apps?

#6 OP svnO.o

svnO.o

    Programmer & Web Developer

  • Joined: 24-March 08
  • Location: Washington State

Posted 08 September 2012 - 23:18

That's pretty cool. I tried to do the same, but I guess I'm just not fast enough with spy++ to do it all....can you also use this to reposition metro apps?


The API is capable so it's just a matter of doing more research to see if the metro apps have classes/titles/parent windows/or other attributes that distinguish them from the rest and retrieving the handles to send the proper API calls to. I'll see what I can find but if anyone else can find out more information that'd be great too :)

Update: I also found the "ImmersiveBackgroundWindow" class with the caption "Immersive Background" which is the solid background used when snapping metro windows to the side and there is nothing in the main container. I couldn't find a lot on the metro apps yet but did notice they all have the "EdgeUiInputWndClass" class at the top point of the screen (which should be responsible for the touch gestures/closing the app). It should be possible to detect using FindWindow if that class exists and to then find the main handle to the window below it though I haven't tested this yet.

#7 streetw0lf

streetw0lf

    Neowinian

  • Joined: 03-January 04
  • Location: USA

Posted 08 September 2012 - 23:28

Oops

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not find file 'E:\My Downloads\sm.ico'.
File name: 'E:\My Downloads\sm.ico'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Drawing.Icon..ctor(String fileName, Int32 width, Int32 height)
at System.Drawing.Icon..ctor(String fileName)
at SMModifier.frmSMModifier.createTaskTray()
at SMModifier.frmSMModifier.frmMain_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
StartMenuModifier
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///E:/My%20Downloads/StartMenuModifier.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

#8 OP svnO.o

svnO.o

    Programmer & Web Developer

  • Joined: 24-March 08
  • Location: Washington State

Posted 08 September 2012 - 23:40

^ Did you extract the icon too? Seems like that should fix it. I was a bit lazy and didn't reference it from the internal resources. I'll try and make it a single .exe the next time I update this.

#9 Dashel

Dashel

    Disgustipator

  • Joined: 03-December 01
  • Location: USA

Posted 09 September 2012 - 02:07

Cool idea

#10 TTGSteve

TTGSteve

    Neowinian

  • Joined: 06-September 12

Posted 09 September 2012 - 07:39

Looks really good, man. Keep up the awesome work.

#11 _Heavens

_Heavens

    YOLO Gangsta Prinzes

  • Joined: 27-August 12
  • Location: Philippines
  • OS: Windows 8.1, Android 4.2.1
  • Phone: O+ 8.91

Posted 09 September 2012 - 13:07

MUCH better than the Start8/S-Launcher/REtroUI rubbish.

#12 SuperKid

SuperKid

    Im no superman

  • Joined: 21-April 08
  • Location: Birmingham, England, UK
  • OS: OS X 10.8, iOS 7
  • Phone: iPhone 4S

Posted 09 September 2012 - 13:08

I love how all the apps I am seeing right now for Windows 8 are Start menu apps.

#13 _Heavens

_Heavens

    YOLO Gangsta Prinzes

  • Joined: 27-August 12
  • Location: Philippines
  • OS: Windows 8.1, Android 4.2.1
  • Phone: O+ 8.91

Posted 09 September 2012 - 13:17

I love how all the apps I am seeing right now for Windows 8 are Start menu apps.


LMAO!!!

#14 NinjaGinger

NinjaGinger

    Neowinian

  • Joined: 06-January 02

Posted 09 September 2012 - 13:24

I think it looks really good, but having to hack a brand new operating system to make it usable for a desktop seems wrong. I like it, don't get me wrong.

#15 grayscale

grayscale

    Neowinian

  • Joined: 13-February 11

Posted 09 September 2012 - 13:33

I love how all the apps I am seeing right now for Windows 8 are Start menu apps.

But what is there to add (as a 3rd party dev)? There wasn't any 'revolutionary' application that has popped up for a while now, even for Win7, at least not that I remember of.