0
votes

My application is designed to launch in full screen, at any cost taskbar should not be visible to the user. For taskbar hiding below ahk scripts will be running in the background to perform the needed operations.

Regarding AHK scripting please select the below link for its description.

http://ahkscript.org/

The script doesn`t work if "Auto Hide taskbar" functionality of windows 7 is selected.

Hence I have taken the below C# code to solve the issue from the application side.

But in certain conditions like when the application launches for the first time after windows restart, showwindow function is not working properly especially when Auto Hide taskbar option selected.

Sample Code

    [DllImport("user32.dll")]
    public static extern int FindWindowEx(int parentHandle, int childAfter, string className, int windowTitle);

    [DllImport("user32.dll")]
    private static extern int GetDesktopWindow();

    [DllImport("user32.dll")]
    private static extern int ShowWindow(int hwnd, int command);

    protected static int Handle
    {
        get
        {
            return (int)FindWindow("Shell_TrayWnd", "");
        }
    }

    protected static int HandleOfStartButton
    {
        get
        {
            int handleOfDesktop = GetDesktopWindow();
            int handleOfStartButton = FindWindowEx(handleOfDesktop, 0, "button", 0);
            return handleOfStartButton;
        }
    }
    public static void HideTaskbar()
    {
        int Taskbar = ShowWindow(Handle, SW_HIDE);
        int StartButton = ShowWindow(HandleOfStartButton, SW_HIDE);

    }

    private void button1_Click(object sender, EventArgs e)
    {
        HideTaskbar();
    }

Script Below script hides the taskbar and disables the execution of some keys.(right window and left window button and ctrl+esc)

WinHide,ahk_class Shell_TrayWnd
LWin::Suspend
RWin::Suspend
^Esc::Suspend

other options I have tried out

[DllImport("user32.dll")]
    public static extern bool SetWindowPos(
    int hWnd,                 //   handle to window    
    int hWndInsertAfter,  //   placement-order handle    
    short X,                  //   horizontal position    
    short Y,                  //   vertical position    
    short cx,                 //   width    
    short cy,                //    height    
    uint uFlags             //    window-positioning options    
    );

    private void button1_Click(object sender, EventArgs e)
    {

        int hwnd = FindWindow("Shell_TrayWnd", "");
        SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
    }

Above code alters the functionality. Not working properly.

Please suggest any ways to handle this scenario.

2
You should provide complete code examples for both your C# and .ahk code, otherwise it's not clear the precise nature of the interaction between your two codes. That said, it seems to me that you should not be attempting to affect the task tray at all. This kind of fiddling with user interfaces outside your own process is often found as annoying by users, and in some cases can actually interfere significantly with legitimate use of the computer by the user.Peter Duniho
At the very least, you should explain in detail why it is you think this type of behavior is appropriate in your scenario, in case someone can provide a more suitable alternative to achieve the same goal.Peter Duniho
@PeterDuniho I have modified the question and ahk scripts.raj

2 Answers

0
votes

Here's an AutoHotkey solution to check OS Version and change the Hide Taskbar Setting:

If (A_OSVersion = WIN_7) {
    ; retrieve Registry Value of AutoHide Taskbar
    RegRead, OutputVar, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2, Settings 

    ; If AutoHide Taskbar is On
    If (SubStr(OutputVar, 18, 1) == 3) {
        ChangeSetting := RegExReplace(OutputVar, (03), "02",, 1, 16) 
        ;ChangeSetting := StrReplace(OutputVar, "3", "2",,1)
        RegWrite, REG_BINARY, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2, Settings, % ChangeSetting
        ; The Code below Automatically applies Registry settings (and on Win 8.1 Explorer.exe is also restarted immediatley
        ; Alternatively you could use Shutdown Command to Reboot the system but this is much faster...
        Process, Close, explorer.exe 

    }   
}

Here's some code if you just want to test it out:

Gui, Add, Button, x1 y1 w110 h30 gButton1, Change AutoHide
Gui, Show,, New GUI Window
Return

Button1:
    RegRead, OutputVar, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2, Settings 
    ChangeSetting := ((SubStr(OutputVar, 18, 1) == 3) 
                   ? RegExReplace(OutputVar, (03), "02",, 1, 16)
                   : RegExReplace(OutputVar, (02), "03",, 1, 16))
    RegWrite, REG_BINARY, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2, Settings, % ChangeSetting
    Process, Close, explorer.exe 
Return

GuiClose:
ExitApp
0
votes

People will still be able to access the taskbar by pressing the Windows key on the keyboard or some other shortcut. All you're doing is hacking the computer's registry keys to mess with the user's customized shortcuts.

What you really want to do is create a fullscreen maximized window (similar to what you see when you maximize a youtube video).

Set the properties of your window such that: 1. FormBorderStyle = None, 2. On form load, get screen rects and resize your window to be of that size.