将任务栏图标设置为始终显示 [英] Set tray icon to always show

查看:136
本文介绍了将任务栏图标设置为始终显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置NotifyIcon在右托盘中始终可见:
http: //screensnapr.com/v/qKWHe2.png

How I can I set a NotifyIcon to be always visible in the right tray: http://screensnapr.com/v/qKWHe2.png

因为它已将其移至非活动图标窗口:
http://screensnapr.com/v/jjtuK0.png

because it shifts it over into the inactive icon window: http://screensnapr.com/v/jjtuK0.png

问题是任务栏图标上有一个上下文菜单,可让某人进行屏幕截图。
因此,每次他们拍摄屏幕快照时,图片中都会显示不活动的图标窗口,像照片轰炸机一样挡住了它后面的所有内容。

The issue is that the tray icon has a context menu that lets someone take a screen shot. So every time they take a screenshot, that inactive icon window is in the picture, blocking whatever is behind it like a photo bomber.

我知道这是可以通过代码完成此操作,因为诸如comodo之类的其他应用程序已经完成了此操作,而无需我将图标拖放到此处。
为了将快捷方式固定到任务栏,我了解到您在此文件夹中设置了快捷方式:

I know it is possible to do it through code because other applications such as comodo has done it without having me drag and drop the icon onto there. For pining a shortcut to the taskbar I learned that you set a shortcut in this folder:

C:\Users\Username\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

托盘是否有类似物品?还是有一种我可以明智地使用代码的选项。

Is there something similar for the tray? Or is there an option I can use code wise.

推荐答案

我在网上搜索,实际上是随机发现的。

I was searching online and actually found this randomly.

长话短说,是PowerShell(提供脚本)和GPO的组合。

Long story short, a combination of PowerShell (script provided) and GPO.

http://4sysops.com/archives/forcing -notification-area-icons-to-always-show-in-windows-7-or-windows-8 /

长话短说,创建一个PowerShell脚本包含以下内容:

Long story, create a PowerShell script containing the following:

param(
    [Parameter(Mandatory=$true,HelpMessage='The name of the program')][string]$ProgramName,
    [Parameter(Mandatory=$true,HelpMessage='The setting (2 = show icon and notifications 1 = hide icon and notifications, 0 = only show notifications')]
        [ValidateScript({if ($_ -lt 0 -or $_ -gt 2) { throw 'Invalid setting' } return $true})]
        [Int16]$Setting
    )

$encText = New-Object System.Text.UTF8Encoding
[byte[]] $bytRegKey = @()
$strRegKey = ""
$bytRegKey = $(Get-ItemProperty $(Get-Item 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify').PSPath).IconStreams
for($x=0; $x -le $bytRegKey.Count; $x++)
{
    $tempString = [Convert]::ToString($bytRegKey[$x], 16)
    switch($tempString.Length)
    {
        0 {$strRegKey += "00"}
        1 {$strRegKey += "0" + $tempString}
        2 {$strRegKey += $tempString}
    }
}
[byte[]] $bytTempAppPath = @()
$bytTempAppPath = $encText.GetBytes($ProgramName)
[byte[]] $bytAppPath = @()
$strAppPath = ""

Function Rot13($byteToRot)
{
    if($byteToRot -gt 64 -and $byteToRot -lt 91)
    {
        $bytRot = $($($byteToRot - 64 + 13) % 26 + 64)
        return $bytRot
    }
    elseif($byteToRot -gt 96 -and $byteToRot -lt 123)
    {
        $bytRot = $($($byteToRot - 96 + 13) % 26 + 96)
        return $bytRot
    }
    else
    {
        return $byteToRot
    }
}

for($x = 0; $x -lt $bytTempAppPath.Count * 2; $x++)
{
    If($x % 2 -eq 0)
    {
        $curbyte = $bytTempAppPath[$([Int]($x / 2))]
            $bytAppPath += Rot13($curbyte)

    }
    Else
    {
        $bytAppPath += 0
    }
}

for($x=0; $x -lt $bytAppPath.Count; $x++)
{
    $tempString = [Convert]::ToString($bytAppPath[$x], 16)
    switch($tempString.Length)
    {
        0 {$strAppPath += "00"}
        1 {$strAppPath += "0" + $tempString}
        2 {$strAppPath += $tempString}
    }
}
if(-not $strRegKey.Contains($strAppPath))
{
    Write-Host Program not found. Programs are case sensitive.
    break
}

[byte[]] $header = @()
$items = @{}
for($x=0; $x -lt 20; $x++)
{
    $header += $bytRegKey[$x]
}

for($x=0; $x -lt $(($bytRegKey.Count-20)/1640); $x++)
{
    [byte[]] $item=@()
    $startingByte = 20 + ($x*1640)
    $item += $bytRegKey[$($startingByte)..$($startingByte+1639)]
    $items.Add($startingByte.ToString(), $item)
}

foreach($key in $items.Keys)
{
$item = $items[$key]
    $strItem = ""
    $tempString = ""

    for($x=0; $x -le $item.Count; $x++)
    {
        $tempString = [Convert]::ToString($item[$x], 16)
        switch($tempString.Length)
        {
            0 {$strItem += "00"}
            1 {$strItem += "0" + $tempString}
            2 {$strItem += $tempString}
        }
    }
    if($strItem.Contains($strAppPath))
    {
        Write-Host Item Found with $ProgramName in item starting with byte $key
            $bytRegKey[$([Convert]::ToInt32($key)+528)] = $setting
            Set-ItemProperty $($(Get-Item 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify').PSPath) -name IconStreams -value $bytRegKey
    }
}

使用您选择的名称将其另存为ps1文件。

Save it as a ps1 file using the name of your choice.

打开组策略管理MMC。选择您选择的组策略对象,右键单击并选择编辑。在编辑器中,导航到用户配置> Windows设置>脚本>登录,然后单击显示属性。转到PowerShell选项卡,然后单击查看文件。

Open up the Group Policy Management MMC. Select your chosen Group Policy Object, right click and select Edit. In the editor, navigate to User Configuration > Windows Settings > Scripts > Logon and click "Display Properties". Go to the PowerShell tab and click View Files.

将刚创建的脚本复制到刚刚打开的资源管理器窗口中,然后关闭该窗口。

Copy the script you just made into the Explorer window that just opened and then close out of the window.

在登录脚本属性窗口中,添加一个新的PowerShell脚本,在脚本名称中,输入您使用的脚本的名称(例如:NotifyIcon.ps1),然后在参数中,输入程序名称(区分大小写!),然后输入要使用的设置:

In the login script properties window, add a new PowerShell script, in the script name, enter the name of the script you used (example: NotifyIcon.ps1), and then in the parameters, enter the program name (case sensitive!) followed by the setting to use:

0 =仅显示通知1 =隐藏图标和通知2 =显示图标和通知< ; ---您需要的那个

0 = only show notifications 1 = hide icon and notifications 2 = show icon and notifications <--- The one you need

例如,如果需要始终显示RealVNC服务器,则输入:

Example, if you need the RealVNC server to always appear, you would enter:

winvnc4.exe 2

winvnc4.exe 2

作为参数器

您可以找到可执行文件的名称以几种不同的方式,例如打开运行对话框并键入msconfig并查看启动程序,手动导航到安装目录C:\Program Files {your progr },或者通过在任务管理器中查看正在运行的进程来尝试匹配所需的程序。 10次​​中有9次将成功。

You can find out the name of the executable in a couple different ways, such as opening a Run dialogue box and typing msconfig and looking at the startup programs, manually navigating to the installation directory C:\Program Files{your program}, or trying to match the desired program by looking at the running processes in Task Manager. 9 times out of 10 this will result in success.

为使此功能有效,用户必须事先运行该应用程序,然后正确注销,以便explorer.exe有机会将更新的通知区域历史记录写入注册表。后续登录时,脚本应成功在历史记录中找到该程序,并将其设置更新为始终显示。

In order for this to work, the user must have previously run the application, and then properly logged out, so that explorer.exe gets a chance to write the updated notification area history to the Registry. On a subsequent login, the script should successfully locate the program in the history, and update its setting to always show.

您还可以尝试从PowerShell中手动运行脚本提示进行调试,但您必须在运行之前杀死explorer.exe('taskkill / f /imexplorer.exe'),否则Explorer将看不到您的更新,并且在退出时会覆盖它。

You can also try running the script manually from a PowerShell prompt to debug, but you MUST kill explorer.exe (‘taskkill /f /im explorer.exe’) before running it, otherwise explorer won’t see your update, and will overwrite it when it does quit.

我对这个过程不屑一顾。我没有写,只是找到了。脚本的贡献归功于Micah Rowland。 GPO流程的功劳归功于Geoff Kendal

I take no credit for this process. I didn't write it, I just found it. Credit for the script goes to Micah Rowland. Credit for the GPO process goes to Geoff Kendal

信誉不佳,无法链接到原始作者,只有顶部的人除外。

Not enough reputation to link to original authors, with the exception of the one at the top.

这篇关于将任务栏图标设置为始终显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆