Logging Windows operations? Moving application to virtual desktop?

If you have a question or need help, this is the place to be.
User avatar
kgschlosser
Site Admin
Posts: 5495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Logging Windows operations? Moving application to virtual desktop?

Post by kgschlosser » Fri Jul 26, 2019 4:51 am

Its not a plugin. so do not pay attention to it. just use the code on the first page of this topic.
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 108
Joined: Mon Sep 24, 2018 7:57 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by dan Edens » Fri Jul 26, 2019 6:48 pm

kgschlosser wrote:
Thu Jul 25, 2019 9:27 pm
well it's not really a plugin yet. This is just a drop into a pyhon script and run at the moment. Once I get the initial connection bits working then a plugin can be developed.
dan Edens wrote:
Thu Jul 25, 2019 6:01 am
No idea how to set the guid for a plugin tbh^
Not sure what you mean by that..

Code: Select all

eg.RegisterPlugin(
    name = "Virtual Desktops",
    author = "Kgschlosser",
    version = "0.0.004",
    guid = "{C2F03A33-21F5-47FA-B4BB-156362A2F239}",
    canMultiLoad = False,
    url = "http://eventghost.net/forum/viewtopic.php?f=10&p=53389#p53389",
    description = "Creates events based on Virtual desktop interactions.",

)
You have it in the register plugin.

if you mean to get a new GUID.

GUID Generator is a good place.

Yes! that is what I meant. Thanks I've been stuck here 4 plugins I want to make. Basically I'm just learning what guid really is other than a number I google what to do with whenever i see it .

dan Edens
Experienced User
Posts: 108
Joined: Mon Sep 24, 2018 7:57 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by dan Edens » Fri Jul 26, 2019 8:36 pm

jachin99 wrote:
Fri Jul 26, 2019 2:28 am
I tried downloading the plug-in and adding it to EG. It wouldn't show up in the list of installed plugins so I tried changing the guide but it still isn't showing. I'm still getting a feel for windows 10 so maybe I'm doing something wrong
O dude sorry I was making a joke. Really wasn't clear my bad. It's the first steps towards a plugin is all. I'll make sure you know if and when it get's done.

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by jachin99 » Sat Jul 27, 2019 11:35 pm

No worries about the plugin not working. Kevin, I get this error now

Code: Select all

from ctypes.wintypes import HRESULT, HWND, BOOL, POINTER, DWORD, INT, UINT, LPVOID, ULONG

import comtypes
import ctypes
from comtypes import helpstring, COMMETHOD
from comtypes.GUID import GUID

REFGUID = POINTER(GUID)
REFIID = REFGUID
ENUM = INT
IID = GUID
INT32 = ctypes.c_int32
INT64 = ctypes.c_int64


CLSID_ImmersiveShell = GUID(
    '{C2F03A33-21F5-47FA-B4BB-156362A2F239}'
)

CLSID_IVirtualNotificationService =  GUID(
    '{A501FDEC-4A09-464C-AE4E-1B9C21B84918}'
)



class HSTRING__(ctypes.Structure):
    _fields_ = [
        ('unused', INT),
    ]

HSTRING = POINTER(HSTRING__)



class EventRegistrationToken(ctypes.Structure):
    _fields_ = [
        ('value', INT64)
    ]

class AdjacentDesktop(ENUM):
    LeftDirection = 3
    RightDirection = 4


class ApplicationViewOrientation(ENUM):
    ApplicationViewOrientation_Landscape = 0
    ApplicationViewOrientation_Portrait = 1


class TrustLevel(ENUM):
    BaseTrust = 0
    PartialTrust = BaseTrust + 1
    FullTrust = PartialTrust + 1


IID_IInspectable = GUID(
    '{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}'
)


class IInspectable(comtypes.IUnknown):
    _case_insensitive_ = True
    _idlflags_ = []
    _iid_ = IID_IInspectable
    _methods_ = [
        COMMETHOD(
            [helpstring('Method GetIids')],
            HRESULT,
            'GetIids',
            (['out'], POINTER(ULONG), 'iidCount'),
            (['out'], POINTER(POINTER(IID)), 'iids'),
        ),
        COMMETHOD(
            [helpstring('Method GetRuntimeClassName')],
            HRESULT,
            'GetRuntimeClassName',
            (['out'], POINTER(HSTRING), 'className'),
        ),
        COMMETHOD(
            [helpstring('Method GetTrustLevel')],
            HRESULT,
            'GetTrustLevel',
            (['out'], POINTER(TrustLevel), 'trustLevel'),
        ),
    ]


IID_IApplicationViewConsolidatedEventArgs = GUID(
    '{514449EC-7EA2-4DE7-A6A6-7DFBAAEBB6FB}'
)

class IApplicationViewConsolidatedEventArgs(IInspectable):
    _case_insensitive_ = True
    _iid_ = IID_IApplicationViewConsolidatedEventArgs
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method get_IsUserInitiated')],
            HRESULT,
            'get_IsUserInitiated',
            (['retval', 'out'], POINTER(BOOL), 'value'),
        ),
    ]


IID_IApplicationView = GUID(
    '{D222D519-4361-451E-96C4-60F4F9742DB0}'
)

class IApplicationView(IInspectable):
    _case_insensitive_ = True
    _iid_ = IID_IApplicationView
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method get_Orientation')],
            HRESULT,
            'get_Orientation',
            (['retval', 'out'], POINTER(ApplicationViewOrientation), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method get_AdjacentToLeftDisplayEdge')],
            HRESULT,
            'get_AdjacentToLeftDisplayEdge',
            (['retval', 'out'], POINTER(BOOL), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method get_AdjacentToRightDisplayEdge')],
            HRESULT,
            'get_AdjacentToRightDisplayEdge',
            (['retval', 'out'], POINTER(BOOL), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method get_IsFullScreen')],
            HRESULT,
            'get_IsFullScreen',
            (['retval', 'out'], POINTER(BOOL), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method get_IsOnLockScreen')],
            HRESULT,
            'get_IsOnLockScreen',
            (['retval', 'out'], POINTER(BOOL), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method get_IsScreenCaptureEnabled')],
            HRESULT,
            'get_IsScreenCaptureEnabled',
            (['retval', 'out'], POINTER(BOOL), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method put_IsScreenCaptureEnabled')],
            HRESULT,
            'put_IsScreenCaptureEnabled',
            (['in'], BOOL, 'value'),
        ),
        COMMETHOD(
            [helpstring('Method put_Title')],
            HRESULT,
            'put_Title',
            (['in'], HSTRING, 'value'),
        ),
        COMMETHOD(
            [helpstring('Method get_Title')],
            HRESULT,
            'get_Title',
            (['retval', 'out'], POINTER(HSTRING), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method get_Id')],
            HRESULT,
            'get_Id',
            (['retval', 'out'], POINTER(INT32), 'value'),
        ),
        COMMETHOD(
            [helpstring('Method add_Consolidated')],
            HRESULT,
            'add_Consolidated',
            (['in'], POINTER(IApplicationViewConsolidatedEventArgs), 'handler'),
            (['retval', 'out'], POINTER(EventRegistrationToken), 'token'),
        ),
        COMMETHOD(
            [helpstring('Method remove_Consolidated')],
            HRESULT,
            'remove_Consolidated',
            (['in',], EventRegistrationToken, 'EventRegistrationToken'),
        ),
    ]

IID_IServiceProvider = GUID(
    '{6D5140C1-7436-11CE-8034-00AA006009FA}'
)


class IServiceProvider(comtypes.IUnknown):
    _case_insensitive_ = True
    _idlflags_ = []
    _iid_ = IID_IServiceProvider
    _methods_ = [
        COMMETHOD(
            [helpstring('Method QueryService'), 'local', 'in'],
            HRESULT,
            'QueryService',
            (['in'], REFGUID, 'guidService'),
            (['in'], REFIID, 'riid'),
            (['out'], POINTER(LPVOID), 'ppvObject'),
        ),
    ]

IID_IObjectArray = GUID(
    "{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}"
)

class IObjectArray(comtypes.IUnknown):
    """
    Unknown Object Array
    """
    _case_insensitive_ = True
    _idlflags_ = []
    _iid_ = None

    _methods_ = [
        COMMETHOD(
            [helpstring('Method GetCount')],
            HRESULT,
            'GetCount',
            (['out'], POINTER(UINT), 'pcObjects'),
        ),
        COMMETHOD(
            [helpstring('Method GetAt')],
            HRESULT,
            'GetAt',
            (['in'], UINT, 'uiIndex'),
            (['in'], REFIID, 'riid'),
            (['out', 'iid_is'], POINTER(LPVOID), 'ppv'),
        ),
    ]

IID_IVirtualDesktop = GUID(
    '{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}'
)


class IVirtualDesktop(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktop
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method IsViewVisible')],
            HRESULT,
            'IsViewVisible',
            (['out'], POINTER(IApplicationView), 'pView'),
            (['out'], POINTER(INT), 'pfVisible'),
        ),
        COMMETHOD(
            [helpstring('Method GetID')],
            HRESULT,
            'GetID',
            (['out'], POINTER(GUID), 'pGuid'),
        )
    ]


IID_IVirtualDesktopManager = GUID(
    '{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}'
)


class IVirtualDesktopManager(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktopManager
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method IsWindowOnCurrentVirtualDesktop')],
            HRESULT,
            'IsWindowOnCurrentVirtualDesktop',
            (['in'], HWND, 'topLevelWindow'),
            (['out'], POINTER(BOOL), 'onCurrentDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method GetWindowDesktopId')],
            HRESULT,
            'GetWindowDesktopId',
            (['in'], HWND, 'topLevelWindow'),
            (['out'], POINTER(GUID), 'desktopId'),
        ),
        COMMETHOD(
            [helpstring('Method MoveWindowToDesktop')],
            HRESULT,
            'MoveWindowToDesktop',
            (['in'], HWND, 'topLevelWindow'),
            (['in'], REFGUID, 'desktopId'),
        ),
    ]

CLSID_VirtualDesktopManagerInternal = GUID(
    '{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}'
)

IID_IVirtualDesktopManagerInternal = GUID(
    '{F31574D6-B682-4CDC-BD56-1827860ABEC6}'
)
	
# IID_IVirtualDesktopManagerInternal = GUID(
#     '{AF8DA486-95BB-4460-B3B7-6E7A6B2962B5}'
# )

# IID_IVirtualDesktopManagerInternal = GUID(
#     '{EF9F1A6C-D3CC-4358-B712-F84B635BEBE7}'
# )

class IVirtualDesktopManagerInternal(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktopManagerInternal
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method GetCount')],
            HRESULT,
            'GetCount',
            (['out'], POINTER(UINT), 'pCount'),
        ),
        COMMETHOD(
            [helpstring('Method MoveViewToDesktop')],
            HRESULT,
            'MoveViewToDesktop',
            (['out'], POINTER(IApplicationView), 'pView'),
            (['out'], POINTER(IVirtualDesktop), 'pDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method CanViewMoveDesktops')],
            HRESULT,
            'CanViewMoveDesktops',
            (['out'], POINTER(IApplicationView), 'pView'),
            (['out'], POINTER(INT), 'pfCanViewMoveDesktops'),
        ),
        COMMETHOD(
            [helpstring('Method GetCurrentDesktop')],
            HRESULT,
            'GetCurrentDesktop',
            (['out'], POINTER(POINTER(IVirtualDesktop)), 'desktop'),
        ),
        COMMETHOD(
            [helpstring('Method GetDesktops')],
            HRESULT,
            'GetDesktops',
            (['out'], POINTER(POINTER(IObjectArray)), 'ppDesktops'),
        ),
        COMMETHOD(
            [helpstring('Method GetAdjacentDesktop')],
            HRESULT,
            'GetAdjacentDesktop',
            (['out'], POINTER(IVirtualDesktop), 'pDesktopReference'),
            (['in'], AdjacentDesktop, 'uDirection'),
            (['out'], POINTER(POINTER(IVirtualDesktop)), 'ppAdjacentDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method SwitchDesktop')],
            HRESULT,
            'SwitchDesktop',
            (['in'], POINTER(IVirtualDesktop), 'pDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method CreateDesktopW')],
            HRESULT,
            'CreateDesktopW',
            (['out'], POINTER(POINTER(IVirtualDesktop)), 'ppNewDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method RemoveDesktop')],
            HRESULT,
            'RemoveDesktop',
            (['in'], POINTER(IVirtualDesktop), 'pRemove'),
            (['in'], POINTER(IVirtualDesktop), 'pFallbackDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method FindDesktop')],
            HRESULT,
            'FindDesktop',
            (['in'], POINTER(GUID), 'desktopId'),
            (['out'], POINTER(POINTER(IVirtualDesktop)), 'ppDesktop'),
        ),
    ]


IID_IVirtualDesktopNotification = GUID(
    '{C179334C-4295-40D3-BEA1-C654D965605A}'
)


class IVirtualDesktopNotification(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktopNotification
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method VirtualDesktopCreated')],
            HRESULT,
            'VirtualDesktopCreated',
            (['in'], POINTER(IVirtualDesktop), 'pDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method VirtualDesktopDestroyBegin')],
            HRESULT,
            'VirtualDesktopDestroyBegin',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopDestroyed'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopFallback'),
        ),
        COMMETHOD(
            [helpstring('Method VirtualDesktopDestroyFailed')],
            HRESULT,
            'VirtualDesktopDestroyFailed',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopDestroyed'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopFallback'),
        ),
        COMMETHOD(
            [helpstring('Method VirtualDesktopDestroyed')],
            HRESULT,
            'VirtualDesktopDestroyed',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopDestroyed'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopFallback'),
        ),
        COMMETHOD(
            [helpstring('Method ViewVirtualDesktopChanged')],
            HRESULT,
            'ViewVirtualDesktopChanged',
            (['in'], POINTER(IApplicationView), 'pView'),
        ),
        COMMETHOD(
            [helpstring('Method CurrentVirtualDesktopChanged')],
            HRESULT,
            'CurrentVirtualDesktopChanged',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopOld'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopNew'),
        ),
    ]


IID_IVirtualDesktopNotificationService = GUID('{0CD45E71-D927-4F15-8B0A-8FEF525337BF}')


class IVirtualDesktopNotificationService(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktopNotificationService
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method Register')],
            HRESULT,
            'Register',
            (['in'], POINTER(IVirtualDesktopNotification), 'pNotification'),
            (['out'], POINTER(DWORD), 'pdwCookie'),
        ),
 
        COMMETHOD(
            [helpstring('Method Unregister')],
            HRESULT,
            'Unregister',
            (['in'], DWORD, 'dwCookie'),
        ),
    ]


comtypes.CoInitialize()

pServiceProvider = comtypes.CoCreateInstance(
    CLSID_ImmersiveShell,
    IServiceProvider,
    comtypes.CLSCTX_LOCAL_SERVER,
)


pDesktopManagerInternal  = comtypes.cast(
    pServiceProvider.QueryService(
        CLSID_VirtualDesktopManagerInternal,
        IID_IVirtualDesktopManagerInternal
    ),
    ctypes.POINTER(IVirtualDesktopManagerInternal)
)

pObjectArray = POINTER(IObjectArray)()

pDesktopManagerInternal.GetDesktops(ctypes.byref(pObjectArray))

count = UINT()
pObjectArray.GetCount(ctypes.byref(count))

for i in range(count):
    pDesktop  = POINTER(IVirtualDesktop)()
    pObjectArray.GetAt(i, IID_IVirtualDesktop, ctypes.byref(pDesktop))

    id = GUID()
    pDesktop.GetID(ctypes.byref(id))

    print(id)

User avatar
kgschlosser
Site Admin
Posts: 5495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Logging Windows operations? Moving application to virtual desktop?

Post by kgschlosser » Sun Jul 28, 2019 4:20 am

There is a guy that I am working with on getting this going. He has some ctypes and python experience. So it is coming together. It should only be a little while longer before it is finished.
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 108
Joined: Mon Sep 24, 2018 7:57 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by dan Edens » Sun Jul 28, 2019 8:40 pm

kgschlosser wrote:
Sun Jul 28, 2019 4:20 am
There is a guy that I am working with on getting this going. He has some ctypes and python experience. So it is coming together. It should only be a little while longer before it is finished.
Well than this might of been unnecessary, but I tried to make a template to work from on it, going to convert the code you have in there as best i can to fit as i get time this week.

https://github.com/DanEdens/Virtual_Desktops_Plugin

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by jachin99 » Sun Jul 28, 2019 11:57 pm

I just noticed I posted the code and not the error message so sorry about that. Anyway I saw a tidbit about some changes coming to virtual desktops in future builds of windows. Might want to pass it along. https://www.bleepingcomputer.com/news/m ... -desktops/

User avatar
kgschlosser
Site Admin
Posts: 5495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Logging Windows operations? Moving application to virtual desktop?

Post by kgschlosser » Mon Jul 29, 2019 7:28 am

I know they added the ability to set names to application views the build before last.

They have been adding more and more with each new build of windows 10.

They are on their 9th version of the IApplicationView interface.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by jachin99 » Mon Jul 29, 2019 1:29 pm

I think they are going to switch to a major/minor release schedule so that might give everyone some relief. A new version of Windows every year still sounds like a lot but at least it's not every six months

dan Edens
Experienced User
Posts: 108
Joined: Mon Sep 24, 2018 7:57 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by dan Edens » Mon Jul 29, 2019 2:02 pm

kgschlosser wrote:
Mon Jul 29, 2019 7:28 am
I know they added the ability to set names to application views the build before last.

They have been adding more and more with each new build of windows 10.

They are on their 9th version of the IApplicationView interface.
Virtual desktops are for me the biggest struggles between my linux and windows machines. I'm really efficient with them on with KDE, but in windows I almost never bother with it because It ends up being more management than it's worth. Being able to control it with EG is going to seriously level the playing field. Because this is NOT ENOUGH SCREENS lol
not enough screens.jpg
There's one in the back behind the mains I mostly teamviewer into, and I have a 3 way HDMI splitter velcro'ed for my raspberry pi station

User avatar
kgschlosser
Site Admin
Posts: 5495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Logging Windows operations? Moving application to virtual desktop?

Post by kgschlosser » Mon Jul 29, 2019 6:59 pm

If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Logging Windows operations? Moving application to virtual desktop?

Post by kgschlosser » Mon Jul 29, 2019 7:07 pm

If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 108
Joined: Mon Sep 24, 2018 7:57 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by dan Edens » Mon Jul 29, 2019 8:49 pm

kgschlosser wrote:
Mon Jul 29, 2019 6:59 pm
http://eventghost.net/forum/viewtopic.php?f=14&t=9135

ever looked at this?
I have been meaning too, I'll check it out.


sick! This is going to be so cool.

dan Edens
Experienced User
Posts: 108
Joined: Mon Sep 24, 2018 7:57 pm

Re: Logging Windows operations? Moving application to virtual desktop?

Post by dan Edens » Fri Aug 02, 2019 3:27 pm

Incase anyone reading this is interested in this awesome project,

There is more conversation to see at this link on github.
https://github.com/DanEdens/Virtual_Des ... n/issues/1

-pops more popcorn furiously-
I'm learning a lot this is truly a gold mine.

User avatar
kgschlosser
Site Admin
Posts: 5495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Logging Windows operations? Moving application to virtual desktop?

Post by kgschlosser » Sat Aug 03, 2019 12:16 pm

glad to see you have found some entertainment. and educational entertainment at that!
If you like the work I have been doing then feel free to Image

Post Reply