visnja Posted July 12, 2013 Share Posted July 12, 2013 why cant i drag it? and i switched in guigetmsg() $GUI_EVENT_PRIMARYDOWN ? expandcollapse popup#include <SendMessage.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> timer() Func timer() global $sb=0 , $sl=0 ,$mb=0 , $ml=0 ,$hl=0 ,$hb=0 ,$text ="00:00:00" Global Const $SC_DRAGMOVE = 0xF012 Local $iHeight= 60, $iWidth = 200 Local $hGUI = GUICreate('', $iWidth, $iHeight, Default, Default, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) GUISetBkColor(0x000000) WinSetTrans($hGUI, "", 170) GUICtrlCreateGroup('', 0, -5, $iWidth, $iHeight + 5, $WS_THICKFRAME) GUICtrlCreateGroup('', -99, -99, 1, 1) Global $Label1 = GUICtrlCreateLabel($text, 5, 0, 190, 60, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetFont(-1, 20, 700, 2, "DINPro-Regular") GUICtrlSetColor(-1, 0x00FF00) GUISetState(@SW_SHOW, $hGUI) While 1 Global $h = $hb & $hl , $m = $mb & $ml ,$s = $sb & $sl,$text = $h&":"&$m&":"&$s upd() sleep(1000) $sl= $sl + 1 if $sl = 10 Then $sl = 0 $sb = $sb +1 EndIf If $sb = 6 Then $sb = 0 $ml = $ml +1 EndIf If $ml = 10 Then $ml = 0 $mb = $mb +1 EndIf If $mb = 6 Then $mb = 0 $hl = $hl +1 EndIf if $hl = 10 Then $hl = 0 $hb = $hb +1 EndIf if $hb = 24 Then $h=$m=$s=0 EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch WEnd GUIDelete($hGUI) EndFunc func upd() GUICtrlSetData($Label1,$text) EndFunc Link to comment Share on other sites More sharing options...
AZJIO Posted July 12, 2013 Share Posted July 12, 2013 (edited) Digital Clock expandcollapse popup#include <SendMessage.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $sb = 0, $sl = 0, $mb = 0, $ml = 0, $hl = 0, $hb = 0, $text = "00:00:00" Global Const $SC_DRAGMOVE = 0xF012 Global $h, $m, $s, $text, $Label1 timer() Func timer() Local $iHeight = 60, $iWidth = 200 Local $hGUI = GUICreate('', $iWidth, $iHeight, -1, -1, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) GUISetBkColor(0x000000) WinSetTrans($hGUI, "", 170) GUICtrlCreateGroup('', 0, -5, $iWidth, $iHeight + 5, $WS_THICKFRAME) GUICtrlCreateGroup('', -99, -99, 1, 1) $Label1 = GUICtrlCreateLabel($text, 5, 0, 190, 60, BitOR($SS_CENTER, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 20, 700, 2, "DINPro-Regular") ; ??? GUICtrlSetColor(-1, 0x00FF00) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST') While 1 $h = $hb & $hl $m = $mb & $ml $s = $sb & $sl $text = $h & ":" & $m & ":" & $s upd() Sleep(1000) ; + GUIGetMsg() <> Good $sl = $sl + 1 If $sl = 10 Then $sl = 0 $sb = $sb + 1 EndIf If $sb = 6 Then $sb = 0 $ml = $ml + 1 EndIf If $ml = 10 Then $ml = 0 $mb = $mb + 1 EndIf If $mb = 6 Then $mb = 0 $hl = $hl + 1 EndIf If $hl = 10 Then $hl = 0 $hb = $hb + 1 EndIf If $hb = 24 Then $h = 0 $m = 0 $s = 0 EndIf ; Switch GUIGetMsg() ; Case $GUI_EVENT_CLOSE ; Exit ; Case $GUI_EVENT_PRIMARYDOWN ; _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) ; EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>timer Func upd() GUICtrlSetData($Label1, $text) EndFunc ;==>upd Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam) Local $iProc = DllCall('user32.dll', 'int', 'DefWindowProc', 'hwnd', $hWnd, 'int', _ $Msg, 'wparam', $wParam, 'lparam', $lParam) ; ToolTip($iProc[0]&@CRLF&$HTCLIENT&@CRLF&$HTCAPTION&@CRLF&BitAND($lParam, 0xFFFF) &@CRLF&BitShift($lParam, 16)) ; просмотр возвращаемых параметров If $iProc[0] = $HTCLIENT Then Return $HTCAPTION Return $GUI_RUNDEFMSG EndFunc ;==>WM_NCHITTEST Edited July 12, 2013 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
visnja Posted July 12, 2013 Author Share Posted July 12, 2013 thanks AZJIO ~visnja Link to comment Share on other sites More sharing options...
PhoenixXL Posted July 14, 2013 Share Posted July 14, 2013 (edited) The event didn't respond because you used Sleep(1000), it should not be more than 10ms. with WM_NCHITTEST as posted by AZJIO your update process would be blocked as soon as the user starts dragging since Autoit hidden window can't process two commands at the same time. Edited July 14, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
PhoenixXL Posted July 14, 2013 Share Posted July 14, 2013 (edited) Have a look - Stopwatch stops when the user starts dragging expandcollapse popup#include <SendMessage.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> ;better to declare Globals outside the script Global $iLabel, $iHour, $iMin, $iSec, $iTimer Global Const $SC_DRAGMOVE = 0xF012 timer() Func timer() Local $iWidth = 200, $iHeight = 60 Local $hWin = GUICreate('', $iWidth, $iHeight, -1, -1, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) GUISetBkColor(0x000000) WinSetTrans($hWin, "", 170) GUICtrlCreateGroup('', 0, -5, $iWidth, $iHeight + 5, $WS_THICKFRAME) GUICtrlCreateGroup('', -99, -99, 1, 1) $iLabel = GUICtrlCreateLabel("00:00:00", 5, 0, 190, 60, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 20, 700, 2, "DINPro-Regular") GUICtrlSetColor(-1, 0x00FF00) GUISetState() ;we can create a better neat and short stopwatch using Timers. $iTimer = TimerInit() AdlibRegister("_UpdateStopWatch", 1000) Do Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hWin, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch Until $nMsg = $GUI_EVENT_CLOSE AdlibUnRegister("_UpdateStopWatch") EndFunc ;==>timer ; call back function Func _UpdateStopWatch() _TicksToTime(TimerDiff($iTimer), $iHour, $iMin, $iSec) GUICtrlSetData($iLabel, StringFormat("%02d:%02d:%02d",$iHour , $iMin , $iSec)) EndFunc ;==>_UpdateStopWatch To enable the update process simultaneously with that of the drag we would have to use timer associated with the current window, since Autoit is single threaded expandcollapse popup#include <SendMessage.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <Timers.au3> ;better to declare Globals outside the script Global $iLabel, $iHour, $iMin, $iSec, $iTimer Global Const $SC_DRAGMOVE = 0xF012 timer() Func timer() Local $iWidth = 200, $iHeight = 60 Local $hWin = GUICreate('', $iWidth, $iHeight, -1, -1, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) GUISetBkColor(0x000000) WinSetTrans($hWin, "", 170) GUICtrlCreateGroup('', 0, -5, $iWidth, $iHeight + 5, $WS_THICKFRAME) GUICtrlCreateGroup('', -99, -99, 1, 1) $iLabel = GUICtrlCreateLabel("00:00:00", 5, 0, 190, 60, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 20, 700, 2, "DINPro-Regular") GUICtrlSetColor(-1, 0x00FF00) GUISetState() ;we can create a better neat and short stopwatch using Timers. $iTimer = TimerInit() _Timer_SetTimer($hWin, 1000, "_UpdateStopWatch") Do Sleep(10) $nMsg = GUIGetMsg() _TicksToTime(TimerDiff($iTimer), $iHour, $iMin, $iSec) Switch $nMsg Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hWin, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch Until $nMsg = $GUI_EVENT_CLOSE _Timer_KillAllTimers($hWin) EndFunc ;==>timer ; call back function Func _UpdateStopWatch($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime _TicksToTime(TimerDiff($iTimer), $iHour, $iMin, $iSec) GUICtrlSetData($iLabel, StringFormat("%02d:%02d:%02d", $iHour, $iMin, $iSec)) EndFunc ;==>_UpdateStopWatch Regards Edited July 14, 2013 by PhoenixXL nybegblya 1 My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. 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