|
|
Ive been searching through my ebooks and google literally for 5 hours now looking for a solution! Can anyone guide me on how to select a particular tab in a 3rd party application, either by the index number, or the tab name?
This selects the window I want to interact with:
<br />
Private Sub Button1_Click(...) Handles Button1.Click<br />
Dim Window As String<br />
Window = "PetDeviceMainDlg"<br />
AppActivate(Window)<br />
SendKeys.SendWait("%{F6}")<br />
End Sub<br />
And Ive tried every variation of this code from the MSDN (http://msdn2.microsoft.com/en-us/library/cdc8ebh8.aspx) that I can think of:
<br />
Private Sub Button1_Click(...) Handles Button1.Click<br />
<br />
Dim Window As String<br />
Window = "PetDeviceMainDlg"<br />
AppActivate(Window)<br />
SendKeys.SendWait("%{F6}")<br />
SelectTab(6)<br />
<br />
End Sub<br />
<br />
Public Sub SelectTab(ByVal index As Integer)<br />
<br />
Dim instance As New TabControl<br />
instance.SelectTab(index)<br />
<br />
End Sub<br />
When I debug, index does equal 6, but I get the error 6 isnt valid for index.
Any help would be much appreciated.
|
|
|
|
|
Tekkie wrote: Dim instance As New TabControl
instance.SelectTab(index)
A New TabConrol won't have any pages.
Seems like you are trying to select a Tab page in another application, correct?
If so, the SelectTab(6) is executing against your application and not the intended target application.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
If I take out the "new" i get the error "'instance' is used before it has been assigned a value". Im not sure why I had new in there, just picked it up from one of the google articles I think. How do I get it to keep focus on the other application? "Me." is for the VB form right?
Thanks
|
|
|
|
|
I think you miss the larger picture.
You can use SendKeys to send key strokes to another window.
But you can't write code in your application that executes in another window, especially if it's in another process.
Your tab selection code is running locally in your application but can't effect the other application or window.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Im going about this the wrong way then, I just want to either scroll through tabs using ctrl + tab until I hit the right one, or just activate TabIndex 9. I know it can be done because I have a program written in VB6 that does exactly what I want, using a combination of SendKeys and FindWindow. I just figured since tab index is constant that would be the fastest and most reliable way to accomplish this. I'll see if I dont have better luck tomorrow.
|
|
|
|
|
Are you using Vista?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Win XP SP2. I think the answer is in using the user32 API, but Im not knowledgeable enough to know what Im doing yet. My 3 hour video tutorial didnt get into this haha.
Too bad its not as simple as the script language I use... "WinActivate, PetDeviceMainDlg, Manual" Done
|
|
|
|
|
The reason I asked about Vista is because the VB.NET and VB SendKeys function no longer works on Vista like it used to. There are aricles out there for a replacement that does work on Vista.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Ok, since there is obviously no practical way to pick a tab, how do I go about using a loop? Something like
<br />
While "ActiveWindow" <> "GetInfo"<br />
SendKeys.SendWait("^{TAB})<br />
Wend<br />
|
|
|
|
|
Since I can see what you are seeing I'm not sure. But trying different things can't hurt.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Here is the application Im trying to automate. Basicly, switch to a window, send a modem command/string, switch to another window and click a button, switch to another window and verify some text, etc. There has to be some easy way to switch between the 20 tabs in SysTabControl32. Im pulling my hair out here trying to figure it out though.
http://img110.imageshack.us/img110/4738/tabslr5.th.jpg
|
|
|
|
|
The questions seesm to be, how does tab switching work in the other application?
Hot keys, mouse clicks, menu choices? How do you know what tab is currently selected?
Just trying to use the TAB key could be difficult because your program won't know where 'FOCUS' is in that program. If 'FOCUS' is in a TextBox control and you start sending keys to the application that could be a big problem for you.
I'm sure you have read this on MSDN.
http://msdn2.microsoft.com/en-us/library/ms171548.aspx[^]
The image is super small, 150x150. Any change to see it full size?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hello,
I would like to Change control color dynamically, every time I am sending in the following function another control (Button, Label,...) and change the backcolor of it.
I trying to do the following:
Private MyCtrl as New Object
Public Sub ChangeControlColor(ByVal _MyCtrl As Object)
Dim t As System.Type
t = _MyCtrl.GetType()
CType(MyCtrl,t).backColor=Color.red
End Sub
I got message that t is not defined(the last line: "CType(MyCtrl,t).backColor=Color.red")
Please help
Shay Noy
|
|
|
|
|
You can't use a variable as type specificaiton in a CType function call.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
I think you're looking for this:
Public Sub ChangeControlColor(ByVal c As Control)
c.BackColor = Color.Red
End Sub
Which is pretty pointless considering you can just change the backcolor of the contorl from the place you were going to call this anyway.
|
|
|
|
|
|
im doin a convertion from hex to ascii.the formula is working fine.but the is one problem whereby if the input is 00.its cant be display in the output..eg input="101010" the output="..." but for 1001 the output only ".".how could is resolve this?
|
|
|
|
|
1 - try to use an intelligent header, everyone here needs help
2 - try posting your code if you have a question about code you wrote.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
this is the decoding function,its working
Public Function sHexDecode(ByVal sData As String) As String<br />
Dim iChar As Integer<br />
Dim sOutString As String<br />
Dim sTmpChar As String<br />
<br />
<br />
For iChar = 1 To Len(sData) Step 2<br />
If Mid(sData, iChar, 2) = "00" Then<br />
'sTmpChar = vbNullString<br />
oCP.Write(Chr("&H" & (1 - 1)))<br />
GoTo skipDecode<br />
End If<br />
<br />
sTmpChar = Chr("&H" & Mid(sData, iChar, 2))<br />
skipDecode:<br />
sOutString = sOutString & sTmpChar<br />
<br />
Next iChar<br />
sHexDecode = sOutString<br />
'Mod By TC Kua<br />
TextBox1.Text = ""<br />
TextBox1.Text = sHexDecode<br />
End Function
this is the part to display the output
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
Try<br />
'Mod by TC Kua 21st Feb 2008 <br />
Call sHexDecode(txtHex.Text)<br />
oCP.Write(Encoding.ASCII.GetBytes(Me.TextBox1.Text)))))<br />
oCP.Write(Chr("&H" & (1)))<br />
Catch ex As Exception<br />
' Warn the user.<br />
MessageBox.Show("Unable to write to comm port")<br />
Finally<br />
<br />
End Try<br />
End Sub
|
|
|
|
|
Is this VB.NET ? Don't use stuff like 'Mid', use the proper .NET stuff.
pandapatin wrote: GoTo skipDecode
This use of Goto is just plain lazy and it makes your code hard to read. Don't use goto if you don't need to.
pandapatin wrote: If Mid(sData, iChar, 2) = "00" Then
What if the string has an odd number of characters ?
Given that your original complaint is about what happens when the code hits 00, and given that you have a special case for this, can't you make it do whatever you like ?
pandapatin wrote: sTmpChar = Chr("&H" & Mid(sData, iChar, 2))
I guess you came from VB6. Please try to learn VB.NET. If MS had their way, this code would not work, all this VB6 stuff was originally to be removed. The string class as all the methods you need for this stuff.
pandapatin wrote: TextBox1.Text = ""
TextBox1.Text = sHexDecode
Plain bizarre. Why set it twice in two lines ? And, what's wrong with using sensible variable names ?
pandapatin wrote: Call sHexDecode(txtHex.Text)
oCP.Write(Encoding.ASCII.GetBytes(Me.TextBox1.Text)))))
Why not rewrite the function to return a string ? It looks like you don't really need the textbox ? Do you really need to specify 'call' ? I don't think so.
What was the exact problem again ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
now the code already working.but the location of the output is not the same as the input.let say the input=101000,the output would look like this"001010=...".its changes place from last place to 1st place.actually i set it to read pair by pair.If Mid(sData, iChar, 2) = "00" Then it doest read odd num input.
|
|
|
|
|
pandapatin wrote: doest read odd num input.
I'm suggesting you should fix that, so that the code doesn't break on bad input.
I guess you need to step through the debugger and work out what's going on. If the values are being flipped, then perhaps you need to flip the assignment to assign the values in reverse.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thx dude..its working now..
|
|
|
|