【已解决】无标题窗口移动问题
本帖最后由 zerobin 于 2012-5-6 09:08 编辑一个桌面浮动工具。
目前两个问题拦着我
1、几个按钮老在闪,如何不闪。
2、窗口怎么不能移动,是 消息循环模式 与 onevent模式 导致的吗?
请指教,我新学,23点搞到现在。。。。。。。都通宵了。搞不出来。睡不着。#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <ButtonConstants.au3>
#NoTrayIcon
;
Opt("GUIOnEventMode",1)
Local $label1, $label2, $label3, $label4, $label5
$Form1 = GUICreate("float", 120, 21, @DesktopWidth/2-50, 10, $WS_POPUP, $WS_EX_TOPMOST);, $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUICtrlSetOnEvent($Form1, "mouseCHK")
While 1
$label1 = GUICtrlCreateButton("C",0, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label1 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label1,"_go1")
$label2 = GUICtrlCreateButton("D",21, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label2 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label2,"_go2")
$label3 = GUICtrlCreateButton("E",42, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label3 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label3,"_go3")
$label4 = GUICtrlCreateButton("F",63, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label4 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label4,"_go4")
$label5 = GUICtrlCreateButton("R",84, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label5 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label5,"_go5")
GUISetState(@SW_SHOW)
WEnd
Func _go1()
ShellExecute("C:\")
EndFunc
Func _go2()
ShellExecute("D:\")
EndFunc
Func _go3()
ShellExecute("E:\")
EndFunc
Func _go4()
ShellExecute("F:\")
EndFunc
Func _go5()
ShellExecute("R:\")
EndFunc
;mouseCHK
Func mouseCHK()
$MS = GUIGetCursorInfo($Form1)
MsgBox(0,"","test")
If $MS =$Form1 Then move()
EndFunc
;==>move
Func move()
Local $PosDiff, $MousePos, $WinPos
$MousePos = MouseGetPos()
$WinPos = WinGetPos($Form1, "")
$PosDiff = $WinPos - $MousePos
$PosDiff = $WinPos - $MousePos
While _IsPressed("01", DllOpen("user32.dll"))
$MousePos = MouseGetPos()
WinMove($Form1, "", $MousePos + $PosDiff, $MousePos + $PosDiff)
Sleep(10)
WEnd
EndFunc
Func SpecialEvents()
Exit
EndFunc ;==>SpecialEvents
本帖最后由 zerobin 于 2012-5-6 07:41 编辑
12行 改为GUICtrlSetOnEvent($GUI_EVENT_PRIMARYDOWN, "mouseCHK") 也是不能移动窗口。怎么办呀 把14行移动到30行之后,然后加个sleepWhile 1
Sleep(100)
WEnd 把14行移动到30行之后,然后加个sleep
haijie1223 发表于 2012-5-6 07:50 http://www.autoitx.com/images/common/back.gif
这个解决了问题1,按钮不闪了,谢谢。理解了,原来的太快了。。
问题2请问怎么解决还,这样改了还是不能移动窗口呀 回复 4# zerobin
代码开始添加
#include <StaticConstants.au3>
在13行添加
GUICtrlCreateLabel("",0,0,104, 41,$SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG) 回复zerobin
代码开始添加
#include
在13行添加
GUICtrlCreateLabel("",0,0,104, 41,$SS ...
haijie1223 发表于 2012-5-6 08:32 http://www.autoitx.com/images/common/back.gif
端着早饭在等呢,吃完就试。谢谢 都是别人的代码,为什么不用看起来舒服点的。。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <ButtonConstants.au3>
#NoTrayIcon
Opt("GUIOnEventMode",1)
Local $label1, $label2, $label3, $label4, $label5
$Form1 = GUICreate("float", 104, 41, @DesktopWidth/2-50, 10, $WS_POPUP, $WS_EX_TOPMOST);, $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
$label1 = GUICtrlCreateButton("C",0, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label1 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label1,"_go")
$label2 = GUICtrlCreateButton("D",21, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label2 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label2,"_go")
$label3 = GUICtrlCreateButton("E",42, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label3 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label3,"_go")
$label4 = GUICtrlCreateButton("F",63, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label4 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label4,"_go")
$label5 = GUICtrlCreateButton("R",84, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label5 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label5,"_go")
GUIRegisterMsg($WM_NCHITTEST,"WM_NCHITTEST")
GUISetState(@SW_SHOW)
While 1
Sleep(1000)
WEnd
Func _go()
ShellExecute(GUICtrlRead(@GUI_CtrlId)&":\")
EndFunc
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
if ($hWnd = $Form1 ) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION
EndFunc
Func SpecialEvents()
Exit
EndFunc ;==>SpecialEvents
回复zerobin
代码开始添加
#include
在13行添加
GUICtrlCreateLabel("",0,0,104, 41,$SS ...
haijie1223 发表于 2012-5-6 08:32 http://www.autoitx.com/images/common/back.gif
改后倒是可以移动了,但是弹不出文件夹了 回复 8# whitehead
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
;
Opt("GUIOnEventMode", 1)
Local $label1, $label2, $label3, $label4, $label5
$Form1 = GUICreate("float", 104, 41, @DesktopWidth / 2 - 50, 10, $WS_POPUP, BitOR($WS_EX_TOPMOST, $GUI_WS_EX_PARENTDRAG));, $WS_EX_TOOLWINDOW
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUICtrlSetOnEvent($Form1, "mouseCHK")
$label1 = GUICtrlCreateButton("C", 0, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label1 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label1, "_go1")
$label2 = GUICtrlCreateButton("D", 21, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label2 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label2, "_go2")
$label3 = GUICtrlCreateButton("E", 42, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label3 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label3, "_go3")
$label4 = GUICtrlCreateButton("F", 63, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label4 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label4, "_go4")
$label5 = GUICtrlCreateButton("R", 84, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label5 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label5, "_go5")
GUICtrlCreateLabel("", 0, 0, 104, 41, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func _go1()
ShellExecute("C:\")
EndFunc ;==>_go1
Func _go2()
ShellExecute("D:\")
EndFunc ;==>_go2
Func _go3()
ShellExecute("E:\")
EndFunc ;==>_go3
Func _go4()
ShellExecute("F:\")
EndFunc ;==>_go4
Func _go5()
ShellExecute("R:\")
EndFunc ;==>_go5
;mouseCHK
Func mouseCHK()
$MS = GUIGetCursorInfo($Form1)
MsgBox(0, "", "test")
If $MS = $Form1 Then move()
EndFunc ;==>mouseCHK
;==>move
Func move()
Local $PosDiff, $MousePos, $WinPos
$MousePos = MouseGetPos()
$WinPos = WinGetPos($Form1, "")
$PosDiff = $WinPos - $MousePos
$PosDiff = $WinPos - $MousePos
While _IsPressed("01", DllOpen("user32.dll"))
$MousePos = MouseGetPos()
WinMove($Form1, "", $MousePos + $PosDiff, $MousePos + $PosDiff)
Sleep(10)
WEnd
EndFunc ;==>move
Func SpecialEvents()
Exit
EndFunc ;==>SpecialEvents
回复whitehead
haijie1223 发表于 2012-5-6 08:46 http://www.autoitx.com/images/common/back.gif
楼主的两个问题解决了 是啊。谢谢。看来还是要再建一个 标签 才可以。GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUICtrlSetOnEvent($Form1, "mouseCHK")
$label1 = GUICtrlCreateButton("C", 0, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label1 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label1, "_go1")
$label2 = GUICtrlCreateButton("D", 21, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label2 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label2, "_go2")
$label3 = GUICtrlCreateButton("E", 42, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label3 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label3, "_go3")
$label4 = GUICtrlCreateButton("F", 63, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label4 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label4, "_go4")
$label5 = GUICtrlCreateButton("R", 84, 1, 20, 20, $BS_FLAT)
; GUICtrlSetBkColor( $label5 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label5, "_go5")
GUICtrlCreateLabel("█", 104, 0, 6, 21, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
或者GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUICtrlSetOnEvent($Form1, "mouseCHK")
GUICtrlCreateLabel("█", 104, 0, 6, 21, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$label1 = GUICtrlCreateButton("C",0, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label1 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label1,"_go1")
$label2 = GUICtrlCreateButton("D",21, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label2 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label2,"_go2")
$label3 = GUICtrlCreateButton("E",42, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label3 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label3,"_go3")
$label4 = GUICtrlCreateButton("F",63, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label4 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label4,"_go4")
$label5 = GUICtrlCreateButton("R",84, 1, 20, 20,$BS_FLAT)
; GUICtrlSetBkColor( $label5 , $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($label5,"_go5")
GUISetState(@SW_SHOW)
都可以了。
今天就到这了,实现了我要的功能。
下一步就是给他做成半透明的。
再次感谢上面为我解惑的前辈。 回复 9# haijie1223
谢谢 回复 10# whitehead
谢谢 回复 7# 502762378
谢谢。 回复 13# zerobin
不客气
页:
[1]
2