Hello, I am very new to VB.net. I know some other languages but this seems completely different, anyways, I am trying to make an autoclicker and auto skill leveler for an online mmorpg. I have the code doing what I want it to; however, I was wondering if I could somehow dynamically search for the game window PID and attach it to that window so it would level stuff in the background so I could do work at the same time. Any ideas?

[CODE]Public Class Form1
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Const MOUSEEVENTF_MOVE As Int32 = &H1 ' mouse move
Const MOUSEEVENTF_LEFTDOWN As Int32 = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP As Int32 = &H4 ' left button up
Const MOUSEEVENTF_RIGHTDOWN As Int32 = &H8 ' right button down
Const MOUSEEVENTF_RIGHTUP As Int32 = &H10 ' right button up
Const MOUSEEVENTF_MIDDLEDOWN As Int32 = &H20 ' middle button down
Const MOUSEEVENTF_MIDDLEUP As Int32 = &H40 ' middle button up
Const MOUSEEVENTF_ABSOLUTE As Int32 = &H8000 ' absolute move
Const MOUSEEVENTF_WHEEL As Int32 = &H800 ' wheel button rolled
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Timer1.Stop()
End Sub

Private Sub MyMethod1()
    Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)
    mouse_event(&H8, 0, 0, 0, 1)
    mouse_event(&H10, 0, 0, 0, 1)
End Sub ...

Maybe I am missing something that is clearly obvious but I have fiddled with this printHelper and print function for a while and cant seem to figure it out. The rest of the program works and gets the correct code, but this does not. It should print out 1 -> 3 -> 5

instead i get this
The shortest path from 1 to 5 has length 27 and is
1 -> 3 -> 1 -> 1 -> 0 next value is 5
1 next value is 1
2 next value is 1
3 next value is 1
4 next value is 1
5 next value is 3

I have a graph g that has a vertex* including next which is the number that comes previous to it. I have it so it sets them right but it is not outputting them correctly. Here is the print functions I am using.

[code=c]
// printPathHelper(Graph g, int start, int end) prints out the
// length of the shortest path from start vertex to finish vertex
// in Graph g
void printPathHelper(Graph g,int start,int n)
{
while(n != start)
{
n = g.info[n].next;
cout << n << " -> ";
printPathHelper(g,start,n);
}
}

// printPath(Graph g) prints out the shortest path
// from start vertex to finish vertex in Graph g
void printPath(Graph g, int start, int end)
{
cout << "The shortest path from " << start << " to " << end;
cout << " has length " << g.info[end].distance << ...

[QUOTE=jonsca;1166424]Dereference s before you try to get the c_str() method:
[icode] c = (*s).c_str(); [/icode] since s is a pointer to string not a string. Or [icode]c=s->c_str();[/icode] will work too I just thought the other form was more illustrative for your benefit.

Also, strlen won't give you the length of the std::string, use [icode] s->length() [/icode](same need to dereference) instead-- unless you meant to take strlen of c instead.[/QUOTE]

got it :) thank you. though i didnt use this method, instead i just used the ofstream feature of append. appreciate the feedback though :)

I am trying to copy a string into an array then write bits out to a file accordingly. (compression assignment). here is the code

[code=c]
// strnewdup(const char s) returns a copy of a
// null-terminated string, with the copy stored
// in the heap
char
strnewdup(const char s)
{
char
space = new char[strlen(s) + 1];
strcpy(space, s);
return space;
}

// putCodes(Node& t, string codes) traverses
// the tree t, recording the non-leaves(0) and
// leaves(1) into the correct letters code array
// to identify that letter
void putCodes(Node t, string s, string codes)
{
if(t->kind == leaf)
{
const char* c = s.c_str();
codes[(int)t->ch] = c;
}
else
{
putCodes(t->left, s+"0", codes);
putCodes(t->right, s+"1", codes);
}
}

ONE I AM HAVING TROUBLE WITH
// encFile(cont char argv[], BFILE& f, string code)
// encodes the file argv and using the codes from code
// array puts them into file f
void encFile(const char
argv, BFILE& f, string code)
{
string s;
s = code;
const char
c;
c = s.c_str();
int length = strlen(s);
}
[/code]

Here is the error I am getting

huffman.cpp: In function ‘void encFile(const char, BFILE&, std::string)’:
huffman.cpp:164: error: request for member ‘c_str’ in ‘s’, which is of non-class type ‘std::string

huffman.cpp:165: error: cannot convert ‘std::string’ to ‘const char’ for argument ‘1’ to ‘size_t strlen(const char*)’
huffman.cpp:165: warning: unused variable ‘length’
make: *** [huffman] Error 1

They are both string are they not? Also, I have tried const char and that does not work ...

figured it out and fixed it. works now. thank you all who helped <3 <3

I am sorry for that last one I was brain dead. I have been working on this coding just the first step for about 3 days and have gotten pretty much no where on it. I am not trying to be a bother and ask for every little thing either and I am just getting frustrated with this coding and myself that I cannot even figure out what to do next. I have everything working and all, but it won't return the right vertex. I have tried multiple ways of doing it and nothing has worked. ListCell l is not null when I read it in and for this assignment it won't be. It is returning 0 as of right now which I do not understand. I get it to either return junk or return 0. I have even tried drawing diagrams tracing what it does. With the recursion is it going from the end of the list to the front and therefore not giving me the right answer?

Test File:
[code=c]
5
1 2 9.0
1 3 12.0
2 4 18.0
2 3 6.0
2 5 20.0
3 5 15.0
0
2 4
[/code]

Coding: (The part I am having trouble with is stepOne() )
[code=c]
// Zachary Dain
// CSCI 3300 Assignment 3
// tab stops: every 2 spaces

include <iostream>
include <math.h>

using namespace std;

enum StatusType {Done, Pending, Peripheral};

struct ListCell
{
ListCell next;
int adjVertex;
double weight;
ListCell(int v, double wt, ListCell
n)
{
adjVertex ...

Anyone willing to help me find why this is giving me a segmentation fault?

[code=c]
// Zachary Dain
// CSCI 3300 Assignment 3
// tab stops: every 2 spaces

include <iostream>
include <math.h>

using namespace std;

enum StatusType {Done, Pending, Peripheral};

struct ListCell
{
ListCell next;
int adjVertex;
double weight;
ListCell(int v, double wt, ListCell
n)
{
adjVertex = v;
weight = wt;
next = n;
}
};

struct Vertex
{
StatusType s;
ListCell* cell;
double distance;
int next;
Vertex()
{
distance = 0;
s = Peripheral;
cell = NULL;
}
};

struct Graph
{
Vertex* info;
int numVertices;
};

// readGraph() reads in the graph and puts the
// values into the appropriate lists

void readGraph(Graph &g)
{
int u = -1, v;
double weight;

cin >> g.numVertices;
g.info = new Vertex[g.numVertices+1];
while(u != 0)
{
    cin >> u;
    if(u != 0)
    {
        cin >> v;
        cin >> weight;
        g.info[u].cell = new ListCell(v,weight, g.info[u].cell);
        g.info[v].cell = new ListCell(u,weight, g.info[v].cell);
    }
}

}

// printGraphHelper() calculates and prints the values
// of each cell using recursion
void printGraphHelper(int i, ListCell* l)
{
if(l != NULL)
{
if(l->adjVertex > i)
{
cout << " (" << i << "," << l->adjVertex << ")";
cout << " weight " << l->weight << "\n";
}
printGraphHelper(i,l->next);
}
}

// printGraph() prints out the number of vertices,
// each connecting edge, and its weight

void printGraph(int n, const Graph g)
{
cout << "There are " << n << " vertices.\n";
cout << "The ...

[QUOTE=Fbody;1139930]Line 43, move the "[]" after the 'j' and see what happens. The braces need to be associated with the variable name, not the dataType.[/QUOTE]

That does work and thank you; however, now one more thing. I get an error stating it doesn't know the size of j and I know how to fix it by putting j[<number here>] (line 33) before the ; then just using j later on.......but I don't want to hard code it. I am asking for the size from numVertex before I call readGraph(n) and I am passing that value. What's wrong with it?

This is a homework problem; however I just want some direction. I have to write a module graph.cpp that implements djikstra's algorithm. so far i am at the reading in module and am trying to make an array of structures. here is the code.

[code=c]
// Zachary Dain
// CSCI 3300 Assignment 3
// tab stops: every 2 spaces

include <iostream>
include <math.h>

using namespace std;

enum StatusType {Done, Pending, Peripheral};

struct ListCell
{
ListCell next;
int adjVertex;
double weight;
ListCell(int v, double wt, ListCell
n)
{
adjVertex = v;
weight = wt;
next = n;
}
};

struct arrayOfStructs
{
StatusType s;
ListCell* cell;
arrayOfStructs()
{
s = Pending;
cell = NULL;
}
};

// readGraph() reads in the graph and puts the
// values into the appropriate lists/PQ

void readGraph(int n)
{
int firstVert, secondVert;
double weight;
arrayOfStructs[] j = new arrayOfStructs[n+1];
while(firstVert != 0)
{
cin >> firstVert;
if(firstVert != 0)
{
cin >> secondVert;
cin >> weight;
j[firstVert].cell = new ListCell(secondVert,weight, j[firstVert].cell);
j[secondVert].cell = new ListCell(firstVert,weight, j[secondVert].cell);
}
}
}

int main()
{
int numVertex;
cin >> numVertex;
readGraph(numVertex);
}
[/code]

I am getting the following errors:
graph.cpp: In function ‘void readGraph(int)’:
graph.cpp:43: error: expected unqualified-id before ‘[’ token
graph.cpp:51: error: ‘j’ was not declared in this scope
make: *** [graph] Error 1

I understand that the second error is due to the first one. I have looked around and have found no solution. Any advice? Should i use a typedef?