|
-
Aug 18th, 2012, 01:21 AM
#1
Thread Starter
Addicted Member
Reading a TextBox.Text ?
Hi, so i have this code so far:
if TextBox1.Text.Contains("movemouse") then
msgbox("moved mouse!")
Buuutt how could i do something like this:
if it contains movemouse and then with an input stuff like: movemouse(x,y)
so it will actually read your input where the X is and where the Y is. so you can say something like:
cursor.position = new point(x,y);
-
Aug 18th, 2012, 10:09 AM
#2
Re: Reading a TextBox.Text ?
mouse movements are not shown in the text of a text box so unless you are talking about having the user type in this data it is not going to be there
-
Aug 18th, 2012, 10:36 AM
#3
Re: Reading a TextBox.Text ?
 Originally Posted by DataMiser
mouse movements are not shown in the text of a text box so unless you are talking about having the user type in this data it is not going to be there
I think that's exactly what the idea is!
if it contains movemouse and then with an input stuff like: movemouse(x,y)
You'd actually be better off with, for example, .... mousemove 10 20
Then it's simply ...
vb.net Code:
Dim parse As String = TextBox1.Text.Substring(10) 'removes mousemove
Dim xy() As String = Split(parse, " ") 'separates the two numbers
Try
Cursor.Position = New Point(CInt(xy(0)), CInt(xy(1)))
Catch ex As Exception
MsgBox("I'm sorry Dave, I can't do that!") 'GIGO failsafe
End Try
-
Aug 18th, 2012, 12:36 PM
#4
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
That code works really good but lets say i type another 9 letter word and its not "MoveMouse". Example: Tittylick 500 500. it will still do as movemouse to 500, 500. Sooo how do i make it specificly to only MoveMouse then X then Y. Exmaple: MoveMouse X Y?
-
Aug 18th, 2012, 12:37 PM
#5
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Oh igot it! What if i try to do something like this (idk code for it but ill explain what i mean)
1.Find/Search for word "MoveMouse"
2. if next char is a " " then
3. input next as a X value to move
4. then if there a " " then
5. input next as a Y value to move.
if catch an error say
Msgbox("error on movemouse!");
EDIT:
something like this: But idk code
If RichTextBox1.Find("MoveMouse") Then
'See if next char is a space " "
'Then put this char as X value to move mouse
'Then see if there is a another " "
'then put this char as Y value
End If
Last edited by therehere3; Aug 18th, 2012 at 12:40 PM.
-
Aug 18th, 2012, 12:52 PM
#6
Re: Reading a TextBox.Text ?
My code carries on from your 'If TextBox1.Text.Contains("movemouse") Then'. You can change that to
If TextBox1.Text.StartsWith("movemouse ") Then
and include the space. If the space between the numbers is missed out or there is only one number or anything other than spaces and numbers is entered, that error will be caught so you don't need anything else other than an End If to finish it off.
Last edited by dunfiddlin; Aug 18th, 2012 at 12:55 PM.
-
Aug 18th, 2012, 03:26 PM
#7
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Noooo know what i am trying to say is how do i make it if it FINDS the actaully word "MoveMouse" because right now if i put in my big textbox1.text this:
bllahh bllah
blah
blahh
MoveMouse 500 500
it will not move the mouse to 500 500 becuase your are making a "Fixed" number of characters you have which is "10". I want it NOT to be a fixed value and just actaully find the word "MoveMouse" then do as i said above:
'See if next char is a space " "
'Then put this char as X value to move mouse
'Then see if there is a another " "
'then put this char as Y value
-
Aug 18th, 2012, 03:28 PM
#8
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Maybe i shud tell you my whole idea of this program im making.. like how you make visual basic codes:
it does line after line after line of code in that order
sooo if i was to put:
msgbox("ihii")
msgbox("noo")
msgbox("yup")
it wud first say "ihii" then "noo" then "yup"
I am trying to make my own actual thing like visaul basic coding stuff. Idk but it might be very complicated:/
-
Aug 18th, 2012, 06:06 PM
#9
Re: Reading a TextBox.Text ?
Yeah, it will be very complicated. One thing you might consider is making it simpler for yourself. You have probably noticed that VB is divided up into lines. Up until VB2010, each line of code had to end at the end of the line of text unless you explicitly indicated that the line of code extended onto the next line of text with the _ continuation character. I would suggest requiring that each line stood alone, as it does in your example. For instance, I would suggest that you would be fine to say:
msgbox("ihii")
msgbox("noo")
but it would be invalid to write:
msgbox("ihii"") msgbox("noo")
and something like this would be right out:
msgbox("
ihii")
If you make that one simple rule, that each line must be complete and independent, then you can divide the textbox into lines, which would be an array of strings. You can then examine each string independently of all the others, and the code that dunfiddlin suggested would work. You would have to parse each line independently, but you would be checking whether each line started with MouseMove, msgbox, and whatever else you want. The fact that the MouseMove line was the nth line in the textbox wouldn't matter because each line would be considered independent of all the others.
My usual boring signature: Nothing
 
-
Aug 18th, 2012, 06:07 PM
#10
Re: Reading a TextBox.Text ?
Ok. Then you'll need to find a way to read the textbox line by line and direct the code to a the relevant function or sub. So my code would become,
vb.net Code:
Sub MoveMouse(ByVal Command As String)
Dim parse As String = Command.Substring(10) 'removes mousemove
Dim xy() As String = Split(parse, " ") 'separates the two numbers
Try
Cursor.Position = New Point(CInt(xy(0)), CInt(xy(1)))
Catch ex As Exception
MsgBox("I'm sorry Dave, I can't do that!") 'GIGO failsafe
End Try
End Sub
And elsewhere in your code you'd have the equivalent of
vb.net Code:
If TextBox1.Lines(i).StartsWith("movemouse ") Then MoveMouse(TextBox1.Lines(i))
-
Aug 18th, 2012, 06:07 PM
#11
Re: Reading a TextBox.Text ?
Yeah, it will be very complicated. One thing you might consider is making it simpler for yourself. You have probably noticed that VB is divided up into lines. Up until VB2010, each line of code had to end at the end of the line of text unless you explicitly indicated that the line of code extended onto the next line of text with the _ continuation character. I would suggest requiring that each line stood alone, as it does in your example. For instance, I would suggest that you would be fine to say:
msgbox("ihii")
msgbox("noo")
but it would be invalid to write:
msgbox("ihii"") msgbox("noo")
and something like this would be right out:
msgbox("
ihii")
If you make that one simple rule, that each line must be complete and independent, then you can divide the textbox into lines, which would be an array of strings. You can then examine each string independently of all the others, and the code that dunfiddlin suggested would work. You would have to parse each line independently, but you would be checking whether each line started with MouseMove, msgbox, and whatever else you want. The fact that the MouseMove line was the nth line in the textbox wouldn't matter because each line would be considered independent of all the others.
My usual boring signature: Nothing
 
-
Aug 18th, 2012, 06:09 PM
#12
Re: Reading a TextBox.Text ?
I figured that dunfiddlin would get a reply in there before this posted, especially since the forum decided to pause on me, as it is wont to do these days. My reply was intended to be prior to his, but it still mostly works, except that he also suggested examining line by line.
My usual boring signature: Nothing
 
-
Aug 18th, 2012, 08:26 PM
#13
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Ehh for dunfiddlin wut wud i use as my i interger?
-
Aug 19th, 2012, 08:22 AM
#14
Re: Reading a TextBox.Text ?
Well the most obvious thing to do would be to loop through the lines when you run the 'program' from the textbox
vb.net Code:
For i = 0 to TextBox1.Lines.Length-1
'read each line in turn
'determine what sub to run
If TextBox1.Lines(i).StartsWith("movemouse ") Then MoveMouse(TextBox1.Lines(i))
'more sub/function choices
Next
-
Aug 19th, 2012, 11:00 AM
#15
Re: Reading a TextBox.Text ?
How the heck did my post get duplicated both before AND after dunfiddlin's post???? I'm pretty sure it wasn't there more than once when I first posted it.
Gad, this upgrade hasn't been a great thing.
My usual boring signature: Nothing
 
-
Aug 19th, 2012, 02:05 PM
#16
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
ok tyvm, sooo i have tried the same thing but with a "Log" command instead of the movemouse command.
The log commands it suppsoed to be like this:
Log hello world!
and on another textbox i have on the bottom of the program is where the logs will go, so it shud just say "hello world!" not "Log hello world!" sooo this is what i have so far:
Code:
Sub Log(ByVal Command As String)
Dim parse As String = RichTextBox1.Text.Substring(4) 'removes log
Try
LogBox.Text = LogBox.Text + parse
Catch ex As Exception
MsgBox("Error on Log!")
End Try
End Sub
(in my run button):
For i = 0 To RichTextBox1.Lines.Length - 1
If RichTextBox1.Lines(i).StartsWith("MoveMouse ") Then
MoveMouse(RichTextBox1.Lines(i))
End If
If RichTextBox1.Lines(i).StartsWith("Log ") Then
Log(RichTextBox1.Lines(i))
End If
Next
Sooo i want when i do this: "Log hiii" it wont show up as "Log hiii" it will show up as "hiii" and also it does this too (but i dnt want it too):
if i type in my big richtextbox1 this:
Code:
sdas
sd
s
das
Log hello!
sdf
ss
ss
s
it will actually say on my textbox: "Log hello!sdfsssss"
it also ttakes all the other lines after it when i type Log, but i dnt want that, sooo can u help plz?;/
-
Aug 19th, 2012, 02:19 PM
#17
Re: Reading a TextBox.Text ?
vb.net Code:
Sub Log(ByVal Command As String) 'you work with Command in the sub which contains the line you passed to it
'Dim parse As String = RichTextBox1.Text.Substring(4) 'removes log .... no it doesn't, you're using the whole of the text here
Dim Parse As string = Command.Substring(4) 'removes log
Try
LogBox.AppendText(parse & vbcrlf) 'add text and force new line for next entry
Catch ex As Exception
MsgBox("Error on Log!")
End Try
End Sub
-
Aug 19th, 2012, 07:19 PM
#18
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Ok sooo what i need know is, how do i make it read the line after line with a wait period on it?
For example if i was do type in my richtextbox1:
MoveMouse 50 50
MoveMouse 900 900
MoveMouse 123 35
it will end up going to the coords: 123, 35. How could i make another command such as this:
MoveMouse 50 50
Wait 1000
MoveMouse 900 900
Wait 1000
MoveMouse 123 35
so it will move mouse to 50,50 then wait 1sec then move to 900,900 then wait 1sec then move to 123,35.
Can u help me out on that? Ikno it will be alot complicated, i tried
Last edited by therehere3; Aug 19th, 2012 at 07:30 PM.
-
Aug 20th, 2012, 09:16 AM
#19
Re: Reading a TextBox.Text ?
Not complicated at all once you know about Now!
vb.net Code:
Sub Wait(Command As String)
Application.DoEvents 'this just ensures that there is nothing queued up before entering the wait
Try
Dim millisecs As ULong = CULng(Command.Substring(5)) 'as we only need to deal with positive integers, use ULong
Dim start As ULong = Now.Ticks 'Now gives the exact current computer time in various formats. Ticks is the most basic unit
Dim timeup As Boolean = False
millisecs = millisecs * 10000 '10000 ticks per millisecond
Do Until timeup = True
If Now.Ticks - start >= millisecs Then timeup = True
Loop
Catch
'error message
End Try
End Sub
-
Aug 20th, 2012, 10:43 PM
#20
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
YOU ARE SOOO AMAZING!! I cant tell you how much i thank you right now! I might even donate sum moneyz to u!
The only problem with that Wait command now is it will ALWAYS 100% goto the Catch error. I made it say "msgBox("Error on Wait!")"
And it will always say that when a Wait command is put in my richtextbox1.
Soo this is what i had:
MoveMouse 30 30
Wait 1000
MoveMouse 200 200
it moves mouse to 30,30 waits 1sec, then moves to 200,200 and gives me a message box of "Error on Wait!"
-
Aug 20th, 2012, 10:45 PM
#21
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
trolololol XD i accidently kept my old "Wait" command in there too, thats why:P
Ok sooo one sec, ill probably ask for more help in alil like usual haha :P
-
Aug 20th, 2012, 10:59 PM
#22
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Got it! Two things now:P Srry if bothering u :'(
1. Find a RBG Color and make the mouse move to it.
2. Select a Range of where to have the coordinates.
I might need to explain alittle bit more on number 2:
Sooo, my very top-left of my screen is coordinate 0,0 and the bottom-right is my max X,Y coordinates my screen has. Soooo if I was to have a code such as to move to a specific spot in a webbrowser (324,672) and if i was to move the webbrowser just a little ALL coordinates will be off Soooo i was wondering how i can make a "Select Client" thingy, such as this video i made shows you more detail:
-
Aug 22nd, 2012, 06:07 PM
#23
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
-
Aug 23rd, 2012, 08:44 AM
#24
Re: Reading a TextBox.Text ?
On 2. take a look athttp://msdn.microsoft.com/en-us/libr...ttoclient.aspx
1. on the other hand doesn't make a lot of sense. On an 800 x 600 screen (and who uses a screen that size these days?) there are nearly half a million pixels. If I was to go looking for a red one, say, not only would it take up all the CPU room available trolling through all those values, but which pixel would I actually choose. The first one I came to, the one nearest the middle of the screen, the one next to two blues and a green, the largest prime x co-ordinate? It is one thing to detect the colour at a specified point. It is quite another to specify a point by colour!
-
Sep 3rd, 2012, 04:59 PM
#25
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
im not exactly sure on how to use the method "PointToClient". can u give me an example usage please?
-
Sep 4th, 2012, 10:45 AM
#26
Re: Reading a TextBox.Text ?
Actually looking at this again I should have said PointToScreen rather than PointToClient.
vb.net Code:
Cursor.Position = WebBrowser1.PointToScreen(p)
'takes a specified point within the webbrowser and converts to screen co-ordinates
'so that wherever the webbrowser is moved the cursor is always at the same point within it
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Sep 5th, 2012, 12:09 AM
#27
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Havnt tested or tried it yet, but what is that "p" variable inside that PointToScreen function? do i need to declare that "p" somewhere? or just call that?
-
Sep 5th, 2012, 09:27 AM
#28
Re: Reading a TextBox.Text ?
p is a drawing point. You can either declare it separately if you're going to use it more than once or simply create it on the fly.
vb.net Code:
'either
Dim p As Point = New Point(310, 250)
Cursor.Position = WebBrowser1.PointToScreen(p)
'or
Cursor.Position = WebBrowser1.PointToScreen(New Point(310,250))
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Sep 5th, 2012, 11:17 PM
#29
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
I dont believe this is what i kinda was looking for:/
So if i was to move my mouse anywhere on the screen it would have the coords of: 0,0 on my top-left and on my top-right would be whatever my max screen monitor is (1305,1670) <-example.
Soo, what if i wanted to make it move the mouse with my MoveMouse function to a certain spot inside a program maybe called "notepad" then i have it perfectly set up to move to that certain spot, but once i move my "notepad" prorgam, my coordinates are aaallll screwed up and will not work anymore Sooo i wanted to make something like a button or something to make it get coords of a certain program area. Soo if i wanted to get the coords of the "notepad" program, then i can move that "notepad" program anywhere on my screen but the still have the top-left of that "notepad" pgrogram be 0,0 and the top-right of that program be the max of the "notepad" program's window size.
-
Sep 6th, 2012, 10:37 AM
#30
Re: Reading a TextBox.Text ?
Right. Well, I bow to your expertise then. Obviously you know so much more than I do and will have this working in no ti ..... oh!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Sep 6th, 2012, 10:36 PM
#31
Thread Starter
Addicted Member
Re: Reading a TextBox.Text ?
Woe woe.. dont take me wrong? I am not trying to attack you in any way? I clearly can see that you are wwaayyy better than me at this visual basic coding stuff. withyou, my program i have right now would be what it is today. So i am defently not saying i am better or i can fix it. I was just asking of what i said above, is that "pointToScreen" function could work as what i said on my last post? I did not mean to be rude or mean or say im better. Sorry if it sounded like that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|