zoukankan      html  css  js  c++  java
  • 在windows环境下更改某软件的窗口位置

    #include<stdio.h>
    #include <stdlib.h>
    #include <Windows.h>
    #include <time.h>

    void main()
    {
        //HWND win = FindWindowA("TXGuiFoundation", "QQ");//获取窗口,TXGuiFoundation是通过spy软件获取的类名。
        HWND win = FindWindowA("StandardFrame", "阿里旺旺");//获取窗口

        int i = 0;
        while (1)
        {
            POINT pt;
            pt.x = pt.y = 0;//初始化
            GetCursorPos(&pt);//获取位置
            


            time_t ts;
            unsigned int num = time(&ts);
            srand(num);//随机数
            int data = rand() % 4;
            switch (data)
            {
            case 0:
                SetWindowPos(win, NULL, pt.x-500, pt.y-500, 0, 0, 1);//1禁止改变窗口大小
                break;  //如果x+的话,是向右移动,如果y+的话是向下移动。
            case 1:
                SetWindowPos(win, NULL, pt.x + 500, pt.y - 500, 0, 0, 1);//1禁止改变窗口大小
                break;
            case 2:
                SetWindowPos(win, NULL, pt.x -500, pt.y + 500, 0, 0, 1);//1禁止改变窗口大小
                break;
            case 3:
                SetWindowPos(win, NULL, pt.x + 500, pt.y + 500, 0, 0, 1);//1禁止改变窗口大小
                break;
            default:
                break;
            }
            i++;

            if (i==1000)
            {
                //break;//跳出循环
                return;
            }
            Sleep(100);
        }
        //system("taskkill /f /im iexplore.exe");
        //MesaageBox(0,"发现病毒","")



    }

  • 相关阅读:
    前端代码美化的艺术
    CSS3 简单的砸金蛋样式
    为什么 VS Code 能迅速占领 JavaScript 开发者社区
    了解并使用 CSS 中的 rem 单位
    CSS中一些利用伪类、伪元素和相邻元素选择器的技巧
    SVG入门指南
    PAT 1035 Password [字符串][简单]
    生信学习-二代测序知乎专栏总结[转]
    PAT 1119 Pre- and Post-order Traversals [二叉树遍历][难]
    生信笔记-mooc【武大】
  • 原文地址:https://www.cnblogs.com/sjxbg/p/5565734.html
Copyright © 2011-2022 走看看