window 시스템 트레이가 자동으로 숨겨지지 않습니다
10155 단어 학습 과정
1. PowerShell 스크립트는 원문 링크 구현
예: 다음 코드를 스크립트에 복사합니다. 예를 들어 123.ps1,
실행 시./를 입력합니다.123.ps1 myapp.exe < 매개 변수 보이기 > (0= 비활성 시 숨기기 1 = 항상 숨기기 2 = 항상 숨기기)
실행이 완료되면 스스로 Explorer를 다시 시작해야 합니다.exe, 효과를 얻을 수 있습니다.
이 방법을 통해 문제가 발생할 수 있는 것은 Explorer를 다시 시작해야 한다는 것이다.exe, 그래서 인터페이스가 깜빡거려요.
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
}
}
2.C# 코드는 원문 링크 구현
이런 방법은 위의 파워셸과 마찬가지로 인터페이스를 깜빡이게 할 수 있다.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Collections;
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
Program p1 = new Program();
string prName = null;
RegistryKey myKey = Registry.CurrentUser.OpenSubKey("Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\TrayNotify", true);
byte[] all = (byte[])myKey.GetValue("IconStreams");
byte[] allwithoutheader = new byte[all.Length - 20];
byte[] header = new byte[20];
//Parse Header
//------------------------
for (int i = 0; i < all.Length; i++)
{
if (i <= 19)
{
header[i] = all[i];
}
else
{
allwithoutheader[i - 20] = all[i];
}
}
//------------------------
ArrayList blocklist = p1.storeBlocks(allwithoutheader);
Console.WriteLine("Name(or part) of program:");
prName = Console.ReadLine();
string alldataString = null;
bool found = false;
int value = 0;
int blocknumber = 0;
for (int i = 0; i < blocklist.Count; i++)
{
for (int j = 0; j < 1639; j++)
{
if (j < 528)
{
alldataString += System.Convert.ToChar(((List)(blocklist[i]))[j]);
if (j == 526)
{
string transformed = p1.Transform(alldataString);
string trimmed = System.Text.RegularExpressions.Regex.Replace(transformed, "\0+", "");
if (trimmed.Contains(prName))
{
alldataString = null;
Console.WriteLine("
===================
"+prName+" block found!"); //Block in ArrayList
Console.WriteLine("current setting --> " + ((List)(blocklist[i]))[528]);
Console.WriteLine("===================
settings:
2 = show icon and notifications,
1 = hide icon and notifications,
0 = only show notifications
===================");
blocknumber = i;
found = true;
break;
}
}
}
}
}
if (found == false)
{
Console.WriteLine("Nothing found");
Console.ReadLine();
Environment.Exit(1);
}
Console.WriteLine("new setting:");
value = Convert.ToInt32(Console.ReadLine());
((List)(blocklist[blocknumber]))[528] = (byte)(value);
byte[] alloriginal = p1.getOriginalFormat(blocklist, allwithoutheader.Length);
byte[] combined = p1.Combine(header, alloriginal);
myKey.SetValue("IconStreams", combined);
Console.WriteLine("Successfully wrote to Registry, please restart explorer.exe");
Process[] pp = Process.GetProcessesByName("explorer");
foreach (Process p in pp)
{
p.Kill();
}
Process.Start("explorer.exe");
}
private byte[] Combine(byte[] first, byte[] second)
{
byte[] ret = new byte[first.Length + second.Length];
Buffer.BlockCopy(first, 0, ret, 0, first.Length);
Buffer.BlockCopy(second, 0, ret, first.Length, second.Length);
return ret;
}
private ArrayList storeBlocks(byte[] all)
{
ArrayList main = new ArrayList();
List bytelist = new List();
int help = 1639;
int j = 0;
for (int i = 0; i < all.Length; i++)
{
bytelist.Add(all[i]);
if (i == help)
{
main.Add(bytelist);
bytelist = new List();
help = help + 1640;
}
}
return main;
}
private byte[] getOriginalFormat(ArrayList list, int bufferSize)
{
int help = 0;
byte[] original = new byte[bufferSize];
for (int i = 0; i < list.Count; i++)
{
for (int j = 0; j < (((List)(list[i])).Count); j++)
{
original[help] = (((List)(list[i]))[j]);
help++;
}
}
return original;
}
private string Transform(string value)
{
char[] array = value.ToCharArray();
for (int i = 0; i < array.Length; i++)
{
int number = (int)array[i];
if (number >= 'a' && number <= 'z')
{
if (number > 'm')
{
number -= 13;
}
else
{
number += 13;
}
}
else if (number >= 'A' && number <= 'Z')
{
if (number > 'M')
{
number -= 13;
}
else
{
number += 13;
}
}
array[i] = (char)number;
}
return new string(array);
}
}
3. 윈도우 API로 구현
윈도우즈는api로 트레이의 표시와 숨김을 제어합니다. 단지 우리에게 개방되지 않았을 뿐입니다. 그러나 누군가가 그것을 어떻게 호출하는지 찾았습니다.텍스트 링크
구체적으로 win7에서 잘 일하고 있습니다. win8은 테스트를 하지 않았지만 win10 1809는 반응이 없습니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Go - iris 프레임 워 크 핵심 내용목차 Iris 프레임 워 크 1. 아이 리 스 소개 2. Iris 인 스 턴 스 데모 3. Get, Post, Put, Delete Iris 프레임 워 크 1. 아이 리 스 소개 Go 의 웹 프레임 워 크 는 실행 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.