I have some VB.NET codes that I want to try as a native language (C++). I know there's no converter, because of the .NET framework codes, but I was hoping someone that knows both VB.NET and C++ could take a look at it and convert it for me. It's only about 10 lines of code, not including API. Here it is:
Thank you!
Also, could you pre-compile it as an exe for me? :)
Code:
Dim hDC As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function GetDC Lib "user32" (ByVal hWnd As IntPtr) As IntPtr
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As IntPtr, ByVal X As Int32, ByVal Y As Int32) As Int32 Public Declare Function SleepEx Lib "kernel32" Alias "SleepEx" (ByVal dwMilliseconds As Integer, ByVal bAlertable As Boolean) As Integer
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SendKeys.Flush()
Dim hWnd As IntPtr = FindWindow(vbNullString, "Untitled - Notepad")
hDC = GetDC(hWnd)
Activate_Notepad()
Threading.Thread.Sleep(1000)
Do
If GetPixel(hDC, 379, 174) = 13693949 Then
SleepEx(TextBox1.Text, False)
SendKeys.SendWait("{W}")
Exit Do
End If
Loop
End Sub
Code:
Private Sub Activate_Notepad()
For Each Process As Process In Process.GetProcesses
If Process.MainWindowTitle = "Untitled - Notepad" Then
AppActivate(Process.Id)
Exit For
End If
Next
End Sub
Also, could you pre-compile it as an exe for me? :)