Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HWND error
#1
Hey guys, im trying to make a external WoW addon, but i keep getting an error when im using the hwnd function.

Here's my code and i keep getting declare, findwindow, and SetFocusAPI underlined.

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function SetFocusAPI Lib "user32.dll" Alias "SetFocus" (ByVal hWnd As Long) As Long
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim hWnd As Long
        hWnd = FindWindow(vbNullString, "World Of Warcraft")
        SetFocusAPI(hWnd)
        SendKeys.Send("{ENTER}")
SendKeys.Send("/run if(not scm) then scm = SendChatMessage; end; function SendChatMessage(msg, type, lang, chan) scm("\124cff00B4FF\124Hitem:19:0:0:0:0:0:0:0\124h" ..msg.."\124h\124r", type, lang, chan);end;")
    End Sub
End Class

What am i doing wrong?
Reply
#2
Shouldnt it just be public function and not public declare function, so that will probably fix 2 of those errors. And for the last one you probably need to import something, does it give you an option under the squiggly line that allows you to add the import.
Reply
#3
(07-28-2011, 09:53 PM)bigandrewgold Wrote: Shouldnt it just be public function and not public declare function, so that will probably fix 2 of those errors. And for the last one you probably need to import something, does it give you an option under the squiggly line that allows you to add the import.

No it's "Declare Function".

But you don't need to use Public for this, I would use "Private" instead personally unless you're using it for something else outside of the class.

But why... why are you putting them inside of form load?? lol

Get rid of form load completely, you're not using it for anything

Code:
Public Class Form1

Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetFocusAPI Lib "user32.dll" Alias "SetFocus" (ByVal hWnd As Long) As Long

I don't use WoW so I don't know exactly what you're doing with this

I don't know how WoW works, but try something along these lines:
Code:
Public Class Form1

    Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function SetFocusAPI Lib "user32.dll" Alias "SetFocus" (ByVal hWnd As Long) As Long

    Private hWnd As Long
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        hWnd = FindWindow(vbNullString, "World Of Warcraft")
        SetFocusAPI(hWnd)
        SendKeys.Send("{ENTER}")
        SendKeys.Send("/run if(not scm) then scm = SendChatMessage; end; function SendChatMessage(msg, type, lang, chan) scm("\124cff00B4FF\124Hitem:19:0:0:0:0:0:0:0\124h" ..msg.."\124h\124r", type, lang, chan);end;")
    End Sub
End Class
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)