C# Simulating Keys in SWTOR ->  SendKeys, SendMessage, PostMessage??? menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C# Simulating Keys in SWTOR -> SendKeys, SendMessage, PostMessage???

    I have attempted all 3 on swtor and none are working for wasd.

    I can get F1 .. and other keys to work but it seems a-z are not working.

    Does anyone have success using any of these or other methods to simulating keystrokes in swtor?

    Please dont say to use AutoIt.

    Anyone try "SendInput"?

    [SOLVED BELOW]
    Last edited by zewt; 02-05-2012 at 09:58 AM.

    C# Simulating Keys in SWTOR ->  SendKeys, SendMessage, PostMessage???
  2. #2
    GRB's Avatar Established Member CoreCoins Purchaser
    Reputation
    65
    Join Date
    Oct 2008
    Posts
    222
    Thanks G/R
    0/1
    Trade Feedback
    2 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    SendKeys.Send("o");
    This is working

  3. #3
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by GRB View Post
    Code:
    SendKeys.Send("o");
    This is working
    Yes.. you are right.. Now try this:

    SendKeys.Send("wwwwwwwwwwwwwwwwwwwwwwwwwwwww");

    Let me know if your character runs...

    Mine doesnt. For things like TAB F1 or buttons to open game menu's, sendkey works... but when it comes to movement nope!

    I just tried a SendInput and its also failing.

    I am testing all methods and none are working. But, if i start typing in game, then run my test, it does type out what my program says to. It just doesnt work for movement.

  4. #4
    Mikanor's Avatar Corporal
    Reputation
    1
    Join Date
    Jan 2012
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use mouse_event - it work for the movement.

  5. #5
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Mikanor View Post
    You can use mouse_event - it work for the movement.
    Mouse event works for changing mouse position and making clicks(right,left).

    How can I use mouse event for movement.

  6. #6
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Mikanor View Post
    You can use mouse_event - it work for the movement.
    Are you saying I should bind my in game movement to mouse events? and then use mouse_event in c#?

    EDIT:

    I tested this and its working for setting my run forward binding to middle mouse down. This is a really awkward way of doing it.. and then I would need to bind my other asd to mouse down's... and i only have 1 mouse down... this is not the way to do it

    ADDING CODE:

    HTML Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Windows;
    using System.Runtime.InteropServices;
    using System.IO;
    using System.Threading;
    
    
    namespace SendInput
    {
       
    
    
        public partial class Form1 : Form
        {
    
            
            //Win32 API imports
            [DllImportAttribute("User32.dll")]
            private static extern int FindWindow(String ClassName, String WindowName);
    
            //Import the SetForeground API to activate it
            [DllImportAttribute("User32.dll")]
            private static extern IntPtr SetForegroundWindow(int hWnd);
            [DllImport("user32.dll", ExactSpelling = true)]
            public static extern long mouse_event(Int32 dwFlags, Int32 dx, Int32 dy, Int32 cButtons, Int32 dwExtraInfo);
    
            [DllImport("user32.dll", ExactSpelling = true)]
            public static extern void SetCursorPos(Int32 x, Int32 y);
    
            public const Int32 MOUSEEVENTF_ABSOLUTE = 0x8000;
            public const Int32 MOUSEEVENTF_LEFTDOWN = 0x0002;
            public const Int32 MOUSEEVENTF_LEFTUP = 0x0004;
            public const Int32 MOUSEEVENTF_MIDDLEDOWN = 0x0020;
            public const Int32 MOUSEEVENTF_MIDDLEUP = 0x0040;
            public const Int32 MOUSEEVENTF_MOVE = 0x0001;
            public const Int32 MOUSEEVENTF_RIGHTDOWN = 0x0008;
            public const Int32 MOUSEEVENTF_RIGHTUP = 0x0010;
    
    
    
            public static void PerformLeftKlick(Int32 x, Int32 y)
            {
                SetCursorPos(x, y);
                mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0);
                //mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
            }
    
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
    
            int hWnd = FindWindow(null, "Star Wars: The Old Republic");
            if (hWnd > 0) //If found
            {
                //Bring SWTOR to the front
                SetForegroundWindow(hWnd);
                Thread.Sleep(3000);
                PerformLeftKlick(411, 380);
                
            }
    
            }
        }
    }
    Last edited by zewt; 02-05-2012 at 09:39 AM.

  7. #7
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for pushing me to resolution I figured it out.



    Solution below is successfully spinning my character around with the A key:

    HTML Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Windows;
    using System.Runtime.InteropServices;
    using System.IO;
    using System.Threading;
    
    
    namespace SendInput
    {
       
    
    
        public partial class Form1 : Form
        {
    
     [DllImport("user32.dll", ExactSpelling = true)]
            public static extern void SetCursorPos(Int32 x, Int32 y);
    
            public static class VirtualKeyboard
            {
                [DllImport("user32.dll")]
                static extern uint keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
                public static void KeyDown(System.Windows.Forms.Keys key)
                {
                    keybd_event((byte)key, 0, 0, 0);
                }
    
                public static void KeyUp(System.Windows.Forms.Keys key)
                {
                    keybd_event((byte)key, 0, 0x0002, 0);
                }
            }
    
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
    
            int hWnd = FindWindow(null, "Star Wars: The Old Republic");
            if (hWnd > 0) //If found
            {
                //Bring SWTOR to the front
                SetForegroundWindow(hWnd);
                Thread.Sleep(3000);
    
                VirtualKeyboard.KeyDown(System.Windows.Forms.Keys.A);
                VirtualKeyboard.KeyUp(System.Windows.Forms.Keys.A);
    
    
                
            }
    
            }
        }
    }
    
    
    Last edited by zewt; 02-05-2012 at 10:07 AM.

  8. #8
    Mikanor's Avatar Corporal
    Reputation
    1
    Join Date
    Jan 2012
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SetForegroundWindow is a bad idea to activate other program window. There is others solutions.

  9. #9
    Mikanor's Avatar Corporal
    Reputation
    1
    Join Date
    Jan 2012
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  10. #10
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Mikanor View Post
    SetForegroundWindow is a bad idea to activate other program window. There is others solutions.
    We could opena whole other thread on this. But I value opinions.. so why is it bad? Explain.

    It seems to be working flawlessly for me.

  11. #11
    Mikanor's Avatar Corporal
    Reputation
    1
    Join Date
    Jan 2012
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ups my bad, wrong read.

  12. #12
    GRB's Avatar Established Member CoreCoins Purchaser
    Reputation
    65
    Join Date
    Oct 2008
    Posts
    222
    Thanks G/R
    0/1
    Trade Feedback
    2 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So the VirtualKeyboard is working for movement?

  13. #13
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by GRB View Post
    So the VirtualKeyboard is working for movement?
    yes.... 10 character

  14. #14
    ambintx's Avatar Corporal
    Reputation
    2
    Join Date
    Jan 2012
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you guys are able to send wasd to active windows only, not inactive correct?

  15. #15
    zewt's Avatar Member
    Reputation
    13
    Join Date
    Nov 2008
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ambintx View Post
    you guys are able to send wasd to active windows only, not inactive correct?
    as of right now yes.. i can only send to active window. all the other methods i know for sending to inactive windows do not work for swtor.

    if you know another way plz share

Page 1 of 2 12 LastLast

Similar Threads

  1. [Visual Basic derp] Send keystroke through SendMessage/PostMessage
    By myojinyahiko in forum WoW Memory Editing
    Replies: 10
    Last Post: 02-04-2013, 08:37 AM
  2. [Trading] or WTB Diablo 3 Key or Account (pref key) for SWTOR account
    By lifeofwow in forum Diablo 3 Buy Sell Trade
    Replies: 0
    Last Post: 05-17-2012, 01:41 PM
  3. [Selling] Selling x3 Beta key weekend SWTOR
    By stlamr in forum General MMO Buy Sell Trade
    Replies: 1
    Last Post: 11-17-2011, 08:19 AM
  4. [Buying] Swtor beta key
    By Insaneety in forum Star Wars: The Old Republic Buy Sell Trade
    Replies: 0
    Last Post: 10-04-2011, 06:08 AM
  5. [Buying] Swtor beta key
    By Insaneety in forum General MMO Buy Sell Trade
    Replies: 0
    Last Post: 10-04-2011, 06:08 AM
All times are GMT -5. The time now is 05:53 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search