VERSION 5.00
Begin VB.Form frmMain 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Virtual Hypnotist"
   ClientHeight    =   6705
   ClientLeft      =   4155
   ClientTop       =   2445
   ClientWidth     =   6750
   Icon            =   "Main.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   6705
   ScaleWidth      =   6750
   Begin VB.CommandButton Command5 
      Caption         =   "Downloader"
      Height          =   375
      Left            =   840
      TabIndex        =   25
      Top             =   5380
      Visible         =   0   'False
      Width           =   1815
   End
   Begin VB.CommandButton Command4 
      Caption         =   "Remote Controller"
      Height          =   375
      Left            =   3960
      TabIndex        =   5
      Top             =   5520
      Visible         =   0   'False
      Width           =   1815
   End
   Begin VB.Timer MenuTimer 
      Interval        =   100
      Left            =   5880
      Top             =   120
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Session File Editor"
      Height          =   360
      Left            =   3960
      TabIndex        =   11
      ToolTipText     =   "Directly edit saved session files"
      Top             =   5160
      Width           =   1815
   End
   Begin VB.CommandButton Command10 
      Caption         =   "Script Processor Console"
      Height          =   375
      Left            =   3840
      TabIndex        =   8
      ToolTipText     =   "Starts the Script Processor Console"
      Top             =   2880
      Width           =   2055
   End
   Begin VB.CommandButton Command9 
      Caption         =   "User Information"
      Height          =   360
      Left            =   840
      TabIndex        =   3
      ToolTipText     =   "View or change user information"
      Top             =   3950
      Width           =   1815
   End
   Begin VB.CommandButton Command28 
      Caption         =   "Change Mode/Options"
      Height          =   360
      Left            =   840
      TabIndex        =   2
      ToolTipText     =   "Change session mode"
      Top             =   3600
      Width           =   1815
   End
   Begin VB.CommandButton Command11 
      Caption         =   "Session Configuration"
      Height          =   360
      Left            =   840
      TabIndex        =   1
      ToolTipText     =   "Configure a hypnosis session"
      Top             =   2520
      Width           =   1815
   End
   Begin VB.CommandButton Command36 
      Caption         =   "HypnoChat"
      Height          =   360
      Left            =   840
      TabIndex        =   4
      ToolTipText     =   "HypnoChat Instant Messenger System (multiuser support)"
      Top             =   5040
      Width           =   1815
   End
   Begin VB.CommandButton Command25 
      Caption         =   "Brainwave Synchronizer"
      Height          =   375
      Left            =   3840
      TabIndex        =   10
      ToolTipText     =   "Configure brainwave synchronizer"
      Top             =   4200
      Width           =   2055
   End
   Begin VB.CommandButton Command26 
      Caption         =   "Hypnotic Visual Maker"
      Height          =   375
      Left            =   3840
      TabIndex        =   9
      ToolTipText     =   "Configure custom hypnotic visuals"
      Top             =   3840
      Width           =   2055
   End
   Begin VB.CommandButton Command6 
      Caption         =   "Session Presets"
      Height          =   375
      Left            =   840
      TabIndex        =   0
      ToolTipText     =   "Select from a list of presets"
      Top             =   2160
      Width           =   1815
   End
   Begin VB.CommandButton Command23 
      Caption         =   "Script Maker"
      Height          =   375
      Left            =   3840
      TabIndex        =   7
      ToolTipText     =   "Open the Script Maker"
      Top             =   2520
      Width           =   2055
   End
   Begin VB.CommandButton Command33 
      Caption         =   "Test Speech Recognition"
      Height          =   375
      Left            =   3840
      TabIndex        =   6
      ToolTipText     =   "Open Speech Recognition test window"
      Top             =   2160
      Width           =   2055
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Exit"
      Height          =   375
      Left            =   5520
      TabIndex        =   16
      ToolTipText     =   "Exit Virtual Hypnotist"
      Top             =   6120
      Width           =   975
   End
   Begin VB.CommandButton Command16 
      Caption         =   "About"
      Height          =   375
      Left            =   4320
      TabIndex        =   15
      ToolTipText     =   "About Virtual Hypnotist"
      Top             =   6120
      Width           =   1095
   End
   Begin VB.CommandButton Command27 
      Caption         =   "Help"
      Height          =   375
      Left            =   3000
      TabIndex        =   14
      ToolTipText     =   "Display User's Guide"
      Top             =   6120
      Width           =   1215
   End
   Begin VB.CommandButton Command20 
      Caption         =   "Logbook"
      Height          =   375
      Left            =   1680
      TabIndex        =   13
      ToolTipText     =   "Open session logbook"
      Top             =   6120
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Start Session"
      Height          =   375
      Left            =   240
      TabIndex        =   12
      ToolTipText     =   "Begin hypnosis session"
      Top             =   6120
      Width           =   1335
   End
   Begin VB.Label Label8 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Utilities"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   3840
      TabIndex        =   24
      Top             =   4800
      Width           =   2055
   End
   Begin VB.Label Label7 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "General Settings"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   720
      TabIndex        =   23
      Top             =   3240
      Width           =   2055
   End
   Begin VB.Label Label6 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Network"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   720
      TabIndex        =   22
      Top             =   4680
      Width           =   2055
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Graphics and Sound"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   3840
      TabIndex        =   21
      Top             =   3480
      Width           =   2055
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Session"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   720
      TabIndex        =   20
      Top             =   1800
      Width           =   2055
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Speech System"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   3840
      TabIndex        =   19
      Top             =   1800
      Width           =   2055
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   $"Main.frx":08CA
      ForeColor       =   &H00C0FFC0&
      Height          =   690
      Left            =   720
      TabIndex        =   18
      Top             =   960
      Width           =   5175
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Virtual Hypnotist"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   24
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFC0&
      Height          =   735
      Left            =   1440
      TabIndex        =   17
      Top             =   120
      Width           =   3855
   End
   Begin VB.Image Image3 
      Height          =   1335
      Left            =   0
      Stretch         =   -1  'True
      Top             =   0
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.Menu mnuPopUp 
      Caption         =   "PopUp_Menu"
      Visible         =   0   'False
      Begin VB.Menu mnuOpen 
         Caption         =   "&Open Main Screen"
      End
      Begin VB.Menu mnuLine1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuStartSession 
         Caption         =   "&Start Session"
      End
      Begin VB.Menu mnuStopSession 
         Caption         =   "Stop Session"
      End
      Begin VB.Menu mnuLine2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuPresets 
         Caption         =   "Session Prese&ts"
      End
      Begin VB.Menu mnuConfig 
         Caption         =   "Session Con&figuration"
      End
      Begin VB.Menu mnuMode 
         Caption         =   "Change M&ode"
      End
      Begin VB.Menu mnuInfo 
         Caption         =   "User &Information"
      End
      Begin VB.Menu mnuSR 
         Caption         =   "Test Speech &Recognition"
      End
      Begin VB.Menu mnuScriptMaker 
         Caption         =   "Script &Maker"
      End
      Begin VB.Menu mnuConsole 
         Caption         =   "Script &Processor Console"
      End
      Begin VB.Menu mnuVisualMaker 
         Caption         =   "Hypnotic &Visual Maker"
      End
      Begin VB.Menu mnuBrainwave 
         Caption         =   "&Brainwave Synchronizer"
      End
      Begin VB.Menu mnuLogbook 
         Caption         =   "&Logbook"
      End
      Begin VB.Menu mnuHypnoChat 
         Caption         =   "Hypno&Chat"
      End
      Begin VB.Menu mnuFileEditor 
         Caption         =   "Session &File Editor"
      End
      Begin VB.Menu mnuLine3 
         Caption         =   "-"
      End
      Begin VB.Menu mnuHelp 
         Caption         =   "&Help"
      End
      Begin VB.Menu mnuAbout 
         Caption         =   "&About"
      End
      Begin VB.Menu mnuLine4 
         Caption         =   "-"
      End
      Begin VB.Menu mnuQuit 
         Caption         =   "&Quit"
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Virtual Hypnotist
'©2003-2008 FollowTheWatch Software
'http://vhypno.sourceforge.net
'http://sourceforge.net/projects/vhypno
'Contact - followthewatch55@yahoo.com

'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2
'of the License, or (at your option) any later version.

'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'GNU General Public License for more details.

'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Option Explicit
Private ErrorMode As Boolean
Public WithEvents Tray As TrayIcon
Attribute Tray.VB_VarHelpID = -1
Public ForceQuit As Boolean
Public WithEvents Voice5 As SpVoice
Attribute Voice5.VB_VarHelpID = -1
Public WithEvents DSS As DirectSS
Attribute DSS.VB_VarHelpID = -1
Public WithEvents Agent1 As Agent
Attribute Agent1.VB_VarHelpID = -1

Private Sub Command1_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler

If SynthSpeech = True Then
    If frmSession.chkEnableInduction.Value = 1 And InductionFile = "" Then MsgBox "Please choose an induction file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableDeepener.Value = 1 And DeepenerFile = "" Then MsgBox "Please choose a deepener file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableSuggestions.Value = 1 And SuggestionsFile = "" Then MsgBox "Please choose a suggestions file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableWakener.Value = 1 And WakenerFile = "" Then MsgBox "Please choose a wakener file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableChar.Value = 1 And CharacterFile = "" And UseSAPI5 = False Then MsgBox "Please choose a character file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
End If
If frmSession.chkEnableVideo.Value = 1 And VideoFile = "" Then MsgBox "Please choose a video file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
If (frmSession.chkEnableSubliminals.Value = 1 Or frmSession.optSessionSubliminal.Value = True) And SubliminalsFile = "" Then MsgBox "Please choose a subliminals file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
If frmSession.chkEnableAudio.Value = 1 And AudioFile = "" Then MsgBox "Please choose an audio file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
If frmSession.chkEnableCustom.Value = 1 And frmSession.txtCustomAudio.Text = "" Then MsgBox "Please choose a custom audio file by clicking the Session Types button", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
If frmSession.optSessionStandard.Value = False Then
    frmMain.Visible = False
    If frmSession.optSessionSubliminal.Value = False Then
        Set Tray.Icon = Me.Icon
        Tray.Tooltip = Me.Caption
        Tray.Add
    End If
    If SynthSpeech = True And UseSAPI5 = False Then Char.Hide
    Randomize Timer
    If frmSession.optStartInTime.Value = True Then Sleep ((frmSession.UpDownHours.Value * 3600000) + (frmSession.UpDownMinutes.Value * 60000))
    If frmSession.optStartAtRandom.Value = True Then Sleep Rnd * ((frmSession.UpDownHours.Value * 3600000) + (frmSession.UpDownMinutes.Value * 60000)) + 1
End If
If frmSession.optSessionSubliminal.Value = True And NoSubWindow = False Then
    SubControlPanel.Show
    HypnoWinState = 1
Else
    HypnoWinState = 2
End If

If frmSession.optFullScreen = False Then
    HypnoWinState = 0
Else
    HypnoWinState = 2
End If

'uses SubControlPanel timer to force frmMain invisible
If NoSubWindow = True Then SubControlPanel.Show: SubControlPanel.Hide

'On Error Resume Next 'prevents Object Unloaded errors
On Error GoTo ErrorHandler
frmHypno.Show
Exit Sub

ErrorHandler:
If err.Number = 364 Then Resume Next 'skip this error type
err.Source = "Main Screen - Command1"
Call ErrorReport("An error occurred while starting the session.", vbCritical)

End Sub

Private Sub Command10_Click()
Console.Show
End Sub

Private Sub Command11_Click()
frmSession.Show
End Sub

Private Sub Command16_Click()
frmAbout.Show
End Sub

Private Sub Command2_Click()
If frmRemote.Connected = True Then SendCommand "<stop>", ClientSN
ForceQuit = True
Unload Me
End Sub

Private Sub Command20_Click()
Logbook.Show
End Sub

Private Sub Command23_Click()
ScriptMaker.Show
End Sub

Private Sub Command25_Click()
On Error Resume Next
If getWindowsVersion(0) = 2 And getWindowsVersion(1) <= 4 Then MsgBox "The Brainwave Synchronizer will not work on Windows NT 4", vbOKOnly + vbCritical, "Virtual Hypnotist": Exit Sub
Binaural.Show
End Sub

Private Sub Command26_Click()
'reset spiral
Cextern = Val(VisualMaker.Label16.Caption)
ChangeSpiral = True

VisualMaker.Show
End Sub

Private Sub Command27_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler

Shell "hh " + App.path + "\vh.chm", vbNormalFocus
Exit Sub

ErrorHandler:
err.Source = "Main Screen - Command27"
   Call ErrorReport("An error occurred while loading Windows HTML Help.", vbExclamation)

End Sub

Private Sub Command28_Click()
frmMode.Show
End Sub

Private Sub Command3_Click()
FileEditor.Show
End Sub

Private Sub Command33_Click()
frmSRTest.Show
End Sub

Private Sub Command36_Click()
'  aimDebug.Show
  aimSignOn.Show
End Sub

Private Sub Command4_Click()
frmRemote.Show
End Sub

Private Sub Command5_Click()
Downloader.Show
End Sub

Private Sub Command6_Click()
frmPresets.Show
End Sub

Private Sub Command9_Click()
frmUser.Show
End Sub

Private Sub DSS_TextDataDone(ByVal Hi As Long, ByVal Lo As Long, ByVal flags As Long)
DSSFinished = True
End Sub

Private Sub DSS_TextDataStarted(ByVal Hi As Long, ByVal Lo As Long)
DSSFinished = False
End Sub

Private Sub Form_Activate()
If ErrorMode = True Then Exit Sub
If autorun = True Then Exit Sub
Running = True
Image3.Visible = BackScreen

If SynthSpeech = True And UseSAPI5 = False And frmSession.chkEnableChar.Value = 1 Then
    Command33.Enabled = True
End If

If SynthSpeech = False Or UseSAPI5 = True Then
    Command33.Enabled = False
    mnuSR.Enabled = False
Else
    Command33.Enabled = True
    mnuSR.Enabled = True
End If

'If Me.WindowState = 0 Then
    'Me.Left = (ScreenX / 2) - (Me.Width / 2)
    'Me.top = (ScreenY / 2) - (Me.Height / 2)
'End If
End Sub

Private Sub Form_Load()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
frmMode.Hide

Dim I As Integer

'Init tray icon object
SystemTrayIcon = Int(GetINIString(1, "settings", "systemtrayicon", "1"))
Set Tray = New TrayIcon
Set Tray.OwnerForm = Me
Set Tray.Icon = Me.Icon

ModeVal = Int(GetINIString(1, "settings", "mode"))
If Int(GetINIString(1, "settings", "loadspeechsystem")) = 1 Then SynthSpeech = True Else SynthSpeech = False
If Int(GetINIString(1, "settings", "backgroundpic")) = 1 Then BackScreen = True Else BackScreen = False
If Int(GetINIString(1, "settings", "perfmon", "1")) = 1 Then PerfMon = True Else PerfMon = False
If Int(GetINIString(1, "settings", "scripterrors", "1")) = 1 Then ScriptErrors = True Else ScriptErrors = False
If Int(GetINIString(1, "settings", "scriptdebug", "0")) = 1 Then ScriptDebug = True Else ScriptDebug = False
If Int(GetINIString(1, "settings", "speechrecognition", "1")) = 1 Then EnableSpeechRec = True Else EnableSpeechRec = False
If Int(GetINIString(1, "settings", "sapi5", "0")) = 1 Then UseSAPI5 = True Else UseSAPI5 = False
If Int(GetINIString(1, "settings", "showconsole", "0")) = 1 Then DisplayConsole = True Else DisplayConsole = False
If Int(GetINIString(1, "settings", "showcharacter", "1")) = 1 Then ShowCharacter = True Else ShowCharacter = False
ErrorWaitTime = Int(GetINIString(1, "hypnochat", "waittime", "20000"))
TransmitRate = Int(GetINIString(1, "hypnochat", "transmitrate", "1500"))
RecursionLimit = Int(GetINIString(1, "settings", "recursionlimit", "10"))

'Get user information
UserName = GetINIString(1, "settings", "name", "User")
UserTrigger = GetINIString(1, "settings", "trigger", "Sleep")
UserGender = GetINIString(1, "settings", "gender", "Male")

MainScreenOn = True

'Initialize dynamic arrays
ReDim CustomScript(0)
ReDim CommandQueue(0)

ShapeAColor1 = RGB(0, 255, 0)
ShapeAColor2 = RGB(0, 0, 0)
ShapeBColor1 = RGB(0, 0, 0)
ShapeBColor2 = RGB(0, 220, 255)
Image3.Width = Me.Width
Image3.Height = Me.Height
Image3.Picture = LoadPicture(App.path + "\back.bmp")
Image3.Visible = BackScreen

frmMain.Left = (Screen.Width / 2) - (Me.Width / 2)
frmMain.Top = (Screen.Height / 2) - (Me.Height / 2)

'brainwave generator default values
Frequency1 = 159
Frequency2 = 165
PanVal = 5000
'SetVolume = -2500
SetVolume = -2000
SetMVolume = -2000
BarWidth = 10

Loading = True

If SynthSpeech = True And UseSAPI5 = False Then
    'Turn on SAPI4 speech
    Set DSS = New DirectSS 'load DSS
    Set Agent1 = New Agent 'load Agent
    SAPI4_On = True
    CharacterFile = "angie.acs"
    Agent1.Characters.Load "Hypnotist", CharacterFile
    Set Char = Agent1.Characters("Hypnotist")
    EngineName = "Mary"
    OrigWidth = Char.Width
    OrigHeight = Char.Height
    Char.Balloon.Style = &H21C000C
    frmSession.SkipChar = True
    With frmSession.fileCharacter
    .Refresh
    For I = 0 To .ListCount - 1
        If LCase$(.List(I)) = LCase$(CharacterFile) Then .ListIndex = I
    Next I
    End With
    frmSession.SkipChar = False
    Call frmSession.fileCharacter_Click
End If
If SynthSpeech = True And UseSAPI5 = True Then
    'Turn on SAPI5 speech
    Set Voice5 = New SpVoice
    m_speakFlags = SVSFlagsAsync Or SVSFPurgeBeforeSpeak Or SVSFIsXML
    EngineName = "Microsoft Mike"
    SetSpeakingState False, False
End If
SkipSpeech:
If SynthSpeech = False And frmSession.chkTextOnly.Value = 0 Then frmSession.chkTextOnly.Value = 1

If getWindowsVersion(1) <= 4 And getWindowsVersion(2) <> 90 Then frmSession.chkEnableAudio.Value = 0

Loading = False
autorun = False

'Set custom visual defaults
Call VisualMaker.ResetVisuals(0)
Call VisualMaker.ResetVisuals(1)
Call VisualMaker.ResetVisuals(2)
Call VisualMaker.ResetVisuals(3)

'Set default custom visual mode
VisualMode = 1

'Load Exit Message parameter
frmSession.chkExitMessage.Value = Int(GetINIString(1, "Settings", "exitmessage", "1"))

'Process command line parameters
    Dim Parameters As String
    Dim pos As Long
    Dim new_parameter As String
    
    Parameters = Command$
    Do While Len(Parameters) > 0
        pos = InStr(Parameters, " ")
        If pos = 0 Then
            new_parameter = Parameters
            Parameters = ""
        Else
            new_parameter = Left$(Parameters, pos - 1)
            Parameters = Mid$(Parameters, pos + 1)
        End If
        If Left$(new_parameter, 8) = "/preset=" Then
            'Auto-load preset
            I = Val(Mid$(new_parameter, 9, 10000))
            Loading = True
            If I = 1 Then Call frmPresets.Command5_Click 'hypnotherapist
            If I = 2 Then Call frmPresets.Command9_Click 'hypnotherapist2
            If I = 3 Then Call frmPresets.Command10_Click 'swinging watch
            If I = 4 Then Call frmPresets.Command12_Click 'pendant
            If I = 5 Then Call frmPresets.Command18_Click 'kaleidoscope
            If I = 6 Then Call frmPresets.Command19_Click 'deep sleep
            If I = 7 Then Call frmPresets.Command14_Click 'feature test
            If I = 8 Then Call frmPresets.Command6_Click 'brainwash
            If I = 9 Then Call frmPresets.Command29_Click 'reinduction
            If I = 10 Then Call frmPresets.Command21_Click 'brainwash II
            If I = 11 Then Call frmPresets.Command30_Click 'trigger induction
            If I = 12 Then Call frmPresets.Command22_Click 'obey
            If I = 13 Then Call frmPresets.Command31_Click 'hand drop
            If I = 14 Then Call frmPresets.Command8_Click 'cartoonish
            If I = 15 Then Call frmPresets.Command32_Click 'number press
            If I = 16 Then Call frmPresets.Command13_Click 'eyes
            If I = 17 Then Call frmPresets.Command34_Click 'success loop
            Loading = False
        End If
        If Left$(new_parameter, 3) = "/go" Then autorun = True
        If Left$(new_parameter, 6) = "/load=" Then
            AutoLoadSession = True
            frmSession.CommonDialog1.Filename = App.path + "\sessions\" + Mid$(new_parameter, 7, 10000)
            Call frmSession.cmdLoadSession_Click
        End If
        If Left$(new_parameter, 5) = "/exit" Then AutoExit = True
        If Left$(new_parameter, 12) = "/nosubwindow" Then NoSubWindow = True
        If Left$(new_parameter, 11) = "/notrayicon" Then SystemTrayIcon = 0
        If Left$(new_parameter, 8) = "/menuoff" Then MenuOff = True
    Loop

'Turn on system tray icon if selected
If SystemTrayIcon = 3 Then
    Set Tray.Icon = Me.Icon
    Tray.Tooltip = Me.Caption
    Tray.Add
End If

'fixes a bug where this form pops up incorrectly
If frmSession.optSessionStandard.Value = True Then frmMain.WindowState = 0

If autorun = True Then Call Command1_Click: Exit Sub

If SynthSpeech = True And UseSAPI5 = False Then
    Char.MoveTo 0, 0
    If ShowCharacter = True Then Char.Show
    Char.Balloon.Style = &H21C000C
End If
Exit Sub

ErrorHandler:
ErrorMode = True
err.Source = "Main Screen - Loader"
Call ErrorReport("An error occurred while loading and initializing the Speech System." + vbCrLf + vbCrLf + "It can be obtained from the website at http://vhypno.sourceforge.net" + vbCrLf + "Make sure it is installed properly and that all the libraries exist." + vbCrLf + vbCrLf + "Synthesized Speech has been turned off - click Change Mode to turn it back on when ready.", vbCritical)
Set DSS = Nothing
Set Char = Nothing
Set Agent1 = Nothing
SynthSpeech = False
UseSAPI5 = False
Unload frmMode
WriteINIString 1, "settings", "loadspeechsystem", LTrim$(Str$(Abs(Int(SynthSpeech))))
WriteINIString 1, "settings", "sapi5", LTrim$(Str$(Abs(Int(UseSAPI5))))
Resume SkipSpeech
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
End Sub

Private Sub Form_Resize()
'Minimize to tray
If Me.WindowState = 1 And SystemTrayIcon > 0 Then
    Set Tray.Icon = Me.Icon
    Tray.Tooltip = Me.Caption
    If SystemTrayIcon < 3 Then Tray.Add
    Me.Visible = False
End If

If Me.WindowState <> 1 And SystemTrayIcon < 3 Then
    Tray.Remove
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)
'Close to tray if selected
If SystemTrayIcon > 1 And ForceQuit = False Then
    Set Tray.Icon = Me.Icon
    Tray.Tooltip = Me.Caption
    If SystemTrayIcon < 3 Then Tray.Add
    Me.Visible = False
    Cancel = 1
    Exit Sub
End If

Tray.Remove
Set Tray = Nothing
Set DSS = Nothing
Set Char = Nothing
Set Agent1 = Nothing
'If ErrorMode = False Then End
End
End Sub

Private Sub Image3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
End Sub

Private Sub Label3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
End Sub

Private Sub MenuTimer_Timer()
'This timer handles dynamic aspects of the popup menu

If SessionRunning = True Then
    mnuStartSession.Enabled = False
    mnuStopSession.Enabled = True
    mnuPresets.Enabled = False
    mnuConfig.Enabled = False
    'mnuOpen.Enabled = False
    mnuMode.Enabled = False
Else
    mnuStartSession.Enabled = True
    mnuStopSession.Enabled = False
    mnuPresets.Enabled = True
    mnuConfig.Enabled = True
    'mnuOpen.Enabled = True
    mnuMode.Enabled = True
    If SystemTrayIcon <> 3 And Me.Visible = True Then Tray.Remove
End If


End Sub

Private Sub mnuAbout_Click()
Command16_Click
End Sub

Private Sub mnuBrainwave_Click()
Command25_Click
End Sub

Private Sub mnuConfig_Click()
Command11_Click
End Sub

Private Sub mnuConsole_Click()
Command10_Click
End Sub

Private Sub mnuFileEditor_Click()
FileEditor.Show
End Sub

Private Sub mnuHelp_Click()
Command27_Click
End Sub

Private Sub mnuHypnoChat_Click()
Command36_Click
End Sub

Private Sub mnuInfo_Click()
Command9_Click
End Sub

Private Sub mnuLogbook_Click()
Command20_Click
End Sub

Private Sub mnuMode_Click()
Command28_Click
End Sub

Private Sub mnuOpen_Click()
Me.Visible = True
Me.WindowState = 0
Me.Show
End Sub

Private Sub mnuPresets_Click()
Command6_Click
End Sub

Private Sub mnuQuit_Click()
ForceQuit = True
Command2_Click
End Sub

Private Sub mnuScriptMaker_Click()
Command23_Click
End Sub

Private Sub mnuSR_Click()
Command33_Click
End Sub

Private Sub mnuStartSession_Click()
Command1_Click
End Sub

Private Sub mnuStopSession_Click()
If SessionRunning = True Then Quit = True
End Sub

Private Sub mnuVisualMaker_Click()
Command26_Click
End Sub

Private Sub Tray_MouseUp(ByVal Button As Integer)
    If Button = vbRightButton Then Me.PopupMenu mnuPopUp
End Sub

Private Sub Tray_MouseDblClick(ByVal Button As Integer)
    If Button = vbLeftButton Then mnuOpen_Click
End Sub

Private Sub Voice5_EndStream(ByVal StreamNum As Long, ByVal StreamPos As Variant)
    SetSpeakingState False, m_bPaused
End Sub

Private Sub Voice5_StartStream(ByVal StreamNum As Long, ByVal StreamPos As Variant)
    SetSpeakingState True, m_bPaused
End Sub
