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

[GUI管理] 请教激活并且移动多个同名窗口

[复制链接]
发表于 2014-4-13 12:21:58 | 显示全部楼层 |阅读模式

像上面三个窗口,如何能在这三个窗口来回切换
比如:先激活1号窗口,把它移动到0,0坐标
然后激活2号窗口,把它移动到100,100坐标
然后激活3号窗口,把它移动到200,200坐标

帮助里面有这个GUISwitch ( 窗口句柄 [,标签项目ID] )
切换使用 GUI 函数的"当前"窗口.
这个已经试了,无效。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-4-13 13:55:02 | 显示全部楼层
回复 1# 白隼


   

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("我的窗口", 221, 312, 192, 114)
$Label1 = GUICtrlCreateLabel("我的窗口", 32, 80, 52, 17)
$Form2 = GUICreate("我的窗口", 221, 312, 192, 114)
$Label2 = GUICtrlCreateLabel("我的窗口", 32, 80, 52, 17)
$Form3 = GUICreate("我的窗口", 221, 312, 192, 114)
$Label3 = GUICtrlCreateLabel("我的窗口", 32, 80, 52, 17)
GUISetState(@SW_SHOW,$Form1)
GUISetState(@SW_SHOW,$Form2)
GUISetState(@SW_SHOW,$Form3)

MsgBox(0,"提示","点击确定开始移动窗口!")
MoveWindow("我的窗口")

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd

Func MoveWindow($_title="")
        Local $winlist=WinList($_title)
        If $winlist[0][0]>0 Then
                For $i= 1  To  $winlist[0][0]
                        WinMove( $winlist[$i][1] ,"",Random(1,@DesktopWidth,1),Random(1,@DesktopHeight,1))
                Next
        EndIf
EndFunc
发表于 2014-4-13 14:09:08 | 显示全部楼层
WinActivate(窗口句柄)
WinMove(窗口句柄, '', x坐标, Y坐标)
发表于 2014-4-13 17:41:28 | 显示全部楼层
本帖最后由 skyfree 于 2014-4-13 17:43 编辑

由于楼主没发代码,所以我也只能做个简单例子。并不是完全按你的需求做,但可实现你的要求,你稍加更改就可以了。其实你只要明白,WinMove不一定需要的是标题名,使用窗体ID是一样的。而且如果只是单纯移动的话不需要先激活窗体。
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("我的窗口", 221, 312, 192, 114)
$Label1 = GUICtrlCreateLabel("我的窗口", 32, 80, 52, 17)
$Form2 = GUICreate("我的窗口", 221, 312, 192 + 300, 114)
$Label2 = GUICtrlCreateLabel("我的窗口", 32, 80, 52, 17)
$Form3 = GUICreate("我的窗口", 221, 312, 192 + 600, 114)
$Label3 = GUICtrlCreateLabel("我的窗口", 32, 80, 52, 17)
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_SHOW, $Form2)
GUISetState(@SW_SHOW, $Form3)

Sleep(1000)
_FormMove()
Sleep(2000)
Exit

Func _FormMove()
        WinMove($Form1, "", 192 + 100, 214 + 100)
        WinMove($Form2, "", 192 + 300 + 100, 214 + 100)
        WinMove($Form3, "", 192 + 600 + 100, 214 + 100)
EndFunc   ;==>_FormMove
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-1 01:15 , Processed in 0.083157 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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