Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

[Bug] Windows 10 Jumplist tasks #271

Open
dreisel opened this issue Sep 7, 2020 · 11 comments
Open

[Bug] Windows 10 Jumplist tasks #271

dreisel opened this issue Sep 7, 2020 · 11 comments
Assignees
Labels

Comments

@dreisel
Copy link

dreisel commented Sep 7, 2020

Hi,
Thanks for a great package!

I got an issue, when right clicking the app on windows 10 task bar, (aka jump list)
There is a default task added with the electron name and icon.
I did manage to change the name and icon with the use of rcedit, changing the icon and description....

But, when clicking on the default task it opens the electron.exe with no arguments.
so the default electron window is opened..

image

I've also tested it with one of the demo apps and got the exact same results.

@asticode asticode self-assigned this Sep 7, 2020
@asticode asticode added the bug label Sep 7, 2020
@asticode
Copy link
Owner

asticode commented Sep 7, 2020

@dreisel this issue is a duplicate of #269 if I'm not mistaken.

However this is good to know that you managed to update both icon and description using rcedit. Can you paste your solution here? I may incorporate it in the bundler process since it's already using rcedit.

I've been playing around with those functions but no luck so far... 😞

@dreisel
Copy link
Author

dreisel commented Sep 7, 2020

yea, that's exactly what i was trying to do.
and it seems that event hard-coded values in the main electron files (edited the downloaded files in the AppData folder) seems to help.
I'm afraid that the only solution is to compile the electron with the source code inside using one of the electron bundles and then communicating it with go parent service....

I'm working on a POC with https://electronforge.io/ but in order for the client to connect to the parent IPC we will need to refactor this area a bit.

here are the rc configs:

.\rcedit-x64.exe electron.exe --set-icon myicon.ico --set-version-string "CompanyName" "My CompanyName" --set-version-string "FileDescription" "My App Name" --set-version-string "LegalCopyright" "My copyright" --set-version-string "ProductName" "Axis"

@dreisel
Copy link
Author

dreisel commented Sep 7, 2020

And I don't think this is a duplicate of #269 there he refrences the app icon which works properly here.
This issue is mainly concerning the default task which starts the electron.exe with no command line arguments.

@dreisel
Copy link
Author

dreisel commented Sep 9, 2020

@asticode I think i got a solution...

I would like to change the default_app.asar in the downloaded electron repo.
and running the rcedit on the electron.exe before embedding it in the bundler.

instead of the original electron app, i would put the astilectron app in there.
so when the electron jumps up with no arguments it will signal the other instance that he is alive.

WDYT?

@asticode
Copy link
Owner

@dreisel I don't really get your solution :

I would like to change the default_app.asar in the downloaded electron repo.

which default_app.asar are you talking about ?

and running the rcedit on the electron.exe before embedding it in the bundler.

so your goal is to modify electron.exe instead of the generated go binary ?

instead of the original electron app, i would put the astilectron app in there.

what do you mean by here ?

so when the electron jumps up with no arguments it will signal the other instance that he is alive.

which other instance are you talking about ?

@dreisel
Copy link
Author

dreisel commented Sep 10, 2020

in the downloaded electron release.
the app that the electron displays:
image

is stored as an asar file in the electron zipped folder (under resources).

I would like to replace this file with the astilectron code.

my goal is to modify the electron.exe prior to embedding it into the go binary. (and possibly resigning it on release).

about the other instance, I'm assuming that the main electron window (which go-astilectron spawns up with the respective command line arguments) will be alive. so when the second instance of the electron spawns up (by clicking the button in the jump list). it will register as a single instance and the execution will stop, and call the main process to handle the window focus.

@dreisel
Copy link
Author

dreisel commented Sep 21, 2020

@asticode I think this is the way to go:
https://docs.microsoft.com/en-us/windows/win32/shell/appids?redirectedfrom=MSDN

not sure how to implement it yet

@dreisel
Copy link
Author

dreisel commented Sep 21, 2020

and when the original app didn't request the single instance it won't affect the original app

@dreisel
Copy link
Author

dreisel commented Oct 1, 2020

So what worked for me was to make a standalone electron app (using electron-forge) and adding the compiled go-app as a dependency.

Then I've added the astilectron nodejs code to the electron app and added a section of code that spawns the go app and have this communication.

This allowed the use of all the build tools in the electron echo system and having my electron.exe be the main executable and it seems that this is the preferred way for windows.

@CarsonSlovoka
Copy link
Contributor

CarsonSlovoka commented Mar 30, 2022

I try add the following on it

const os = require('os')
// ...
function onReady() {
  if (os.platform() === 'win32') {
    app.setAppUserModelId("https://www.xxx.com/") // ❗ Set it before calling "setJumpList." Otherwise, the "setJumpList" doesn't work.

    app.setJumpList([{
      type: "custom", name: "My Custom",
      items: [
        {
          type: "task",
          title: "Title",
          description: "Description",
          program: "C:\\Program Files (x86)/Notepad++/notepad++.exe",
        }, {
          type: "task",
          title: "Long Title",
          iconPath: "C:\\Program Files (x86)/Notepad++/updater/updater.ico",
          iconIndex: 0, // if ommit then you will get 'Argument must be null or an array of categories.'
          description: "Description MUST < 256!!!!!",
          program: process.execPath
        }
      ]
    },
      { // has a name so `type` is assumed to be "custom"
        name: 'Tools',
        items: [
          {
            type: 'task',
            title: 'Tool A',
            program: process.execPath,
            args: '--run-tool-a',
            icon: process.execPath,
            iconIndex: 0,
            description: 'Runs Tool A'
          }, {
            type: 'task',
            title: 'Tool B',
            program: process.execPath,
            args: '--run-tool-b',
            icon: process.execPath,
            iconIndex: 0,
            description: 'Runs Tool B'
          }]
      },
      {type: 'frequent'},
      { // has no name and no type so `type` is assumed to be "tasks"
        items: [{
          type: 'task',
          title: 'New Project',
          program: process.execPath,
          args: '--new-project',
          description: 'Create a new project.'
        }, {type: 'separator'}, {
          type: 'task',
          title: 'Recover Project',
          program: process.execPath,
          args: '--recover-project',
          description: 'Recover Project'
        }]
      }])
  }

output

image

The above code can achieve the part of the red box, but unfortunately, it is not clear how the blue arrow items should be replaced. 🤔

@CarsonSlovoka
Copy link
Contributor

CarsonSlovoka commented Mar 30, 2022

which default_app.asar are you talking about ?

where default_app.asar on the

ElectronDirectory()/resources/default_app.asar

for example

%appdata%/appName/vendor/electron-windows-amd64/resources/default_app.asar

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants