[misc] improve ime process detection logic

This commit is contained in:
Klesh Wong 2020-05-11 12:56:25 +08:00
parent 9ee9afb76e
commit d51340686f
2 changed files with 21 additions and 14 deletions

View File

@ -20,5 +20,4 @@ if (Test-Path $sshconf -PathType Leaf) {
$wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' ` $wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' `
-Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1" -Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1"
$wubiTrigger = New-ScheduledTaskTrigger -AtLogOn $wubiTrigger = New-ScheduledTaskTrigger -AtLogOn
$wubiTrigger.Delay = 'PT3S'
Register-ScheduledTask -Action $wubiAction -Trigger $wubiTrigger -TaskName "Wubi No Shift" -Description "Disable Shift key toggling CN/EN" -RunLevel Highest Register-ScheduledTask -Action $wubiAction -Trigger $wubiTrigger -TaskName "Wubi No Shift" -Description "Disable Shift key toggling CN/EN" -RunLevel Highest

View File

@ -32,6 +32,9 @@ Add-Type -MemberDefinition @'
'@ -Name Kernel32 -Namespace Pinvoke '@ -Name Kernel32 -Namespace Pinvoke
$i = 0
while ($i++ -lt 10) {
$ps = Get-Process -Name $ChsIME $ps = Get-Process -Name $ChsIME
foreach ($p in $ps) { foreach ($p in $ps) {
$hModule = $p.Modules | Where-Object {$_.ModuleName -eq $ChsIMEExe} $hModule = $p.Modules | Where-Object {$_.ModuleName -eq $ChsIMEExe}
@ -48,3 +51,8 @@ foreach ($p in $ps) {
throw [System.Exception] "Failed to patch $pidd" throw [System.Exception] "Failed to patch $pidd"
} }
} }
if ($ps) {
break
}
Start-Sleep -Milliseconds 100
}