|
I think if you simply want to find the active window, then you should should run the script as a function (within a common module) rather than in a timer (in a form) or at the very least disable the timer once you have found the active window.
The sample code you provided lives in the TIMER's event routine within the FORM.
This would also mean if you have several forms then they are all running concurrently.
And this is why your system is becoming unresponsive?
For what you want to do, I dont think the sendkeys is the problem, its probably the timer which runs every so often... (100 milliseconds i think you had it at).
If everyone tells you you shouldn't use sendkeys to do what you want, then more than likely they are right! After all so many people cannot be wrong?
Maybe you could use API functions to attain the results you want?
Im not sure but it cannot be too difficult for you to find the answer in the documentation on MSDN.
I have seen several posts on this websites forum which deal with finding the active window.
Maybe surfing through those threads/posts would give you a better resolution to your issue.
|
|
|
|
|
The VB6 code migration wizard no longer exists in Visual Studio 2010 and above. If you've got VB6 code to convert, you'll either need to use Visual Studio 2008 to do a conversion, the quality of which depends entirely on your VB6 code. The more PInvoke stuff you have in it, they worse the conversion will be.
Keep in mind that the conversion utility will not rewrite your code to what you can do by hand today under .NET. It will convert the project so that it has a decent chance of at least compiling. VB6 did so many things poorly that it's sometimes just impossible for it to figure out what you were doing and rewrite appropriately.
|
|
|
|
|
Hello,
I'm using:
Microsoft Visual Basic 2008, Professional Edition
I've run into a problem I can't figure out. I'm using VB 2008. I found the following sample code and was attempting to use it but am not understanding how to setup the query, I bolded it below.
I understand I need to go in and set up my own customer query in my database in order to use it like the example below.
Q) Do I setup the query on my table adapter or on the original table in the database (Maybe even some good info on how to setup these queries)?
Q)If I'm understanding this, once I setup the query correctly I should just have to put in a variable and it fill find all row(s) with that parameter that I can delete?
Q) When using the @XXXX in the query, do I have to then use that as my variable to pass the data I'm looking for or can I use and variable?
' Locate the row to delete.
Dim oldRegionRow As NorthwindDataSet.RegionRow
oldRegionRow = NorthwindDataSet._Region.FindByRegionID(5)
' Delete the row from the dataset
oldRegionRow.Delete()
' Delete the row from the database
Me.RegionTableAdapter.Update(Me.NorthwindDataSet._Region)
I was able to setup the following query on my database but per the example, I'm not sure I did it correctly:
SELECT Gene, FindMethod, TDiscovery, TReplicate, AA_A, AA_T, AA_G, AA_C, ImageFileName, Description, SpxReplicationItem, IconFileName, Complete, Image, Icon, Type,
UniqueID, Chromosome, Rarity, ParentGene, Name
FROM PlazimorphGenes
WHERE (Gene = @genename)
I then tried using it as this:
tRow = PlazimorphDBDataSet.PlazimorphGenes.FillByGene(genename)
and got an error that it is not a member of the database.
Thank you for all the help! I've been searching this forum and the web in general and have found the best help here!
modified 1-Dec-12 15:44pm.
|
|
|
|
|
Have you got a link to the code you are trying?
I suspect that you require a Stored Procedure on the Database:
USE BDNAME
GO
CREATE PROCEDURE SelectByGeneName(
@GeneName VarChar(100)
)
AS
BEGIN
SET NOCOUNT ON;
SELECT Gene, FindMethod, TDiscovery, TReplicate, AA_A, AA_T, AA_G, AA_C, ImageFileName, Description, SpxReplicationItem, IconFileName, Complete, Image, Icon, Type,
UniqueID, Chromosome, Rarity, ParentGene, Name
FROM PlazimorphGenes
WHERE Gene = @genename
RETURN;
END
GO
I dont use the automatic binding etc...so I would retreive the data like this:
Public Function GetByGeneName(name as String) As DataTable
Dim cn as New SqlConnection(ConnStr)
Dim cmd as New SqlCommand
Dim dt as New DataTable("PlazimorphGenes")
Try
cn.Open()
With cmd
.Connection = cn
.CommandType = CommandType.StoredProcedure
.CommandText = "SelectByGeneName"
.Parameters.AddWithValue("@GeneName", name)
Dim da as New SqlDataAdapter(cmd)
da.Fill(dt)
End With
Catch ex as Exception
...
Finally
If cn.State <> ConnectionState.Closed Then cn.Close()
End Try
Return dt
End Function
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
I was attempting to use the sample code above like this:
Dim tRow As PlazimorphDBDataSet.PlazimorphGenesRow
Dim genename As String
genename = MTBGeneLabel.Text.ToString()
tRow = Me.PlazimorphGenesTA.FillByGene(Me.PlazimorphDBDataSet.PlazimorphGenes, genename)
tRow.Delete()
Me.PlazimorphGenesTA.Update(Me.PlazimorphDBDataSet.PlazimorphGenes)
I did go into the database designer and create the specific query on the table. It looks SELECT code section you posted above.
The error I'm getting is specific to this line:
tRow = Me.PlazimorphGenesTA.FillByGene(Me.PlazimorphDBDataSet.PlazimorphGenes, genename)
I'm getting
"Value of type 'Integer' cannot be converted to 'PlazimorphAdmin.PlazimorphDBDataSet.PlazimorphGenesRow'"
I thought Visual Studio would automatically add the stored procedure. Maybe I need to add it as you suggest.
If I change the line to this:
tRow = Me.PlazimorphGenesTA.FillByGene(genename)
I get the following two errors:
"Argument not specified for parameter 'genename' of 'Public Overrideable Overloads Function FillByGene(dataTable as PlazimorphDBDataSet.PlazimorphGenesDataTable, genename as String) As Integer'."
and
"Value of type 'String' cannot be converted to 'PlazimorphAdmin.PlazimorphDBDataSet.PlazimorphGenesDataTable'."
And If I use this version:
tRow = Me.PlazimorphGenesTA.FillByGene(tPlazimorphGenes, genename)
I get
"Value of type 'Integer' cannot be converted to 'PlazimorphAdmin.PlazimorphDBDataSet.PlazimorphGenesRow'"
The query I have attached to the table is this:
SELECT Gene, FindMethod, TDiscovery, TReplicate, AA_A, AA_T, AA_G, AA_C, ImageFileName, Description, SpxReplicationItem, IconFileName, Complete, Image, Icon, Type,
UniqueID, Chromosome, Rarity, ParentGene, Name
FROM PlazimorphGenes
WHERE (Gene = @genename)
I have a solid background in visual basic programming but haven't work this much with a database.
|
|
|
|
|
OK, are you generating the DataSet from the Visual Studio Wizard?
This exposes you to the evils of the BindingSource, TableAdapter, and TableAdapterManager classes. (I and many others here avoid them like the plague).
This may be a usefull article: A Detailed Data Binding Tutorial (CP)[^]
Rolling your own database access is not so hard:
...
Dim cn As New SqlConnection("myConnectionStringHere")
Dim cmd As New SqlCommand()
Try
cn.Open()
With cmd
.Connection = cn
.CommandType = CommandType.Text
.CommandTExt = "your SELECT query here"
.Parameters.AddWithValue("@genename", yourGeneNameVariable)
Dim dt As New DataTable("PlazimorphGenes")
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt)
plazimorphGenesDataGrid.DataSource = dt
End With
...
you can then look after the delete query yourself too
...
Dim dr as DataRow = tRow(0)
Dim queryString as String = "DELETE PlazimorphGenes WHERE Id = @Id"
Dim cn As New SqlConnection("yourConectionString")
Dim cmd As New SqlCommand
Try
cn.Open()
With cmd
.Connection = cn
.CommandType = CommandType.Text
.CommandText = queryString
.Parameters.AddWithValue("@Id", CInt(dr("Id")))
.ExecuteNonQuery()
End With
UpdateDataGrid(...)
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
Thank you for the link! Yes, I've used the data wizard. It's been a few years working on such a big database project as a 'hobby project'. Most of the tutorials and examples use it.
I've been able to create a DELETE function on the tables and its working, also a INSERT on.
The next step I've having issue with is filling a combo box with a query. I've added the query to the table but can't get it/figure our how to apply it to filtering data to the combo box. I also tried using the 'Filter' on the Binding source but it doesn't seem to work.
|
|
|
|
|
hi
Wanted with VB.Net Last Date modified Registry key
To do this I need to use the RegQueryInfoKey API
|
|
|
|
|
alirezamansoori wrote: I need to use the RegQueryInfoKey API Very true; you also need to use the documentation[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
RegistryKey Class does not have the ability to do my job
|
|
|
|
|
Then you probably need to use P/Invoke[^] to get access to the Win32 function.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
i want to learn more about VB & how i can make a program that will allow me to
Add Quotations
make calulation from user inputs,
Cross-ref this information agaisnt a M$ database,
then export a quotation into a pdf, and also export data into M$ Database to create new jobs,
and finally i would like to create a Order acknowledgement from all the information to send to customers & export into Sage.
im hoping there is a magical book that can teach me all these steps
and hoping i can buy it from amazon
and hoping you guys and gals may know the perfect book!
we have been using a system at work at for many years now, which i did create but it is very disjointed,
quotations = made in Excel manual input and searchs
Job = created in Access manual input from quotations
Order acknowledgements = made in sage - another manual repeated job.
overal a job is re-entered 3 to 4 time repeated. when new & 2 times when existing and its a re-order.
so im hoping i can strimeline all this down
|
|
|
|
|
Books aren't written to accommodate ones business-requirements. There are a bunch of video's and how-to's on MSDN, that'd might be a useful introduction into the specific topics you request. I'd recommend "Head on C#", but it's not about VB and not about Access.
|
|
|
|
|
Hi!
I am a VB.Net programmmer. I use the SQL Server and as backend but when I deploy my application to another computer, It is required the SQL Server must be installed on another computer. Please suggest how to work with SQL database (.mdf,.ldf) without installing SQL Server on another computer becuase I cannot go everywhere for each computer to install the application If user of my application is just simple user. If there is another solution, please let me know. I will be very thankful to him/her.
|
|
|
|
|
How is the application going to be installed? Perhaps you can include it there
|
|
|
|
|
hi
how writen code in vb for 8queen genetic algoritm
please send for me source code
|
|
|
|
|
This is not the kind of site which will just give you an answer to your homework.
You must prove that you have made an attempt to solve a problem and the folks here will be happy to help you.
|
|
|
|
|
See here[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
for this system do i need DAQ hardware?
TQVM
WISEL UTeM
modified 21-Nov-12 9:29am.
|
|
|
|
|
So you've slept through your entire course, not learnt anything, and now you expect someone else to write your final year project for you?
That's not going to happen.
I suggest you go and talk to your tutor to find out what your options are.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
tq for ur word.
i haven't learn about visual basic for this 5 years.
i only learnt computer hardware.
|
|
|
|
|
Friends
Please inform me how can we control the monitor brightness
in visualbasic 6.0
Thanks and regards,
Muhammed Niyas
|
|
|
|
|
A quick check on Google shows this article.
http://www.vbforums.com/showthread.php?561682-2008-How-to-adjust-screen-brightness[^]
But please remember that VB6 is a depreciated product and not alot of people will support it.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
I need code for Export data from Gridview to Sql Server in vb.net windows application
|
|
|
|
|
..this ain't MacDonalds, so you can't "order" code like you would do with a hamburger.
The grid is called a DataGridView , not a "gridview". There are quite some examples and tutorials on manipulating data using VB.NET; what did you try?
We don't deliver ready-made solutions here, if you have a specific question we can help.
|
|
|
|
|