From 9cc9310ad8db94686f4ab11d7917fb01ee08c483 Mon Sep 17 00:00:00 2001 From: Kimmo Pekkola Date: Sun, 2 Aug 2009 08:35:00 +0000 Subject: [PATCH] iTunes is not opened automatically anymore when Rainmeter starts because it caused flickering in Rainmeter's windows. --- Plugins/PluginiTunes/iTunesPlugin.cpp | 21 +++++++++++++++++++-- revision-number.h | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Plugins/PluginiTunes/iTunesPlugin.cpp b/Plugins/PluginiTunes/iTunesPlugin.cpp index 2459aab3..f6aa6bf9 100644 --- a/Plugins/PluginiTunes/iTunesPlugin.cpp +++ b/Plugins/PluginiTunes/iTunesPlugin.cpp @@ -363,7 +363,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) CoInitialized = true; } - if (CoInitialized && !InstanceCreated /*&& ::FindWindow(L"iTunes", L"iTunes") */) // rainy: Removed the FindWindow since it fails in 64-bit OS + if (CoInitialized && !InstanceCreated && ::FindWindow(L"iTunes", L"iTunes")) { if (SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER))) { @@ -404,7 +404,24 @@ UINT Update(UINT id) { if (!CoInitialized || !InstanceCreated) { - return 0; + // Check if the iTunes window has appeared + if (::FindWindow(L"iTunes", L"iTunes")) + { + if (SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER))) + { + InstanceCreated = true; + LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesApp initialized successfully."); + } + else + { + LSLog(LOG_DEBUG, L"Rainmeter", L"Unable to create the iTunesApp instance."); + return 0; + } + } + else + { + return 0; + } } CCommandIdMap::const_iterator it = CommandIdMap.find(id); diff --git a/revision-number.h b/revision-number.h index af6096c4..24f487e0 100644 --- a/revision-number.h +++ b/revision-number.h @@ -1,2 +1,2 @@ #pragma once -const int revision_number = 123; \ No newline at end of file +const int revision_number = 133; \ No newline at end of file