Comments (12)
i have succeeded with:
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
[DllImport("User32.dll")]
public static extern Int32 FindWindow(String lpClassName, String lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
int window = FindWindow("triuiScreen", null);
//i don't know how can i get the title of Sanderling Host client window, so this the title is null for now
void key(WindowsInput.Native.VirtualKeyCode keycode)
{
PostMessage((IntPtr)window, WM_KEYDOWN, (IntPtr)(keycode), (IntPtr)0);
Host.Delay(50);
PostMessage((IntPtr)window, WM_KEYUP, (IntPtr)(keycode), (IntPtr)0);
}
//and finally
key(VirtualKeyCode.F10);
also, can you show me an example of how can I use System.Speech.Synthesis.SpeechSynthesizer class? i would like to be announced of local chat changes ;)
from sanderling.
it would be nice to leave separate keyUP and keyDOWN mechanics for users to manage key modifiers. maybe someone needs holding a key for a long time.
for example, my autopilot has no mouse input, just:
key(VirtualKeyCode.SPACE); //focus on overview
for( int a = 1; a < 20; a = a + 1 )
key(VirtualKeyCode.UP); //this can be replaced with holding down up arrow
key(VirtualKeyCode.VK_D); //warp|dock
of course, this needs to sort overview by icon. yellow one will always be on top.
from sanderling.
As title says, Sanderling.KeyboardPress(VirtualKeyCode Key) brings window to front. It would be very nice if this will send keystrokes to client window that is in background without focusing on it. Same with mouse.
Yes, that would be nice. I am interested to see how this could be implemented.
how can I use WinAPI in Sanderling?
The same way as in other .NET applications.
Below is an example of how to call a WinAPI function from the script IDE:
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool MessageBeep(uint uType);
MessageBeep(0);
from sanderling.
void key(WindowsInput.Native.VirtualKeyCode keycode)
{
PostMessage((IntPtr)window, WM_KEYDOWN, (IntPtr)(keycode), (IntPtr)0);
Host.Delay(50);
PostMessage((IntPtr)window, WM_KEYUP, (IntPtr)(keycode), (IntPtr)0);
}
I understand this covers the case of simulating a single (not combined with others) keyboard key press.
Would you benefit from an additional KeyboardPressViaPostMessage(VirtualKeyCode key)
method to wrap this?
from sanderling.
I made the changes required to support the mentioned uses.
This is a binary with the changes included:
Sanderling.zip
These are the signatures to use the key methods:
bool WindowPostMessageKeyDown(VirtualKeyCode key, IntPtr lParam = default(IntPtr));
bool WindowPostMessageKeyUp(VirtualKeyCode key, IntPtr lParam = default(IntPtr));
also, can you show me an example of how can I use System.Speech.Synthesis.SpeechSynthesizer class? i would like to be announced of local chat changes ;)
I added a reference to System.Speech.dll
to the script compilation to enable using the SpeechSynthesizer
from script.
It can be used like this:
using System.Speech.Synthesis;
var synth = new SpeechSynthesizer();
synth.Speak("Sanderling at your service.");
from sanderling.
everything works perfectly. thank you very much!
now i'm trying to simulate mouse clicks, but it seems the game has some kind of protection against this, so clicks are sent only to the coordinates of cursor on screen, no matter what coordinates are sent. I tried using SendMessage and PostMessage. maybe you will succeed with implementing this. it would be very nice to click all controls without losing focus of current window.
I tried:
const int WM_LBUTTONDOWN = 0x201;
const int WM_LBUTTONUP = 0x202;
const int MK_LBUTTON = 1;
const int MK_RBUTTON = 2;
[DllImport("user32.dll")]
static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("User32.dll")]
static extern Int32 SendMessage(int hWnd, int Msg, int wParam, int lParam);
int window = FindWindow("triuiScreen", null);
PostMessage((IntPtr)window, WM_KEYDOWN, (IntPtr)WM_LBUTTONDOWN, (IntPtr)(y_coord << 16) | x_coord));
SendMessage(window, WM_KEYDOWN, WM_LBUTTONDOWN, (y_coord << 16) | x_coord );
from sanderling.
This is weird, but
Sanderling.WindowPostMessageKeyDown(VirtualKeyCode.VK_D);
Sanderling.WindowPostMessageKeyUp(VirtualKeyCode.VK_D);
presses "d" two times.
removing Sanderling.WindowPostMessageKeyUp(VirtualKeyCode.VK_D) causes "d" to be pressed down, not released, but not to spam a letter if chat is focused.
i'm saying that using these two methods to cause a keypress-keyrelease always presses a key twice. can't find the reason yet. this can be bad when trying to activate modules. they will deactivate as soon as they are activated.
from sanderling.
I would need to know what assumptions you used in order to understand how you arrived at these conclusions
Sanderling.WindowPostMessageKeyDown(VirtualKeyCode.VK_D);
Sanderling.WindowPostMessageKeyUp(VirtualKeyCode.VK_D);
presses "d" two times.
How did you arrive at this conclusion?
removing Sanderling.WindowPostMessageKeyUp(VirtualKeyCode.VK_D) causes "d" to be pressed down, not released
How did you arrive at this conclusion?
but not to spam a letter if chat is focused.
Why do you expect it to spam?
from sanderling.
as i understand:
Sanderling.WindowPostMessageKeyDown(VirtualKeyCode.VK_D);
presses down a button D
and
Sanderling.WindowPostMessageKeyUp(VirtualKeyCode.VK_D);
releases it
but when i use these two lines, and my cursor is focused in chat, i see two letters D typed instead of one.
if i try to use only pressing a button without a release (KeyDown without KeyUp), i expect it to become held down and to spam this letter if chat is focused.
from sanderling.
as i understand:
Sanderling.WindowPostMessageKeyDown(VirtualKeyCode.VK_D);
presses down a button D
and
Sanderling.WindowPostMessageKeyUp(VirtualKeyCode.VK_D);
releases it
I see. This is not the case. These methods just call the WinAPI function 'PostMessage' and return its return value (The implementation can be seen at
Sanderling/src/Sanderling/Sanderling/Script/ToScriptExtension.cs
Lines 104 to 111 in c487043
The reason the text 'KeyDown' and 'KeyUp' are contained within the method names is that those are also used in the documentation from microsoft which describes the messages which are being posted by these methods (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646280(v=vs.85).aspx).
For example, a windows application can use the GetAsyncKeyState function to get information about the state of a key. So far, I don't see that the WM_KEYDOWN and WM_KEYUP messages affect the return value of this function as you expect.
from sanderling.
as for sending a mouse click. i failed multiple times trying to send a click to inactive game window. the closest answer i found was at https://autohotkey.com/board/topic/96814-using-postsendmessage-to-send-clicks-to-game-window/ but even this fails for me. clicks are only sent in current mouse position only if mouse cursor is within game client window. maybe you can spend a little time to investigate this? it would be very nice. tell me if i can somehow help.
from sanderling.
clicks are only sent in current mouse position only if mouse cursor is within game client window. maybe you can spend a little time to investigate this? it would be very nice. tell me if i can somehow help.
At the moment it seems the best option is to contain both applications in an VMWare instance or a windows remote desktop session.
So far it seems that investing into research here will not be worth the effort.
from sanderling.
Related Issues (20)
- Why does pressing ctrl + alt cause the robot to pause? HOT 2
- unsuppot 64-bit game client HOT 8
- button undock not work HOT 4
- Last Measurement HOT 7
- is there any document for noob dev? HOT 6
- 32 bit eve client deprecated HOT 2
- Could you please tell me how to build readmemory64 in detail? HOT 3
- Broken info link & can't apply --session-length-limit HOT 7
- speedup finding UIRoot HOT 6
- Proposal for optimizing the used RAM HOT 4
- how is the read-memory project used? HOT 3
- Unhandle Exception in the search of the UI_root_address HOT 6
- Too long search time of UI Root HOT 7
- memory reading under wine
- How to find out this way that can reads eveonline memory data HOT 4
- ButtonGroup childrens parsing HOT 1
- High memory consumption during root search HOT 1
- alternate-ui 'From live game client process' mode does not work for me with the latest sanderling HOT 1
- Ability to read locked target health? HOT 4
- Some object types not parsed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanderling.