Click here to Skip to main content
15,908,673 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: extracting data problem to ms exel and access database location different in some system Pin
Jochen Arndt16-Apr-18 3:32
professionalJochen Arndt16-Apr-18 3:32 
GeneralRe: extracting data problem to ms exel and access database location different in some system Pin
lazy_dude18-Apr-18 4:23
lazy_dude18-Apr-18 4:23 
GeneralRe: extracting data problem to ms exel and access database location different in some system Pin
Jochen Arndt18-Apr-18 4:50
professionalJochen Arndt18-Apr-18 4:50 
GeneralRe: extracting data problem to ms exel and access database location different in some system Pin
lazy_dude18-Apr-18 4:51
lazy_dude18-Apr-18 4:51 
GeneralRe: extracting data problem to ms exel and access database location different in some system Pin
Richard MacCutchan18-Apr-18 5:55
mveRichard MacCutchan18-Apr-18 5:55 
GeneralRe: extracting data problem to ms exel and access database location different in some system Pin
lazy_dude23-Apr-18 6:55
lazy_dude23-Apr-18 6:55 
GeneralRe: extracting data problem to ms exel and access database location different in some system Pin
Richard MacCutchan23-Apr-18 7:00
mveRichard MacCutchan23-Apr-18 7:00 
Questionmy program running on background makes my current open application in desktop to blink blink such excel , google, outlook etc. Pin
Member 1280941214-Apr-18 13:38
Member 1280941214-Apr-18 13:38 
Hi All,

I create a program that runs on backgound using VB.NET minicap.exe with CMD as process. Inside the code is module and SUB_MAIN with system timers. It works fine except i notice that when my program runs on background as process? The other application on desktop is BLINKING intermittently. the system timer is set to 2sec upto 10seconds. heres my code below.
The main purpose of my program is to capture screenshot of desktop and save to network drive using MINICAP.EXE and CMD and SYSTEM TIMERS.



Imports System.Timers
Imports Microsoft.Win32
Imports MySql.Data.MySqlClient


Module Module1
    Private myTimer1 As Timer
    Private myTimer2 As Timer
    Private myTimer3 As Timer
    Private WithEvents MyProcess As Process
    Private Delegate Sub AppendOutputTextDelegate(ByVal text As String)

    Sub main()


        DBconnection()

        Dim uname As String
        Dim mname As String
        Dim Yourpath As String


        uname = Environment.UserName
        mname = Environment.MachineName

        Try
            Dim squery As String = "Select * from tbl_settings WHERE Computer = '" & mname & "'"
            Dim sadapter As New MySqlDataAdapter
            Dim scommand As New MySqlCommand
            Dim sqltable As New DataTable
            Dim i As Integer
            Dim PAT
            Dim STAT
            Dim INTR
            Dim COMPR
            Dim x As Integer
            With scommand
                .CommandText = squery
                .Connection = myconnection
            End With
            With sadapter
                .SelectCommand = scommand
                .Fill(sqltable)
            End With

            x = sqltable.Rows.Count
            STAT = IIf(sqltable.Rows(i)("Status") IsNot DBNull.Value, sqltable.Rows(i)("Status"), vbNullChar)
            If STAT = "ON" Then


                COMPR = IIf(sqltable.Rows(i)("Compression") IsNot DBNull.Value, sqltable.Rows(i)("Compression"), vbNullChar)
                INTR = IIf(sqltable.Rows(i)("Interval") IsNot DBNull.Value, sqltable.Rows(i)("Interval"), vbNullChar)
                PAT = IIf(sqltable.Rows(i)("server_path") IsNot DBNull.Value, sqltable.Rows(i)("server_path"), vbNullChar)


                'InputTextBox.Text = "minicap.exe -capturedesktop -stderr -noerr -cursor -compress" & " " & CAP & " " & "-exit -save" & " " & PAT


                Yourpath = PAT & "\" & Format(Now, "MM-d-yyyy") & "\" & mname & "\" & uname
                If (Not System.IO.Directory.Exists(Yourpath)) Then  'CHECK IF BUHAY YUNG SHARED DRIVE OR HINDI.. IF HINDI SA LOCAL MUNA
                    System.IO.Directory.CreateDirectory(Yourpath)
                End If
                sharedval.InputParam = "minicap.exe -capturedesktop -stderr -noerr -cursor -compress" & " " & COMPR & " " & "-exit -save" & " " & Chr(34) + Yourpath & "\" & Format(Now, "HH:mm:ss") & ".jpg" & Chr(34)


                sharedval.Xcompression = COMPR
                sharedval.Xinterval = INTR
                sharedval.xServer = Yourpath






                myTimer1.Enabled = True
                myTimer1.Interval = INTR
            ElseIf STAT = "OFF" Then
                myTimer1.Enabled = False
            End If


            COMPR = IIf(sqltable.Rows(i)("Compression") IsNot DBNull.Value, sqltable.Rows(i)("Compression"), vbNullChar)
            INTR = IIf(sqltable.Rows(i)("Interval") IsNot DBNull.Value, sqltable.Rows(i)("Interval"), vbNullChar)
            PAT = IIf(sqltable.Rows(i)("server_path") IsNot DBNull.Value, sqltable.Rows(i)("server_path"), vbNullChar)
            myTimer1.Interval = INTR

            'InputTextBox.Text = "minicap.exe -capturedesktop -stderr -noerr -cursor -compress" & " " & CAP & " " & "-exit -save" & " " & PAT


            Yourpath = PAT & "\" & Format(Now, "MM-d-yyyy") & "\" & mname & "\" & uname
            If (Not System.IO.Directory.Exists(Yourpath)) Then  'CHECK IF BUHAY YUNG SHARED DRIVE OR HINDI.. IF HINDI SA LOCAL MUNA
                System.IO.Directory.CreateDirectory(Yourpath)
            End If
            sharedval.InputParam = "minicap.exe -capturedesktop -stderr -noerr -cursor -compress" & " " & COMPR & " " & "-exit -save" & " " & Chr(34) + Yourpath & "\" & Format(Now, "HH:mm:ss") & ".jpg" & Chr(34)


            sharedval.Xcompression = COMPR
            sharedval.Xinterval = INTR
            sharedval.xServer = Yourpath
        Catch ex As Exception
            'MsgBox(Err.Description & Err.Number)
        End Try




        'Me.AcceptButton = ExecuteButton






        'MyProcess.BeginErrorReadLine()
        'MyProcess.BeginOutputReadLine()
        'AppendOutputText("Process Started at: " & MyProcess.StartTime.ToString)



        myTimer1 = New System.Timers.Timer()
        myTimer1.Interval = 2000 ' 2sec
        AddHandler myTimer1.Elapsed, AddressOf OnTimedEvent1
        myTimer1.AutoReset = True
        myTimer1.Enabled = True




        myTimer2 = New System.Timers.Timer()
        myTimer2.Interval = 60000 ' 2sec
        AddHandler myTimer2.Elapsed, AddressOf OnTimedEvent2
        myTimer2.AutoReset = True
        myTimer2.Enabled = True


        myTimer3 = New System.Timers.Timer()
        myTimer3.Interval = 2000 ' 2sec
        AddHandler myTimer3.Elapsed, AddressOf OnTimedEvent3
        myTimer3.AutoReset = True
        myTimer3.Enabled = False



        MyProcess = New Process
        With MyProcess.StartInfo
            .FileName = "CMD.EXE"
            .UseShellExecute = False
            .CreateNoWindow = True
            .RedirectStandardInput = True
            .RedirectStandardOutput = False
            .RedirectStandardError = False
        End With
        MyProcess.Start()


        Application.Run()


    End Sub
    Private Sub OnTimedEvent1(source As Object, e As System.Timers.ElapsedEventArgs)
        Call absolutepath()
        MyProcess.StandardInput.WriteLine(sharedval.InputParam)
        MyProcess.StandardInput.Flush()

    End Sub
    Private Sub OnTimedEvent2(source As Object, e As System.Timers.ElapsedEventArgs)
        Call checkstatus()

    End Sub
    Private Sub OnTimedEvent3(source As Object, e As System.Timers.ElapsedEventArgs)
    End Sub

    Private Sub MyProcess_ErrorDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.ErrorDataReceived
        AppendOutputText(vbCrLf & "Error: " & e.Data)
    End Sub

    Private Sub MyProcess_OutputDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.OutputDataReceived
        AppendOutputText(vbCrLf & e.Data)
    End Sub

    Private Sub AppendOutputText(ByVal text As String)
        'If OutputTextBox.InvokeRequired Then
        '    Dim myDelegate As New AppendOutputTextDelegate(AddressOf AppendOutputText)
        '    Me.Invoke(myDelegate, text)
        'Else
        '    OutputTextBox.AppendText(text)
        'End If
    End Sub
    Public Sub absolutepath()
        sharedval.InputParam = "minicap.exe -capturedesktop -stderr -noerr -cursor -compress" & " " & sharedval.Xcompression & " " & "-exit -save" & " " & Chr(34) + sharedval.xServer & "\" & Format(Now, "HH:mm:ss") & ".jpg" & Chr(34)
    End Sub
    Public Sub checkstatus()
        Try
            DBconnection()

            Dim uname As String
            Dim mname As String
            Dim Yourpath As String


            uname = Environment.UserName
            mname = Environment.MachineName

            Try
                Dim squery As String = "Select * from tbl_settings WHERE Computer = '" & mname & "'"
                Dim sadapter As New MySqlDataAdapter
                Dim scommand As New MySqlCommand
                Dim sqltable As New DataTable
                Dim i As Integer
                Dim PAT
                Dim STAT
                Dim INTR
                Dim COMPR
                Dim x
                With scommand
                    .CommandText = squery
                    .Connection = myconnection
                End With
                With sadapter
                    .SelectCommand = scommand
                    .Fill(sqltable)
                End With

                x = sqltable.Rows.Count
                STAT = IIf(sqltable.Rows(i)("Status") IsNot DBNull.Value, sqltable.Rows(i)("Status"), vbNullChar)
                If STAT = "ON" Then
                    myTimer1.Enabled = True

                ElseIf STAT = "OFF" Then
                    myTimer1.Enabled = False

                End If

                COMPR = IIf(sqltable.Rows(i)("Compression") IsNot DBNull.Value, sqltable.Rows(i)("Compression"), vbNullChar)
                INTR = IIf(sqltable.Rows(i)("Interval") IsNot DBNull.Value, sqltable.Rows(i)("Interval"), vbNullChar)
                PAT = IIf(sqltable.Rows(i)("server_path") IsNot DBNull.Value, sqltable.Rows(i)("server_path"), vbNullChar)
                myTimer1.Interval = INTR

                'InputTextBox.Text = "minicap.exe -capturedesktop -stderr -noerr -cursor -compress" & " " & CAP & " " & "-exit -save" & " " & PAT


                Yourpath = PAT & "\" & Format(Now, "MM-d-yyyy") & "\" & mname & "\" & uname
                If (Not System.IO.Directory.Exists(Yourpath)) Then  'CHECK IF BUHAY YUNG SHARED DRIVE OR HINDI.. IF HINDI SA LOCAL MUNA
                    System.IO.Directory.CreateDirectory(Yourpath)
                End If


                sharedval.Xcompression = COMPR
                sharedval.Xinterval = INTR
                sharedval.xServer = Yourpath


                'InputTextBox.Text = "minicap.exe -capturedesktop -stderr -noerr -cursor -compress" & " " & COMPR & " " & "-exit -save" & " " & Chr(34) + Yourpath & "\" & Format(Now, "HH:mm:ss") & ".jpg" & Chr(34)


            Catch ex As Exception

            End Try

        Catch ex As Exception
        End Try
    End Sub

End Module


modified 14-Apr-18 19:52pm.

AnswerRe: my program running on background makes my current open application in desktop to blink blink such excel , google, outlook etc. Pin
Richard MacCutchan14-Apr-18 21:10
mveRichard MacCutchan14-Apr-18 21:10 
GeneralRe: my program running on background makes my current open application in desktop to blink blink such excel , google, outlook etc. Pin
Member 1280941215-Apr-18 8:01
Member 1280941215-Apr-18 8:01 
AnswerRe: my program running on background makes my current open application in desktop to blink blink such excel , google, outlook etc. Pin
Eddy Vluggen17-Apr-18 0:08
professionalEddy Vluggen17-Apr-18 0:08 
GeneralRe: my program running on background makes my current open application in desktop to blink blink such excel , google, outlook etc. Pin
Member 1280941218-Apr-18 12:40
Member 1280941218-Apr-18 12:40 
QuestionHow to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Member 136918614-Apr-18 4:20
Member 136918614-Apr-18 4:20 
AnswerRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Gerry Schmitz4-Apr-18 4:49
mveGerry Schmitz4-Apr-18 4:49 
AnswerRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Dave Kreskowiak4-Apr-18 4:57
mveDave Kreskowiak4-Apr-18 4:57 
AnswerRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Richard Deeming4-Apr-18 5:04
mveRichard Deeming4-Apr-18 5:04 
GeneralRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Mycroft Holmes4-Apr-18 13:16
professionalMycroft Holmes4-Apr-18 13:16 
AnswerRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Richard MacCutchan4-Apr-18 7:05
mveRichard MacCutchan4-Apr-18 7:05 
AnswerRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Eddy Vluggen4-Apr-18 23:54
professionalEddy Vluggen4-Apr-18 23:54 
GeneralRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Member 136918615-Apr-18 3:12
Member 136918615-Apr-18 3:12 
GeneralRe: How to use multi user login with visual basic 6 and Microsoft access 2007 Pin
Eddy Vluggen5-Apr-18 6:34
professionalEddy Vluggen5-Apr-18 6:34 
QuestionHow to display on the form automatically the user that logins in a VB program Pin
Member 136918614-Apr-18 3:32
Member 136918614-Apr-18 3:32 
AnswerRe: How to display on the form automatically the user that logins in a VB program Pin
Dave Kreskowiak4-Apr-18 3:57
mveDave Kreskowiak4-Apr-18 3:57 
GeneralRe: How to display on the form automatically the user that logins in a VB program Pin
Member 136918614-Apr-18 4:26
Member 136918614-Apr-18 4:26 
GeneralRe: How to display on the form automatically the user that logins in a VB program Pin
Dave Kreskowiak4-Apr-18 4:55
mveDave Kreskowiak4-Apr-18 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.