SendKeys.SendWait Method in Different Program
-
vendredi 13 avril 2012 02:57
trying to find out what i need to do to use the "sendkeys.sendwait" method in other programs. I found a method using C# but I need a solution for VB. The one I found for C# was this
//using System.Runtime.InteropServices; [DllImport("User32.dll")] public static extern Int32 SetForegroundWindow(int hWnd); [DllImport("user32.dll")] public static extern int FindWindow(string lpClassName, string lpWindowName); private void button2_Click(object sender, EventArgs e) { int handle = FindWindow(null, "Untitled - Notepad"); SetForegroundWindow(handle); SendKeys.SendWait("This is my test text!"); SendKeys.SendWait("^s"); }
Toutes les réponses
-
vendredi 13 avril 2012 04:55
Strange, I found 306000 search results
However, it is completely described on this official Microsoft Developers Website including sample
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx
If you want to use the C# then use a snippet converter. Although the most part is converting that code is removing the semicolons ";"
http://tangiblesoftwaresolutions.com/Product_Details/CPlusPlus_to_VB_Converter_Details.html
Success
Cor -
vendredi 13 avril 2012 17:28Ive allready looked at all this before and tried it. the method does nt work as described and from what ive read you need something about a user32.lib or something line of code as well to make the program work/execute in other programs.
-
dimanche 15 avril 2012 00:25
Tried this method still not working
Imports System.Windows.Forms Public Class Form1 'reference System.Windows.Forms added Public Sub RunOnce() System.Threading.Thread.Sleep(10000) ' Send ALT + ENTER, and wait for it to be processed SendKeys.SendWait("%({ENTER})") SendKeys.SendWait("Testing") SendKeys.SendWait("%({ENTER})") My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Exclamation) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click RunOnce() End Sub End Classnot sure if anyone else has suggestions for lord of the rings online or not. Thats the program Im trying to use this method in. Anyone else ever try to make little macro's etc for it?
The ultimate goal now is to create a auto traveling type system for people who cant afford to use the stables or need to travel to locations. This should send key strokes based on timed key presses. This of course is just a test to get it to work.
- Modifié mholmes_3038 dimanche 15 avril 2012 00:27
-
dimanche 15 avril 2012 02:54
Look. My applcation cannot be redirected.
Module Module1 Private stdInput As System.IO.TextReader Private stdOutput As System.IO.TextWriter Sub Main() stdInput = Console.In stdOutput = Console.Out End Sub Sub WriteChar(ByVal c As Char) stdOutput.Write(c) End Sub Function ReadChar() As ConsoleKey Return stdInput.Read() End Function End Module
Mark the best replies as answers. "Fooling computers since 1971."
http://thesharpercoder.blogspot.com/
- Modifié Rudedog2MVP dimanche 15 avril 2012 02:56
-
dimanche 15 avril 2012 03:29not sure if this will make a difference or not but your making a module and Im making a form. You also did not explain your code or comment it. So I'm clueless as to what your logic/concept is and how your code functions.
-
dimanche 15 avril 2012 15:56
How my code works was not the point. Aside from the fact that it is not bullet-proof, the point was that an application can easily be made to resistant to I/O redirection. Consider the real possibility that there is an outside chance that your code isn't working with a given application for a reason, because the appication was designed to be resistant.
Rudy =8^D
Mark the best replies as answers. "Fooling computers since 1971."
-
dimanche 15 avril 2012 19:33Rude I know you think your helping but I'm sorry but its not helping. I can make calls inside the program using the mouse. Now I need to make calls to it using key strokes. Please do not post your suggestions in my posts please. I know your trying but I don't understand your logic and you have a hard time explaining your logic to me as well. Anyone else please feel free to make suggestions. As i said before I think Im missing something that points toa uer32.dll file Ive seen in other peoples examples but Im not sure what I'm missing.
-
dimanche 15 avril 2012 19:59
trying to find out what i need to do to use the "sendkeys.sendwait" method in other programs. I found a method using C# but I need a solution for VB. The one I found for C# was this
//using System.Runtime.InteropServices; [DllImport("User32.dll")] public static extern Int32 SetForegroundWindow(int hWnd); [DllImport("user32.dll")] public static extern int FindWindow(string lpClassName, string lpWindowName); private void button2_Click(object sender, EventArgs e) { int handle = FindWindow(null, "Untitled - Notepad"); SetForegroundWindow(handle); SendKeys.SendWait("This is my test text!"); SendKeys.SendWait("^s"); }
CODE CONVERTER SITE
http://www.carlosag.net/Tools/CodeTranslator/.
http://www.developerfusion.com/tools/convert/csharp-to-vb/.
Mark the best replies as answers. "Fooling computers since 1971."
-
dimanche 15 avril 2012 20:25
Rude I know you think your helping but I'm sorry but its not helping. I can make calls inside the program using the mouse. Now I need to make calls to it using key strokes. Please do not post your suggestions in my posts please. I know your trying but I don't understand your logic and you have a hard time explaining your logic to me as well. Anyone else please feel free to make suggestions. As i said before I think Im missing something that points toa uer32.dll file Ive seen in other peoples examples but Im not sure what I'm missing.
Open Notepad. Run this code without the Debugger.
Imports System.Runtime.InteropServices Imports System.Windows.Forms Module Module2 <DllImport("User32.dll")> _ Public Function SetForegroundWindow(ByVal hWnd As Int32) As Int32 End Function <DllImport("User32.dll")> _ Public Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As Int32 End Function Public Sub SendKeys_To_Notepad() ' Notepad should already be open Dim handle As Int32 = FindWindow(Nothing, "Untitled - Notepad") SetForegroundWindow(handle) SendKeys.SendWait("This is my test text!") SendKeys.SendWait("^s") End Sub End Module
Happy Coding
Mark the best replies as answers. "Fooling computers since 1971."
- Marqué comme réponse Shanks ZenMicrosoft Contingent Staff, Moderator mercredi 25 avril 2012 09:23

