有什么方法可以让我运行某个程序作为壁纸吗?只需在后台持续运行一个 exe 即可。它本质上就是我自己的“壁纸应用程序”。
答案1
不,这是不可能的。在 Vista 中,Microsoft 创建了梦幻场景这只是在桌面下播放的视频。Windows 7 中已删除此功能,并且 Microsoft 再也没有添加类似功能。
现在有一个名为动态壁纸 声称它可以在后台运行应用程序/游戏
答案2
是的,根据 EXE 和您的技能,可以将应用程序作为桌面背景运行。
最好的选择是编写一个程序或脚本来创建正确的窗口类型。这并不容易,但这是可能的。有 Python 脚本演示了如何仅用几百行代码来实现这一点。这提供了最大的灵活性和效率以及最低的成本。
有一款名为 Lively 的免费开源程序,可帮助您轻松添加大多数内容(图片、视频、网页、Unity Engine 游戏/应用程序等)作为桌面背景。它的功能不如某些付费程序那么广泛,而且效率也不高。
有一款价格便宜(4 至 5 美元)的程序叫做 Wallpaper Engine,它比 Lively 提供更多功能且性能更佳。
还有其他付费壁纸程序。您需要尝试每个选项,找出哪一个适合您的特定目的。
答案3
如果您想要一种直接的方式来实现完全控制并且使用 EXE 作为壁纸具有最大的灵活性,那么您必须自己制作该程序,将其设置为在启动时运行并确保它不会占用大量资源。
简而言之,您可以使用壁纸引擎。但如果您不想花 5 美元并且能够编程,我不建议您使用它。
如果您选择从头开始编程,那么我建议您使用 C 和 <windows.h> 库以及您需要的任何其他东西。windows.h 提供了大量的函数和类型,可用于创建 WINDOW 并对其进行控制,以及在更低的级别管理 I/O。例如:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "v/Vec.h"
#include <windows.h>
#define PI 3.14159265358979323846
#define SECONDS_ANGLE PI/60*2
#define MINUTES_ANGLE PI/60/60*2
#define HOURS_ANGLE PI/60/60/12*2
#define SECONDS_HAND_LENGTH 135*3
#define MINUTES_HAND_LENGTH 140*3
#define HOURS_HAND_LENGTH 90*3
#define PIXEL_RATIO_X 2.0
#define PIXEL_RATIO_Y 5.0
#define nScreenWidth (1920.0)/PIXEL_RATIO_X // Console Screen Size X (columns)
#define nScreenHeight (1080.0)/PIXEL_RATIO_Y // Console Screen Size Y (rows)
typedef struct Circle{
Vector center;
float radius;
} Circle,*PCircle;
void scrprint(wchar_t* scrn, Vector center, Vector b, char L){
//Vector a = VaddR(c,VratioScale(b,(Vector){1,1}));
Vector a = VaddR(center,b);
scrn[(int)((int)a.y*nScreenWidth + a.x)] = L;
}
void mlerp (wchar_t* scrn, Vector c, Vector b, double count,char L){
double inc = 1/count;
for (double i = 0; i <1 ; i+=inc)
{
scrprint(scrn, c, VscaleR(b,i), L);
}
}
void DrawCircle(wchar_t* scrn, Circle C, double definition){
Vector pointer = {0, -1,1};
double angle = 2*PI/definition;
for (double i = 0; i<2*PI; i+=angle){
scrprint(scrn,C.center,VratioScale(VscaleR(pointer,C.radius),(Vector){1/PIXEL_RATIO_X,1/PIXEL_RATIO_Y}),'0');
Vrotate(&pointer,angle);
}
}
// #define _WIN32_WINNT 0x0601
// #include<windows.h>
// typedef struct _CONSOLE_FONT_INFOEX
// {
// ULONG cbSize;
// DWORD nFont;
// COORD dwFontSize;
// UINT FontFamily;
// UINT FontWeight;
// WCHAR FaceName[LF_FACESIZE];
// }CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
// //the function declaration begins
// #ifdef __cplusplus
// extern "C" {
// #endif
// BOOL WINAPI SetCurrentConsoleFontEx(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX
// lpConsoleCurrentFontEx);
// #ifdef __cplusplus
// }
// #endif
int main(){
//*set up font size , screen and allocation of buffer
CONSOLE_FONT_INFOEX cfi;
//WindowFromPoint((POINT){0,0});
//ShowWindow(GetConsoleWindow(), SW_MAXIMIZE);
ShowCursor(SW_HIDE);
cfi.nFont = FF_DECORATIVE;
cfi.FontWeight = 1;
cfi.FontFamily = FKF_CLICKON;
cfi.dwFontSize.X = 1;
cfi.dwFontSize.Y = 1;
PCONSOLE_FONT_INFOEX cfiP = &cfi;
// Create Screen Buffer
wchar_t *screen = (wchar_t*)malloc(sizeof(wchar_t[(int)(nScreenWidth*nScreenHeight)]));
POINT mousexy;
MOUSEINPUT mI;
COORD loc;
//*/
//*handle the console screen
PCOORD throwaway;
HWND hCosWindow = GetConsoleWindow();
UINT hConsoleOut = GetConsoleOutputCP();
HANDLE hSTDCon = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, 0);
SetConsoleActiveScreenBuffer(hConsole);
SetCurrentConsoleFontEx(hCosWindow, 0,cfiP);
SetConsoleDisplayMode(hCosWindow,SHOW_FULLSCREEN,throwaway);
DWORD dwBytesWritten = 0;
//*/
Vector VminutesHand, VhoursHand, VsecondsHand, VscrCenter,
VhalfCM, VrescaledHands_S, VrescaledHands_M, VrescaledHands_H;
//*Vector Init
VscrCenter.x = (nScreenWidth)/2;
VscrCenter.y = (nScreenHeight)/2;
VsecondsHand.y = -SECONDS_HAND_LENGTH;
VminutesHand.y = -MINUTES_HAND_LENGTH;
VhoursHand.y = -HOURS_HAND_LENGTH;
VsecondsHand.x = 0;
VminutesHand.x = 0;
VhoursHand.x = 0;
//*/
clock_t start =clock(), end = clock();
double timeTaken = 0;
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
//angle between 12o'clock and current time
Vrotate(&VsecondsHand,(2*(double)timeinfo->tm_sec*PI)/60);
Vrotate(&VminutesHand,(2*((double)timeinfo->tm_min+(double)timeinfo->tm_sec/60)*PI)/60);
Vrotate(&VhoursHand,(2*((double)timeinfo->tm_hour+((double)timeinfo->tm_min/60+(double)timeinfo->tm_sec/60/60))*PI)/12);
Circle ClockCirc = {VscrCenter, 150*3};
Circle Clock12thDots = {VscrCenter, 120*3};
Circle Clock60thDots = {VscrCenter, 140*3};
while(GetAsyncKeyState('Q')==0 || GetAsyncKeyState(VK_LCONTROL)==0 || GetAsyncKeyState(VK_LMENU)==0){
start = clock();
//clear screen
for (size_t i = 0; i < nScreenWidth*nScreenHeight; i++)
{
screen[i] = ' ';
}
DrawCircle(screen,ClockCirc,800);
DrawCircle(screen,Clock12thDots,12);
DrawCircle(screen,Clock60thDots,60);
Vrotate(&VsecondsHand, -SECONDS_ANGLE * timeTaken);
Vrotate(&VminutesHand, -MINUTES_ANGLE * timeTaken);
Vrotate(&VhoursHand, -HOURS_ANGLE * timeTaken);
//GetCursorPos(&mousexy);
//loc.X = (mousexy.x)/2;
//loc.Y = (mousexy.y)/5;
//VhalfCM = VaddR(VscrCenter,VratioScale(VsubR((Vector){loc.X, loc.Y},VscrCenter),(Vector){0.5,0.5}));
//screen[(int)(loc.Y*(nScreenWidth) + loc.X)] = '0';
//screen[(int)(((int)VhalfCM.y)*nScreenWidth + (VhalfCM.x))] = '0';
//screen[(int)((VhalfCM.y) * (nScreenWidth) + (VhalfCM.x))] = '0';
//always 1half shifted towards vscrncenter but it is smooth
//screen[(int)((VscrCenter.y+loc.Y-VscrCenter.y/2)*(nScreenWidth) + VscrCenter.x+(loc.X-VscrCenter.x/2))] = '0';
screen[(int)(VscrCenter.y*(nScreenWidth) + VscrCenter.x)] = '0';
VrescaledHands_S = VratioScale(VsecondsHand,(Vector){0.5,0.2});
VrescaledHands_M = VratioScale(VminutesHand,(Vector){0.5,0.2});
VrescaledHands_H = VratioScale(VhoursHand,(Vector){0.5,0.2});
//mlerp(screen, VscrCenter, VsubR((Vector){loc.X,loc.Y}, VscrCenter),20,'q');
mlerp(screen,VscrCenter,VrescaledHands_S,60,'.');
mlerp(screen,VscrCenter,VrescaledHands_M,100,'m');
mlerp(screen,VscrCenter,VrescaledHands_H,150,'H');
/*mouse cursor handler
SetConsoleCursorPosition(hConsole, loc);
//screen[(int)(loc.Y*(nScreenWidth) + loc.X)] = '0';
//printf("\033[%d;%dH",mousexy.x, mousexy.y);
//*/
if (-0.01<VangleR(VsecondsHand,(Vector){0,-1}) && VangleR(VsecondsHand,(Vector){0,-1})<0.01){
//MessageBeep(MB_ICONWARNING);
}
//diagnostics and writeout
//swprintf_s(screen, 60, L"X= %d, Y= %d, halfCM.x= %.2f, halfCM.y= %.2f", loc.X, loc.Y, VhalfCM.x, VhalfCM.y*nScreenWidth);
WriteConsoleOutputCharacterW(hConsole, screen, nScreenWidth * nScreenHeight, (COORD){0,0} , &dwBytesWritten);
timeTaken = ((double) (end - start)) / CLOCKS_PER_SEC;
end = start;
}
free(screen);
return 0;
}
这是我为在控制台中制作时钟而编写的简单程序。要使其工作,您需要将控制台字体设置为 5;右键单击窗口进入控制台属性,然后按 f11 进入全屏。注释用于故障排除和测试;您可以删除它们,但如果您对 Windows 编程不熟悉,最好通过它们来了解命名方案,如果您想要更多文档:https://learn.microsoft.com/en-us/windows/win32/learnwin32/what-is-a-window-
对于我的“Vec.h”,它只是一个常规的矢量库:
#ifndef VEC_H
#define VEC_H
#include <math.h>
typedef struct Vector{
double x,y,m;
} Vector, *PVector;
void VSetEqual (PVector v1,Vector v2){
v1->x = v2.x;
v1->y = v2.y;
v1->m = v2.m;
}
void Vadd (PVector v1,Vector v2){
v1->x += v2.x;
v1->y += v2.y;
}
void Vsub (PVector v1,Vector v2){
v1->x -= v2.x;
v1->y -= v2.y;
}
void Vscale (PVector v1, double s1){
v1->x*=s1;
v1->y*=s1;
v1->m*=s1;
}
Vector VaddR (Vector v1,Vector v2){
return (Vector){v1.x + v2.x, v1.y + v2.y};
}
Vector VsubR (Vector v1,Vector v2){
return (Vector){v1.x - v2.x, v1.y - v2.y};
}
Vector VscaleR (Vector v1, double s1){
return (Vector){v1.x * s1, v1.y * s1};
}
double Vdot(Vector A, Vector B){
return (A.x* B.x + A.y * B.y);
}
double VmagR(Vector v1){
return sqrt(v1.x*v1.x + v1.y*v1.y);;
}
void Vmag(PVector v1){
v1->m = sqrt(v1->x*v1->x + v1->y*v1->y);
}
void Vnorm(PVector v1) {
Vmag(v1);
if(v1->m==0) return;
v1->x /= v1->m;
v1->y /= v1->m;
v1->m = 1;
}
Vector VnormR(Vector v1){
double m = VmagR(v1);
if (m==0)return (Vector){0,0,0};
return VscaleR(v1,m);
}
Vector VratioScale(Vector v1,Vector scalars){
v1.x *= scalars.x;
v1.y *= scalars.y;
return v1;
}
void Vrotate (PVector v1, double angle){
double temp = v1->x;
v1->x = v1->x*cosf(angle) - v1->y*sinf(angle);
v1->y = temp*sinf(angle) + v1->y*cosf(angle);
}
Vector VrotateR (Vector v1, double angle){
double temp = v1.x;
v1.x = (v1.x * cos(angle)) - (v1.y * sin(angle));
v1.y = (temp * sin(angle)) + (v1.y * cos(angle));
return v1;
}
double VangleR(Vector v1, Vector v2){
return (acos((v1.x*v2.x+v1.y+v2.y)/(VmagR(v1)*VmagR(v2))));
}
//cos -sin | x
// |
//sin cos | y
#endif