Hi all,
I got a problem with my code to check a game's chat position and write text to the game when a command is written by someone on the chat. I haven't figured out yet how to make it send keys to the gamewindow when it's not focussed, and WriteProcessMem ory, but that's for a later issue.
This is my current code: -
Public Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
-
Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
-
Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Byte, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
-
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
-
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As IntPtr) As Integer
-
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As IntPtr
-
-
Public Sub ReadChat(ByVal Command As String)
-
-
Dim hwnd As Integer
-
Dim hprocess As Integer
-
Dim readprocess
-
Dim chataddress As Integer
-
Dim votesneeded As String = txtvotesneeded.Text
-
-
If hwnd = FindWindow(vbNullString, Game1) = True Then
-
chataddress = &H698726
-
ElseIf hwnd = FindWindow(vbNullString, Game2) = True Then
-
chataddress = &H685381
-
Else
-
MsgBox("Please Startup the game first before clicking the Start button", MsgBoxStyle.Critical, "Error!")
-
End If
-
-
On Error Resume Next
-
MsgBox("Error #17 occured. Please ask for help at support forum.", MsgBoxStyle.Critical, "Error!")
-
-
If hwnd >= 0 Then
-
hprocess = OpenProcess(PROCESS_ALL_ACCESS, False, hwnd)
-
readprocess = ReadProcessMemory(hprocess, ChatAddress, 78, 78, vbNullString)
-
CloseHandle(hprocess)
-
End If
-
-
If readprocess = Command Then
-
SendKeys.Send("{T}")
-
Wait(100)
-
SendKeys.Send("There are " & votesneeded & " more votes needed to skip map.")
-
Wait(100)
-
SendKeys.Send("{ENTER}")
-
End If
-
-
End Sub
-
The game consists of 2 different versions, that's why I want it to change the chataddress to suit each version.
I'm not sure if I done all this code the right way. The only error it gave me during runtime was something with "readproces s". A conversion from type String to type Double failed.
I hope someone can help me get this code right and help me taking any errors out which could prevent it from working perfect.
Thanks in advance !
Evolution445
5 2926
Um... what data type is readprocess supposed to be?
Um... what data type is readprocess supposed to be?
-
Dim readprocess
-
-
readprocess = ReadProcessMemory(hprocess, ChatAddress, 78, 78, vbNullString)
-
Would the problem be solved if I Dim readprocess as Double ?
Would the problem be solved if I Dim readprocess as Double ?
I don't know, but it wouldn't hurt to try.
I guess the main questions to be answered would be... - What data type does ReadProcessMemo ry() function return?
- What are the specific details of the error?
- Exactly where in the code does the error occur?
If this were VB6, I'd advise against calling a variable Command, since that's the name under which command-line parameters are retrieved. But in VB2005, I don't know how that works.
I don't know, but it wouldn't hurt to try.
I guess the main questions to be answered would be...- What data type does ReadProcessMemo ry() function return?
- What are the specific details of the error?
- Exactly where in the code does the error occur?
If this were VB6, I'd advise against calling a variable Command, since that's the name under which command-line parameters are retrieved. But in VB2005, I don't know how that works.
ReadProcessMemo ry should only read the chat position and see if there's a specified word written by someone. I think it should only return either True or False.
I think this is how it should go, or what it suposes to do:
------------------
* Read the chataddress with ReadProcessMemo ry
* If "......." is written Then
* Respond using SendKeys
------------------
This is where the error occured: -
If readprocess = Command Then
-
SendKeys.Send("{T}")
-
Wait(100)
-
SendKeys.Send("There are " & votesneeded & " more votes needed to skip map.")
-
Wait(100)
-
SendKeys.Send("{ENTER}")
-
End If
-
I'm not sure if I done this right. Infact, I'm not sure about whole my code.
Any help is appreciated.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Luke |
last post by:
I am trying to convert some VB6 projects to VB.NET, however I'm having
trouble finding documentation of a new format for some functions, in
specific ReadProcessMemory. Since .NET no longer supports the 'as any'
declare I found myself trying integers & longs, however all attempts throw
back the error message 'Object reference not set to an instance of an
object.'.
My API declare is as follows
Public Declare Function ReadProcessMemory Lib...
|
by: pangel83 |
last post by:
I've been trying for days to write a piece of VB.NET code that will
read from winamp's memory space the paths of the files from the current
winamp playlist.
The GETPLAYLISTFILE command of the winamp API will only return a
pointer to the position of the asked path. An article available on
http://msmvps.com/ch21st/archive/2004/02/26.aspx provides a VB6
implementation of this, using the ReadProcessMemory Windows API
command, but something...
|
by: Jerry Spence1 |
last post by:
1. Is there a more suitable, dedicated newsfeed for VB2005 yet?
2. I'm confused as to which version to get. I work for a small company and
we will just need VB2005 on my PC. Therefore that tends to suggest the
express version, but I write some pretty complicated stuff (including
SQLServer transactions, network programming etc) and I am wondering what is
missing from the Express version in terms of components, functionality etc.
I don't...
|
by: Rich |
last post by:
Hello,
I just upgraded a vb2003 app to vb2005. The vb2003 app had/has a statusbar
object - which contains panels and I can see the properties of the statusbar
in the properties window in vb2005.
But in the tools list of vb2005 I do not see a statusbar selection. Instead
I see a statusStrip, and even though the Items collection has a property to
set the statusStrip labels to sunken, etched,... I can see these appearances
when I...
|
by: erickwan88 |
last post by:
I am doing a final year project for my school and is going to provide for an organization, so I am asking for some help on here.
Indeed, I have no idea on how to get the input from my pen driver and use on vb2005 as when I activate the pen driver, it will run its own program itself and when I deactivate it, it become a mouse.
Therefore, I need to find out how to use the pen to write words on the vb2005 program instead of being either a...
| |
by: Aalaan |
last post by:
I am presently a user of classic vb6 and hang out on those newsgroups. Some
of you may be aware that there is a very anti MS and vb2005 feeling there. I
have tried to get them to tell me which features of vb2005 are actually
worse then vb6 in practice, and forget the philosophy of backward
compatibility for a moment.
I would now like to hear "the other side". Could *anyone who previously used
vb6* (only those pleased; I feel the others...
|
by: Jeffrey Christiansen |
last post by:
I wanted to add a toggle button to a VB2005 form to be used for a
simple Windows Application (i.e. compiled to a "*.exe"), so I added
the ActiveX Microsoft Forms Object toggle button, however I can't get
this button does work properly. The documentation I found in the
FM20.CHM files says the button state can be determined from its
"Value" property, but the property list shown in VB2005 does not have
a "Value" property. How is the button...
|
by: Vae07 |
last post by:
Ok so here is a brief summary of my problem. I need a pop up form that submits input text box information to a pocket excel workbook upon a command botton click. Text box inputs are checked for validity upon individual text box exit (don't have a problem with this part).
All this could be done with Excel VBA easily, but pocket excel doesn't have VBA/Macro support. In as much, I have been trying to create a VB2005 application that I can load...
|
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= |
last post by:
Hi,
can someone postme a running sample of the
ReadProcessMemory(...) function. I would
like to dump the complete memory of the main
module in my application e.g MyApplication.exe
into a file. Here is a working example of the API
import call:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |