Search the Community
Showing results for tags 'gadget'.
-
well. Reading in msdn I found an interface to run a Gadget. So I wrote it. #include <Array.au3> #include <File.au3> Global Const $sCLSID_DesktopGadget = "{924CCC1B-6562-4C85-8657-D177925222B6}" Global Const $sIID_IDesktopGadget = "{C1646BC4-F298-4F91-A204-EB2DD1709D1A}" Global Const $sTagIDesktopGadget = "RunGadget hresult(wstr);" Global Enum $eNoShared = 1, $eShared, $eAll Local $aGadGets = _GetGadget($eAll) If IsArray($aGadGets) Then For $i = 1 To $aGadGets[0] If StringInStr($aGadGets[$i], "CPU") Then ;Run CPU GadGet RunGadget($aGadGets[$i]) EndIf Next EndIf Func RunGadget($sGadGetPath) Local $oDesktopGadget = ObjCreateInterface($sCLSID_DesktopGadget, $sIID_IDesktopGadget, $sTagIDesktopGadget) if not IsObj($oDesktopGadget) then Return False return SUCCEEDED($oDesktopGadget.RunGadget($sGadGetPath)) EndFunc ;==>RunGadget Func _GetGadget($GadgetType = $eNoShared) Local $aNoSharedGadGets = 0 Local $aSharedGadGets = 0 Local $aGadGets = 0 Local $Size = 0 Local Const $sSharedGadget = @ProgramFilesDir & "\Windows Sidebar\Shared Gadgets" Local Const $sNoShared = @ProgramFilesDir & "\Windows Sidebar\Gadgets" If $GadgetType < $eNoShared Or $GadgetType > $eAll Then Return 0 If BitAND($GadgetType, $eNoShared) Then $aNoSharedGadGets = _FileListToArray($sNoShared, Default, Default, True) If BitAND($GadgetType, $eShared) Then $aSharedGadGets = _FileListToArray($sSharedGadget, Default, Default, True) If IsArray($aSharedGadGets) And IsArray($aNoSharedGadGets) Then $Size = UBound($aNoSharedGadGets) - 1 + (UBound($aSharedGadGets) - 1) _ArrayConcatenate($aNoSharedGadGets, $aSharedGadGets, 1) $aGadGets = $aNoSharedGadGets $aGadGets[0] = $Size Else If IsArray($aSharedGadGets) Then $aGadGets = $aSharedGadGets If IsArray($aNoSharedGadGets) Then $aGadGets = $aNoSharedGadGets EndIf $aSharedGadGets = 0;Free $aNoSharedGadGets = 0 ;Free Return $aGadGets EndFunc ;==>_GetGadget Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos