CodyBarrett Posted May 22, 2009 Share Posted May 22, 2009 (edited) yeah.. ill just post the whole code here since when its finished it will be in the Examples forums anyway... im trying to make a Widgit type thing.. and having problems moving the controls if the mousepos is at a certain point expandcollapse popup#NoTrayIcon #include <Misc.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #Include <string.au3> #Include <Misc.au3> HotKeySet ('{ESC}', '_Exit_') HotKeySet ('+{DEL}', '_Show_TM_') Opt ('GUIoneventmode',1) $sName = @ScriptName Do $sName = StringTrimRight ($sName,1) Until StringRight ($sName, 1) = '.' $sName = StringTrimRight ($sName,1) $State = 'CPU:Win:Time' $hBkColor = '0xFFFFA2' $Gui = GUICreate ($sName, 200,400, -1, -1, -2138570616) GUISetBkColor ($hBkColor, $Gui) $lTitle = GUICtrlCreateLabel ($sName, 41, 1, 158,18, $SS_CENTER) GUICtrlSetOnEvent (-1, '_Win_Move_') GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) $lxTitle = GUICtrlCreateLabel ('x', 1, 1, 18,18, $SS_CENTER) GUICtrlSetOnEvent (-1, '_Exit_') GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) $lhTitle = GUICtrlCreateLabel ('?', 20, 1, 18,18, $SS_CENTER) GUICtrlSetOnEvent (-1, '_Help_') GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) dim $lWin[4] $lWin[0] = GUICtrlCreateLabel ('', 1, 121, 198,10, $SS_CENTER) $lWin[1] = GUICtrlCreateLabel ('', 1, 131, 8,168, $SS_CENTER) $lWin[2] = GUICtrlCreateLabel ('', 191, 131, 8,168, $SS_CENTER) $lWin[3] = GUICtrlCreateLabel ('', 9, 237, 189,62, $SS_CENTER) For $i = 0 To UBound ($lWin) -1 GUICtrlSetBkColor ($lWin[$i], 0x000000) GUICtrlSetFont ($lWin[$i], 60, '', '', 'Fixedsys') GUICtrlSetColor ($lWin[$i], 0xFFFFA2) GUICtrlSetOnEvent ($lWin[$i], '_Move_Win_') Next $lBkColor = GUICtrlCreateLabel ('BackGround Color', 10, 132, 180,20, $SS_CENTER) GUICtrlSetOnEvent (-1, '_BkColor_') GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) $tInput = GUICtrlCreateInput ($sName, 10, 153, 120, 20) GUICtrlSetState (-1, $GUI_DISABLE) $lCtrl = GUICtrlCreateLabel ('[+]-OFF', 131, 153, 59, 20) GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) GUICtrlSetState (-1, $GUI_DISABLE) $Slider = GUICtrlCreateSlider (10, 174, 180, 20) GUICtrlSetLimit (-1, 250, 50) GUICtrlSetData (-1, 250) $lHide = GUICtrlCreateLabel ('Hide', 10, 195, 89, 20, $SS_CENTER) GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) GUICtrlSetOnEvent (-1, '_Hide_') $lUnHide = GUICtrlCreateLabel ('UnHide', 100, 195, 90, 20, $SS_CENTER) GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) GUICtrlSetOnEvent (-1, '_Un_Hide_') $lWinList = GUICtrlCreateLabel ('Window List', 10, 216, 180, 20, $SS_CENTER) GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 10, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) GUICtrlSetOnEvent (-1, '_Win_List_') $lStatus = GUICtrlCreateLabel ('', 1, 22, 198,98, $SS_CENTER) GUICtrlSetOnEvent (-1, '_Move_Status_') GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 60, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit_',$Gui) $lTime = GUICtrlCreateLabel ('', 1, 301, 198,98, $SS_CENTER) GUICtrlSetOnEvent (-1, '_Move_Time_') GUICtrlSetBkColor (-1, 0x000000) GUICtrlSetFont (-1, 60, '', '', 'Fixedsys') GUICtrlSetColor (-1, 0xFFFFA2) GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit_',$Gui) GUISetState() WinSetTrans ($Gui, '', 100) WinSetOnTop ($Gui, '', 1) Run(@SystemDir & '\taskmgr.exe', '', @SW_HIDE) While 1 $iStatus = StatusbarGetText ('Windows Task Manager', '', 2) GUICtrlSetData ($lStatus, StringTrimLeft ($iStatus, 10)) If @HOUR > 12 Then $ihTime = @HOUR - 12 $ihTime = _StringInsert ($ihTime, 'PM', 1) Else If StringLeft (@HOUR, 1) = 0 Then $ihTime = StringTrimLeft (@HOUR, 1) Else $ihTime = @HOUR EndIf $ihTime = _StringInsert ($ihTime, 'AM', 1) EndIf $iTime = $ihTime & ':' & @MIN GUICtrlSetData ($lTime, $iTime) If _IsPressed ('6B') Then Do $wAtitle = WinGetTitle ('[active]', '') GUICtrlSetData ($tInput, $wAtitle) Until Not _IsPressed ('6B') EndIf WinSetTrans (GUICtrlRead ($tInput), '', GUICtrlRead ($Slider)) Sleep (300) If Not ProcessExists ('Taskmgr.exe') Then Run(@SystemDir & '\taskmgr.exe', '', @SW_HIDE) WEnd Func _BkColor_ () $iColor = _ChooseColor (2, 0, 1, $GUI) If Not @error Then GUISetBkColor ($iColor, $Gui) $hBkColor = $iColor EndIf EndFunc Func _Hide_ () If GUICtrlRead ($tInput) <> $sName Then WinSetState (GUICtrlRead ($tInput), '', @SW_HIDE) EndFunc Func _Un_Hide_ () WinSetState (GUICtrlRead ($tInput), '', @SW_SHOW) EndFunc Func _Help_ () MsgBox (32, 'Help', 'HotKeys :' & @CRLF & _ '[ESC] OR "x" tto Close it.' & _ '[CTRL]&[DEL] to show the taskmanager.', '', $GUI) EndFunc Func _Win_Move_ () $MouseXY = MouseGetPos () $WinXY = WinGetPos ($Gui) $xOff = $MouseXY[0] - $WinXY[0] $yOFF = $MouseXY[1] - $WinXY[1] While _IsPressed ('01') WinMove ($Gui, '',MouseGetPos (0) - $xOff ,MouseGetPos (1) - $yOFF) Sleep (100) WEnd EndFunc Func _Win_List_ () $List = WinList () $wList = '' For $i = 1 To UBound ($List, 1) - 1 If WinGetState ($List[$i][0],'') = 7 Then $wList &= $List[$i][0] & @CRLF Next MsgBox (0, 'Windows List', '' & $wList, '', $Gui) EndFunc Func _Move_Status_ () While _IsPressed ('01') $MouseXY = GUIGetCursorInfo ($Gui) ControlMove ($Gui, '', $lStatus, 1, $MouseXY[1], 198, 98) If $State = 'CPU:Win:Time' And $MouseXY[1] + 98 > 151 Then ControlMove ($Gui, '', $lWin[0], 1, 22, 198, 10) ControlMove ($Gui, '', $lWin[1], 1, 32, 8, 168) ControlMove ($Gui, '', $lWin[2], 191, 32, 8, 168) ControlMove ($Gui, '', $lWin[3], 9, 138, 189, 62) ControlMove ($Gui, '', $lBkColor, 10, 33, 180,20 ) ControlMove ($Gui, '', $tInput, 10, 54, 120, 20 ) ControlMove ($Gui, '', $lCtrl, 131, 54, 59, 20 ) ControlMove ($Gui, '', $Slider, 10, 75,180, 20) ControlMove ($Gui, '', $lHide,10, 96 ,89, 20 ) ControlMove ($Gui, '', $lUnHide,100, 96, 90, 20 ) ControlMove ($Gui, '', $lWinList,10, 117, 180, 20 ) ControlMove ($Gui, '', $lStatus, 1, 202, 198, 98) $State = 'Win:CPU:Time' ElseIf $State = 'Win:CPU:Time' And $MouseXY[1] < 151 Then ControlMove ($Gui, '', $lWin[0], 1, 121, 198, 10) ControlMove ($Gui, '', $lWin[1], 1, 131, 8, 168) ControlMove ($Gui, '', $lWin[2], 191, 131, 8, 168) ControlMove ($Gui, '', $lWin[3], 9, 237, 189, 62) ControlMove ($Gui, '', $lBkColor, 10, 122, 180,20 ) ControlMove ($Gui, '', $tInput, 10, 143, 120, 20 ) ControlMove ($Gui, '', $lCtrl, 131, 143, 59, 20 ) ControlMove ($Gui, '', $Slider, 10, 164,180, 20) ControlMove ($Gui, '', $lHide,10, 185 ,89, 20 ) ControlMove ($Gui, '', $lUnHide,100, 185, 90, 20 ) ControlMove ($Gui, '', $lWinList,10, 205, 180, 20 ) ControlMove ($Gui, '', $lStatus, 1, 226, 198, 98) $State = 'CPU:Win:Time' ElseIf $State = 'Win:CPU:Time' And $MouseXY[1] + 98 > 301 Then ControlMove ($Gui, '', $lTime, 1, 202, 198, 98) ControlMove ($Gui, '', $lStatus, 1, 301, 198, 98) $State = 'Win:Time:CPU' ElseIf $State = 'Win:Time:CPU' And $MouseXY[1] + 98 < 301 Then ControlMove ($Gui, '', $lTime, 1, 301, 198, 98) ControlMove ($Gui, '', $lStatus, 1, 202, 198, 98) $State = 'Win:CPU:Time' EndIf WEnd If $State = 'CPU:Win:Time' Then ControlMove ($Gui, '', $lStatus, 1, 22, 198, 98) ElseIf $State = 'CPU:Time:Win' Then ControlMove ($Gui, '', $lStatus, 1, 22, 198, 98) ElseIf $State = 'Time:Win:CPU' Then ControlMove ($Gui, '', $lStatus, 1, 301, 198, 98) ElseIf $State = 'Time:CPU:Win' Then ControlMove ($Gui, '', $lStatus, 1, 121, 198, 98) ElseIf $State = 'Win:Time:CPU' Then ControlMove ($Gui, '', $lStatus, 1, 301, 198, 98) ElseIf $State = 'Win:CPU:Time' Then ControlMove ($Gui, '', $lStatus, 1, 202, 198, 98) EndIf EndFunc Func _Move_Time_ () While _IsPressed ('01') $MouseXY = GUIGetCursorInfo ($Gui) ControlMove ($Gui, '', $lTime, 1, $MouseXY[1], 198, 98) If $State = 'CPU:Win:Time' And $MouseXY[1] < 100 Then ControlMove ($Gui, '', $lTime, 1, 22, 198, 98) ControlMove ($Gui, '', $lStatus, 1, 301, 198, 98) $State = 'Time:Win:CPU' ElseIf $State = 'Time:Win:CPU' And $MouseXY[1] + 98 >= 301 Then ControlMove ($Gui, '', $lTime, 1, 301, 198, 98) ControlMove ($Gui, '', $lStatus, 1, 22, 198, 98) $State = 'CPU:Win:Time' EndIf WEnd If $State = 'CPU:Win:Time' Then ControlMove ($Gui, '', $lTime, 1, 301, 198, 98) If $State = 'CPU:Time:Win' Then ControlMove ($Gui, '', $lTime, 1, 121, 198, 98) If $State = 'Time:Win:CPU' Then ControlMove ($Gui, '', $lTime, 1, 22, 198, 98) If $State = 'Time:CPU:Win' Then ControlMove ($Gui, '', $lTime, 1, 22, 198, 98) If $State = 'Win:Time:CPU' Then ControlMove ($Gui, '', $lTime, 1, 121, 198, 98) If $State = 'Win:CPU:Time' Then ControlMove ($Gui, '', $lTime, 1, 301, 198, 98) EndFunc Func _Move_Win_ () EndFunc Func _Show_TM_ () WinSetState ('Windows Task Manager', '', @SW_SHOW) EndFunc Func _Exit_ () ProcessClose ("TaskMgr.exe") Exit EndFunc so far i only have the CPU usage completed.. and its not very goodlooking is there an easyer way i can do this.. maybe with a math formula? Edited May 22, 2009 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
picea892 Posted May 22, 2009 Share Posted May 22, 2009 Oh another Canuck....I'm in Timmins Ontario. I think you mean the whole window......right? Anyways, here is a script you can use to move your widget around. Easy and effective. Your sleep(300) should be fine. If you find it jumping lower your sleep expandcollapse popup; Move any Window - Click & Drag ; Author Valuater Run("notepad.exe") WinWaitActive("") While WinExists("Untitled -") _WinMove("Untitled -") Sleep(10) WEnd ;=============================================================================== ; ; Description: Moves any Window by Left Mouse "Click & Drag" ; Syntax: _WinMove($hWnd) or _WinMove($s_Title) ; Parameter(s): $s_hWnd = as returned by GUICreate() ; $s_Title = title of window to be moved ; Requirement(s): None ; Return Value(s): On Success - Repositions the Window ; On Failure - Returns "" ; Author(s): Valuater, Valuater [at] aol [.com], Inspired by Martin ; ;=============================================================================== Func _WinMove($hWnd) If Not WinActive($hWnd) Then Return Local $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x1') If @error Or BitAND($a_R[0], 0x8000) <> 0x8000 Then Return Local $a = WinGetPos($hWnd), $b = MouseGetPos() If $b[0] < $a[0] Or $b[1] < $a[1] Or $b[0] > $a[2] + $a[0] Or $b[1] > $a[3] + $a[1] Then Return While WinActive($hWnd) Local $c = MouseGetPos() WinMove($hWnd, '', $a[0] + $c[0] - $b[0], $a[1] + $c[1] - $b[1]) $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x1') If @error Or BitAND($a_R[0], 0x8000) <> 0x8000 Then Return WEnd EndFunc ;==>_WinMove Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 22, 2009 Author Share Posted May 22, 2009 Thank you for the reply and the code.. but its not my problem...i can move the window around perfectly... my problems is that moving the CONTROLS in the window... like there are 3 groups... #1 a clock.. #2 a CPU meter (cheating i know) #3 various window functions... before when i had the clock and the cpu movable it was perfect.. but when i added the third group... a group of.. about...9 controls in it.. and moving them makes it flicker... and jump around making the GUI look ugly.. and i can't seem to find a coordinate that works :\ any other help? [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now