• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • HB Relog Supporter - VBA Spreadsheet

    Discussion in 'Plugins' started by Dubzie, Nov 18, 2014.

    1. Dubzie

      Dubzie New Member

      Joined:
      Oct 22, 2012
      Messages:
      58
      Likes Received:
      0
      Trophy Points:
      0
      So some of my dungeon profiles like to get my character stuck in the dungeon server and i can login to that character till it times out.
      HB relog will get stuck on "waiting for wow to start" so i made this VBA script that i run from an Excel Spreadsheet
      Every 5 mins it will check to see if both HB and Wow are open, if HB isnt it closes wow so HB relog can open them again.

      I didnt want to upload the spreadsheet because of macro security ext :)

      Put this in a module:
      Code:
      Option Explicit
       
      Private Declare Function OpenProcess Lib "kernel32" ( _
          ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
          
      Private Declare Function CloseHandle Lib "kernel32" ( _
          ByVal hObject As Long) As Long
       
      Private Declare Function EnumProcesses Lib "PSAPI.DLL" ( _
         lpidProcess As Long, ByVal cb As Long, cbNeeded As Long) As Long
       
      Private Declare Function EnumProcessModules Lib "PSAPI.DLL" ( _
          ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long
       
      Private Declare Function GetModuleBaseName Lib "PSAPI.DLL" Alias "GetModuleBaseNameA" ( _
          ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
       
      Private Const PROCESS_VM_READ = &H10
      Private Const PROCESS_QUERY_INFORMATION = &H400
      Type PROCESSENTRY32
          dwSize As Long
          cntUsage As Long
          th32ProcessID As Long
          th32DefaultHeapID As Long
          th32ModuleID As Long
          cntThreads As Long
          th32ParentProcessID As Long
          pcPriClassBase As Long
          dwFlags As Long
          szexeFile As String * 260
      End Type
      '-------------------------------------------------------
      
      Declare Function ProcessFirst Lib "kernel32.dll" Alias "Process32First" (ByVal hSnapshot As Long, _
      uProcess As PROCESSENTRY32) As Long
      
      Declare Function ProcessNext Lib "kernel32.dll" Alias "Process32Next" (ByVal hSnapshot As Long, _
      uProcess As PROCESSENTRY32) As Long
      
      Declare Function CreateToolhelpSnapshot Lib "kernel32.dll" Alias "CreateToolhelp32Snapshot" ( _
      ByVal lFlags As Long, lProcessID As Long) As Long
      
      Declare Function TerminateProcess Lib "kernel32.dll" (ByVal ApphProcess As Long, _
      ByVal uExitCode As Long) As Long
      
      
       
      Private Function IsProcessRunning(ByVal sProcess As String) As Boolean
          Const MAX_PATH As Long = 260
          Dim lProcesses() As Long, lModules() As Long, N As Long, lRet As Long, hProcess As Long
          Dim sName As String
          
          sProcess = UCase$(sProcess)
          
          ReDim lProcesses(1023) As Long
          If EnumProcesses(lProcesses(0), 1024 * 4, lRet) Then
              For N = 0 To (lRet \ 4) - 1
                  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, lProcesses(N))
                  If hProcess Then
                      ReDim lModules(1023)
                      If EnumProcessModules(hProcess, lModules(0), 1024 * 4, lRet) Then
                          sName = String$(MAX_PATH, vbNullChar)
                          GetModuleBaseName hProcess, lModules(0), sName, MAX_PATH
                          sName = Left$(sName, InStr(sName, vbNullChar) - 1)
                          If Len(sName) = Len(sProcess) Then
                              If sProcess = UCase$(sName) Then IsProcessRunning = True: Exit Function
                          End If
                      End If
                  End If
                  CloseHandle hProcess
              Next N
          End If
      End Function
      '-------------------------------------------------------
      
      '-------------------------------------------------------
      
      Public Sub KillProcess(NameProcess As String)
      Const PROCESS_ALL_ACCESS = &H1F0FFF
      Const TH32CS_SNAPPROCESS As Long = 2&
      Dim uProcess  As PROCESSENTRY32
      Dim RProcessFound As Long
      Dim hSnapshot As Long
      Dim SzExename As String
      Dim ExitCode As Long
      Dim MyProcess As Long
      Dim AppKill As Boolean
      Dim AppCount As Integer
      Dim i As Integer
      Dim WinDirEnv As String
              
             If NameProcess <> "" Then
                AppCount = 0
      
                uProcess.dwSize = Len(uProcess)
                hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
                RProcessFound = ProcessFirst(hSnapshot, uProcess)
        
                Do
                  i = InStr(1, uProcess.szexeFile, Chr(0))
                  SzExename = LCase$(Left$(uProcess.szexeFile, i - 1))
                  WinDirEnv = Environ("Windir") + "\"
                  WinDirEnv = LCase$(WinDirEnv)
              
                  If Right$(SzExename, Len(NameProcess)) = LCase$(NameProcess) Then
                     AppCount = AppCount + 1
                     MyProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
                     AppKill = TerminateProcess(MyProcess, ExitCode)
                     Call CloseHandle(MyProcess)
                  End If
                  RProcessFound = ProcessNext(hSnapshot, uProcess)
                Loop While RProcessFound
                Call CloseHandle(hSnapshot)
             End If
      
      End Sub
      Public Sub CheckWow()
          If IsProcessRunning("wow.exe") = True Then
              If IsProcessRunning("honorbuddy.exe") = False Then
                  KillProcess ("wow.exe")
              End If
          End If
          
          
          Sheet1.Cells(1, 1) = Now
          Application.OnTime Now + TimeValue("00:5:00"), "CheckWow"
          
      End Sub
      Put this in the workbook:
      Code:
      Private Sub Workbook_Open()
      Application.OnTime Now + TimeValue("00:5:00"), "CheckWow"
      End Sub
      
       
    2. asdrubal

      asdrubal New Member

      Joined:
      Jun 6, 2013
      Messages:
      25
      Likes Received:
      1
      Trophy Points:
      0
      pretty neat work to get that working on an excel spreadsheet, you really should download visual studio and try to learn a bit/adapt into .net and get stuff going. it will make your life so much easier
      anyway thanks for sharing
       
    3. Dubzie

      Dubzie New Member

      Joined:
      Oct 22, 2012
      Messages:
      58
      Likes Received:
      0
      Trophy Points:
      0
      Yea thanks mate.

      I keep saying to myself that i should get it and learn it, but i've been coding VB for years, lol i couldnt even be bothered to download VB6 haha.
      At the end of the day it works XD

      I also have a spreadsheet that auto updates the AH Bot's prices from wowauction which i plan on releasing once i have it all locked down and easily configurable.
       

    Share This Page