找回密码
 加入
搜索
查看: 1534|回复: 3

[AU3基础] [已解决]能麻烦大家帮忙转一段C++程序为AU3的吗?

[复制链接]
发表于 2013-9-1 15:43:19 | 显示全部楼层 |阅读模式
本帖最后由 yinui 于 2013-9-8 01:00 编辑

#include <iostream>
#include <conio.h>
#include <Windows.h>

using namespace std;

int main(int, char **, char **)
{
    RECT rtWorkArea;
    SystemParametersInfo(SPI_GETWORKAREA, 0, &rtWorkArea, 0);
    RECT rtWorkAreaTmp;
    rtWorkAreaTmp.left = rtWorkArea.left + 20;
    rtWorkAreaTmp.top = rtWorkArea.top + 20;
    rtWorkAreaTmp.right = rtWorkArea.right - 20;
    rtWorkAreaTmp.bottom = rtWorkArea.bottom - 20;
    SystemParametersInfo(SPI_SETWORKAREA, 0, &rtWorkAreaTmp, 0);
    cout << "Open notepad.exe and maximize the window, then press any key...";
    getch();
    SystemParametersInfo(SPI_SETWORKAREA, 0, &rtWorkArea, 0);

    return 0;
}
 楼主| 发表于 2013-9-1 15:44:14 | 显示全部楼层
或者帮忙看一下,SystemParametersInfo函数SPI_SETWORKAREA怎样用,实在不懂API,谢谢
发表于 2013-9-1 16:33:33 | 显示全部楼层
#Include <Misc.au3>
#include <WinApi.au3>
Local Const $SPI_GETWORKAREA = 0x0030
Local Const $SPI_SETWORKAREA = 0x002F
Local $stRect = DllStructCreate($tagRect);旧的矩形范围
Local $stRectNew = DllStructCreate($tagRect);新的矩形范围
Local $iResult = _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, DllStructGetPtr($stRect), 0)
;~ If $iResult Then
;~         MsgBox(0, "Desktop Working Area", "Left = " & _
;~                         DllStructGetData($stRect, "left") & @CRLF & "Top = " & _
;~                         DllStructGetData($stRect, "top") & @CRLF & "Right = " & _
;~                         DllStructGetData($stRect, "right") & @CRLF & "Bottom = " & _
;~                         DllStructGetData($stRect, "bottom"))
;~ Else
;~         MsgBox(0, "Desktop Working Area", "Faild to get Desktop work area")
;~ EndIf
;上下左右减小20像素
DllStructSetData($stRectNew, "left", DllStructGetData($stRect, "left") + 20)
DllStructSetData($stRectNew, "top", DllStructGetData($stRect, "top") + 20)
DllStructSetData($stRectNew, "right", DllStructGetData($stRect, "right") - 20)
DllStructSetData($stRectNew, "bottom", DllStructGetData($stRect, "bottom") - 20)
_WinAPI_SystemParametersInfo($SPI_SETWORKAREA, 0, DllStructGetPtr($stRectNew), 0)
TrayTip("说明","现在你可以打开一个窗口(比如记事本)然后最大化,看看最大化的效果!,按空格键退出!", 5)
Do 
Sleep(10)
Until _IsPressed(20);等待按空格键,等待任意键不会写
_WinAPI_SystemParametersInfo($SPI_SETWORKAREA, 0, DllStructGetPtr($stRect), 0)

评分

参与人数 1金钱 +10 收起 理由
nmgwddj + 10 学习了。

查看全部评分

 楼主| 发表于 2013-9-2 14:23:28 | 显示全部楼层
回复 3# seniors

谢谢,学到了新的东西,但能麻烦你再帮忙一下吗?这个对已经最大化的不立即生效,要再次最大化窗口才起作用,能直接刷新,或别的方法使他立即生效吗??
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 21:19 , Processed in 0.105632 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表