Guest User

Npcap AutoHotkey

a guest
Dec 11th, 2019
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. InstallNpcapAutoHotkey.ahk
  2. ---snip
  3. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  4. ; #Warn ; Enable warnings to assist with detecting common errors.
  5. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  6. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  7.  
  8. if not A_IsAdmin ;the control clicks dont work without elevation
  9. {
  10. Run *RunAs "%A_ScriptFullPath%" ;
  11. ExitApp
  12. }
  13. ;SetTitleMatchMode,RegEx
  14.  
  15. if not A_IsAdmin ;the control clicks dont work without elevation
  16. {
  17. Run *RunAs "%A_ScriptFullPath%" ;
  18. ExitApp
  19. }
  20. SetControlDelay -1
  21. BaseFolder := A_ScriptDir "\*.*"
  22. FileName := "npcap" ;
  23. Loop, Files, % BaseFolder ;Loop over all files in the Base Folder
  24. If RegExMatch(A_LoopFileName, "i)^" FileName) ;If the filename begins with the name we set
  25. Run, % A_LoopFilePath ;Run the file
  26.  
  27. WinWait, ahk_class #32770,
  28. ControlClick, Button2,
  29. If !WinExist("ahk_class #32770") ;
  30. return
  31. WinWait, ahk_class #32770, Installation Options
  32. Control, Check,, Button6,
  33. Control, Check,, Button7,
  34. WinWait, ahk_class #32770,
  35. ControlClick, Button2,
  36. WinWait, ahk_class #32770, Installation Complete
  37. ControlClick, Button2,
  38. WinWait, ahk_class #32770, Finished
  39. ControlClick, Button2,
  40. return
  41. ---snap
  42.  
  43. UninstallNpcapAutoHotkey.ahk
  44. ---snip
  45. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  46. ; #Warn ; Enable warnings to assist with detecting common errors.
  47. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  48. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  49. ;SetTitleMatchMode,RegEx
  50.  
  51. if not A_IsAdmin ;the control clicks dont work without elevation
  52. {
  53. Run *RunAs "%A_ScriptFullPath%" ;
  54. ExitApp
  55. }
  56. SetControlDelay -1
  57. BaseFolder := "C:\Program Files\Npcap\"
  58. Run, % BaseFolder "Uninstall.exe" ;Run the file
  59. WinWait, ahk_class #32770,
  60. ControlClick, Button2,
  61. Loop{
  62. Sleep 20
  63. ControlGet bEnabled, Enabled,, Button2,
  64. if bEnabled
  65. {
  66. ControlClick, Button2,
  67. break
  68. }
  69. }
  70. return
  71. ---snap
  72.  
  73. tr
RAW Paste Data