RDT1C/DataProcessors/ирПлатформа/Templates/СкриптОткрытыеПриложения1С1/Ext/Template.txt
Администратор c2290077e6 .
2021-03-18 16:14:11 +03:00

34 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Этот скрипт почему то очень долго работает при запуске из 64-битного приложения 1С, а из 32-битного вообще зависает. При этом независимый запуск выполняется быстро.
param (
[string]$outFileName = $(throw "Укажите файл для вывода списка главных окон конфигураторов 1С с помощью ключа -outFileName.")
)
#$outFileName = "C:\TerminalDisk\1.txt"
#REQUIRES -Version 3.0
[void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationClient")
[void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationTypes")
[void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationProvider")
[void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationClientsideProviders")
$client = [System.Reflection.Assembly]::LoadWithPartialName("UIAutomationClientsideProviders")
try
{
[Windows.Automation.ClientSettings]::RegisterClientSideProviderAssembly($client.GetName()) # WORKAROUND: There is a weird bug: first call fails ... https://gist.github.com/xiongjia/6749035
}
catch {}
[Windows.Automation.ClientSettings]::RegisterClientSideProviderAssembly($client.GetName()) # second call succeeds
$rootElement = [Windows.Automation.AutomationElement]::RootElement
$nameType = New-Object Windows.Automation.PropertyCondition([Windows.Automation.AutomationElement]::ClassNameProperty, "V8TopLevelFrame")
$condType = New-Object Windows.Automation.PropertyCondition([Windows.Automation.AutomationElement]::ControlTypeProperty, [Windows.Automation.ControlType]::Window)
$condFinal = New-Object Windows.Automation.AndCondition($condType, $nameType)
$windows = $rootElement.FindAll([Windows.Automation.TreeScope]::Children, $condFinal)
$outText = ""
foreach($window in $windows)
{
$windowName = $window.Current
$windowName = $windowName.Name
if($windowName -like "*Конфигуратор*" -or $windowName -like "*Designer*")
{
$outText += "" + $window.Current.ProcessId + " " + $window.Current.Name + "`n"
}
}
Set-Content $outFileName $outText -Force