检测Skype是否在“紧凑视图"中.或“默认视图" [英] Detecting whether Skype is in "Compact View" or "Default View"

查看:245
本文介绍了检测Skype是否在“紧凑视图"中.或“默认视图"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的运行方式由Skype的查看模式决定,这是因为我的应用程序正在查找类TConversationWindow的窗口,如果在默认视图中该窗口是tSkMainForm的子级,并且在Compact中视图,它不是tSkMainForm的子代.

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.

这是我想要做的:

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;

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

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.

现在解决实际问题:每当用户在2个视图之间切换时,顶级的TConversationForm都不会刷新".它们消失了,但是为了使其再次显示为tSkMainForm的子代(因此更改在 Winspector Spy 中可见),您必须在Skype中选择它,我不能依靠用户这样做.

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:

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

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

推荐答案

而不是使用Windows方法检测Skype是处于紧凑视图"还是默认视图"中,请尝试阅读 config.xml 文件,这些文件存储这些类型的设置,并由skype实时"更新.该文件位于

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>

例如在Windows 7中,这是位置

for example in windows 7 this is the location

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

在此文件中,存在一个名为MultiWindowMode

Inside of this file in the exist a entry called MultiWindowMode

这是MultiWindowMode

/config/UI/General/MultiWindowMode'

对于紧凑视图",此条目的值为"1",对于默认视图",此值为"0"

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

检查此演示,该演示使用XPath解析文件并读取MultiWindowMode的值.

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.

这篇关于检测Skype是否在“紧凑视图"中.或“默认视图"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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