ContextMenuForWindows11 icon indicating copy to clipboard operation
ContextMenuForWindows11 copied to clipboard

Access from WinUI 3

Open ghost1372 opened this issue 3 years ago • 4 comments

Hi, Can you create a Library with easy access in C# (WinUI 3)?

ghost1372 avatar Aug 27 '22 07:08 ghost1372

https://github.com/ikas-mc/ContextMenuForWindows11/tree/main/ContextMenuCustom/ContextMenuCustomHost This is an independent project... Can be used in winui3

<com:Extension Category="windows.comServer">
          <com:ComServer>
            <com:SurrogateServer  DisplayName="Custome Context Menu">
              <com:Class Id="46F650E5-9959-48D6-AC13-A9637C5B3787" Path="ContextMenuCustomHost.dll" ThreadingModel="STA"/>
            </com:SurrogateServer>
 </com:ComServer>

ikas-mc avatar Aug 27 '22 08:08 ikas-mc

@ikas-mc tnx, i used in my app and i cant see my menu! image Should I do something else?

ghost1372 avatar Aug 27 '22 11:08 ghost1372

https://github.com/ikas-mc/ContextMenuForWindows11/blob/main/ContextMenuCustom/ContextMenuCustomPackage/Package.appxmanifest

ikas-mc avatar Aug 27 '22 18:08 ikas-mc

I still can't see the created menu. Do I have to change something special in vcxproj? or something else in appxmanifest? I copied your codes exactly App31.zip

ghost1372 avatar Aug 28 '22 12:08 ghost1372

@ikas-mc I'm still having trouble creating a menu, Can you take a look at what I'm doing? i added ContextMenuCustomHost project to my project and i added as a refrence project. then I specified the output location of the project image

I also edited the manifest file

<Extensions>
        <desktop4:Extension Category="windows.fileExplorerContextMenus">
          <desktop4:FileExplorerContextMenus>
            <desktop5:ItemType Type="Directory"  >
              <desktop5:Verb Id="CustomMenu" Clsid="46F650E5-9959-48D6-AC13-A9637C5B3787" />
            </desktop5:ItemType>
            <desktop5:ItemType Type="*"  >
              <desktop5:Verb Id="CustomMenu" Clsid="46F650E5-9959-48D6-AC13-A9637C5B3787" />
            </desktop5:ItemType>
            <desktop5:ItemType Type="Directory\Background">
              <desktop5:Verb Id="CustomMenu" Clsid="46F650E5-9959-48D6-AC13-A9637C5B3787" />
            </desktop5:ItemType>
          </desktop4:FileExplorerContextMenus>
        </desktop4:Extension>
        <com:Extension Category="windows.comServer">
          <com:ComServer>
            <com:SurrogateServer  DisplayName="Custome Context Menu">
              <com:Class Id="46F650E5-9959-48D6-AC13-A9637C5B3787" Path="ContextMenuCustomHost.dll" ThreadingModel="STA"/>
            </com:SurrogateServer>
          </com:ComServer>
        </com:Extension>
		  <uap3:Extension Category="windows.appExecutionAlias">
			  <uap3:AppExecutionAlias>
				  <desktop:ExecutionAlias Alias="customeContextMenuDebug.exe"/>
			  </uap3:AppExecutionAlias>
		  </uap3:Extension>
      </Extensions>

I ran the app, but I didn't see any new menu for my program, I restarted the Explorer, I still didn't see anything. I decided to create a menu (json):

private async void myButton_Click(object sender, RoutedEventArgs e)
        {
            MenuService menuService = new MenuService();
            var menu = new MenuItem
            {
                Exe = "\"C:\\Program Files\\Notepad3\\Notepad3.exe\"",
                Param = "\"{path}\"",
                Title = "open in notepad"
            };
            await menuService.SaveAsync(menu);
        }

Nothing happens again. Where is my work wrong, what have I left out?

ghost1372 avatar Dec 04 '22 06:12 ghost1372

@ghost1372

ContextMenuCustom-winui3.zip

1

  1. backup some menu json
  2. uninstall ContextMenuCustomApp(uwp)
  3. build host, copy dll to ContextMenuCustom-winui3, run ContextMenuCustom-winui(package),then ,click button to open config folder
  4. copy menu json to folder

ikas-mc avatar Dec 08 '22 17:12 ikas-mc

@ghost1372

ContextMenuCustom-winui3.zip

1

  1. backup some menu json
  2. uninstall ContextMenuCustomApp(uwp)
  3. build host, copy dll to ContextMenuCustom-winui3, run ContextMenuCustom-winui(package),then ,click button to open config folder
  4. copy menu json to folder

Thanks, I learned how to use it completely

ghost1372 avatar Dec 08 '22 17:12 ghost1372

Hi @ikas-mc I have a question, I want to run my packaged app when the menu is clicked, so what should I enter in the exe section? As you know, the exe file of the packaged programs does not run

ghost1372 avatar Dec 10 '22 10:12 ghost1372

use windows.appExecutionAlias https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-desktop-executionalias like this

<uap3:Extension Category="windows.appExecutionAlias">
			  <uap3:AppExecutionAlias>
				  <desktop:ExecutionAlias Alias="customeContextMenuDebug.exe"/>
			  </uap3:AppExecutionAlias>
		  </uap3:Extension>

ikas-mc avatar Dec 19 '22 13:12 ikas-mc