有什麼辦法可以讓我運行一個程式作為壁紙嗎?只需在後台持續運行 exe 即可。它本質上是我自己的「壁紙應用程式」。
答案1
不,這是不可能的。在 Vista 中微軟創建了夢境這只是在桌面下播放的影片。這在 Windows 7 中被刪除,微軟再也沒有添加過類似的東西。
現在有一個名為的第三方工具活潑壁紙 聲稱它可以作為後台運行應用程式/遊戲
答案2
是的,根據 EXE 和您的技能,可以讓應用程式作為您的桌面背景運作。
最好的選擇是編寫一個程式或腳本來創建正確類型的視窗。這並不容易,但卻是可能的。有一些 Python 腳本演示了只需幾百行程式碼即可完成此操作。這提供了最大的靈活性和效率以及最低的成本。
有一個名為 Lively 的免費開源程序,可以幫助您添加大多數內容(圖像、影片、網頁、Unity 引擎遊戲/應用程式等)作為桌面背景。它的功能不像某些付費程式那麼廣泛,而且效率也不高。
有一個名為“Wallpaper Engine”的廉價程式(4-5 美元),它提供比 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