In the GeneralEvents_OnStartTest routine you could use an if statement to check a temporary project variable.
I created a boolean type temporary project variable with default value set to true. It will be true for the test item then it is changed to false below. In my case I only wanted to run a Login script before the first test item selected. Another option would be to use script-level code (code outside functions and subroutines) that is executed automatically when the script loads.
Sub GeneralEvents_OnStartTest(Sender)
If Project.Variables.blnFirstTestItem = True Then
' code only executed once before the first test item
Login
Project.Variables.blnFirstTestItem = False
End If
' other code to execute before every test item
End Sub