Sign in to follow this  
Followers 0
Rad

Rads udf

2 posts in this topic

#1 ·  Posted (edited)

This include includes:

  • _ControlIsActive($vControl)

    Returns 1 if mouse is hovering over control

  • _ControlGetActive()

    Returns control mouse is hovering over

  • _WinGetWidth($sTitle[, $sText ])

    Get window width without using WinGetPos()

  • _WinGetHeight($sTitle[, $sText])

    Get window height without using WinGetPos()

  • _PanWindow($sTitle, [$sText[, $x]])

    Makes the window begin to follow the mouse until it is released (Supposed to *click* on a control to fire this)

  • _StringSlideLtoR($sString[, $sModifier = " "])

    Slides the first character of a string from the left, to the right

  • _StringSlideRtoL($sString[, $sModifier])

    Slides the first character of a string from the right, to the left

  • _StringSeed($sString[, $sSeed])

    Inserts the seed between every character in a string (ABDEF, * would return A*B*D*E*F)

  • _FileCountOccurrences($sFile[, $sString])

    Counts how many times a string appears in a file (One per line)

These arent very fancy, theres no DLLs or anything. It basically makes the thing easier to use. You dont have to create an array to find the width of a window... Or to find the control thats active...

You can use the control hover functions to make picture buttons, for my media player when you hover over play it turns orange, and when you click it presses in. It looks really good

Check out the example - Its not very explanitory but it shows what all the stuff does in 1 program

Unless theres a rule about UDF names, im just gonna use Rad as my misc.au3, since its already taken and I dont want to overwrite it... this is my first udf release :whistle:

#include-once

; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:       English
; Description:    Functions that return active controls and their state.
;
; ------------------------------------------------------------------------------


;===============================================================================
;
; Description:      Returns 1 if mouse is hovering over given control.
; Syntax:           _GUICtrlIsActive($vControl)
; Parameter(s):     $vControl - Variable returned by GUICtrlCreate functions
; Requirement(s):   Requires #Include <GUIConstants.au3>
; Return Value(s):  On Success - 1
;                   On Failure - 0
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          Very basic and simple function derived mostly from GUIGetCursorInfo().
;
;===============================================================================
Func _ControlIsActive($vControl)
    Local $temp
    $temp = GUIGetCursorInfo()
    If $vControl = $temp[4] Then 
        Return 1
    Else
        Return 0
    EndIf
EndFunc  


;===============================================================================
;
; Description:      Returns 1 if mouse is hovering over given control.
; Syntax:           _GUICtrlIsActive()
; Parameter(s):     None
; Requirement(s):   Requires #Include <GUIConstants.au3>
; Return Value(s):  On Success - Returns control ID (Compare to GUICtrlCreate variable)
;                   On Failure - 0
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          Very basic and simple function derived mostly from GUIGetCursorInfo().
;
;===============================================================================
Func _ControlGetActive()
    Local $temp
    $temp = GUIGetCursorInfo()
    Return $Temp[4]
EndFunc  


;===============================================================================
;
; Description:      Returns the width of given window.
; Syntax:           _WinGetWidth($sTitle [,$sText])
; Parameter(s):     $sTitle             - Title of the window
;                   $sText              - Text of the window
; Requirement(s):   None
; Return Value(s):  On Success - Returns the windows width
;                   On Failure - Returns -1
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          None
;
;===============================================================================
Func _WinGetWidth($sTitle, $sText = "")
    Local $temp
    $temp = WinGetPos($sTitle, $sText)
    Return $temp[2]
EndFunc


;===============================================================================
;
; Description:      Returns the width of given window.
; Syntax:           _WinGetWidth($sTitle [,$sText])
; Parameter(s):     $sTitle             - Title of the window
;                   $sText              - Text of the window
; Requirement(s):   None
; Return Value(s):  On Success - Returns the windows width
;                   On Failure - Returns -1
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          None
;
;===============================================================================
Func _WinGetHeight($sTitle, $sText = "")
    Local $temp
    $temp = WinGetPos($sTitle, $sText)
    Return $temp[3]
EndFunc


;===============================================================================
;
; Description:      Allows window to be panned around until mouse is released
; Syntax:           _PanWindow($sTitle, [$sText])
; Parameter(s):     $sTitle             - Title of the window
;                   $sText              - Text of the window
; Requirement(s):   Requires #Include <Misc.au3>
; Return Value(s):  None
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          None
;
;===============================================================================
Func _PanWindow($sTitle, $sText = "", $x = "0")
    Local $Mouse = MouseGetPos(), $Win = WinGetPos($sTitle, $sText), $Offset[2], $tempMouse, $tempWin
    $Offset[0] = $Mouse[0] - $Win[0]
    $Offset[1] = $Mouse[1] - $Win[1]
    Do
        Sleep(10)
        $tempMouse = MouseGetPos()
        WinMove($sTitle, $sText, $tempMouse[0] - $Offset[0], $tempMouse[1] - $Offset[1])
    Until _IsPressed("01") = 0 OR (_ControlIsActive($x) = 0 AND WinActive($sTitle, $sText) = 0)
    Return
EndFunc

;===============================================================================
;
; Description:      Allows window to be panned around until mouse is released
; Syntax:           _StringSlideLtoR($sString[, $sModifier])
; Parameter(s):     $sString            - The string to be adjusted
;                   $sModifier          - The string to be added in between split string
; Requirement(s):   None
; Return Value(s):  None
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          If the string is Rad, and the modifier is ":", it would return "ad:R"
;                   You can make it Marquee when your string is returned hole, then adding 
;                   a modifier, then looping without one until its whole again (With the modifier attached)
;===============================================================================
Func _StringSlideLtoR($sString, $sModifier = "")
    Local $sTemp
    $sTemp = StringLeft($sString,1)
    $sString = StringTrimLeft($sString, 1) & $sModifier & $sTemp
    Return $sString
EndFunc

;===============================================================================
;
; Description:      Allows window to be panned around until mouse is released
; Syntax:           _StringSlideRtoL($sString[, $sModifier])
; Parameter(s):     $sString            - The string to be adjusted
;                   $sModifier          - The string to be added in between split string (Default "")
; Requirement(s):   None
; Return Value(s):  None
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          If the string is Rad, and the modifier is ":", it would return "ad:R"
;                   You can make it Marquee when your string is returned hole, then adding 
;                   a modifier, then looping without one until its whole again (With the modifier attached)
;===============================================================================
Func _StringSlideRtoL($sString, $sModifier = "")
    Local $sTemp
    $sTemp = StringRight($sString,1)
    $sString = StringTrimRight($sString, 1) & $sModifier & $sTemp
    Return $sString
EndFunc

;===============================================================================
;
; Description:      Adds a character between every character in a string
; Syntax:           _StringSeed($sString[, $sSeed])
; Parameter(s):     $sString            - The string to be adjusted
;                   $sSeed              - String to be seeded between every character
; Requirement(s):   None
; Return Value(s):  None
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          String Rad with seed ":" would return: "R:a:d"
;
;===============================================================================
Func _StringSeed($sString, $sSeed = " ")
    Local $sTemp[StringLen($sString) + 1], $i
    For $i = 1 to StringLen($sString) -1
        $sTemp[$i] = StringMid($sString, $i,1)
    Next
    $sTemp[StringLen($sString)] = StringRight($sString,1)
    $sString = ""
    For $i = 0 to UBound($sTemp) - 1
        $sString = $sString & $sTemp[$i] & $sSeed
    Next
    $sString = StringTrimLeft($sString, 1)
    $sString = StringTrimRight($sString, 1)
    Return $sString
EndFunc

;===============================================================================
;
; Description:      Counts the number lines that contain a certain string in a file
; Syntax:           _FileCountOccurrences($sFile, $sString)
; Parameter(s):     $sFile              - File to be examined
;                   $sString            - String to be searched for
; Requirement(s):   None
; Return Value(s):  Success             - Returns number of occurences
;                   Failure             - Sets @error to 1 and returns 0
; Author(s):        Rad (RadleyGH at GMail dot com)
; Note(s):          None
;
;===============================================================================
Func _FileCountOccurrences($sFile, $sString)
    Local $data, $stringcount, $lines, $linecount, $i
    $data = FileRead($File, 1024)
    $stringcount = 0

    $lines = StringSplit($data, @lf)
    If IsArray($lines) Then
        $linecount = $lines[0]
    Else
        $linecount = 0
    Endif

    For $i = 1 to $linecount
        If StringinStr(FileReadLine($sFile, $i), $sString) Then
            $stringcount = $stringcount + 1
        EndIf
    Next
    If $StringCount > 0 Then
        Return $stringcount
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc

Rad.au3 goes in Beta\Include

Rads test.au3 is for testing obviously ;)

Rads_Test.au3

Rad.au3

Edited by Rad

Share this post


Link to post
Share on other sites



The slide from side to side is MUCH better to marquee with than the other method that I have seen on here. Just set a label with flag $SS_CENTERIMAGE and loop through this slide function and its relatively smooth and fast too. Less jumpy than the other one.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0