It is currently May 19th, 2024, 7:17 am

How To Open The Default Windows Calendar Pop-up [Solved]

Get help with creating, editing & fixing problems with skins
Clivian
Posts: 2
Joined: September 29th, 2011, 5:31 pm

How To Open The Default Windows Calendar Pop-up [Solved]

Post by Clivian »

Hello! My first post here. :)

I'm modifying a calendar skin and trying to find a way to "pop-up" the default calendar window in Windows 7. The one that you get with a left mouse click on the default clock/calendar on the taskbar. I want to simulate the same action but on a Rainmeter skin.

I already know how to write the Rainmeter code. I'm just wondering if there is a shell command in Windows or shortcut like "Show Desktop" or AutoHotkey script... anything that would work with Rainmeter?

Screenie:
Image
AutoIt Window Info:
>>>> Window <<<<
Title: Date and Time Information
Class: ClockFlyoutWindow
Position: 1099, 727
Size: 566, 268
Style: 0x94800000
ExStyle: 0x00000000
Handle: 0x0000000000100C40

>>>> Control <<<<
Class: DirectUIHWND
Instance: 1
ClassnameNN: DirectUIHWND1
Name:
Advanced (Class): [CLASS:DirectUIHWND; INSTANCE:1]
ID:
Text:
Position: 0, 0
Size: 564, 266
ControlClick Coords: 91, 235
Style: 0x56000000
ExStyle: 0x00000000
Handle: 0x000000000019097E

>>>> Mouse <<<<
Position: 1191, 963
Cursor ID: 2
Color: 0xF1F5FB

>>>> Visible Text <<<<
8:54:34 PM
8:54:34 PM
8:54:34 PM
10:54 AM
10:54 AM
10:54 AM
1:54 PM
1:54 PM
1:54 PM
With other programs I can modify the window like change it's Transparency using it's Class name but I still can't figure out how to open the damn thing with a command.

Thanks a lot. :)

P.S. Simulating a mouse click or chain of hotkeys with AutoHotkey doesn't work for me since I have the taskbar completely hidden.
Last edited by Clivian on October 2nd, 2011, 10:55 pm, edited 2 times in total.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: How To Open The Default Windows Calendar Pop-up

Post by santa_ryan »

Unfortunately no. I can give the source in C# on how to do it.

I do believe that it requires the taskbar to be shown though :/

Code: Select all

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;

class ShowCalendar
{
    private delegate bool EnumChildCallback(IntPtr hwnd, 
            ref IntPtr lParam);

    [DllImport("User32.dll")]
    private static extern bool EnumChildWindows(IntPtr hWndParent, 
            EnumChildCallback lpEnumFunc, 
            ref IntPtr lParam);

    [DllImport("User32.dll")]
    private static extern int GetClassName(IntPtr hWnd, 
        StringBuilder lpClassName, 
        int nMaxCount);

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    private static extern IntPtr SendMessage(IntPtr hWnd, 
        UInt32 Msg, 
        IntPtr wParam, 
        IntPtr lParam);

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

    [DllImport("user32.dll", SetLastError = true)]
    private static extern IntPtr FindWindowEx(IntPtr hwndParent, 
        IntPtr hwndChildAfter, 
        string lpszClass, 
        string lpszWindow);

    [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool GetWindowRect(IntPtr hWnd, 
            out RECT lpRect);

    [StructLayout(LayoutKind.Sequential)]
    private struct RECT
    {
        public int Left;        
        public int Top;         
        public int Right;       
        public int Bottom;      
    }

    private static readonly string TrayWndClassName = "Shell_TrayWnd";
    private static readonly string TrayNotifyWndClassName = "TrayNotifyWnd";
    private static readonly string ClockWndClassName = "TrayClockWClass";
    private static readonly uint WM_NCLBUTTONDOWN = 0x00A1;
    private static readonly uint HTCAPTION = 2;

    private static bool EnumChildProc(IntPtr hwndChild, ref IntPtr lParam)
    {
        StringBuilder className = new StringBuilder(128);
        GetClassName(hwndChild, className, 128);

        if (className.ToString() == ClockWndClassName)
        {
            lParam = hwndChild;
            return false;
        }
        return true;
    }


    static void Main(string[] args)
    {
        IntPtr hWndTray = FindWindow(TrayWndClassName, string.Empty);
        if (hWndTray == IntPtr.Zero)
        {
            throw new Win32Exception();
        }

        IntPtr hWndTrayNotify = FindWindowEx(hWndTray, 
            IntPtr.Zero, 
            TrayNotifyWndClassName, 
            string.Empty);
        if (hWndTrayNotify == IntPtr.Zero)
        {
            throw new Win32Exception();
        }

        // search clock window
        EnumChildCallback cb = new EnumChildCallback(EnumChildProc);
        IntPtr hWndClock = IntPtr.Zero;
        EnumChildWindows(hWndTray, cb, ref hWndClock);
        if (hWndClock == IntPtr.Zero)
        {
            throw new Win32Exception();
        }

        // get clock window position
        RECT rect;
        if (!GetWindowRect(hWndClock, out rect))
        {
            throw new Win32Exception();
        }

        // send click, lParam contains window position
        IntPtr wParam = new IntPtr(HTCAPTION);
        IntPtr lParam = new IntPtr(rect.Top << 16 | rect.Left);
        SendMessage(hWndTray, WM_NCLBUTTONDOWN, wParam, lParam);
    }
}
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: How To Open The Default Windows Calendar Pop-up

Post by Seahorse »

This CAN be done according to this thread... 8-)

Code: Select all

"C:\WINDOWS\System32\control.exe" timedate.cpl
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: How To Open The Default Windows Calendar Pop-up

Post by Kaelri »

Seahorse wrote:This CAN be done according to this thread... 8-)

Code: Select all

"C:\WINDOWS\System32\control.exe" timedate.cpl
That's something different, unfortunately.



Clivian wants this:

Clivian
Posts: 2
Joined: September 29th, 2011, 5:31 pm

Re: How To Open The Default Windows Calendar Pop-up

Post by Clivian »

@santa_ryan: Works like a charm, even with the taskbar hidden. Thanks a lot! :thumbup:

Here's a link of the compiled code: ShowCalendar.zip
Feel free to check it for viruses with VirusTotal before downloading.

In Rainmeter:

Code: Select all

LeftMouseUpAction=!Execute [#CURRENTPATH#ShowCalendar.exe]  
Huyek
Posts: 1
Joined: March 5th, 2014, 8:54 pm

Re: How To Open The Default Windows Calendar Pop-up [Solved]

Post by Huyek »

Hello and please do accept my appologies for digging such old thread but I do have the same exact problem, however the link for ShowCalendar.exe is dead and I cannot find a way to solve it, neither find the file over the net, I do wanna add that I'm using windows 8.1, so probably the /dir of the calendar changed since earlier releases.

Can someone help Me?