[Help]My MultiTool[Solved]

Posts 1–14 of 14 · Page 1 of 1
[Help]My MultiTool[Solved]
I'm making a some what multi tool, I first started with a highly advanced notepad but now I added a few more things, I'm working a calculator for it now. I wanted it to where you can type it on your keyboard and/or use the mouse and click the buttons for it, I was hoping someone here knows how to do this.


I tried the SendKeys but it doesn't work. Please post the code, you'll get thanks and +rep


Also whats the coding to make a keyboard key, such as F3, a hot button for a button?


Thank you, If I'm allowed I'll release source and the application when it done Should take maybe 2 (4 days max) to be totally done with version 1.
A hot button for a button? Hotkey?

Global or Program-Wide?

Global: GetAsynckeystate

Timer

If Getasynckeystate(keys.f3)
button1_click(sender,e)
end if

Program: Form_KeyDown Event

If e.keydata = keys.f3
button1_click(sender,e)
end if


-------------------------

On button click just do like textbox1.text &= button.text
Okay thanks and I meant making hot buttons (Keys) for buttons.

gonna test this now, thanks again
Few hours later:

Okay it works but I have 2 text boxes, and if I put both then it types it into both boxes! How could I get around that? Okay heres the code for the calculator, could you help please? If I can't get the buttons to work then I'll just take the buttons out and you'll just have to type it. (Which isn't that bad, I type it anyways, its faster.)

Code:
Public Class Calculator

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox.Text &= Button1.Text
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox.Text &= Button2.Text
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox.Text &= Button3.Text
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox.Text &= Button4.Text
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox.Text &= Button5.Text
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        TextBox.Text &= Button6.Text
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox.Text &= Button7.Text
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        TextBox.Text &= Button8.Text
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        TextBox.Text &= Button9.Text
    End Sub

    Private Sub Zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Zero.Click
        TextBox.Text &= Zero.Text
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Label2.Text = "+"
        Label1.Text = Val(TextBox.Text) + Val(TextBox1.Text)
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        Label2.Text = "-"
        Label1.Text = Val(TextBox.Text) - Val(TextBox1.Text)
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Label2.Text = "*"
        Label1.Text = Val(TextBox.Text) * Val(TextBox1.Text)
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Label2.Text = "/"
        Label1.Text = Val(TextBox.Text) / Val(TextBox1.Text)
    End Sub
End Class
Quote Originally Posted by Web-Designer View Post
Few hours later:

Okay it works but I have 2 text boxes, and if I put both then it types it into both boxes! How could I get around that? Okay heres the code for the calculator, could you help please? If I can't get the buttons to work then I'll just take the buttons out and you'll just have to type it. (Which isn't that bad, I type it anyways, its faster.)

Code:
Public Class Calculator

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox.Text &= Button1.Text
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox.Text &= Button2.Text
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox.Text &= Button3.Text
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox.Text &= Button4.Text
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox.Text &= Button5.Text
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        TextBox.Text &= Button6.Text
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox.Text &= Button7.Text
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        TextBox.Text &= Button8.Text
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        TextBox.Text &= Button9.Text
    End Sub

    Private Sub Zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Zero.Click
        TextBox.Text &= Zero.Text
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Label2.Text = "+"
        Label1.Text = Val(TextBox.Text) + Val(TextBox1.Text)
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        Label2.Text = "-"
        Label1.Text = Val(TextBox.Text) - Val(TextBox1.Text)
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Label2.Text = "*"
        Label1.Text = Val(TextBox.Text) * Val(TextBox1.Text)
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Label2.Text = "/"
        Label1.Text = Val(TextBox.Text) / Val(TextBox1.Text)
    End Sub
End Class
Hmmm, well it seems you're going to have to make the application realise what textbox was selected last.

Try something like this:

Declare these globally:

[php]
Dim BoxToWrite As String = TextBox1.Text ' By default, the box to write to is TextBox1.Text.
[/php]

Now you'll need to add textbox_click events like so:

[php]
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick

BoxToWrite = TextBox1.Text

End Sub

Private Sub TextBox2_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox2.MouseClick

BoxToWrite = TextBox2.Text

End Sub
[/php]

This way, if the user clicks textbox1, then starts using buttons to input data, the program will recognise that it needs to write to TextBox1, in the other case it will write to TextBox2.

Now it's just a matter of changing your button_click events slightly like so:

[php]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
BoxToWrite &= Button1.Text
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
BoxToWrite &= Button2.Text
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BoxToWrite &= Button3.Text
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
BoxToWrite &= Button4.Text
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
BoxToWrite &= Button5.Text
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
BoxToWrite &= Button6.Text
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
BoxToWrite &= Button7.Text
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
BoxToWrite &= Button8.Text
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
BoxToWrite &= Button9.Text
End Sub

Private Sub Zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Zero.Click
BoxToWrite &= Zero.Text
End Sub
[/php]

And that should just about do it Enjoy!

EDIT: Okay I couldn't stand looking at all those Button_Click events when I was rewriting some bits for you, so I started experimenting with ways of fixing it so it's nice and neat.

Here's what I came up with:

One event, that handles every instance of a button being clicked (you'll need to add addition "ButtonX.Click" to the handled list as the need arises) And extracts the text of the object that it was sent from

[php]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
BoxToWrite &= sender.ToString.Substring(sender.ToString.LastInde xOf(":") + 2)
End Sub
[/php]

At the moment this only handles up to Button3.Click, see if you can edit it to accommodate all your buttons
idk im not a coder but id do somthing like

if my.computer.keyboard.key 1
then button1.preform click
Quote Originally Posted by tremaster View Post
idk im not a coder but id do somthing like

if my.computer.keyboard.key 1
then button1.preform click
Not minding that this is totally wrong, I already answered his question.

Keydown for program-wide, getasynckeystate for global hotkeys.

Button1_click(sender,e)

my.computer.keyboard.key....
Quote Originally Posted by tremaster View Post
idk im not a coder but id do somthing like

if my.computer.keyboard.key 1
then button1.preform click
Sorry, but did you even look at the thread before posting that? It has hardly any relevance to any unanswered questions, plus none of it is actual code and is misleading.
hmm this is from youtube TUT..

sendkey code??:
sendkeys.send(textbox1.text) '<- this is for spamming message
sendkeys.send("{ENTER}") '<- dat is for enter.
Quote Originally Posted by /b/oss View Post
hmm this is from youtube TUT..

sendkey code??:
sendkeys.send("{textbox1.text}") '<- this is for spamming message
sendkeys.send("{ENTER}") '<- dat is for enter.
sendkeys.send(textbox1.text)

Actually...
Quote Originally Posted by /b/oss View Post
hmm this is from youtube TUT..

sendkey code??:
sendkeys.send("{textbox1.text}") '<- this is for spamming message
sendkeys.send("{ENTER}") '<- dat is for enter.
Again, I'm not meaning to be disrespectful to anyone here, but have you actually read over the thread? There's only like 6 replies so it doesn't take long. /
Quote Originally Posted by Hawky1337 View Post
sendkeys.send(textbox1.text)

Actually...
lol i was thinking about enter.. srry.. edited.. GET ON MSN
Alright I'm done with this project, thanks to those who tried to help, I only thanked the ones who I used there help.


Can someone close this tread now? Thanks.
Sure thing.
Posts 1–14 of 14 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?