"RLPy.RUi.GetMainWindow()" does not return the window handle. It returns the lets say Qt window handler or object. So this does not work.
However I found out that xyz.winId() is working and returns the HWND. So the code would be:
mainWindow = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)
mainWindowHWND = mainwindow.winId()
The simple truth is in my code I wrote it wrong ".WinId()" instead of ".winId()" and did not notice it even when checking it.
OMG what a binners mistake I could not believe it when I saw it.
Many thanks again for your answers.