当前位置: 首页 > news >正文

unity 桌面程序

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;

public class chuantou : MonoBehaviour
{
[DllImport(“user32.dll”)]
public static extern int MessageBox(IntPtr hwnd,string text,string caption,uint type);
private struct MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cxTopHeight;
public int cxButtomHeight;
}

[DllImport("user32.dll")]
private static extern IntPtr GetActiveWindow();
[DllImport("Dwmapi.dll")]
private static extern uint DwmExtendFrameIntoClientArea(IntPtr hWnd,ref MARGINS margins);[DllImport("user32.dll")] //窗口属性
private static extern int SetWindowLong(IntPtr hWnd,int nIndex,uint dwNewLong);
[DllImport("user32.dll",SetLastError =true)] //设置位置置顶
private static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);[DllImport("user32.dll")]//设置透明层级
private static extern int SetLayeredWindowAttributes(IntPtr hWnd, uint crKey,byte bAlpha,uint dwFlags);const int GWL_EXSTYLE = -20;
const uint WS_EX_LAYERED = 0X00080000;
const uint WS_EX_TRANSPARENT = 0X00000020;static readonly IntPtr HWND_TOPMOST=new IntPtr(-1);
const uint LWA_COLORKEY = 0X00000001;IntPtr hwnd;
void Start()
{hwnd = GetActiveWindow();MARGINS margins = new MARGINS { cxLeftWidth = -1 };DwmExtendFrameIntoClientArea(hwnd, ref margins);SetWindowLong(hwnd,GWL_EXSTYLE,WS_EX_LAYERED);SetLayeredWindowAttributes(hwnd, 0, 0, LWA_COLORKEY);SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, 0);Application.runInBackground = true;
}// Update is called once per frame
void Update()
{this.transform.RotateAround(Vector3.zero,new Vector3(0,1,0),0.5f);
}

}

http://www.lryc.cn/news/174704.html

相关文章:

  • echarts统一纵坐标y轴的刻度线,刻度线对齐。
  • 一个数据库版本兼容问题
  • 学习Nano编辑器:入门指南、安装步骤、基本操作和高级功能
  • 在北京多有钱能称为富
  • Chrome扩展程序开发随记
  • 使用命令行快速创建Vite项目
  • int *a, int **a, int a[], int *a[]的区别
  • leetcode100----双指针
  • ORM基本操作
  • c语言进阶部分详解(指针进阶2)
  • Java基础(一)——Hello World,8种数据类型,键盘录入
  • JAVA学习笔记(IF判断结构)
  • 【跟小嘉学 PHP 程序设计】二、PHP 基本语法
  • 面试总结之微服务篇
  • ElementUI之登陆+注册
  • 新版kafka可视化界面组件
  • ​P1102 A-B 数对 【双指针(尺取法)】​
  • Flutter绘制拖尾效果
  • 【Newman+Jenkins】实施接口自动化测试
  • kr 第三阶段(六)C++ 逆向
  • 医药行业安全生产信息化建设分享
  • C 语言简单入门
  • Levels - UE5中的建模相关
  • 数据中心与数据仓库的区别
  • [2023.09.18]: Rust中类型转换在错误处理中的应用解析
  • 前端工作日常
  • C++:C++哪些时候用到const
  • OpenCV之九宫格图像
  • OpenGLES:绘制一个颜色渐变的圆
  • javascript数据类型错误造成的前端分页不准的问题