Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
SendMessage in vb.net?
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 09-24-2011, 12:13 PM
Terrankiller's Avatar
Ex-Administrator
Ex-Administrator Visual Basic Programmers
 
Join Date: May 2005
Location: California
Posts: 1,262
Send a message via MSN to Terrankiller Send a message via Skype™ to Terrankiller
Default SendMessage in vb.net?

It might just be because I am too tired to figure out what I am doing wrong. I am attempting to use the SendMessage API to simulate keystrokes. Any suggestions? I will sleep on this and check this thread tomorrow.

Code:
'Declaration

Public Declare Auto Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

'Constants

Public Const WM_KEYDOWN As Integer = &H100
Public Const WM_KEYUP As Integer = &H101
Public Const WM_CHAR As Integer = &H102

'TypeKeys Function
'Why does this not work? Freaking tired.
Public Sub TypeKeys(ByVal hWND As IntPtr, ByVal sText As String, ByVal iWait As Integer)

Try

For i = 1 To sText.Length

Call SendMessage(hWND, WM_KEYDOWN, Asc(Mid(sText, i, 1)), 0)
Call SendMessage(hWND, WM_CHAR, Asc(Mid(sText, i, 1)), 0)
Call SendMessage(hWND, WM_KEYUP, Asc(Mid(sText, i, 1)), 0)

Next i

Catch ex As Exception

MsgBox(ex.ToString)

End Try

End Sub
Edit:

I currently think as of this moment:

Call SendMessage(hWND, WM_KEYDOWN, Asc(Mid(sText, i, 1)), 0)

>>Asc(Mid(sText, i, 1))<<

Is the problem. I am just too tired to figure out how to convert that value into an acceptable parameter in order to execute the SendMessage method.

Also:

It might also be the API declaration itself that is the problem.

Another Also:

I think I will have to read up on this method.
__________________
E PLURIBUS UNUM



Spam Forum: Where boys become men.


Last edited by Terrankiller : 09-24-2011 at 03:28 PM. Reason: sleepy
Reply With Quote
  #2  
Old 09-24-2011, 04:47 PM
Guru
 
Join Date: Jun 2005
Location: Canada
Posts: 1,844
Default Re: SendMessage in vb.net?

I've had problems with things such as simulating keystrokes with .NET. A lot of the time the window needs to have focus or not be minimized.

The only thing I can think of is maybe you need to send a the ascii keycode for a key instead of WM_KEYUP although that should be an enum with keycodes.

Try asking on stackoverflow, I'm sure you'll get some working solutions there.
__________________

Reply With Quote
  #3  
Old 09-24-2011, 09:52 PM
Guru
 
Join Date: Jan 2007
Location: /home/Canada
Posts: 1,768
Default Re: SendMessage in vb.net?

Are you maybe not specifying the handle of the exact control you want the message to be sent to and just using the form`s hWND.

This works for me using your code unchanged.
Code:
    Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
        TypeKeys(Me.TextBox1.Handle, "Testing", 0)
    End Sub
Reply With Quote
  #4  
Old 09-25-2011, 04:03 AM
Terrankiller's Avatar
Ex-Administrator
Ex-Administrator Visual Basic Programmers
 
Join Date: May 2005
Location: California
Posts: 1,262
Send a message via MSN to Terrankiller Send a message via Skype™ to Terrankiller
Default Re: SendMessage in vb.net?

Probably should of checked that lol. Now I got to figure out other stuff .
__________________
E PLURIBUS UNUM



Spam Forum: Where boys become men.

Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 12:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1