检测Skype是否处于“紧凑视图”状态或“默认视图”

发布于 2024-11-18 08:38:18 字数 1113 浏览 8 评论 0原文

我的应用程序的运行方式由 Skype 的视图模式决定,因为我的应用程序正在寻找类 TConversationWindow 的窗口,如果在默认视图中,该窗口是 tSkMainForm 的子级code>,并且如果在紧凑视图中,它不是 tSkMainForm 的子项。

这是我尝试做的:

Function IsCompactView:Boolean;
Var
 Wnd : Hwnd;
Begin
  Result := True;
  Wnd := FindWindow('TConversationForm',nil);

  if Wnd <> 0 then
  begin
   Wnd := GetParent(Wnd);
   // Custom function that grabs the Window Text
   if GetHandleText(Wnd) <> '' then
   Result := False;

  end;

End;

上面的函数将通过检查其父级是否有文本来查找顶级(除非我弄错了 - 没有窗口父级的窗口)TConversationForm 。如果 Skype 处于默认视图,则 TConversationFormtSkMainForm 的子级,后者始终包含一些文本。它按预期工作。

现在解决实际问题:每当用户在两个视图之间切换时,顶级 TConversationForm 都不会“刷新”。它们消失了,但为了让它再次显示为 tSkMainForm 的子项(因此更改在 Winspector Spy 中可见),您必须在 Skype 中选择它,我不能依赖用户来做到这一点。

如果您不知道,这里是 2 个视图之间的区别:

紧凑视图

Compact View

默认视图

默认视图

如果您需要更多信息,请告诉我,谢谢!

The way my application functions, is determined by Skype's view mode, due to the fact that my application is looking for windows of class TConversationWindow, which if in Default View is a child of tSkMainForm, and if in Compact View, it is not a child of tSkMainForm.

Here is what I tried to do:

Function IsCompactView:Boolean;
Var
 Wnd : Hwnd;
Begin
  Result := True;
  Wnd := FindWindow('TConversationForm',nil);

  if Wnd <> 0 then
  begin
   Wnd := GetParent(Wnd);
   // Custom function that grabs the Window Text
   if GetHandleText(Wnd) <> '' then
   Result := False;

  end;

End;

The above function will look for top-level (unless I am mistaken - the windows with no window parent) TConversationForm's, by checking if their parent has text or not. If Skype is in Default View, the TConversationForm's are children of tSkMainForm, which always has some text. It works as it is supposed to.

Now for the actual problem: Whenever the user switches between the 2 views, the top-level TConversationForm's are not "refreshed". They disappear alright, but in order for it to appear as a child of tSkMainForm again (so the change is visible in Winspector Spy), you have to select it in Skype, and I cannot rely on the user to do that.

In case you dont know, here is the difference between the 2 views:

Compact View

Compact View

Default View

Default View

If you need more info please let me know, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日情怀 2024-11-25 08:38:18

不要使用 Windows 方法检测 Skype 是否处于“紧凑视图”或“默认视图”,而是尝试读取存储此类设置并通过“实时”更新的 config.xml 文件Skype。该文件位于

%AppData%\Skype\<your-skype-user-name>

例如 Windows 7 中,这是该文件内部的位置

C:\Users\<your windows user>\AppData\Roaming\Skype\<your-skype-user-name>

,存在一个名为 MultiWindowMode 的条目,

这是 MultiWindowMode 的 Xpath 位置

/config/UI/General/MultiWindowMode'

的值该条目的“1”表示“紧凑视图”,“0”表示“默认视图”。

请检查此演示,它使用 XPath 解析文件并读取 MultiWindowMode 的值。

{$APPTYPE CONSOLE}

uses
  ComObj,
  ActiveX,
  Variants,
  SysUtils;


function SkypeISCompactView(const SettingsFile : string) : Boolean;
var
   XmlDoc      : OleVariant;
   Node        : OleVariant;
begin
  Result:=False;
   if FileExists(SettingsFile) then
   begin
     XmlDoc       := CreateOleObject('Msxml2.DOMDocument.6.0');
     try
       XmlDoc.Async := False;
       XmlDoc.Load(SettingsFile);
       XmlDoc.SetProperty('SelectionLanguage','XPath');

        if (XmlDoc.parseError.errorCode <> 0) then
         raise Exception.CreateFmt('Error in Xml Data %s',[XmlDoc.parseError]);

       Node  :=XmlDoc.selectSingleNode('/config/UI/General/MultiWindowMode');
       if not VarIsClear(Node) then
        Result:=Node.text='1';
     finally
       XmlDoc:=Unassigned;
     end;
   end;
end;


begin
 try
    CoInitialize(nil);
    try
      Writeln(BoolToStr(SkypeISCompactView('C:\Users\<your windows user>\AppData\Roaming\Skype\<skype user>\config.xml'),True));
    except
      on E:Exception do
      begin
          Writeln(E.Classname, ':', E.Message);
      end;
    end;
 finally
      CoUninitialize;
 end;
 Readln;
end.

Instead of detect if Skype is in “Compact View” or “Default View” using a windows approach try reading the config.xml file which store these kind of settings and is updated in "real-time" by skype. This file is located in

%AppData%\Skype\<your-skype-user-name>

for example in windows 7 this is the location

C:\Users\<your windows user>\AppData\Roaming\Skype\<your-skype-user-name>

Inside of this file in the exist a entry called MultiWindowMode

This is the Xpath location of the MultiWindowMode

/config/UI/General/MultiWindowMode'

The value of this entry is '1' for “Compact View” and '0' for “Default View”

Check this demo which uses XPath to parse the file and read the value of the MultiWindowMode.

{$APPTYPE CONSOLE}

uses
  ComObj,
  ActiveX,
  Variants,
  SysUtils;


function SkypeISCompactView(const SettingsFile : string) : Boolean;
var
   XmlDoc      : OleVariant;
   Node        : OleVariant;
begin
  Result:=False;
   if FileExists(SettingsFile) then
   begin
     XmlDoc       := CreateOleObject('Msxml2.DOMDocument.6.0');
     try
       XmlDoc.Async := False;
       XmlDoc.Load(SettingsFile);
       XmlDoc.SetProperty('SelectionLanguage','XPath');

        if (XmlDoc.parseError.errorCode <> 0) then
         raise Exception.CreateFmt('Error in Xml Data %s',[XmlDoc.parseError]);

       Node  :=XmlDoc.selectSingleNode('/config/UI/General/MultiWindowMode');
       if not VarIsClear(Node) then
        Result:=Node.text='1';
     finally
       XmlDoc:=Unassigned;
     end;
   end;
end;


begin
 try
    CoInitialize(nil);
    try
      Writeln(BoolToStr(SkypeISCompactView('C:\Users\<your windows user>\AppData\Roaming\Skype\<skype user>\config.xml'),True));
    except
      on E:Exception do
      begin
          Writeln(E.Classname, ':', E.Message);
      end;
    end;
 finally
      CoUninitialize;
 end;
 Readln;
end.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文