-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ec32a56
Showing
9 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea/ | ||
node_modules/ | ||
package-lock.json | ||
dist/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Electron As Wallpaper (✨) | ||
|
||
> set your electron window as wallpaper behind desktop icons | ||
--- | ||
|
||
<div align="center"> | ||
|
||
![license](https://badgen.net/badge/license/MIT/blue) | ||
![stars](https://badgen.net/npm/v/electron-as-wallpaper) | ||
![forks](https://badgen.net/npm/dw/electron-as-wallpaper) | ||
![issues](https://badgen.net/github/issues/meslzy/electron-as-wallpaper) | ||
|
||
</div> | ||
|
||
--- | ||
|
||
<div align="center"> | ||
|
||
![issues](assets/app.gif) | ||
|
||
<a href="https://github.com/meslzy/electron-as-wallpaper">`try the app`</a> | ||
|
||
</div> | ||
|
||
--- | ||
|
||
## Getting Started (✅) | ||
|
||
- ### Installation (⏬) | ||
- `npm install electron-as-wallpaper --save` | ||
|
||
- ### How to use (🌠) | ||
```js | ||
import {attach, detach, refresh} from "electron-as-wallpaper"; | ||
// or | ||
const {attach, detach, refresh} = require("electron-as-wallpaper"); | ||
|
||
const hWind = mainWindow.getNativeWindowHandle(); | ||
|
||
attach(hWind); | ||
detach(hWind); | ||
|
||
// if the window closed before detach, you can call refresh | ||
refresh(); | ||
``` | ||
--- | ||
|
||
## The End (💘) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
'targets': [ | ||
{ | ||
'target_name': 'electron-as-wallpaper', | ||
'sources': [ 'src/index.cpp' ], | ||
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"], | ||
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"], | ||
'cflags!': [ '-fno-exceptions' ], | ||
'cflags_cc!': [ '-fno-exceptions' ], | ||
'xcode_settings': { | ||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', | ||
'CLANG_CXX_LIBRARY': 'libc++', | ||
'MACOSX_DEPLOYMENT_TARGET': '10.7' | ||
}, | ||
'msvs_settings': { | ||
'VCCLCompilerTool': { 'ExceptionHandling': 1 }, | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const bindings = require('bindings')('electron-as-wallpaper'); | ||
|
||
/** | ||
* set window behind desktop icons | ||
**/ | ||
export const attach: (hWind: Buffer) => true | null = (hWind: Buffer) => bindings.Attach(hWind); | ||
|
||
/** | ||
* remove window from desktop icons | ||
**/ | ||
export const detach: (hWind: Buffer) => true | null = (hWind: Buffer) => bindings.Detach(hWind); | ||
|
||
/** | ||
* refresh desktop | ||
**/ | ||
export const refresh = () => bindings.Refresh(); | ||
|
||
export default { | ||
attach, detach, refresh | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare module 'module-name' { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "electron-as-wallpaper", | ||
"version": "1.0.0", | ||
"author": { | ||
"name": "meslzy", | ||
"email": "[email protected]", | ||
"url": "https://www.meslzy.com/" | ||
}, | ||
"description": "set your electron window as wallpaper behind desktop icons", | ||
"keywords": [ | ||
"electron", | ||
"wallpaper" | ||
], | ||
"main": "dist/src/index.js", | ||
"files": [ | ||
"dist", | ||
"build" | ||
], | ||
"scripts": { | ||
"watch": "tsc --watch", | ||
"configure": "node-gyp configure", | ||
"build": "node-gyp build", | ||
"clean": "node-gyp clean", | ||
"install": "node-gyp rebuild" | ||
}, | ||
"dependencies": { | ||
"bindings": "^1.5.0", | ||
"node-addon-api": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.10.2", | ||
"typescript": "^4.4.3" | ||
}, | ||
"gypfile": true, | ||
"license": "ISC", | ||
"directories": { | ||
"lib": "lib" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/meslzy/electron-as-wallpaper.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/meslzy/electron-as-wallpaper/issues" | ||
}, | ||
"homepage": "https://github.com/meslzy/electron-as-wallpaper#readme" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include <napi.h> | ||
#include <windows.h> | ||
|
||
using namespace Napi; | ||
|
||
Napi::Value Attach(const Napi::CallbackInfo &info) { | ||
Napi::Env env = info.Env(); | ||
|
||
if (info.Length() != 1) | ||
{ | ||
Napi::TypeError::New(env, "err msg 1").ThrowAsJavaScriptException(); | ||
return env.Null(); | ||
} | ||
|
||
if (info[0].IsBuffer()) | ||
{ | ||
Napi::Buffer<void *> wndHandle = info[0].As<Napi::Buffer<void*>>(); | ||
HWND win = static_cast<HWND>(*reinterpret_cast<void **>(wndHandle.Data())); | ||
|
||
HWND progmanHandle = FindWindow("Progman", nullptr); | ||
|
||
SendMessage(progmanHandle, 0x052C, 0x0000000D, 0); | ||
SendMessage(progmanHandle, 0x052C, 0x0000000D, 1); | ||
|
||
static HWND workerW = nullptr; | ||
EnumWindows([](HWND topHandle, LPARAM topParamHandle) { | ||
HWND shellDllDefView = FindWindowEx(topHandle, nullptr, "SHELLDLL_DefView", nullptr); | ||
|
||
if (shellDllDefView != nullptr) { | ||
workerW = FindWindowEx(nullptr, topHandle, "WorkerW", nullptr); | ||
} | ||
|
||
return TRUE; | ||
}, NULL); | ||
|
||
if (workerW == NULL) | ||
{ | ||
Napi::TypeError::New(env, "couldn't locate WorkerW").ThrowAsJavaScriptException(); | ||
return env.Null(); | ||
} | ||
|
||
SetParent(win, workerW); | ||
|
||
return Napi::Boolean::New(env, true); | ||
} | ||
|
||
Napi::TypeError::New(env, "err msg 2").ThrowAsJavaScriptException(); | ||
return env.Null(); | ||
} | ||
|
||
Napi::Value Detach(const Napi::CallbackInfo &info) { | ||
Napi::Env env = info.Env(); | ||
|
||
if (info.Length() != 1) | ||
{ | ||
Napi::TypeError::New(env, "err msg 1").ThrowAsJavaScriptException(); | ||
return env.Null(); | ||
} | ||
|
||
if (info[0].IsBuffer()) | ||
{ | ||
Napi::Buffer<void *> wndHandle = info[0].As<Napi::Buffer<void*>>(); | ||
HWND win = static_cast<HWND>(*reinterpret_cast<void **>(wndHandle.Data())); | ||
|
||
SetParent(win, 0); | ||
|
||
return Napi::Boolean::New(env, true); | ||
} | ||
|
||
Napi::TypeError::New(env, "err msg 2").ThrowAsJavaScriptException(); | ||
return env.Null(); | ||
} | ||
|
||
Napi::Value Refresh(const Napi::CallbackInfo &info) { | ||
Napi::Env env = info.Env(); | ||
|
||
SystemParametersInfo(20, 0, nullptr, 0x1); | ||
|
||
return Napi::Boolean::New(env, true); | ||
} | ||
|
||
Napi::Object Init(Napi::Env env, Napi::Object exports) { | ||
exports.Set(Napi::String::New(env, "Attach"), Napi::Function::New(env, Attach)); | ||
exports.Set(Napi::String::New(env, "Detach"), Napi::Function::New(env, Detach)); | ||
exports.Set(Napi::String::New(env, "Refresh"), Napi::Function::New(env, Refresh)); | ||
return exports; | ||
} | ||
|
||
NODE_API_MODULE(addon, Init); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"module": "commonjs", | ||
"target": "es2017", | ||
"rootDir": "lib", | ||
"outDir": "dist", | ||
"lib": [ | ||
"es2017", | ||
"dom" | ||
], | ||
"typeRoots": [ | ||
"node_modules/@types", | ||
"lib/types" | ||
], | ||
"declaration": true, | ||
"inlineSourceMap": true, | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"traceResolution": false, | ||
"listEmittedFiles": false, | ||
"listFiles": false, | ||
"pretty": true, | ||
}, | ||
"include": [ | ||
"lib/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules/**" | ||
] | ||
} |