I want to set a particular portion(like only a frame or widget) of my application window to taskbar thumbnail.I found one windows API that is ITaskbarList3::SetThumbnailClip here but this is in C++.I want to do this in python.However PyQt5 contains one class that is Qt Windows Extras which doesnot include this function.I have also found something that show one example here.This link might help you to solve easily. As I am a beginner ,i dont know how to do that properly.
Edit And Fix Me:-
I have tried the second link provided in the question,I have installed comptypes Module through PIP and i have copied taskbarlib.tlb file from github as i have not Windos SDK installed to generate this file as said in the answer here.
Here is my code.
from PyQt5.QtWidgets import *
import sys
##########----IMPORTING Comtypes module
import comtypes.client as cc
cc.GetModule('taskbarlib.tlb')
import comtypes.gen.TaskbarLib as tb
taskbar=cc.CreateObject('{56FDF344-FD6D-11d0-958A-006097C9A090}',interface=tb.ITaskbarList3)
##################
class MainUiClass(QMainWindow):
def __init__(self,parent=None):
super(MainUiClass,self).__init__(parent)
self.resize(600,400)
self.frame=QFrame(self)
self.frame.setGeometry(100,100,400,200)
self.frame.setStyleSheet('background:blue')
if __name__=='__main__':
app=QApplication(sys.argv)
GUI=MainUiClass()
GUI.show()
taskbar.HrInit()
####--This is just to check its working or not by setting a tasbar progress bar value
taskbar.SetProgressValue(GUI.winId(),40,100)
##########################################
##########This is a method to get the LP_RECT instace as per Microsoft API doc.Using Ctypes and got ctypes.wintypes.RECT object
from ctypes import POINTER, WINFUNCTYPE, windll, WinError
from ctypes.wintypes import BOOL, HWND, RECT
prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
paramflags = (1, "hwnd"), (2, "lprect")
GetWindowRect = prototype(("GetWindowRect", windll.user32), paramflags)
newrect=GetWindowRect(int(GUI.frame.winId()))
print(newrect)
taskbar.SetThumbnailClip(int(GUI.winId()),newrect)
sys.exit(app.exec_())
i have got that method to find LP_RECT instance form Ctypes module Doc. here
But I have a problem I want to set the frame(blue colored) into taskbar and i got this
Look at the screenshot,the taskbarprogress value that i have set for testing, works fine ,but the thumbnail part is just Unexpected. Can anyone help me to fix this?