Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/01/2016 in all areas

  1. Ah, another problem solved by asking the right questions, make the user think about it and letting him find the solution himself
    2 points
  2. Here is a UDF to easily apply that "snappy edge" effect to your GUI that you have probably seen on many programs. "Snappy" meaning anytime the boarder of your gui gets close to another windows boarder, or the desktop edges, your gui will automatically snap and align itself to that boarder. It is a very nice feature when it comes to aligning and resizeing your GUIs side by side. One problem that I still have to hammer out is what Style you use for your GUI. If you choose to make the GUI non sizeable, it will still work but you'll see the edges will overlap a little bit. There is some invisible boarder there that isnt acounted for when I get the gui width and height. I need to look at Getsystemmetrics. Im pretty sure the answer is there. Anyway plz take a look and tell me what you think. I love feed back or any new ideas. Thanks Updated 9/17/11: Automatic alignment to ALL visible windows now. Not just other Autoit windows. Also removed _WinSnap_RegisterMsgs() as it is not nessasary. Windows Msgs are automatically registered on startup. See UDF header for more details. Updated 5/31/11: Added new function _WinSnap_SetStyle() to configure what the window snaps to and to be able to enable/disable then snaps. Needed if you want to lock a window to another. WinSnap.html Previous Download:122 Note: The .html link is just to help me keep track of downloads. Open the .html file and a download dialog will display. Examples: UDF: #region Header ; #INDEX# ======================================================================================================================= ; Title .........: WinSnap ; AutoIt Version : 3.3.6.1 ; Language ......: English ; Description ...: Functions for making windows have "snap to" edges ; Author(s) .....: Beege ; Remarks........: This UDF registers windows msgs WM_MOVING, WM_ENTERSIZEMOVE, WS_WM_SIZING. If any of these msgs ; are registered in your script, your function must pass the msgs on to this UDF. Below are examples of the calls ; you will need to add if this is the case: ; ; Func WM_ENTERSIZEMOVE($hWndGUI, $MsgID, $wParam, $lParam) ; WS_WM_ENTERSIZEMOVE($hWndGUI, $MsgID, $wParam, $lParam) ; ;USER CODE; ; EndFunc ;==>WM_SIZING; ; ; Func WM_MOVING($hWndGUI, $MsgID, $wParam, $lParam) ; WS_WM_MOVING($hWndGUI, $MsgID, $wParam, $lParam) ; ;USER CODE; ; EndFunc ;==>WM_SIZING; ; ; Func WM_SIZING($hWndGUI, $MsgID, $wParam, $lParam) ; WS_WM_SIZING($hWndGUI, $MsgID, $wParam, $lParam) ; ;USER CODE; ; EndFunc ;==>WM_SIZING; ; ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _WinSnap_Set ; _WinSnap_SetStyle ; =============================================================================================================================== #include-once #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <WinAPI.au3> #endregion Header #region Global Varialbes ;~ Opt('MustDeclareVars', 1) Global Enum $g_iHwnd, $g_iStyle Global $g_aSnapGUIs[1][2] = [[0, 0]] #cs $g_aSnapGUIs[$i][$g_iHwnd] = Handle to window $g_aSnapGUIs[$i][$g_iStyle] = Style Flag #ce Global $g_iMouseDistancetoX, $g_iMouseDistancetoY Global $g_iDesktopHeight Global $g_bMovingStarted = False Global $g_iMonitorTotal Global Const $WS_WM_MOVING = 0x0216 Global Const $WS_WM_ENTERSIZEMOVE = 0x0231 GUIRegisterMsg($WS_WM_MOVING, "WS_WM_MOVING") GUIRegisterMsg($WS_WM_ENTERSIZEMOVE, 'WS_WM_ENTERSIZEMOVE') GUIRegisterMsg($WM_SIZING, 'WS_WM_SIZING') #endregion Global Varialbes #region Public functions ; #FUNCTION# ==================================================================================================== ; Name...........: _WinSnap_Set ; Description....: Sets window to have "snap to" edges ; Syntax.........: _WinSnap_Set($hGUI) ; Parameters.....: $hGUI - handle to window ; Return values..: Success - 1 ; Failure - 0 and sets @error ; Author.........: Beege ; Remarks........: None ; =============================================================================================================== Func _WinSnap_Set($hGUI) $g_aSnapGUIs[0][0] += 1 ReDim $g_aSnapGUIs[$g_aSnapGUIs[0][0] + 1][2] $g_aSnapGUIs[$g_aSnapGUIs[0][0]][$g_iHwnd] = $hGUI $g_aSnapGUIs[$g_aSnapGUIs[0][0]][$g_iStyle] = 3 Local $tRectMoving = DllStructCreate($tagRECT) _WinAPI_SystemParametersInfo(0x0030, 0, DllStructGetPtr($tRectMoving), 0);SPI_GETWORKAREA If @error Then Return SetError(1, 0, 0) $g_iDesktopHeight = DllStructGetData($tRectMoving, 'Bottom') $g_iMonitorTotal = _WinAPI_GetSystemMetrics(80);SM_CMONITORS If @error Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinSnap_Set ; #FUNCTION# ==================================================================================================== ; Name...........: _WinSnap_SetStyle ; Description....: Sets what the window will snap to. Desktop edges or Window edges ; Syntax.........: _WinSnap_SetStyle($hGUI, $iFlag) ; Parameters.....: $hGUI - Handle to window to set style ; $iFlag - Style Value: ; | 0 = No Snap at all ; | 1 = Snap to Desktop Edges ; | 2 = Snap to Other Autoit Windows ; | 3 = Snap to all (Defualt) ; Return values..: Success - Returns the value of the previous setting ; Failure - 0 and set @error to 1 ; Author.........: Beege ; =============================================================================================================== Func _WinSnap_SetStyle($hGUI, $iFlag) Local $iIndex = _GetIndex($hGUI) If Not $iIndex Then Return SetError(1, 0, 0) Local $iLast = $g_aSnapGUIs[$iIndex][$g_iStyle] $g_aSnapGUIs[$iIndex][$g_iStyle] = $iFlag Return $iLast EndFunc ;==>_WinSnap_SetStyle #endregion Public functions #region internel functions ; #FUNCTION# ==================================================================================================== ; Name...........: _GetIndex ; Description....: returns array index for handle ; Syntax.........: _GetIndex($hGUI) ; Parameters.....: $hGUI - handle to window ; Return values..: Success - array index for gui handle ; Failure - 0 ; Author.........: Beege ; =============================================================================================================== Func _GetIndex($hGUI) For $i = 1 To $g_aSnapGUIs[0][0] If $hGUI = $g_aSnapGUIs[$i][$g_iHwnd] Then Return $i Next Return 0 EndFunc ;==>_GetIndex ; #FUNCTION# ==================================================================================================== ; Name...........: WS_WM_ENTERSIZEMOVE ; Description....: Called when window begins to move. ; Syntax.........: WS_WM_ENTERSIZEMOVE($hWndGUI, $MsgID, $wParam, $lParam) ; Return values..: None ; Author.........: Beege ; =============================================================================================================== Func WS_WM_ENTERSIZEMOVE($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam, $lParam Local $pGUI1 = WinGetPos($hWndGUI) Local $aMousePos = MouseGetPos() $g_bMovingStarted = False $g_iMouseDistancetoX = $aMousePos[0] - $pGUI1[0] $g_iMouseDistancetoY = $pGUI1[1] - $aMousePos[1] EndFunc ;==>WS_WM_ENTERSIZEMOVE ; #FUNCTION# ==================================================================================================== ; Name...........: WS_WM_MOVING ; Description....: Called when a window is being moved ; Syntax.........: WS_WM_MOVING($hWndGUI, $MsgID, $wParam, $lParam) ; Return values..: None ; Author.........: Beege ; =============================================================================================================== Func WS_WM_MOVING($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam, $lParam Static $iStartW, $iStartH Local $iIndex = _GetIndex($hWndGUI) If Not $iIndex Then Return $GUI_RUNDEFMSG Local $tRectMoving = DllStructCreate($tagRECT, $lParam) If Not $g_bMovingStarted Then $g_bMovingStarted = True $iStartW = DllStructGetData($tRectMoving, 'Right') - DllStructGetData($tRectMoving, 'Left') $iStartH = DllStructGetData($tRectMoving, 'Bottom') - DllStructGetData($tRectMoving, 'Top') EndIf ;If window is snaped we need to monitor how much the mouse has moved ;from is original drag point position on the title bar. Local $aMousePos = MouseGetPos() Local $iChangeinX = Abs($aMousePos[0] - (DllStructGetData($tRectMoving, 'Left') + $g_iMouseDistancetoX)) Local $iChangeinY = Abs((DllStructGetData($tRectMoving, 'Top') - $aMousePos[1]) - $g_iMouseDistancetoY) Local $iTopMoving = DllStructGetData($tRectMoving, 'Top'), $iBottomMoving = DllStructGetData($tRectMoving, 'Bottom') Local $iLeftMoving = DllStructGetData($tRectMoving, 'Left'), $iRightMoving = DllStructGetData($tRectMoving, 'Right') #region Check if near desktop edges ;Check if style includes snaping to desktop edges If BitAND($g_aSnapGUIs[$iIndex][$g_iStyle], 1) Then For $i = 1 To $g_iMonitorTotal If _IsClose($iRightMoving, (@DesktopWidth * $i)) Then DllStructSetData($tRectMoving, 'Right', (@DesktopWidth * $i)) DllStructSetData($tRectMoving, 'Left', DllStructGetData($tRectMoving, 'Right') - $iStartW) EndIf Next For $i = 0 To $g_iMonitorTotal - 1 If _IsClose($iLeftMoving, (@DesktopWidth * $i)) Then DllStructSetData($tRectMoving, 'Left', (@DesktopWidth * $i)) DllStructSetData($tRectMoving, 'Right', DllStructGetData($tRectMoving, 'Left') + $iStartW) EndIf Next If _IsClose($iTopMoving, 0) Then DllStructSetData($tRectMoving, 'Top', 0) DllStructSetData($tRectMoving, 'Bottom', DllStructGetData($tRectMoving, 'Top') + $iStartH) EndIf If _IsClose($iBottomMoving, $g_iDesktopHeight) Then DllStructSetData($tRectMoving, 'Bottom', $g_iDesktopHeight) DllStructSetData($tRectMoving, 'Top', DllStructGetData($tRectMoving, 'Bottom') - $iStartH) EndIf If _IsClose($iBottomMoving, @DesktopHeight) Then DllStructSetData($tRectMoving, 'Bottom', @DesktopHeight) DllStructSetData($tRectMoving, 'Top', DllStructGetData($tRectMoving, 'Bottom') - $iStartH) EndIf ;Here we check if the mouse has moved from original drag point. if it has we unsnap the window If $iChangeinX > 20 Then DllStructSetData($tRectMoving, 'Left', $aMousePos[0] - $g_iMouseDistancetoX) DllStructSetData($tRectMoving, 'Right', DllStructGetData($tRectMoving, 'Left') + $iStartW) EndIf If $iChangeinY > 15 Then DllStructSetData($tRectMoving, 'Top', $aMousePos[1] + $g_iMouseDistancetoY) DllStructSetData($tRectMoving, 'Bottom', DllStructGetData($tRectMoving, 'Top') + $iStartH) EndIf EndIf #endregion Check if near desktop edges #region Check if window in near other Autoit Windows Local $aWinlist = WinList() ;Check if style of window includes other Autoit Windows If BitAND($g_aSnapGUIs[$iIndex][$g_iStyle], 2) Then For $i = 1 To $aWinlist[0][0] If $aWinlist[$i][0] = '' Or $aWinlist[$i][1] = $hWndGUI Or Not _IsVisible($aWinlist[$i][1]) Then ContinueLoop Local $tRectNonMoving = _WinAPI_GetWindowRect($aWinlist[$i][1]) Local $iTopNonMoving = DllStructGetData($tRectNonMoving, 'Top'), $iBottomNonMoving = DllStructGetData($tRectNonMoving, 'Bottom') Local $iLeftNonMoving = DllStructGetData($tRectNonMoving, 'Left'), $iRightNonMoving = DllStructGetData($tRectNonMoving, 'Right') If $iTopMoving <= ($iBottomNonMoving + 5) And ($iBottomMoving + 5) >= $iTopNonMoving Then ;Gui1Right to Gui2Right If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iRightNonMoving) DllStructSetData($tRectMoving, 'Left', DllStructGetData($tRectMoving, 'Right') - $iStartW) EndIf ;Gui1Left to Gui2left If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iLeftNonMoving) DllStructSetData($tRectMoving, 'Right', DllStructGetData($tRectMoving, 'Left') + $iStartW) EndIf ;Gui1Left to Gui2Right If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iRightNonMoving) DllStructSetData($tRectMoving, 'Right', DllStructGetData($tRectMoving, 'Left') + $iStartW) EndIf ;Gui1Right to Gui2Left If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iLeftNonMoving) DllStructSetData($tRectMoving, 'Left', DllStructGetData($tRectMoving, 'Right') - $iStartW) EndIf EndIf If ($iLeftMoving <= $iRightNonMoving + 5) And ($iRightMoving + 5 >= $iLeftNonMoving) Then ;gui1top to gui2top If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iTopNonMoving) DllStructSetData($tRectMoving, 'Bottom', DllStructGetData($tRectMoving, 'Top') + $iStartH) EndIf ;~ gui1top to gui2bottom If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iBottomNonMoving) DllStructSetData($tRectMoving, 'Bottom', DllStructGetData($tRectMoving, 'Top') + $iStartH) EndIf ;gui1bottom to gui2bottom If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iBottomNonMoving) DllStructSetData($tRectMoving, 'Top', DllStructGetData($tRectMoving, 'Bottom') - $iStartH) EndIf ;gui1bottom to gui2top If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iTopNonMoving) DllStructSetData($tRectMoving, 'Top', DllStructGetData($tRectMoving, 'Bottom') - $iStartH) EndIf EndIf ;Here we check if the mouse has moved from original drag point. if it has we unsnap the window If $iChangeinX > 20 Then DllStructSetData($tRectMoving, 'Left', $aMousePos[0] - $g_iMouseDistancetoX) DllStructSetData($tRectMoving, 'Right', DllStructGetData($tRectMoving, 'Left') + $iStartW) EndIf If $iChangeinY > 15 Then DllStructSetData($tRectMoving, 'Top', $aMousePos[1] + $g_iMouseDistancetoY) DllStructSetData($tRectMoving, 'Bottom', DllStructGetData($tRectMoving, 'Top') + $iStartH) EndIf Next EndIf #endregion Check if window in near other Autoit Windows Return $GUI_RUNDEFMSG EndFunc ;==>WS_WM_MOVING ; #FUNCTION# ==================================================================================================== ; Name...........: WS_WM_SIZING ; Description....: Called when a window is being sized ; Syntax.........: WS_WM_SIZING($hWndGUI, $MsgID, $wParam, $lParam) ; Return values..: None ; Author.........: Beege ; =============================================================================================================== Func WS_WM_SIZING($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam, $lParam If Not _GetIndex($hWndGUI) Then Return $GUI_RUNDEFMSG Local $tRectMoving = DllStructCreate($tagRECT, $lParam) Local $iLeftMoving = DllStructGetData($tRectMoving, 'Left'), $iRightMoving = DllStructGetData($tRectMoving, 'Right') Local $iTopMoving = DllStructGetData($tRectMoving, 'Top'), $iBottomMoving = DllStructGetData($tRectMoving, 'Bottom') #region check if resizing near desktop edge Switch $wParam Case 6; bottom edge If _IsClose($iBottomMoving, $g_iDesktopHeight) Then DllStructSetData($tRectMoving, 'Bottom', $g_iDesktopHeight) Case 7; bottom Left corner If _IsClose($iBottomMoving, $g_iDesktopHeight) Then DllStructSetData($tRectMoving, 'Bottom', $g_iDesktopHeight) If _IsClose($iLeftMoving, @DesktopWidth) Then DllStructSetData($tRectMoving, 'Left', @DesktopWidth) If _IsClose($iLeftMoving, 0) Then DllStructSetData($tRectMoving, 'Left', 0) Case 1; left If _IsClose($iLeftMoving, @DesktopWidth) Then DllStructSetData($tRectMoving, 'Left', @DesktopWidth) If _IsClose($iLeftMoving, 0) Then DllStructSetData($tRectMoving, 'Left', 0) Case 2; right If _IsClose($iRightMoving, @DesktopWidth) Then DllStructSetData($tRectMoving, 'Right', @DesktopWidth) ElseIf _IsClose($iRightMoving, @DesktopWidth * 2) Then DllStructSetData($tRectMoving, 'Right', (@DesktopWidth * 2)) EndIf Case 8; bottom right If _IsClose($iBottomMoving, $g_iDesktopHeight) Then DllStructSetData($tRectMoving, 'Bottom', $g_iDesktopHeight) If _IsClose($iRightMoving, @DesktopWidth) Then DllStructSetData($tRectMoving, 'Right', @DesktopWidth) ElseIf _IsClose($iRightMoving, @DesktopWidth * 2) Then DllStructSetData($tRectMoving, 'Right', (@DesktopWidth * 2)) EndIf Case 3; top If _IsClose($iTopMoving, 0) Then DllStructSetData($tRectMoving, 'Top', 0) Case 4; top left If _IsClose($iTopMoving, 0) Then DllStructSetData($tRectMoving, 'Top', 0) If _IsClose($iLeftMoving, @DesktopWidth) Then DllStructSetData($tRectMoving, 'Left', @DesktopWidth) Case 5; top right If _IsClose($iRightMoving, @DesktopWidth) Then DllStructSetData($tRectMoving, 'Right', @DesktopWidth) ElseIf _IsClose($iRightMoving, @DesktopWidth * 2) Then DllStructSetData($tRectMoving, 'Right', (@DesktopWidth * 2)) EndIf If _IsClose($iTopMoving, 0) Then DllStructSetData($tRectMoving, 'Top', 0) EndSwitch #endregion check if resizing near desktop edge #region Check if resizing near other windows Local $aWinlist = WinList() For $i = 1 To $aWinlist[0][0] If $aWinlist[$i][0] = '' Or $aWinlist[$i][1] = $hWndGUI Or Not _IsVisible($aWinlist[$i][1]) Then ContinueLoop Local $tRectNonMoving = _WinAPI_GetWindowRect($aWinlist[$i][1]) Local $iLeftNonMoving = DllStructGetData($tRectNonMoving, 'Left'), $iRightNonMoving = DllStructGetData($tRectNonMoving, 'Right') Local $iTopNonMoving = DllStructGetData($tRectNonMoving, 'Top'), $iBottomNonMoving = DllStructGetData($tRectNonMoving, 'Bottom') Switch $wParam Case 6; bottom edge If ($iLeftMoving <= $iRightNonMoving + 5) And ($iRightMoving + 5 >= $iLeftNonMoving) Then If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iBottomNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iTopNonMoving) EndIf Case 7; bottom Left corner If ($iLeftMoving <= $iRightNonMoving + 5) And ($iRightMoving + 5 >= $iLeftNonMoving) Then If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iLeftNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iRightNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iBottomNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iTopNonMoving) EndIf Case 1; left If $iTopMoving <= ($iBottomNonMoving + 5) And ($iBottomMoving + 5) >= $iTopNonMoving Then If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iLeftNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iRightNonMoving) EndIf Case 2; right If $iTopMoving <= ($iBottomNonMoving + 5) And ($iBottomMoving + 5) >= $iTopNonMoving Then If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iRightNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iLeftNonMoving) EndIf Case 8; bottom right If ($iLeftMoving <= $iRightNonMoving + 5) And ($iRightMoving + 5 >= $iLeftNonMoving) Then If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iBottomNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Bottom'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Bottom', $iTopNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iRightNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iLeftNonMoving) EndIf Case 3; top If ($iLeftMoving <= $iRightNonMoving + 5) And ($iRightMoving + 5 >= $iLeftNonMoving) Then If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iBottomNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iTopNonMoving) EndIf Case 4; top left If ($iLeftMoving <= $iRightNonMoving + 5) And ($iRightMoving + 5 >= $iLeftNonMoving) Then If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iBottomNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iTopNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iLeftNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Left'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Left', $iRightNonMoving) If _IsClose($iLeftMoving, 0) Then DllStructSetData($tRectMoving, 'Left', 0) EndIf Case 5; top right If ($iLeftMoving <= $iRightNonMoving + 5) And ($iRightMoving + 5 >= $iLeftNonMoving) Then If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iBottomNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iBottomNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Top'), $iTopNonMoving) Then DllStructSetData($tRectMoving, 'Top', $iTopNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iRightNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iRightNonMoving) If _IsClose(DllStructGetData($tRectMoving, 'Right'), $iLeftNonMoving) Then DllStructSetData($tRectMoving, 'Right', $iLeftNonMoving) EndIf EndSwitch Next #endregion Check if resizing near other windows Return $GUI_RUNDEFMSG EndFunc ;==>WS_WM_SIZING ; #FUNCTION# ==================================================================================================== ; Name...........: _IsClose ; Description....: Tests if Position a is near Postion b ; Syntax.........: _IsClose($a, $b) ; Parameters.....: $a - Position 1 ; $b - Position 2 ; Return values..: True/False ; Author.........: Beege ; =============================================================================================================== Func _IsClose($a, $b) Return (Abs($a - $b) < 15) EndFunc ;==>_IsClose #endregion internel functions Func _IsVisible($handle) Return (BitAND(WinGetState($handle), 2) = 2) EndFunc ;==>_IsVisible
    1 point
  3. Dhilip89

    HTML Entity UDF

    Hello, I just made an UDF for Encoding/Decoding the string and HTML Entity Number. HTML.au3: #include-once #include <Array.au3> Dim $Entity[65536] $Entity[34] = "quot" $Entity[38] = "amp" $Entity[39] = "apos" $Entity[60] = "lt" $Entity[62] = "gt" $Entity[160] = "nbsp" $Entity[161] = "iexcl" $Entity[162] = "cent" $Entity[163] = "pound" $Entity[164] = "curren" $Entity[165] = "yen" $Entity[166] = "brvbar" $Entity[167] = "sect" $Entity[168] = "uml" $Entity[169] = "copy" $Entity[170] = "ordf" $Entity[171] = "laquo" $Entity[172] = "not" $Entity[173] = "shy" $Entity[174] = "reg" $Entity[175] = "macr" $Entity[176] = "deg" $Entity[177] = "plusmn" $Entity[178] = "sup2" $Entity[179] = "sup3" $Entity[180] = "acute" $Entity[181] = "micro" $Entity[182] = "para" $Entity[183] = "middot" $Entity[184] = "cedil" $Entity[185] = "sup1" $Entity[186] = "ordm" $Entity[187] = "raquo" $Entity[188] = "frac14" $Entity[189] = "frac12" $Entity[190] = "frac34" $Entity[191] = "iquest" $Entity[192] = "Agrave" $Entity[193] = "Aacute" $Entity[194] = "Acirc" $Entity[195] = "Atilde" $Entity[196] = "Auml" $Entity[197] = "Aring" $Entity[198] = "AElig" $Entity[199] = "Ccedil" $Entity[200] = "Egrave" $Entity[201] = "Eacute" $Entity[202] = "Ecirc" $Entity[203] = "Euml" $Entity[204] = "Igrave" $Entity[205] = "Iacute" $Entity[206] = "Icirc" $Entity[207] = "Iuml" $Entity[208] = "ETH" $Entity[209] = "Ntilde" $Entity[210] = "Ograve" $Entity[211] = "Oacute" $Entity[212] = "Ocirc" $Entity[213] = "Otilde" $Entity[214] = "Ouml" $Entity[215] = "times" $Entity[216] = "Oslash" $Entity[217] = "Ugrave" $Entity[218] = "Uacute" $Entity[219] = "Ucirc" $Entity[220] = "Uuml" $Entity[221] = "Yacute" $Entity[222] = "THORN" $Entity[223] = "szlig" $Entity[224] = "agrave" $Entity[225] = "aacute" $Entity[226] = "acirc" $Entity[227] = "atilde" $Entity[228] = "auml" $Entity[229] = "aring" $Entity[230] = "aelig" $Entity[231] = "ccedil" $Entity[232] = "egrave" $Entity[233] = "eacute" $Entity[234] = "ecirc" $Entity[235] = "euml" $Entity[236] = "igrave" $Entity[237] = "iacute" $Entity[238] = "icirc" $Entity[239] = "iuml" $Entity[240] = "eth" $Entity[241] = "ntilde" $Entity[242] = "ograve" $Entity[243] = "oacute" $Entity[244] = "ocirc" $Entity[245] = "otilde" $Entity[246] = "ouml" $Entity[247] = "divide" $Entity[248] = "oslash" $Entity[249] = "ugrave" $Entity[250] = "uacute" $Entity[251] = "ucirc" $Entity[252] = "uuml" $Entity[253] = "yacute" $Entity[254] = "thorn" $Entity[255] = "yuml" $Entity[338] = "OElig" $Entity[339] = "oelig" $Entity[352] = "Scaron" $Entity[353] = "scaron" $Entity[376] = "Yuml" $Entity[402] = "fnof" $Entity[710] = "circ" $Entity[732] = "tilde" $Entity[913] = "Alpha" $Entity[914] = "Beta" $Entity[915] = "Gamma" $Entity[916] = "Delta" $Entity[917] = "Epsilon" $Entity[918] = "Zeta" $Entity[919] = "Eta" $Entity[920] = "Theta" $Entity[921] = "Iota" $Entity[922] = "Kappa" $Entity[923] = "Lambda" $Entity[924] = "Mu" $Entity[925] = "Nu" $Entity[926] = "Xi" $Entity[927] = "Omicron" $Entity[928] = "Pi" $Entity[929] = "Rho" $Entity[931] = "Sigma" $Entity[932] = "Tau" $Entity[933] = "Upsilon" $Entity[934] = "Phi" $Entity[935] = "Chi" $Entity[936] = "Psi" $Entity[937] = "Omega" $Entity[945] = "alpha" $Entity[946] = "beta" $Entity[947] = "gamma" $Entity[948] = "delta" $Entity[949] = "epsilon" $Entity[950] = "zeta" $Entity[951] = "eta" $Entity[952] = "theta" $Entity[953] = "iota" $Entity[954] = "kappa" $Entity[955] = "lambda" $Entity[956] = "mu" $Entity[957] = "nu" $Entity[958] = "xi" $Entity[959] = "omicron" $Entity[960] = "pi" $Entity[961] = "rho" $Entity[962] = "sigmaf" $Entity[963] = "sigma" $Entity[964] = "tau" $Entity[965] = "upsilon" $Entity[966] = "phi" $Entity[967] = "chi" $Entity[968] = "psi" $Entity[969] = "omega" $Entity[977] = "thetasym" $Entity[978] = "upsih" $Entity[982] = "piv" $Entity[8194] = "ensp" $Entity[8195] = "emsp" $Entity[8201] = "thinsp" $Entity[8204] = "zwnj" $Entity[8205] = "zwj" $Entity[8206] = "lrm" $Entity[8207] = "rlm" $Entity[8211] = "ndash" $Entity[8212] = "mdash" $Entity[8216] = "lsquo" $Entity[8217] = "rsquo" $Entity[8218] = "sbquo" $Entity[8220] = "ldquo" $Entity[8221] = "rdquo" $Entity[8222] = "bdquo" $Entity[8224] = "dagger" $Entity[8225] = "Dagger" $Entity[8226] = "bull" $Entity[8230] = "hellip" $Entity[8240] = "permil" $Entity[8242] = "prime" $Entity[8243] = "Prime" $Entity[8249] = "lsaquo" $Entity[8250] = "rsaquo" $Entity[8254] = "oline" $Entity[8260] = "frasl" $Entity[8364] = "euro" $Entity[8465] = "image" $Entity[8472] = "weierp" $Entity[8476] = "real" $Entity[8482] = "trade" $Entity[8501] = "alefsym" $Entity[8592] = "larr" $Entity[8593] = "uarr" $Entity[8594] = "rarr" $Entity[8595] = "darr" $Entity[8596] = "harr" $Entity[8629] = "crarr" $Entity[8656] = "lArr" $Entity[8657] = "uArr" $Entity[8658] = "rArr" $Entity[8659] = "dArr" $Entity[8660] = "hArr" $Entity[8704] = "forall" $Entity[8706] = "part" $Entity[8707] = "exist" $Entity[8709] = "empty" $Entity[8711] = "nabla" $Entity[8712] = "isin" $Entity[8713] = "notin" $Entity[8715] = "ni" $Entity[8719] = "prod" $Entity[8721] = "sum" $Entity[8722] = "minus" $Entity[8727] = "lowast" $Entity[8730] = "radic" $Entity[8733] = "prop" $Entity[8734] = "infin" $Entity[8736] = "ang" $Entity[8743] = "and" $Entity[8744] = "or" $Entity[8745] = "cap" $Entity[8746] = "cup" $Entity[8747] = "int" $Entity[8756] = "there4" $Entity[8764] = "sim" $Entity[8773] = "cong" $Entity[8776] = "asymp" $Entity[8800] = "ne" $Entity[8801] = "equiv" $Entity[8804] = "le" $Entity[8805] = "ge" $Entity[8834] = "sub" $Entity[8835] = "sup" $Entity[8836] = "nsub" $Entity[8838] = "sube" $Entity[8839] = "supe" $Entity[8853] = "oplus" $Entity[8855] = "otimes" $Entity[8869] = "perp" $Entity[8901] = "sdot" $Entity[8968] = "lceil" $Entity[8969] = "rceil" $Entity[8970] = "lfloor" $Entity[8971] = "rfloor" $Entity[9001] = "lang" $Entity[9002] = "rang" $Entity[9674] = "loz" $Entity[9824] = "spades" $Entity[9827] = "clubs" $Entity[9829] = "hearts" $Entity[9830] = "diams" ;=============================================================================== ; ; Function Name: _HTMLEncode() ; Description: Encode the normal string into HTML Entity Number ; Parameter(s): $String - The string you want to encode. ; ; Requirement(s): AutoIt v3.2.4.9 or higher (Unicode) ; Return Value(s): On Success - Returns HTML Entity Number ; On Failure - Nothing ; ; Author(s): Dhilip89 ; ;=============================================================================== Func _HTMLEncode($Str) $StrLen = StringLen($Str) Local $Encoded If $StrLen = 0 Then Return '' For $i = 1 To $StrLen $StrChar = StringMid($Str, $i, 1) $Encoded &= '&#' & AscW($StrChar) & ';' Next Return $Encoded EndFunc ;==>_HTMLEncode ;=============================================================================== ; ; Function Name: _HTMLDecode() ; Description: Decode the HTML Entity Number into normal string ; Parameter(s): $HTMLEntityNum - The HTML Entity Number you want to decode. ; ; Requirement(s): AutoIt v3.2.4.9 or higher (Unicode) ; Return Value(s): On Success - Returns decoded strings ; On Failure - Nothing ; ; Author(s): Dhilip89 ; ;=============================================================================== Func _HTMLDecode($Str) Local $Decoded If $Str = '' Then Return '' $X1 = StringRegExp($Str, '&#x(.*?);', 3) $X2 = StringRegExp($Str, '&#(.*?);', 3) $X3 = StringRegExp($Str, '&(.*?);', 3) For $i = 0 To UBound($X1) - 1 Step 1 $Str = StringReplace($Str, '&#x' & $X1[$i] & ';', ChrW(Dec($X1[$i]))) Next For $i = 0 To UBound($X2) - 1 Step 1 $Str = StringReplace($Str, '&#' & $X2[$i] & ';', ChrW($X2[$i])) Next For $i = 0 To UBound($X3) - 1 Step 1 $Str = StringReplace($Str, '&' & $X3[$i] & ';', ChrW(_ArraySearch($Entity, $X3[$i], 0, 0, 1))) Next $Decoded = $Str Return $Decoded EndFunc ;==>_HTMLDecode Download: HTML.au3
    1 point
  4. A Beep music made by me Enjoy ! ;################################################### ; Mario Bros Theme ( Beep Music )################### ;################################################### ;###################### by J0keR ################## ;################################################### Beep(480,200); Beep(1568,200); Beep(1568,200); Beep(1568,200); Beep(739.99,200); Beep(783.99,200); Beep(783.99,200); Beep(783.99,200); Beep(369.99,200); Beep(392,200); Beep(369.99,200); Beep(392,200); Beep(392,400); Beep(196,400); Beep(739.99,200); Beep(783.99,200); Beep(783.99,200); Beep(739.99,200); Beep(783.99,200); Beep(783.99,200); Beep(739.99,200); Beep(83.99,200); Beep(880,200); Beep(830.61,200); Beep(880,200); Beep(987.77,400); Beep(880,200); Beep(783.99,200); Beep(698.46,200); Beep(739.99,200); Beep(783.99,200); Beep(783.99,200); Beep(739.99,200); Beep(783.99,200); Beep(783.99,200); Beep(739.99,200); Beep(783.99,200); Beep(880,200); Beep(830.61,200); Beep(880,200); Beep(987.77,400); Sleep(200); Beep(1108,10); Beep(1174.7,200); Beep(1480,10); Beep(1568,200); Sleep(200); Beep(739.99,200); Beep(783.99,200); Beep(783.99,200); Beep(739.99,200); Beep(783.99,200); Beep(783.99,200); Beep(739.99,200); Beep(783.99,200); Beep(880,200); Beep(830.61,200); Beep(880,200); Beep(987.77,400); Beep(880,200); Beep(783.99,200); Beep(698.46,200); Beep(659.25,200); Beep(698.46,200); Beep(784,200); Beep(880,400); Beep(784,200); Beep(698.46,200); Beep(659.25,200); Beep(587.33,200); Beep(659.25,200); Beep(698.46,200); Beep(784,400); Beep(698.46,200); Beep(659.25,200); Beep(587.33,200); Beep(523.25,200); Beep(587.33,200); Beep(659.25,200); Beep(698.46,400); Beep(659.25,200); Beep(587.33,200); Beep(493.88,200); Beep(523.25,200); Sleep(400); Beep(349.23,400); Beep(392,200); Beep(329.63,200); Beep(523.25,200); Beep(493.88,200); Beep(466.16,200); Beep(440,200); Beep(493.88,200); Beep(523.25,200); Beep(880,200); Beep(493.88,200); Beep(880,200); Beep(1760,200); Beep(440,200); Beep(392,200); Beep(440,200); Beep(493.88,200); Beep(783.99,200); Beep(440, 200); Beep(783.99,200); Beep(1568,200); Beep(392,200); Beep(349.23,200); Beep(392,200); Beep(440,200); Beep(698.46,200); Beep(415.2,200); Beep(698.46,200); Beep(1396.92,200); Beep(349.23,200); Beep(329.63,200); Beep(311.13,200); Beep(329.63,200); Beep(659.25,200); Beep(698.46,400); Beep(783.99,400); Beep(440,200); Beep(493.88,200); Beep(523.25,200); Beep(880,200); Beep(493.88,200); Beep(880,200); Beep(1760,200); Beep(440,200); Beep(392,200); Beep(440,200); Beep(493.88,200); Beep(783.99,200); Beep(440,200); Beep(783.99,200); Beep(1568,200); Beep(392,200); Beep(349.23,200); Beep(392,200); Beep(440,00); Beep(698.46,200); Beep(659.25,200); Beep(698.46,200); Beep(739.99,200); Beep(783.99,200); Beep(392,200); Beep(392,200); Beep(392,200); Beep(392,200); Beep(196,200); Beep(196,200); Beep(196,200); Beep(185,200); Beep(196,200); Beep(185,200); Beep(196,200); Beep(207.65,200); Beep(220,200); Beep(233.08,200); Beep(246.94,200);
    1 point
  5. Sturmi, Not at all - I am always happy to look at a problem with any of my code. And in this case you appear to have found a really good one! I will look into it and let you know what I find. M23 Edit: Solved it! You were overwriting the standard extended styles, one of which is $LVS_EX_FULLROWSELECT and without which you cannot detect clicks on anything other then the first column. So create your ListView like this: $List1 = GUICtrlCreateListView("Data|Your Info", 8, 8, 241, 357) _GUICtrlListView_SetExtendedListViewStyle($List1, BitOr($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) Note the use of _GUICtrlListView_SetExtendedListViewStyle - always best to use that as there can be confusion between certain $LVS_EX_* and $WS_EX_* styles if you set them in the GUICtrlCreateListView command.
    1 point
  6. RegiOween, I find it "kinda sad" that after having been a member here for over 10 years you could not find a solution which took me about 10 minutes to produce: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> HotKeySet("{ESC}", "_Exit") Local $hDLL = DllOpen("user32.dll") GUICreate("", 0, 0, 0, 0) GUISetState() GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL") While 1 Sleep(10) WEnd Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $iDelta = BitShift($wParam, 16) ; Mouse wheel movement If _IsPressed("5B", $hDLL) Then ; If Left Win pressed <<<<<<<<<<<<<< If $iDelta > 0 Then ConsoleWrite("Down" & @CRLF) Else ConsoleWrite("Up" & @CRLF) EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_MOUSEWHEEL Func _Exit() Exit EndFunc And not a "mouse hooks, dll call" in sight..... By the way, at the moment it only works for the left Win key - adding the right Win key I leave as "an exercise for the student", as my old maths teacher used to say. M23
    1 point
  7. #1 is ok #2 works only if there is nothing before/after $sData2 #3 and #4 are fantasy There is no need to overcomplicate/overload the pattern $sData = '<a href="/url?q=https://www.autoitscript.com/trial2/&amp;sa=U' & @CRLF & '<a href="/url?q=https://www.autoitscript.com/trial2/&amp;sa=U' $var = StringRegExp($sData, 'http[^&]+', 3) _ArrayDisplay($var)
    1 point
  8. spudw2k

    SubnetCalc [working]

    Project has gone from incomplete to working for anyone whom this may be useful too. See first post.
    1 point
  9. Sturmi, Take a look at this post. M23 P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.
    1 point
  10. Sturmi, Not too difficult to fix: #include <GUIConstantsEx.au3> #include <Array.au3> #include <GUIListViewEx.au3> $hGUI2 = GUICreate("Form1", 258, 442, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 8, 384, 243, 25) $List1 = GUICtrlCreateListView("Col 1|Col 2", 8, 8, 241, 357) GUICtrlCreateListViewItem("test1|test2", $List1) $Label2 = GUICtrlCreateLabel("Label2", 8, 416, 36, 17) GUISetState(@SW_SHOW) ; Read ListView content into an array $aContent = _GUIListViewEx_ReadToArray($List1) ; Initiate ListView $iLV_Index = _GUIListViewEx_Init($List1, $aContent) ; Set column 1 as editable _GUIListViewEx_SetEditStatus($iLV_Index, 1) ; Register required messages _GUIListViewEx_MsgRegister() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Read content of ListView $aReadContent = _GUIListViewEx_ReturnArray($iLV_Index) ; Display content _ArrayDisplay($aReadContent, "ListView", Default, 8) EndSwitch ; Allow ListView editing _GUIListViewEx_EditOnClick() WEnd Might I suggest reading the guide to the UDF that I added to the zip file which explains in some detail how to use it. M23
    1 point
  11. Inpho, Not only do you have to delete all the items in the ListView, you need to remove it from the UDF and then re-initialise it as explained in this post from the previous UDF thread. That way you purge the original shadow array and the UDF will then sort the new one. Let me know if that does not work and let me see the code you used. bourny, Looking into the matter - but as I will have to write all the code myself it might take a while (hint: provide your own reproducer script and things go faster). M23
    1 point
  12. No problem @kcvinu, Feel free to PM or Chat with me if you encounter any problems regarding automating things . I have put a fair amount of effort on researching them when I was working on one of my early UDFs .
    1 point
  13. UEZ

    StringRegExp receive data?

    #include <Array.au3> $sData = '<a href="/url?q=https://www.autoitscript.com/trial2/&amp;sa=U' & @CRLF & '<a href="/url?q=https://www.autoitscript.com/trial2/&amp;sa=U' $var = StringRegExp($sData, '(?i).*=(http.+)\&.*', 3) _ArrayDisplay($var)
    1 point
  14. @kcvinu Source: https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine Good luck
    1 point
  15. HI kcvinu! Yeah that are good ideas...but i have to say that this will not happen. As i started with the ISN there was this clean seperation of the ISN itselfe and the form studio. (Yeah if i began from start...i would make it different..) To implement these feautes this would be so many work...i think it would be better to totally rewrite the ISN (or/and the formstudio). I will not say it will never happen, but do not get too much hope.
    1 point
  16. Look man I'm just trying to help. We don't know what the op is even trying to do, we haven't seen the full code. How can you be so sure stuff doesn't work when you don't know what the op is trying to do. For all we know, he might be trying to automate a Java based speed test. We just don't know so don't be so sure. Everything is case by case, some stuff works, others dont. Sorry if you don't like my opinion.
    1 point
  17. I use code like this to increase the windows volume to 100% Switch @OSVersion Case "WIN_VISTA", "WIN_7" Run("sndvol.exe", "", @SW_HIDE) Case "WIN_XP" Run("sndvol32.exe", "", @SW_HIDE) EndSwitch WinWaitActive("Volume Mixer") ControlSend("Volume Mixer", "", "msctls_trackbar321", "{HOME}") ; Max system volume WinClose("Volume Mixer")
    1 point
×
×
  • Create New...