• Visit Rebornbuddy
  • [VBS] Simple Anti-AFK script, supporting single/multiple WoW instances

    Discussion in 'Uncataloged' started by Corleone, Dec 16, 2013.

    1. Corleone

      Corleone Well-Known Member

      Joined:
      May 24, 2013
      Messages:
      2,255
      Likes Received:
      28
      Trophy Points:
      48
      A simple method to implement an anti AFK behavior with Windows standard applications
      is running a VBScript in the background as a Windows process.
      This always works without stressing one or more Honorbuddy processes by reducing
      their CPU/FPS load, because it is completely independent from HB.

      Q: How to run the Anti-AFK script

      A: Copy the script into a text editor and adjust the "step left" and "step right" keys
      to your needs (short instruction on top of the script).
      After that, save the script with the extension "something.VBS" to your harddisk.

      Now start your WoW.
      You are ready to start Anti-AFK by a double-click on your VBS file now. That's all.

      The script terminates itself after the last WoW instance has been closed and the actual
      executed time lapse expired.
      Otherwise you can terminate the process by opening your taskmanager and kill wscript.exe.

      Q: What does the script do?

      A: After each time lapse, the script brings the (stacked) WoW window(s) on top and lets your
      toon step left-right for about 1 millisecond.
      This ist almost not detectable (makes 1 or 2 pixels) and surely not as conspicious
      than making a jump or other funny contortions.

      Q: This script doesn't work on my PC

      A: First you have to check, if your Windows has Windows Scripting Host (WSH) installed,
      which should be delivered with Windows by default.
      Open START -> Run, write wscript.exe into the input field and then hit OK.
      If a "WSH Options" window opens, everything is ok.
      Otherwise install Windows Script from Microsoft:
      Windows Script 5.6 aus dem Microsoft Download Center herunterladen.


      This script is designed for fishing. It's not tested for other purposes, but should work likewise for idling around.
      However, you should better terminate the script before fighting in dungeons for example, because the steps may cancel your spell casts.


      Have fun. ;)


      Code:
      ' Anti-AFK for single or multiple WoW sessions
      ' --------------------------------------------
      ' coded by Corleone, 12/2013
      ' 
      ' Assign 2 keys of your choice in WoW for sideward moving to the left and to the right,
      ' or use your already predefined keys.
      ' Alter those keys in the user config section below (in quotation marks!) as described:
      '
      ' i.e. "A" for left, "D" for right, 
      ' or as presetted here as an example "%{left}" = ALT+left arrow, "%{right}" = ALT+right arrow
      '
      ' Special keys are SHIFT = +, CTRL = ^, ALT = %
      ' Non-ASCII keys have to be enclosed in curly brackets { }, i.e. "^{F12}" for CTRL-F12
      ' You can find more keycodes here: http://msdn.microsoft.com/en-us/library/8c6yea83
      '
      ' This VBS script accepts a numeric value of milliseconds as start parameter for the repetition time.
      ' Default value is 200000 milliseconds if no parameter is passed.
      ' The script closes automatically when no more WoW instances are running and the iteration expires.
      
      
      On Error Resume Next
      
      ' ########################### begin user config
      strStepLeft = "%{left}"
      strStepRight = "%{right}"
      ' ########################### end user config
      
      Set WshShell = Wscript.CreateObject("WScript.Shell")
      Set args = WScript.Arguments
      num = args.Count
      if num = 0 then
        n = 200000
      else
        n =  args(0)
      end if
      
      strComputer = "."
      strExeName = "Wow.exe"
      
      Do
        Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
        Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")
        numCount = 0
        For Each objProcess in colProcessList
          If Instr(1, objProcess.Name, strExeName) then
            numCount = numCount + 1
          End If
        Next
        If numCount = 0 then
          Exit Do
        End If
          
        For Each objProcess in colProcessList
          colPID = objProcess.processID
          colName = objProcess.Name
          
          If Instr(1, colName, strExeName) then
            WshShell.AppActivate colPID
            WshShell.sendkeys strStepLeft
            WshShell.sendkeys strStepRight
          End If
        Next  
          Wscript.sleep n
      Loop
      
      MsgBox "No running WoW instance found. Terminating AntiAFK now.",0,"AntiAFK VBS"
       
      Last edited: Sep 28, 2015
      cevaps likes this.
    2. cevaps

      cevaps New Member

      Joined:
      Jul 26, 2013
      Messages:
      176
      Likes Received:
      1
      Trophy Points:
      0
      Hey it works really good! Thanks much man! It uses just 1.7MB memory, better than any plugin, lol.
       
    3. Corleone

      Corleone Well-Known Member

      Joined:
      May 24, 2013
      Messages:
      2,255
      Likes Received:
      28
      Trophy Points:
      48
      No problem, hope you enjoy it.

      The only issue with using VBS "SendKeys" function is that the NUMLOCK key will be deactivated (LED off) after the script ends.
      But this is a loooooong known Microsoft bug, that has never been fixed. There's no workaround for it, because it can only be reactivated
      per software with a PC restart (except, of course, you can push the NUMLOCK manually to be reactivated).

      So don't worry about that. ;)
       
    4. fabi229

      fabi229 Member

      Joined:
      Nov 4, 2014
      Messages:
      97
      Likes Received:
      0
      Trophy Points:
      6
      AWESOME script! Thank you mate!


      Actually, it doesn't work '-'
       
      Last edited: Nov 19, 2014
    5. mginster

      mginster New Member

      Joined:
      Aug 28, 2012
      Messages:
      124
      Likes Received:
      0
      Trophy Points:
      0
      FYI - If you are running the 64-bit wow you need to edit "Wow.exe" to "Wow-64.exe"
       
    6. Corleone

      Corleone Well-Known Member

      Joined:
      May 24, 2013
      Messages:
      2,255
      Likes Received:
      28
      Trophy Points:
      48
      FYI - unfortunately HB doesn't bind on x64 WoW. :p

      If you have problems with starting x86 and x64 WoW, simply delete all files containing "64" in your WoW folder
      and start WoW.exe directly, not via BN launcher.
      If the BN launcher detects the absence of the 64er files, it restores them... not good for us. ;)
       
      Last edited: Nov 25, 2014
    7. mrdej

      mrdej New Member

      Joined:
      Mar 13, 2015
      Messages:
      2
      Likes Received:
      0
      Trophy Points:
      0
      More simple Anti AFK solution





      I am using MouseMove App and it solved the AFK problem easily :)

      https://www.youtube.com/watch?v=2-AWaYnvFW0
       
    8. mrdej

      mrdej New Member

      Joined:
      Mar 13, 2015
      Messages:
      2
      Likes Received:
      0
      Trophy Points:
      0
    9. Corleone

      Corleone Well-Known Member

      Joined:
      May 24, 2013
      Messages:
      2,255
      Likes Received:
      28
      Trophy Points:
      48
      Oh please, don't lose touch with reality.

      Most used mice are laser mice these days.
      Optical mice are relics from stone age in the meantime. ^^
      What, if your mobile switches the display off to save energy?
      What if your battery pack is empty?
      Ok, you may connect your power supply, but this costs you extra money in the long run.
      Not to mention that you can't use your PC before removing the tape.

      This VBS script runs silently beside your WoW and it only costs a doubleclick to start, nothing more. ;)
       
    10. lostmyz

      lostmyz New Member

      Joined:
      Sep 3, 2010
      Messages:
      259
      Likes Received:
      0
      Trophy Points:
      0
      I am not very versed with programming and scripts so forgive me.... I copied everything and adjusted to A and D which i use for left and right...I did it all in NotePad++ ( I have been attempting to write some profiles for myself to camp things i am interested in) Can you tell me if i did this right?

      On Error Resume Next

      ' ########################### begin user config
      strStepLeft = "%{A}"
      strStepRight = "%{D}"
      ' ########################### end user config

      Set WshShell = Wscript.CreateObject("WScript.Shell")
      Set args = WScript.Arguments
      num = args.Count
      if num = 0 then
      n = 200000
      else
      n = args(0)
      end if

      strComputer = "."
      strExeName = "Wow.exe"

      Do
      Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
      Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")
      numCount = 0
      For Each objProcess in colProcessList
      If Instr(1, objProcess.Name, strExeName) then
      numCount = numCount + 1
      End If
      Next
      If numCount = 0 then
      Exit Do
      End If

      For Each objProcess in colProcessList
      colPID = objProcess.processID
      colName = objProcess.Name

      If Instr(1, colName, strExeName) then
      WshShell.AppActivate colPID
      WshShell.sendkeys strStepLeft
      WshShell.sendkeys strStepRight
      End If
      Next
      Wscript.sleep n
      Loop

      MsgBox "No running WoW instance found. Terminating AntiAFK now.",0,"AntiAFK VBS"



      Thanks and I ran "Open START -> Run, write wscript.exe into the input field and then hit OK" I appear to have it
       
    11. Corleone

      Corleone Well-Known Member

      Joined:
      May 24, 2013
      Messages:
      2,255
      Likes Received:
      28
      Trophy Points:
      48
      Hi lostmyz

      For simple A and D keys, the config part should look like

      Code:
      ' ########################### begin user config
      strStepLeft = "A"
      strStepRight = "D"
      ' ########################### end user config
      What you've configured was an Alt-A and Alt-D.
      In this case, you should omit the { } and simply write %A and %D instead, as these keys are no non-ASCII keys and therefore need no curly brackets.

      HTH ;)
       
      Last edited: Sep 28, 2015
    12. bib

      bib New Member

      Joined:
      Feb 9, 2016
      Messages:
      3
      Likes Received:
      0
      Trophy Points:
      0
      hi.
      i get No running WoW instance found. Terminating AntiAFK now. message as soon as i start it.
      is it because i play on private server or because i run 64 bit win 7 ?
      i looked in the task manager and i get wow.exe *32 process.
      i tried to replace that in the script . i tried wow-32.exe , wow-64.exe , with the same result.
      any ideas ?
      ty
       
    13. Corleone

      Corleone Well-Known Member

      Joined:
      May 24, 2013
      Messages:
      2,255
      Likes Received:
      28
      Trophy Points:
      48
      Watch the WoW build from the left lower corner at the login screen. There has to be "x86", not "x64".
      The WoW executable must be mandatory named "wow.exe" (as it is originally for 32-bit default).
      Also delete all files with "64" in your wow directory and don't use the BN launcher, as it would restore the deleted files.
      If you start "wow.exe" and there are still files with "64" in your folder, wow.exe starts up as 64-bit, also restoring the missing files.
      Make sure you start wow.exe directly with no "64" files and the script should work.

      "No running WoW instance found." should appear, when you terminated the last wow instance or when wow.exe is not already found running in your tasks
      (no matter which windows version you're using).
       
    14. bib

      bib New Member

      Joined:
      Feb 9, 2016
      Messages:
      3
      Likes Received:
      0
      Trophy Points:
      0
      i dont use the launcher , and the exe is wow.exe
      when i said i tried to change the name . i ment i changed strExeName = "Wow.exe" in the script to wow-32.exe
      anyway it still does not work. could it be because wow is not installed is actually unziped from an archive and was not installed with an installer ?
      and i dont have a x64 file in my wow directory since it was not installed and it is a 32bit version
      ty
       
    15. Corleone

      Corleone Well-Known Member

      Joined:
      May 24, 2013
      Messages:
      2,255
      Likes Received:
      28
      Trophy Points:
      48
      strExeName = .... should always be the same name that your taskmanager shows you, because the script takes
      the name from the list of running programs.
      Means if your taskmanager shows you "wow.exe *32", strExeName should also be "wow.exe" (without the *32 process info).
      In opposite to wow-64.exe, there's no named 32-bit version. That's always "wow.exe".
      The script runs both, 32-bit and 64-bit (64-bit after editing strExeName="wow-64.exe").

      Have you tried to start wow.exe and the script in admin mode ("...run as administrator").?

      If your taskmanager shows "wow.exe *32" and the script can't find the same process name in the tasks, you very likely have a system policy problem
      with Windows Scripting Host trying to access the internal process database in your registry.
      Sorry, in this case I can't help you, since, at that, you're also the first one ever having such a problem. :(
       
      Last edited: Feb 12, 2016
    16. bib

      bib New Member

      Joined:
      Feb 9, 2016
      Messages:
      3
      Likes Received:
      0
      Trophy Points:
      0
      So the problem was strexename was Wow , and in my task manager it was WoW , ( both W were in caps)
      I didnt think it would matter first time i noticed but i said i`ll give it a chance . And that was it
      Now its working perfect.
      Thanks for all the quick replies and for the script
       

    Share This Page