Xcelled194 28 Junior Poster in Training

Can the DirectX.AudioVideoPlayback record sound too? Also, I'm a little confused how to call the method, using captured data.

Xcelled194 28 Junior Poster in Training

Hi guys, I'm making a program that will display the actual balance output of a sound. It's going to be used with a game that uses 3D sound. What I want to do is have the application monitor audio output from the system -- it can use the Stereo Mix. What I want to do is take a sample and determine the volume of the left channel, and the volume of the right channel. But I must confess to having NO idea where to begin.

Note that I don't want to save the sound, merely display the actual stereo balance output, much like most Audio Editors do.

Xcelled194 28 Junior Poster in Training

Hi, I have a rather interesting question... I'm writing an uninstaller, and I need it to load itself into memory, delete associated files, preform cleanup actions, and finally exit, all without using the CMD prompt. How can I do this?

Xcelled194 28 Junior Poster in Training

Hi guys, I'm an experienced VB programmer, but recently started using C# and I like it. But what I need to do now, is get a list of all printers installed on the computer (not a problem) and print a page to all of them (also not a problem)...

BUT (You knew there was a but coming...) it also tries to print to Virtual Printers (Like Adobe PDF, NoteWriter, XML loader, ect) which pops up a really annoying dialogue each time. I want to eventually use this automatically, IE no human intervention to close pesky dialogues.

So is there some way I can find out if it is a virtual printer?

Heres the relevant portion of my code:

String server = Console.ReadLine();
            if (server.ToLower() == "y")
                server = Environment.UserDomainName;
            else
                server = Environment.MachineName;
            System.Management.ManagementObjectCollection moReturn = default(System.Management.ManagementObjectCollection);
            System.Management.ManagementObjectSearcher moSearch = default(System.Management.ManagementObjectSearcher);
                List<String> Printers = new List<String>();      
            try {
	            moSearch = new System.Management.ManagementObjectSearcher("Select * from Win32_Printer");
                moSearch.Scope.Path.Server = server;
	            moReturn = moSearch.Get();
                Console.WriteLine("Fetching Printer list from " + server + "...");

	            foreach (System.Management.ManagementObject mo in moReturn) {
                    Printers.Add(mo.GetPropertyValue("name").ToString());
		           Console.WriteLine(mo.GetPropertyValue("name"));
	            }
            } catch (Exception ex) {
	            Console.WriteLine(ex.Message);
            } finally {
	            moReturn = null;
	            moSearch = null;
            }
            System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
            pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage);
            foreach (String printer in Printers)
            {
                Pos = 0;
                pd.PrinterSettings.PrinterName = printer;
                PB = new Rectangle(0, 0, pd.DefaultPageSettings.Bounds.Width, pd.DefaultPageSettings.Bounds.Height);
                try
                {
                    pd.Print();
                }
                catch
                {
                    continue;
                }
            }
Xcelled194 28 Junior Poster in Training

Hi, I'm making a custom sound class, basically, outside the class, I mesh several sounds into one byte array. Thats fine, It's not a problem. Now, I want to play one byte at a time. Long story short, I can't use DirectX or simply give the program a huge byte array. So, how do I pull one sound byte off and play it and then move on?

This is my API

Friend Declare Function PlaySound Lib "winmm.dll" (ByVal data() As Byte, _
            ByVal hMod As IntPtr, ByVal hwFlags As Integer) As Integer
Xcelled194 28 Junior Poster in Training

Doesn't it figure? I came up with that code a few minutes before you posted >_>

Thanks though, it works :D

Here's my code:

Private Sub WebBrowser1_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
        UpdateLabel.Text = e.Url.AbsoluteUri
        If e.Url.ToString.Substring(Len(e.Url.ToString) - 12) <> "?x=pt-sd.org" Then
            e.Cancel = True
            WebBrowser1.Navigate(e.Url.ToString & "?x=pt-sd.org", False)
        End If
        If WebBrowser1.CanGoBack Then BackBox.Enabled = True Else BackBox.Enabled = False
        If WebBrowser1.CanGoForward Then ForwardBox.Enabled = True Else ForwardBox.Enabled = False
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        ComboBox1.Text = WebBrowser1.Document.Url.AbsoluteUri
        UpdatePanel.Visible = False
    End Sub
Xcelled194 28 Junior Poster in Training

Hi,

I'm making a simple utility for browsing an intra-net site using VB.net webbrowser and for reasons outside my control, everything requires a passcode to be accessed. So, for example,

Index.html

is blocked by the company server but

Index.html?pass=123456

is allowed.

Is there a way to get the web browser to automatically add the "?pass=123456" bit to the end of every URL? Including images/ other content?

I'll take care of only using the "?pass=123456" on intra net sites, but what I need help with is getting it to Auto append.

I don't have VB on this computer, but I'm thinking of something like this:

Public Sub Webbrowser1_Navigate() Handles Webbrowser1.Navigate
'Preform intra-net check here
Webbrowser1.Location += "?pass=123456"
Webbrowser1.navigate()

Any thoughts?

Xcelled194 28 Junior Poster in Training

Thanks for your reply, you've given me some food for thought. Anyway, I have a fairly decent one going,

href="(((Http://)?((.*\.)?mysite\.com))?(/)?.*\.php[^"&;]*)

Unfortunately, theres a major problem. It uses the href to detect a link, but returns it in the match, creating

href="index.php

from

href="index.php"

So for now, I'll just use a second regex replace to strip out the href="

Also, it doesnt return any other file extentions, but they could be included with a "(.*)"

Xcelled194 28 Junior Poster in Training

Hi, I'm writing a web crawling program for my personal site, and I'm looking at using regex to extract the URLs. However, I have both absolute and relative URLs, and I want to match URLs only on my site (mysite.com).

So it would match:

/index.php
image1.jpg
page1.html
Http://mysite.com/
Http://mysite.com/page1.html
Http://Wiki.mysite.com/
Wiki.mysite.com/

but it wouldn't match:

Bob
Www.google.com
Mailto:Admin@mysite.com

Can anyone give me assistance? I'd post what I have so far, but it is this:

Nothing.

Xcelled194 28 Junior Poster in Training

This is untested:

'Make a new form, put this code in it, and set it as your startup form
'Also, make a new user setting of the type "date" called Expiration_Date
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Application.Deployment.IsFirstRun Then
            My.Settings.Expiration_Date = Now.Date
            My.Settings.Save()
        End If
        If DateDiff(DateInterval.Day, Now, My.Settings.Expiration_Date) > 30 Then '30 is the expiration date
            Dim Response As String = "~"
            While Response <> "Password here" And Response <> Nothing
                Response = InputBox("The 30 day trial is up! Please enter a password to continue using this software!", "Trial")
            End While
            If Response = Nothing Then End 'A crude, but effective, way of forcing a close
        End If
        Me.Hide()
        Mainform.show() 'If it passes all the tests, start the main program
    End Sub
End Class
Xcelled194 28 Junior Poster in Training

I thought of that, but the program randomly picks a point, and then does a random length flood fill, removing points from the list. My thought is to make a nested array. Then the program can randomly choose a sub array, and then a point from there.... and confine itself to those points....

Xcelled194 28 Junior Poster in Training

Hi, for a program, I need to map the location of all the back pixels in an image into some kind of structure. The program later uses the structure to select a random pixel location. It then removes the location, to prevent it being used again. The problem is, there is a huge number of black pixels (close to 40,000) so an ordinary array takes forever to search for and eliminate the "used" pixels. Is there some other "Faster" data structure?

Xcelled194 28 Junior Poster in Training

You could check into the FirstRun property, and somehow save that, and check it each time to program is run by using DateDiff....

Xcelled194 28 Junior Poster in Training

I have two forms (Form1 and Form2) which appear side by side. I want to "tie" them together, IE, you drag form1, and form2 follows it. I was thinking of using the Me.LocationChanged Event, but before I do that, I'm wondering if I'm overlooking a native way to get the same result.

Xcelled194 28 Junior Poster in Training

Correct me if I am wrong, but DocVeiwForm is a seperate form, no?

Sh why are you using Me.DocViewFrm.Show() ?

It should just be DocViewFrm.Show()

And you can open multiple forms with something like this (untested)

'This goes in your main form class
Dim WindowArray(0) as DocViewFrm

And then to actually show mutliple windows, you do this:

Redim Preserve WindowArray(Ubound(WindowArray)+1)
Dim M as long = ubound(WindowArray)
WindowArra(M) = new DocViewFrm
WindowArray(M).show
Xcelled194 28 Junior Poster in Training

Me.Close actually exits the program. Use Me.hide() instead.

Xcelled194 28 Junior Poster in Training

How do I say it? The keystrokes are getting to the proper application. its just ignoring them.

Xcelled194 28 Junior Poster in Training

Thats not my problem. The window is active, and if I activate notepad instead, the keystrokes do send. No, its an issue of the actual Send method, if that makes sense.

Xcelled194 28 Junior Poster in Training

I am replacing an AutoHotkey script with a VB.net application. Part of the script involves sending keystrokes to an active application. VB uses SendInput and does send the keystrokes, but the application doesn't "get" them, but when AutoHotkey sends the same key to the same application, it works. I have verified that VB is indeed sending the keys properly. Does anyone know how to imitate the autohotkey Send function?

Xcelled194 28 Junior Poster in Training

Its not a very elegant solution, but it should work for what you need.

Dim sTemp As String = "12             25.53            35"
        Try
            For I = 1 To sTemp.Length - 1
                If sTemp.Substring(I, 1) = " " Then
                    Dim SpaceCTR = 0
                    For L = I To sTemp.Length
                        If sTemp.Substring(L, 1) <> " " Then Exit For
                        SpaceCTR += 1
                    Next
                    If SpaceCTR > 1 Then
                        sTemp = sTemp.Remove(I, SpaceCTR - 1)
                    End If
                End If
            Next
        Catch ex As System.ArgumentOutOfRangeException
        End Try
Xcelled194 28 Junior Poster in Training

Great! Finally worked! Thanks!

Xcelled194 28 Junior Poster in Training

My curse seems to be SendInput... I have tried many sites and code variations and it never works right... it always returns an error. So can someone just whip together a quick class that has 3 public methods, one for keyboard (that takes a Keys data type) one for mouse, and one for Hardware? Please don't link me to anything, I've tried so many sites that my head's spinning.

Xcelled194 28 Junior Poster in Training

The Try and Do examples are interchangeable, as well as any other blocks that can be exited, such as a While.

Xcelled194 28 Junior Poster in Training
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim word As String
        word = TxtBox1.Text.ToLower
        For I = 0 To word.Length - 1
            If word.Substring(I, 1) = word.Substring(word.Length - I - 1, 1) Then
                Continue For
            Else
                TxtBox1.Text = "The word is not a palindrome." : Exit Sub
            End If
        Next
        TxtBox1.Text = "The word is a palindrome."
    End Sub
Xcelled194 28 Junior Poster in Training

I've noticed an "awkward" issue in VB.... how to escape from things like nested loops or nested IFs, where the standard Exit Loop, Exit For, or Exit If simply starts a new iteration.

For example, assume we have a 3-dimensional array (TheArray) that we want to brute-force test to see if it contains a "true" value. The easiest way would probably be this:

For X = 0 To 50
            For Y = 0 To 50
                For Z = 0 To 50
                    If TheArray(X, Y, Z) = True Then GoTo ExitLoops
                Next
            Next
        Next
ExitLoops:
'Do something else here

But I've always been taught to avoid GOTO statements.... With that in mind, I could do this:

Dim Exiting As Boolean = False
        For X = 0 To 50
            For Y = 0 To 50
                For Z = 0 To 50
                    If TheArray(X, Y, Z) = True Then Exiting = True : Exit For
                Next
                If Exiting Then Exit For
            Next
            If Exiting Then Exit For
        Next
        'Do what you will here

but that makes the code longer, harder to read, and its a pain to have to explicitly exit all the loops, especially as the nest gets deeper...

So we could do this:

Do
            For X = 0 To 50
                For Y = 0 To 50
                    For Z = 0 To 50
                        If TheArray(X, Y, Z) = True Then Exit Do
                    Next
                Next
            Next
        Loop While 1 <> 1
        'Do something here

But that also gets …

Xcelled194 28 Junior Poster in Training

Well, I found it. I, being the idiot I am, forgot to add this line

Chessboard(location.X, location.Y) = 1

so it wasn't recording progress.

Xcelled194 28 Junior Poster in Training

OK, this one has me baffled. I'm trying to teach myself more about recursive functions, so I'm making a prgoram to figure out the Knights Tour (http://en.wikipedia.org/wiki/Knight's_tour). It went well until I tried to run it. It stops randomly between 2,000 and 3,000 iterations with a Stack Overflow Error, yet its not doing a math operation. I thought it was a result of me using unsafe threading, so i removed threading, and it still threw the error. I removed the counter. Still error. Maybe someone can help me find this bug? Its a very sinple program....

The program uses an array of 0s and 1s to record where its "been". It uses another array of all the possible moves it can make, and tries those one at a time, brute force.

It also bugs me because I could understand if it was running out of memory, but it's not throwing a Out Of Memory error....

Public Class Form1
    Dim Chessboard(7, 7)
    Dim Moves(8) As Point
    Dim G As Double = 0
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
        For I = 0 To 7
            For J = 0 To 7
                Chessboard(I, J) = 0
            Next
        Next
        Moves(0) = New Point(3, 1)
        Moves(1) = New Point(1, 3)
        Moves(2) = New Point(3, -1)
        Moves(4) = New Point(-3, -1)
        Moves(5) = New Point(-3, 1)
        Moves(6) = New Point(-1, 3)
        Moves(7) = New Point(-1, -3)
        Moves(8) = New Point(1, -3)
    End Sub
    Private Sub …
Xcelled194 28 Junior Poster in Training

Thanks for your replies. Altarium, that's not quite what I'm looking for; the other application isn't mine.

codeorder, your suggestion looks promising, but i want to draw on a program, not the desktop. So I would just replace the Desktop Handle finder with one for the program, and use that instead?

Also, will I have to re-draw the guide whenever the program refreshes itself?

Thanks for the lead, I'm checking into it now.

Xcelled194 28 Junior Poster in Training

I'm attempting to make a program that will simply draw a guide (consisting of two perpendicular lines) on another program's window. I tried using a form with a transparency key and TopMost set to true, but then whenever the user inadvertently clicked the guide, it would un-focus the application. This happened a lot, and was a great source of annoyance... So I did some research, and the only lead I could find was a suggestion to "Draw directly on the other application's window". I can't find anything that tells me how to do this, or if its even possible... So I need to know one of three things:

1) Is it possible?
2) How do you do it?
or 3) is there some way to make a form completely un-focusable?


The effect I'm trying to get is so that it looks like someone physically drew the line on the monitor itself.

Xcelled194 28 Junior Poster in Training

Set AutoPostBack=True of Textbox8 control.

I did, but now it reloads the entire page, not just the UpdatePanel

Xcelled194 28 Junior Poster in Training

Hi all,

I'm designing a web page in ASPX. I have a few textboxes where the user enters the number of items, and a label that shows what they would currently pay if they checked out at that moment. I need help using a UpdatePanel to refresh the label when they make a change. I have a custom function called Calc() that calulates and returns the amount they owe.. So, for example, when the user changes the text in textbox8, I want the label to be updated with the new value of calc(). Heres my code for the updatepanel/label:

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
              <ContentTemplate>
                  <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="20pt" 
              style="text-align: center" Text="You owe: $0.00"></asp:Label>
              </ContentTemplate>
          </asp:UpdatePanel>

Then, in my Textbox8.TextChanged method:

Private Sub TextBox8_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
        Me.Label1.Text = "You owe: " & Calc()
        Me.UpdatePanel1.Update()
    End Sub

But that doesnt refresh the label. What am I doing wrong?

Xcelled194 28 Junior Poster in Training

You Might look into using regular expressions or the Like operator:

If phonenumbertxtbox.Text Like "$$$-$$$-$$$$" Then Msgbox ("Correct")

Regular expressions are more advanced, but you can do more checking with them.

Xcelled194 28 Junior Poster in Training

So you want to raise the Picturebox1.Click event when the user presses the enter key?

Why not make a hidden button, make it your "accept button" and then use the following code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1_Click(sender, e)
    End Sub
Xcelled194 28 Junior Poster in Training

So wait. When the use presses the Enter key, what do you want to have happen?

Xcelled194 28 Junior Poster in Training

1) Get values of X, Y, and C and assign them to respective variables
2) If C = 1 then
If X > Y then print X else Print Y
3) If C Is Not = 1 then
If X < Y then Print X else Print Y
4) End

Xcelled194 28 Junior Poster in Training

There are several problems with your code. I've corrected them in the following:

Public Class frmAssign6
    Dim sr As IO.StreamReader = IO.File.OpenText("words.txt")
    Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
        Dim words1 As String = "" 'Always initialize it, just to be safe

        While Not (sr.EndOfStream)
            words1 = sr.ReadLine
            lstResults.Items.Add(words1) 'This needs to be inside the loop, or you just add the last line of the file
        End While

        sr.Close() 'Always close a file when you are done reading it
    End Sub
End Class

1. You should always give things an initial value, just to be safe (Especially if the text document may be empty. Check your words.txt and make sure there is stuff in it)

2. Your lstResults.Items.Add(words1) line should be inside the while loop. Otherwise, it loops through the file and adds only the last line.

3. Its always a good idea to close a file after you're done with it.

Xcelled194 28 Junior Poster in Training

Its my first post, and its a complicated one... I need some help writing an image coloring algorithm for a personal project.

I have two programs, a restorer and a code generator. The restorer reads code generated by the code generator and manipulates the mouse accordingly. Every mouse event is one line. This means moving the mouse, holding the left button, moving it somewhere else, and letting it up would take up four lines!

The pictures are 200x200. They are all white, except for a red object in the middle. The shape of this object varies. A sample picture would be:

http://img19.imageshack.us/img19/6554/pumpkine.png

The program can switch between two brushes, one that is 28 pixels across, and one that is 8 pixels across.

The brush cannot touch any red!

I have all the coding in place and working. It checks for a red pixel in the vicinity of the brush. If it finds one, it simply moves on.

What I need help with is figuring out an algorithm that will eliminate all of the white in as few Mouse events as possible. There is a limit of approximately 600 Mouse events. So far I've tried the brute force linear with big brush, then finishing details with the small brush. But, needless to say, that took up wayyy to many lines.... Can anyone help?

P.S. My language of choice is VB