|
Hi!
I am looking for the code that write a string to the Textbox of a other Program.
I find out, that I can activate a other open Program by :
"AppActivate(Program)"
and write there something by :
"My.Computer.Keyboard .SendKeys(XYstring)"
if there is any textbox activated.
And now the Question: is it possible to activate in this other "Program" a certain Textbox?
Just the hope that accidently the right textbox is activ is not enough.
Hans-Christian
|
|
|
|
|
Maybe. It depends on the other program. If it is possible, it's with great difficulty.
You have to find the window handle of the application is question, then traverse the window tree to find the window handle of the textbox in question. Then you can pass that window handle to the Win32 function ShowWindow (I think!) to give it the input focus. Then you can TRY to stuff keystrokes into it with SendKeys.
There is a problem with this though. You cannot guarantee that the focus will stay in that window in the time it takes to go from focusing that window and stuffing the keyboard. You could very well end up stuff those keys into another window!
A better method would be to use the Win32 function SetWindowText to put the string into that window.
But, the hardest part of this is going to be getting the handle of that textbox. You have to be very familiar with the windows in that application (not the visual part you see on the screen, but the parent/child relationship of the variable controls in those windows!
In short, you simply don't have that much control over the visual elements of another application.
|
|
|
|
|
As the previous poster said, it can be done with great difficulty. If you decide to delve into the Win32API, I would strongly recommend a book by Dan Appleman "Visual Basic Programmer's Guide to the Win32 api". It is a superb api reference documenting a significant number of the underlying windows api's and how the OS works at an api level. It was written for VB4-6 so any code examples have to be adjusted language wise for vb.net/c#, but as a C# programmer I can tell you I've never found a better api reference.
topcoderjax
|
|
|
|
|
You might want to try replying to the original poster. That way, he'll get an email you replied.
|
|
|
|
|
Thanks... Guess I assumed that as the original poster he would get all traffic on the post.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Nope. Only the person you reply to gets the notifications.
|
|
|
|
|
Reposting the following just in case it wasn't received:
As the previous poster said, it can be done with great difficulty. If you decide to delve into the Win32API, I would strongly recommend a book by Dan Appleman "Visual Basic Programmer's Guide to the Win32 api". It is a superb api reference documenting a significant number of the underlying windows api's and how the OS works at an api level. It was written for VB4-6 so any code examples have to be adjusted language wise for vb.net/c#, but as a C# programmer I can tell you I've never found a better api reference.
topcoderjax
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Visual Basic 2005 Express:
My app checks the website to see if a new version is available.
How can I have it link to MyApp.msi on the website to download and install it if a new version is available?
|
|
|
|
|
I may be wrong, but doesn't ClickOnce deployment already support doing this? I don't konw for sure since I have very little use for ClickOnce in my environment.
|
|
|
|
|
I don't like ClickOnce, I am using a Windows Installer Setup project to deploy.
|
|
|
|
|
Then you'r going to have to write the code to check a website yourself. The website should have an XML file for version information and a download package available. This package would have to be unpacked and installed on the client side, but from a seperate executeable, not your main EXE. This is because you can't overwrite an EXE while it's running.
The web information can be had by using the WebRequest class, along with downloading the file. Launching a seperate process is easy with the Process class. XML file processing is also easy with the XmlDocument class and XPath.
|
|
|
|
|
Hi Everyone:
This problem has been plaguing me for three days, and I can’t for the life of me find a logical reason why this problem occurs.
My problem occurs when I try to write data into a dataset that contains nothing more than the table schema.
This subroutine is supposed to write a new record into the dataset.
Private Sub New_Bindings(ByVal intOrdinal As Integer, _
ByVal strCode As String, _
ByVal strName As String)
tblBindings = MyDataSet.Tables("tblBindings")
drCurrent = tblBindings.NewRow()
drCurrent("Ordinal") = intOrdinal
drCurrent("BindingCode") = strCode
drCurrent("BindingName") = strName
tblBindings.Rows.Add(drCurrent)
End Sub
I write new data into the dataset when this subroutine is activated. It is activated when the Private Sub BindingNavigatorAddNewItem_Click event is triggered: The AddNew Button on the BindingNavigator control on the form.
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
Call New_Bindings(1, "SDLS", "Saddle-stitch")
Call New_Bindings(2, "SPRL", "Spiral Bound")
Call New_Bindings(3, "STUL", "Staple Upper Left")
Call New_Bindings(4, "STUR", "Staple Upper Right")
Call New_Bindings(5, "ST2L", "Two Staples on left side")
End Sub
The dataset’s data should read like this:
BindingID – 1
Ordinal – 1
Code – SDLS
Name – Saddle-stitch
BindingID – 2
Ordinal – 2
Code – SPRL
Name – Spiral Bound
BindingID – 3
Ordinal – 3
Code – STUL
Name – Staple Upper Left
BindingID – 4
Ordinal – 4
Code – STUP
Name – Staple Upper Right
BindingID – 5
Ordinal – 5
Code – ST2l
Name – Two Staples on Left Side
What I am actually getting is:
BindingID – 0
Ordinal – 1
Code – SDLS
Name – Saddle-stitch
BindingID – 1
Ordinal – 2
Code – SPRL
Name – Spiral Bound
BindingID – 2
Ordinal – 3
Code – STUL
Name – Staple Upper Left
BindingID – 3
Ordinal – 4
Code – STUP
Name – Staple Upper Right
BindingID – 4
Ordinal – 5
Code – ST2l
Name – Two Staples on Left Side
For some reason when the first record is written out to the dataset the auto increment field (BindingID) is not incremented to one when the record is written. It has an ID of “0” which logically can’t happen when the column has been defined to be an auto increment column starting at one and incrementing by one every time a new record is added.
Can anyone tell me why this is happening and what I need to do to correct it?
Thanks,
Quecumber256
|
|
|
|
|
Quecumber256 wrote: tblBindings = MyDataSet.Tables("tblBindings")
drCurrent = tblBindings.NewRow()
drCurrent("Ordinal") = intOrdinal
drCurrent("BindingCode") = strCode
drCurrent("BindingName") = strName
tblBindings.Rows.Add(drCurrent)
Wow I just saw something here.
You need to do the following instead.
drCurrent = MyDataSet.Tables("tblBindings").NewRow()
drCurrent("Ordinal") = intOrdinal
drCurrent("BindingCode") = strCode
drCurrent("BindingName") = strName
MyDataSet.Tables("tblBindings").Rows.Add(drCurrent) That is one issue. The other I still cant see based on what you provided.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Cleako:
Just to let you know I appreciate your help.
I tried your fix. I still get the same results. Therefore I'm providing you the entire code for the data entry form. I hope this give you enough information to see what is causing the first record to not be recorded properly.
Option Explicit On
Imports System.Data.SqlClient
Public Class frmBindings
Private Msg As String
Private strSQL As String
'Declare the SQLDataAdapter and DataSet objects
Private daBindings As New SqlDataAdapter()
Private MyDataSet As New DataSet()
Dim tblBindings As DataTable
Dim drCurrent As DataRow
Private Sub Clear_Form()
txtBindingCode.Text = Nothing
txtBindingName.Text = Nothing
txtOrdinal.Text = Nothing
End Sub
Private Sub Load_DataSet()
'Connect to the SQL Server database
Dim cn As SqlConnection = New SqlConnection((My.Settings.PrintsByMe_DevConnectionString))
cn.Open()
'Retrieve the data using a SQL statement
strSQL = "SELECT * FROM [tblBindings];"
Dim cd As New SqlCommand(strSQL, cn)
'Set the database connection for MySqlDataAdapter
daBindings.SelectCommand = cd
'Fill the DataSet and DataSet Schema
daBindings.FillSchema(MyDataSet, SchemaType.Source, "tblBindings")
daBindings.Fill(MyDataSet, "tblBindings")
'Close database connection
cn.Close()
'Set the BindingNavigator's DataSource to the DataSet we created.
bsBindings.DataSource = MyDataSet
'Set the BindingSource Datamember to the table we are using.
bsBindings.DataMember = MyDataSet.Tables(0).TableName()
'Bind form control txtBindingID to the BindingID field
txtBindingID.DataBindings.Add("Text", bsBindings, "BindingID")
'Bind form control txtOrdinal to the Ordinal field
txtOrdinal.DataBindings.Add("Text", bsBindings, "Ordinal")
'Bind form control txtBindingCode to the BindingCode field
txtBindingCode.DataBindings.Add("Text", bsBindings, "BindingCode")
'Bind form control txtBindingName to the BindingName Field
txtBindingName.DataBindings.Add("Text", bsBindings, "BindingName")
End Sub
Private Sub New_Bindings(ByVal intOrdinal As Integer, _
ByVal strCode As String, _
ByVal strName As String)
drCurrent = MyDataSet.Tables("tblBindings").NewRow()
drCurrent("Ordinal") = intOrdinal
drCurrent("BindingCode") = strCode
drCurrent("BindingName") = strName
MyDataSet.Tables("tblBindings").Rows.Add(drCurrent)
'Call Clear_Form()
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnExit.Click
Me.Close()
End Sub
Private Sub frmBindings_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Call Load_DataSet()
naviBindings.BindingSource = bsBindings
End Sub
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles BindingNavigatorAddNewItem.Click
'Call New_Bindings(CInt(txtOrdinal.Text), txtBindingCode.Text, txtBindingName.Text)
Call New_Bindings(1, "SDLS", "Saddle-stitch")
Call New_Bindings(2, "SPRL", "Spiral Bound")
Call New_Bindings(3, "STUL", "Staple Upper Left")
Call New_Bindings(4, "STUR", "Staple Upper Right")
Call New_Bindings(5, "ST2L", "Two Staples on left side")
End Sub
End Class
Thanks again,
Quecumber256
|
|
|
|
|
I dont think you're doing anything wrong, at least nothing obvious. Just curious, have you actually tried to send the updated dataset to the database to see what happens?
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
No, I haven't. In a prior message I tried to add new records to the end of the dataset. I was afraid to commit the updates because the dataset was hosed up.
Secondly - I need to add another button to the BindingNavigator control for updating purposes. I have to create a new image(Update) for this new button to indicate that when this button is activated it will commit the updates to the SQL Server database. I also need to write the updating code. I have put this off until I'm satisfied that the data in the dataset is represented properly.
Thanks,
Quecumber256
|
|
|
|
|
Im just curious if the database/dataadapter connection will help resolve the ID issue because you have to think of other situations where a company has 15 apps going all with in memory datasets, how does it resolve the ID's when they're updated? It has to let SQL Server or whichever database handle the "REAL" ID's (or at least I would think so).
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
I don't think that will be a problem with this particular application. This application is just a tool to help the administrator with data management.
For-what-its-worth: Here is the T-SQL script for the table I'm having trouble with.
CREATE TABLE Tool_Dev.dbo.tblBindings
([BindingId] INT IDENTITY (1,1) PRIMARY KEY,
[BindingCode] CHAR(4) NOT NULL,
[Ordinal] INT NOT NULL,
[BindingName] VARCHAR(50) NOT NULL)
Thanks,
Quecumber256
|
|
|
|
|
Due to a lack of funds, I have been trying to use the free obfuscators for a .net assembly.
Skater Lite doesn't seem to do anything - I select the assembly to open, click the button and nothing happens. Their support team did however respond to this query with an immensely helpful reply (relevant section below)
Open your .NET assembly (dll or exe) by using "Open" dialog box. On the Info
Tab page you able to browse main assembly properties and the assembly structure as well.
Apsose Obfuscator appears to do something - at least it's busy for a minute or two. It generated something in the output/temp folder and produces a new .exe version of my app.
"Great" I thought. I then got out Reflector to have a look at this file and it produced very readable "source" code with all my original variable/method names.
Does anyone have similar experiences or any suggestions?
At the moment it's a chicken and egg situation - if I could obfuscate my code I could maybe sell a few copies, make some money and buy a decent obfuscator!!!
Cheers,
Rich
|
|
|
|
|
Didnt you try Dotfuscator..???
Cheers,
Suresh
|
|
|
|
|
Not included in VS Express and I don't have the cash for the standard edition.
Using the trial version of Dotfuscator, I believe the licence prohibits use for commercial purposes.
Rich
|
|
|
|
|
My program is patterned after the excellent article by Sujith C. Jose entitled "How to use Stored Procedures in VB6." My stored procedure follows:
CREATE PROCEDURE empdetails (@empid varchar(9), @lastname varchar(18),
@firstname varchar(18), @deptno varchar(30), @deptname varchar(30))
AS
UPDATE sysadm.table001
SET I0013=@firstname
WHERE I0010 = @empid
GO
My VB6 code(edited) is:
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As ADODB.Command
Dim str_empid As String, strconnect As String
Dim lastname As String, firstname As String, deptno As String, deptname As String
Dim str_lastname As String, str_firstname As String, str_deptno As String, str_deptname As String
Private Sub Form_Load()
strconnect = "Provider=SQLOLEDB; Data Source=esp; Initial Catalog=DMTESTDB"
con.Open strconnect, "sysadm", "sysadm"
str_empid = Field0
str_lastname = Field1
str_firstname = Field2
str_deptno = Field3
str_deptname = Field4
Set cmd = New ADODB.Command
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "empdetails"
cmd.Parameters.Append cmd.CreateParameter("empid", adVarChar, adParamInput, 9, str_empid)
cmd.Parameters.Append cmd.CreateParameter("lastname", adVarChar, adParamInput, 18, str_lastname)
cmd.Parameters.Append cmd.CreateParameter("firstname", adVarChar, adParamInput, 18, str_firstname)
cmd.Parameters.Append cmd.CreateParameter("deptno", adVarChar, adParamInput, 30, str_deptno)
cmd.Parameters.Append cmd.CreateParameter("deptname", adVarChar, adParamInput, 30, str_deptname)
Set rs = cmd.Execute
Set cmd.ActiveConnection = Nothing
con.Close
End Sub
My stored procedure works fine in SQL Query Analyzer; I believe my database DMTESTDB opens correctly w/o error (because if I change the password, I generate an error message); and in the cmd.Parameters.Append section, the str_ variables are correctly filled from a part of the program not shown. The cmd.Execute statement runs, but does not result in a successful Update of the database table. (I did "grant" the EXEC permission in my SP for that password).
What am I missing here? I'm stumped.
|
|
|
|
|
Since it runs without errors my first thought is to check the value being passed for str_empid for the @empid paramiter.
You are updating WHERE I0010 = @empid, if the value for @empid doesn't match any values in your table then nothing happens.
topcoderjax
|
|
|
|
|
You nailed it! Needed to LTrim leading blanks in str_empid or RTrim trailing blanks in the table. Works fine. Tx.
|
|
|
|
|
vb.net
in a datagrid's dropevent, how can i find out, in which row the user droped? i tried to find out the row with hit-test in my dropevent, but as rowindex '-1' is given back to me.
|
|
|
|
|