I had build an electron app with the tutorial from here.
The problem is now, that the "minimize to tray" function and the 'autostart' function doesnt work anymore. When starting my app via npm start it works but not with the .exe
The code of the tray function is from this answer: Electron.js How to minimize/close window to system tray and restore window back from tray?
The code of the autostart function is from here: How to use auto-launch to start app on system startup?
Does anybody know why those functions doesnt work anymore after building a .exe? (Start as admin doesnt help)
The reason that this doesn't work for was that the path of the icon of the tray menu was defined as ./icon.png but after building the application, the file isn't at the same place anymore. All the app files are moved to ./resources/app/.
So this was the fix for me:
let trayIcon = null
if(!app.isPackaged) {
trayIcon = './icon.png'; // when in dev mode
} else {
trayIcon = './resources/app/icon.png';
}
Related
Here the requirement is to open the exe file from browser on button click.
This is the internal application, so client(angular) and server(node.js) is present in all machines, so here the idea is that, on button click I'm hitting node.js through socket.io and launching the exe by using node.js--child_process.
The above functionality is working fine, in my dev machine, on button click node-js is launching exe successfully, but after deployment (with dist files) it is not opening exe, and also there is no errors
This is my code
const { execFile } = require('node:child_process');
execFile('C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', [], (error, stdout, stderr) => {console.log(error)});
Here my question is, Any config I need to change from node.js side to make it work with deployment files or is there any way to achieve this functionality in nodejs/angular?
Note:-
Even I tried to open .bat file by using spawn to trigger the exe, it is working fine in my dev-machine, but not working after deployment.
Thanks in Advance!
I'm trying to make my own 3d viewer app.
I just want it works like,
Open an app (tap on my smartphone screen),
Show a 3d model,
Close the app when the back button is tapped.
Actually, I made an app (with Kotlin on android studio) that is working like my idea.
The app is working well with a file that is located on a server.
But I want to make an app that works without an internet connection.
How to import a file(glTF format) to the app.?
In the part,
.appendQueryParameter("file", "PATH/XXXX.gltf")
If the PATH is with "https//", it works with an internet connection.
but, How can I set the PATH local storage in order for the apps to work without internet connections?
Here is the kotlin code snippet that I'm using.
val sceneViewerIntent: Intent = Intent(Intent.ACTION_VIEW)
val intentUri: Uri = Uri.parse("https://arvr.google.com/scene-viewer/1.0").buildUpon()
.appendQueryParameter(
"file","ludovic_v2_gltf.gltf" //<<<<---- how to import this file?
//"https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf"
//<<<--- with this line, works very well.
)
.appendQueryParameter("mode", "3d_only")
.build()
sceneViewerIntent.data = intentUri
sceneViewerIntent.setPackage("com.google.ar.core")
startActivity(sceneViewerIntent)
finish()
Thanks a lot!!!
This is my environment.
windows10, android-studio 20212.1Patch1(build on May 18,2022)
My project was started with "empty activity".
I am looking for a way to capture a screenshot of a VS Code extension host window. This window is opened when my extension's tests are being run (this is coming from the default Yeoman template for VS Code extensions).
I cannot use my extension's context as the extension only has access to the VS Code API and VS Code runs extensions in a different Node process from the Electron one (main or renderer). IPC is used through the API instead of running extensions in-process.
I can run this code in an Electron renderer process (using DevTools or as a part of the Electron application's script) to capture the Electron window:
const electron = require('electron');
electron.remote.getCurrentWindow().capturePage(image => {
//electron.clipboard.writeImage(image);
electron.clipboard.writeText(image.toDataURL());
console.log('Data URL is in clipboard.');
});
I have verified that placing this in VS Code window DevTools will produce the correct Data URI.
In order to be able to do this from a different Node process, knowing only the Code window PID, I figured I would attach a debugger to the VS Code extension host Electron window and using CDP I would issue a Runtime.evaluate call to run the above code as if it was entered into the DevTools.
However, I am struggling with attaching the debugger. There are generally two ways to do it:
kill -s SIGUSR1 <node-pid> for Unix/macOS
process._debugProcess(proc.pid); for Windows
I am interested in Windows right now, so I issue the Windows line from a new Node process. What should happen upon successful debugger attachment is the target process should print out something like this:
Debugger listening on ws://127.0.0.1:9229/cf49bcfe-d922-4f89-b438-57755d254198
For help see https://nodejs.org/en/docs/inspector
However in my case, this only works if I start the barebones Electron app with --inspect and then issue process._debugProcess(proc.pid);, without --inspect it doesn't throw an error, but doesn't attach the debugger either.
process._debugProcess now works for me with Electron 5.
I need to test two apps in the same test case in Appium ( android )
for example, write test case to publish ads on app (A) and see the ad in the second app (B). Also, Can I run on emulator ? or should apply on real device?
After many research, I found the solution. the simple way to do that by define new driver with the selected app and this cause to close the first app and open new one.
Example Code
return driver
.elementById('username')
.click()
.init(Common.SelectApp(apps.AppName)) //Open new app ( the code below)
.setImplicitWaitTimeout(10000)
.elementById('username')
.click()
// Select App function:
var desired = process.env.npm_package_config_sauce ?
_.clone(require("./helpers/caps").android18) :
_.clone(require("./helpers/caps").android19);
return desired.app = App Name;
This code from appium examples (Node)
I'm developing a Node.js app on Electron so it can be distributed and run by people who won't be using the command line. The app doesn't need an interface, it just needs to be executed. Is there a way to hide the electron window, so the app can just sit in the tray and can be opened/quit?
There a show option in the BrowserWindow options. By default it's true, but by turning it off (show: false) you will hide the window, so the app runs, but there's no visible Window.
From Docs:
show Boolean (optional) - Whether window should be shown when created. Default is true.
Besides the show option the BrowserWindow object has methods for hide/show/focus.
If you want to prevent the users from closing the application when the window is closed you can always intercept the window 'close' event like this:
this.mainWindow.on('close', (event) => {
event.preventDefault()
this.mainWindow.hide()
})
Why do you need to create a BrowserWindow at all? The Tray API runs from the Main process. I just created a small proof of concept app and it seems to work just fine running with no BrowserWindow. You'd just need to make sure to quit the app when the user chooses that option in the tray.