Advertisement
RedFeatherMan

Nord Helper

Jul 8th, 2021
3,829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance Force
  2. #KeyHistory 0
  3. ListLines, Off
  4. SetBatchLines, -1
  5. OnMessage(0x404, "AHK_NOTIFYICON")
  6. Ver = 6.37.5.0
  7. ;--------------------------------------
  8. Menu, Tray, UseErrorLevel
  9. Menu, Tray, Tip, Nord Helper
  10. Menu, Tray, Icon, C:\Program Files\NordVPN\%Ver%\Resources\toast.ico
  11. Menu, Tray, NoStandard
  12. Menu, Tray, Add, R&eload, Reload
  13. Menu, Tray, Add, E&xit, Exit
  14. ;---------------------------------------
  15. RunAsAdmin()
  16. doGui()
  17. return
  18. ;---------------------------------------
  19. return
  20.  
  21. doGui()
  22. {
  23.     if WinExist("Dashboard")
  24.     {
  25.         Gui 1: Destroy
  26.     }
  27.     Gui 1: +AlwaysOnTop
  28.     Gui 1: Color, c005198
  29.     Gui 1: Add, Button, w90 h20 x10 y5 gRunNord, Run Nord
  30.     Gui 1: Add, Button, w90 h20 x10 y35 gKillNord, Close Nord
  31.     Gui 1: Add, Button, w90 h20 x125 y5 gConnectNord, Connect
  32.     Gui 1: Add, Button, w90 h20 x125 y35 gDisconnectNord, Disconnect
  33.     Gui 1: Show, w225 h60, Dashboard
  34.     enableGuiDrag(1)
  35. }
  36.  
  37. KillNord()
  38. {
  39.     RunWait, %ComSpec% /c Taskkill /IM "NordVPN.exe" /F && Taskkill /IM "nordvpn-service.exe" /F,, Hide
  40. }
  41.  
  42. RunNord()
  43. {
  44.     RunWait, %ComSpec% /c cd "C:\Program Files\NordVPN\" && start NordVPN.exe,, Hide
  45. }
  46.  
  47. ConnectNord()
  48. {
  49.     RunWait, %ComSpec% /c cd "C:\Program Files\NordVPN\" && nordvpn --connect,, Hide
  50. }
  51.  
  52. DisconnectNord()
  53. {
  54.     RunWait, %ComSpec% /c cd "C:\Program Files\NordVPN\" && nordvpn --disconnect,, Hide
  55. }
  56.  
  57. RunAsAdmin()
  58. {
  59.     Global 0
  60.     IfEqual, A_IsAdmin, 1, Return 0
  61.    
  62.     Loop, %0%
  63.         params .= A_Space . %A_Index%
  64.    
  65.     DllCall("shell32\ShellExecute" (A_IsUnicode ? "":"A"),uint,0,str,"RunAs",str,(A_IsCompiled ? A_ScriptFullPath : A_AhkPath),str,(A_IsCompiled ? "": """" . A_ScriptFullPath . """" . A_Space) params,str,A_WorkingDir,int,1)
  66.     ExitApp
  67. }
  68.  
  69. enableGuiDrag(GuiLabel=1)
  70. {
  71.     WinGetPos,,,A_w,A_h,A
  72.     Gui, %GuiLabel%:Add, Text, x0 y0 w%A_w% h%A_h% +BackgroundTrans gGUI_Drag
  73.     return
  74.    
  75.     GUI_Drag:
  76.     PostMessage 0xA1,2
  77.     return
  78. }
  79.  
  80. AHK_NOTIFYICON(wParam, lParam, uMsg, hWnd)
  81. {
  82.     if (lParam = 0x201)
  83.     {
  84.         KeyWait, LButton
  85.         KeyWait, LButton, D  T 0.10
  86.         if (Errorlevel)
  87.         {
  88.             return
  89.         }
  90.         else
  91.         {
  92.             doGui()
  93.         }
  94.     }
  95. }
  96. ;----------------------------------------------------
  97. GuiClose:
  98. Gui 1: Destroy
  99. goTo, Exit
  100. return
  101.  
  102. Reload:
  103. Reload
  104. Sleep 1000
  105. ExitApp
  106.  
  107. Exit:
  108. ExitApp
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement