Jump to content

speed up the search


d0n
 Share

Recommended Posts

Hi i wrote a script to basically check if anyone is talking in ventrilo and if anyone is it will pause winamp, then continue it when someone is done talking.

However with a lot of people in the channel it will take a long time to search. Would there be a better way to do this?

#Include <GuiTreeView.au3>
#Include <GuiComboBoxEx.au3>
#include <Winamp_Library.au3>

Opt("WinTitleMatchMode", 2)
Global $Name, $Pause, $PauseON
$Pause = False

_ReduceMemory()

While 1
    If ProcessExists("Ventrilo.exe") > 0 AND ProcessExists("Winamp.exe") > 0 Then
        $Handle1 = ControlGetHandle("Ventrilo", "", "[CLASS:ComboBox; INSTANCE:1]")
        _GUICtrlComboBoxEx_GetItemText($Handle1, 0, $Name)

        $Handle2 = ControlGetHandle("Ventrilo", "", "[CLASS:SysTreeView32; INSTANCE:1]")

        $ChannelHandle = _GUICtrlTreeView_GetParentHandle($Handle2, _GUICtrlTreeView_FindItem($Handle2, $Name))
        $ChannelName = _GUICtrlTreeView_GetText($Handle2, _GUICtrlTreeView_GetParentHandle($Handle2, _GUICtrlTreeView_FindItem($Handle2, $Name)))
        $ChildCount = _GUICtrlTreeView_GetChildCount($Handle2, _GUICtrlTreeView_GetParentHandle($Handle2, _GUICtrlTreeView_FindItem($Handle2, $Name)))
    ;~  ConsoleWrite($ChildCount&":")
        If StringinStr($ChannelName, "AFK") > 0 Then
            ControlCommand("Ventrilo", "", '[CLASS:Button; INSTANCE:12]', 'Check')
            ControlCommand("Ventrilo", "", '[CLASS:Button; INSTANCE:11]', 'Check')
            Sleep(500)
        Else
            ControlCommand("Ventrilo", "", '[CLASS:Button; INSTANCE:12]', 'UnCheck')
            ControlCommand("Ventrilo", "", '[CLASS:Button; INSTANCE:11]', 'UnCheck')
            For $a = 0 to $ChildCount-1
                $ChildHandle = _GUICtrlTreeView_GetItemByIndex($Handle2, $ChannelHandle, $a)
        ;~      ConsoleWrite($ChildHandle)
                If _Winamp_GetCurrentTrackPlayStatus() = 1 OR $Pause = True Then
                    ;ICON IS RED
                    If _GUICtrlTreeView_GetImageIndex($Handle2, $ChildHandle) = 2 AND $Pause = True AND $PauseON = $a Then
                        _Winamp_Play()
            ;~          ConsoleWrite(_GUICtrlTreeView_GetText($Handle2, $ChildHandle)&"(-)")
                        $Pause = False
                    EndIf
                    ;ICON IS GREEN
                    If _GUICtrlTreeView_GetImageIndex($Handle2, $ChildHandle) = 3 AND $Pause = False Then
                        _Winamp_PlayPauseToggle()
            ;~          ConsoleWrite(_GUICtrlTreeView_GetText($Handle2, $ChildHandle)&"(+)")
                        $Pause = True
                        $PauseON = $a
                    EndIf
            ;~      ConsoleWrite("|")
                EndIf
                Sleep(50)
            Next
        ;~  ConsoleWrite(@LF)
        EndIf
        Sleep(200)
    EndIf
WEnd


Func _ReduceMemory($ProcID = 0)
; Original version : w_Outer
; modified by Rajesh V R to include process ID
    If $ProcID = 0 or ProcessExists($ProcID) = 0 Then ; No process id specified or process doesnt exist - use current process instead.
        Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
        $ProcID = $ai_GetCurrentProcessId[0]
    EndIf

    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Return $ai_Return[0]

EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...