[求助] 请帮忙把这个滑动的窗口提出来 (已解决)
本帖最后由 紫色风林 于 2011-6-27 19:06 编辑菜鸟就是菜鸟,搞得头晕脑胀都还是看不懂,坛里又没一个简单类似的例子,只好发贴了
三点小要求
一:请帮我把这个滑动的窗口提出来,里面的控件全不要,只要这个可以滑动的窗口;
二:请解除循环的限制;
三:请改成窗口默认在右边的中间,但能上下滑动。
不要意思,代码有点长,请老师们费点心#region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\..\..\Windows\system32\SHELL32.dll
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#region Setup
If _Singleton(@ScriptName, 1) = 0 Then
MsgBox(0, "警告", "你只能启动该应用程序一次!")
Exit (1)
EndIf
If Not FileExists(@TempDir & "\") Then DirCreate(@TempDir & "\")
FileInstall("devilish.ico", @TempDir & "\devilish.ico", 1)
FileInstall("normal.png", @TempDir & "\normal.png", 1)
FileInstall("over.png", @TempDir & "\over.png", 1)
FileInstall("pressed.png", @TempDir & "\pressed.png", 1)
FileInstall("normal-exit.png", @TempDir & "\normal-exit.png", 1)
FileInstall("over-exit.png", @TempDir & "\over-exit.png", 1)
FileInstall("normal-exit.png", @TempDir & "\pressed-exit.png", 1)
FileInstall("bg.png", @TempDir & "\bg.png", 1)
_GDIPlus_Startup()
TraySetIcon(@TempDir & "\devilish.ico")
Opt("TrayAutoPause", 0)
#endregion Setup
Global Const $NormalImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\normal.png")
Global Const $OverImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\over.png")
Global Const $PressedImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\pressed.png")
Global Const $NormalImage_Small = _ResizeBitmap(@TempDir & "\normal.png", 118, 53)
Global Const $OverImage_Small = _ResizeBitmap(@TempDir & "\over.png", 118, 53)
Global Const $PressedImage_Small = _ResizeBitmap(@TempDir & "\pressed.png", 118, 53)
Global Const $NormalImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\normal-exit.png")
Global Const $OverImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\over-exit.png")
Global Const $PressedImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\pressed-exit.png")
Global Const $bg = _GDIPlus_ImageLoadFromFile(@TempDir & "\bg.png")
Global Const $AC_SRC_ALPHA = 1
Global Const $Sensitivity = 75
Global Const $Width = 167
Global Const $Height = 490
Global $PosX = @DesktopWidth - 163
Global $PosY = @DesktopHeight - 360
Global $Pause = 0
Global $LastActiveWindow = ""
Global $Offline = 1
Dim $LabelArray
Dim $Over
Dim $Pressed
#region Image GUI
$GUI = GUICreate("Launcher-Playlet", $Width, $Height, $PosX, $PosY, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle(""))
GUISetIcon(@TempDir & "\devilish.ico")
GUISetState(@SW_SHOW, $GUI)
;皮肤创作区
$Skin = _ImageDraw()
For $i = 1 To 6
$Over[$i] = _ImageDraw("over", $i)
$Pressed[$i] = _ImageDraw("pressed", $i)
Next
#endregion Image GUI
#region GUI for holding button text, also for getting hover position
$ControlGUI = GUICreate("ControlGUI", $Width, $Height, $PosX, $PosY, $WS_POPUP, BitOR($WS_EX_LAYERED, 0x2000000), $GUI)
;控制区创建
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 167, 80)
;$Group1 = GUICtrlCreateGroup("", 0, 0, 167, 80, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER))
$Radio4 = GUICtrlCreateRadio("", 139, 33, 20, 25)
$Radio3 = GUICtrlCreateRadio("", 99, 33, 20, 25)
$Radio2 = GUICtrlCreateRadio("", 59, 33, 20, 25)
$Radio1 = GUICtrlCreateRadio("", 19, 33, 20, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label2 = GUICtrlCreateLabel("1/4", 16, 56, 25, 25)
$Label3 = GUICtrlCreateLabel("1/3", 56, 56, 25, 25)
$Label4 = GUICtrlCreateLabel("1/2", 96, 56, 25, 25)
$Label5 = GUICtrlCreateLabel("全", 136, 56, 16, 25)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateLabel("仓位选择", 48, 8, 104, 27)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
GUISetState(@SW_SHOW)
GUISetFont(12, 400, -1, "Comic Sans MS")
GUISetBkColor(0x123456, $ControlGUI)
$LabelArray = GUICtrlCreateLabel("买入", 12, 89, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel("卖出", 12, 130, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel("撤单", 12, 171, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel("成交", 12, 212, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
;$LabelArray = GUICtrlCreateLabel("持仓", 12, 253, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel("解锁", 12, 263, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE));状态标签
$LabelArray = GUICtrlCreateLabel("", 116, 264, 40, 36);退出标签
GUICtrlSetFont(-1, 8)
For $i = 1 To 6
GUICtrlSetBkColor($LabelArray[$i], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($LabelArray[$i], 0xFFFFFF)
Next
_API_SetLayeredWindowAttributes($ControlGUI, 0x123456, 230)
GUISetState(@SW_SHOW, $ControlGUI)
#endregion GUI for holding button text, also for getting hover position
;设置状态变量
For $i = 1 To 6
$LabelArray[$i] = 0 ;normal = 0; over = 1; pressed = 2; pressed, but not over on mouseup = 3
Next
;安装程序主要皮肤
SetBitmap($GUI, $Skin, 255)
While 1
$MousePos = MouseGetPos()
If $MousePos > @DesktopWidth - $Sensitivity And $MousePos > 500 Then
$GUIWinPos = WinGetPos($GUI)
If $GUIWinPos <> $PosX Then ;窗口被隐藏
$LastActiveWindow = WinGetTitle("")
GUISetState(@SW_SHOW, $GUI)
For $i = @DesktopWidth To $PosX Step -10 ;滑动窗口中
WinMove($GUI, "", $i, $PosY)
WinMove($ControlGUI, "", $i, $PosY)
Sleep(10)
Next
WinMove($GUI, "", $PosX, $PosY)
WinMove($ControlGUI, "", $PosX, $PosY)
Else ;窗口显示
$CursorInfo = GUIGetCursorInfo($ControlGUI)
;当鼠标接近屏幕的右边缘GUI或鼠标离开GUI 动作
While ($MousePos > @DesktopWidth - $Sensitivity) Or ($MousePos > $PosX And $MousePos > $PosY And $MousePos < $PosY + $Height)
$MousePos = MouseGetPos()
$CursorInfo = GUIGetCursorInfo($ControlGUI)
#region Button Checking Part
For $i = 1 To 6
If $CursorInfo = $LabelArray[$i] Then ;光标在按钮
While $CursorInfo = $LabelArray[$i]
$CursorInfo = GUIGetCursorInfo($ControlGUI)
Switch $CursorInfo
Case 0 ;如果没有按下按钮
If $LabelArray[$i] <> 1 Then
$LabelArray[$i] = 1 ;状态 = over
SetBitmap($GUI, $Over[$i], 255)
EndIf
Case 1 ;如果按下按钮
If $LabelArray[$i] <> 2 Then
$LabelArray[$i] = 2 ;状态 = pressed
SetBitmap($GUI, $Pressed[$i], 255)
EndIf
While $CursorInfo = 1
$CursorInfo = GUIGetCursorInfo($ControlGUI)
If $CursorInfo = $LabelArray[$i] Then ;如果按下按钮,并在控制
If $LabelArray[$i] <> 2 Then
$LabelArray[$i] = 2 ;状态 = pressed
SetBitmap($GUI, $Pressed[$i], 255)
EndIf
Else ;如果按下按钮,没有通过控制
If $LabelArray[$i] <> 3 Then
$LabelArray[$i] = 3 ;状态 = pressed and over
SetBitmap($GUI, $Over[$i], 255)
EndIf
EndIf
Sleep(10)
WEnd
If $CursorInfo = $LabelArray[$i] Then RunButton($i)
EndSwitch
Sleep(10)
WEnd
$LabelArray[$i] = 0 ;设置状态正常
SetBitmap($GUI, $Skin, 255) ;所有按钮复位
EndIf
Next
#endregion Button Checking Part
Sleep(20) ;可以改变取决于CPU的速度
WEnd
EndIf
Else
$GUIWinPos = WinGetPos($GUI)
If $GUIWinPos <> @DesktopWidth Then
For $i = $PosX To @DesktopWidth Step 10
WinMove($GUI, "", $i, $PosY)
WinMove($ControlGUI, "", $i, $PosY)
Sleep(10)
Next
WinMove($GUI, "", @DesktopWidth, $PosY)
WinMove($ControlGUI, "", @DesktopWidth, $PosY)
GUISetState(@SW_HIDE, $GUI)
If $LastActiveWindow <> "" Then WinActivate($LastActiveWindow)
EndIf
EndIf
Sleep(20)
WEnd
Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)
Local Const $AC_SRC_ALPHA = 1
Local Const $ULW_ALPHA = 2
Local Const $LWA_ALPHA = 0x2
Local Const $LWA_COLORKEY = 0x1
If Not $isColorRef Then
$i_transcolor = Hex(String($i_transcolor), 6)
$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
If @error Then
Return SetError(@error, 0, 0)
ElseIf $Ret = 0 Then
Return SetError(4, 0, 0)
Else
Return 1
EndIf
EndFunc ;==>_API_SetLayeredWindowAttributes
Func _ResizeBitmap($sFile, $newW, $newH)
Local $oldImage, $GC, $newBmp, $newGC
; 加载图像
$oldImage = _GDIPlus_ImageLoadFromFile($sFile)
;创建新图像
$GC = _GDIPlus_ImageGetGraphicsContext($oldImage)
$newBmp = _GDIPlus_BitmapCreateFromGraphics($newW, $newH, $GC)
$newGC = _GDIPlus_ImageGetGraphicsContext($newBmp)
;绘制
_GDIPlus_GraphicsDrawImageRect($newGC, $oldImage, 0, 0, $newW, $newH)
;Clenaup
_GDIPlus_GraphicsDispose($GC)
_GDIPlus_GraphicsDispose($newGC)
_GDIPlus_ImageDispose($oldImage)
Return $newBmp
EndFunc ;==>_ResizeBitmap
Func jihuo($dm)
EndFunc ;==>jihuo
Func OnAutoItExit()
If IsDeclared("WS_EX_COMPOSITED") Then ;如果脚本没有关闭_Singleton
_GDIPlus_ImageDispose($NormalImage)
_GDIPlus_ImageDispose($NormalImage_Small)
_GDIPlus_ImageDispose($NormalImage_Exit)
_GDIPlus_ImageDispose($OverImage)
_GDIPlus_ImageDispose($OverImage_Small)
_GDIPlus_ImageDispose($OverImage_Exit)
_GDIPlus_ImageDispose($PressedImage)
_GDIPlus_ImageDispose($PressedImage_Small)
_GDIPlus_ImageDispose($PressedImage_Exit)
_GDIPlus_Shutdown()
WinActivate($LastActiveWindow)
DirRemove(@TempDir & "\essential2", 1)
Beep(1000, 50)
Beep(2000, 50)
Beep(500, 50)
EndIf
EndFunc ;==>OnAutoItExit
Func RunButton($ButtonNumber)
$BB = "网上股票交易系统5.0"
Switch $ButtonNumber
Case 1
$Text = ControlGetText("飞狐交易师 - ", "", 65281)
Sleep(100)
$dm = StringRight($Text, 6)
If Not WinActive($BB, "") Then WinActivate($BB, "")
WinWaitActive($BB, "")
$size = WinGetPos($BB)
Sleep(30)
Send("{F1}")
Sleep(50)
ControlSetText($BB, "", 1032, $dm);输入代码
Sleep(400)
$kemailiang = ControlGetText($BB, "", 1018)
If GUICtrlRead($Radio1) = 1 Then
$mailiang = Int($kemailiang / 400) * 100
EndIf
If GUICtrlRead($Radio2) = 1 Then
$mailiang = Int($kemailiang / 300) * 100
EndIf
If GUICtrlRead($Radio3) = 1 Then
$mailiang = Int($kemailiang / 200) * 100
EndIf
If GUICtrlRead($Radio4) = 1 Then
$mailiang = Int($kemailiang / 100) * 100
EndIf
ControlSetText($BB, "", 1034, $mailiang);输入买量
Case 2
$Text = ControlGetText("飞狐交易师 - ", "", 65281)
Sleep(100)
$dm = StringRight($Text, 6)
If Not WinActive($BB, "") Then WinActivate($BB, "")
WinWaitActive($BB, "")
$size = WinGetPos($BB)
Sleep(30)
Send("{F2}")
Sleep(50)
ControlSetText($BB, "", "", $dm);输卖代码
Sleep(400)
$kemailiang = ControlGetText($BB, "", "")
If GUICtrlRead($Radio1) = 1 Then
$mailiang = Int($kemailiang / 400) * 100
EndIf
If GUICtrlRead($Radio2) = 1 Then
$mailiang = Int($kemailiang / 300) * 100
EndIf
If GUICtrlRead($Radio3) = 1 Then
$mailiang = Int($kemailiang / 200) * 100
EndIf
If GUICtrlRead($Radio4) = 1 Then
$mailiang = Int($kemailiang / 100) * 100
EndIf
ControlSetText($BB, "", "", $mailiang);输卖买量
Case 3
$Text = ControlGetText("飞狐交易师 - ", "", 65281)
Sleep(100)
$dm = StringRight($Text, 6)
If Not WinActive($BB, "") Then WinActivate($BB, "")
WinWaitActive($BB, "")
$size = WinGetPos($BB)
Sleep(30)
Send("{F3}")
Sleep(800)
ControlClick($BB, "", "")
Case 4
$Text = ControlGetText("飞狐交易师 - ", "", 65281)
Sleep(100)
$dm = StringRight($Text, 6)
If Not WinActive($BB, "") Then WinActivate($BB, "")
WinWaitActive($BB, "")
$size = WinGetPos($BB)
Sleep(30)
Send("{F4}")
Sleep(800)
ControlClick($BB, "", "", "left", 1, 73, 100)
Case 5
If Not WinActive($BB, "") Then WinActivate($BB, "")
WinWaitActive($BB, "")
Send("{ENTER}")
Sleep(500)
Send("你的密码");激活用的
Send("{ENTER}")
Sleep(50)
Send("{F4}")
Case 6
Exit
EndSwitch
EndFunc ;==>RunButton
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap
Func _ImageDraw($State = "normal", $Case = ""); 利用为PNG图片
Local $hGraphic1, $hBitmap, $hGraphic2
Local $Image
;默认设置
For $i = 1 To 4
$Image[$i] = $NormalImage
Next
$Image = $NormalImage_Small
$Image = $NormalImage_Exit
;创建一个新的位图,这样,原来打开PNG是保持不变
$hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphic1)
$hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
; 绘制原 png 到我新创建的位图
Switch $State
Case "normal"
Case "pressed"
Switch $Case
Case 1 To 5
$Image[$Case] = $PressedImage
Case 6
$Image = $PressedImage_Exit
EndSwitch
Case "over"
Switch $Case
Case 1 To 5
$Image[$Case] = $OverImage
Case 6
$Image = $OverImage_Exit
EndSwitch
EndSwitch
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $bg, 3, 3, 160, 75)
For $i = 1 To 4
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[$i], 0, ($i - 1) * 41 + 80, 167, 57)
Next
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image, 3, 254, 111, 53)
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image, 107, 254, 57, 52)
;清理不再需要的资源
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_GraphicsDispose($hGraphic1)
;返回新的位图
Return $hBitmap
EndFunc ;==>_ImageDraw
先谢了.................. 坛里也找不到这样的窗口,提出来也可做个例子,让菜鸟们学习
请老师们费点心......... 去搜下论坛里的触边隐藏 太复杂了,还是看不懂,要不请老师帮我做一个纯净的滑动窗口吧,
只要一个窗口,不要在里面加任何东东 是挺麻烦的,有时间搞搞,以后自己也留用 还没人来啊?别人的贴都有高手帮忙而我的没有,看在我昨夜二点发贴的份上帮帮我吧
刚才源码区也跑完了,就没找到一个 回复 1# 紫色风林
随手写了一个,31行
回复紫色风林
随手写了一个,31行
tryhi 发表于 2011-6-27 17:34 http://www.autoitx.com/images/common/back.gif
太谢谢你了,非常感谢,
这个我应会搞了 太谢谢你了,非常感谢,
这个我应会搞了
紫色风林 发表于 2011-6-27 19:03 http://www.autoitx.com/images/common/back.gif
不过实用性还不强,只是很简单的单一功能,希望对你有帮助 海哥海量.... 海哥海量...... 我也收藏一下,谢谢
页:
[1]