delphi – 检测Skype是处于“紧凑视图”还是“默认视图”

我的应用程序运行的方式由Skype的查看模式决定,因为我的应用程序正在查找类TConversationWindow的窗口,如果在默认视图中是tSkMainForm的子项,并且如果在Compact View中,它不是孩子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;

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

现在解决实际问题:每当用户在2个视图之间切换时,顶级TConversationForm都不会“刷新”.它们消失得很好,但是为了让它再次出现在tSkMainForm的孩子身上(所以Winspector Spy中的变化是可见的),你必须在Skype中选择它,我不能依赖用户这样做.

万一你不知道,这是两个视图之间的区别:

紧凑的视图

默认视图

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

解决方法

而不是使用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.

相关文章

 从网上看到《Delphi API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...