Greetings.
I'm going to automate a particular piece of software. In order to do that, I need to be able to read the process memory and send keyboard and mouse messages to it.
It's quite straightforward under Windows. But can it be done for a process running under Wine with a controlling script running in a Linux environment? I guess, there are different approaches. I would be glad to hear any ideas. References for relevant reading are welcome too
akamaus wrote:It's quite straightforward under Windows. But can it be done for a process running under Wine with a controlling script running in a Linux environment?
It is the same on Wine. But no, you can't run script in Linux. It will have to be a Windows program running inside Wine.
vitamin wrote:
It is the same on Wine. But no, you can't run script in Linux. It will have to be a Windows program running inside Wine.
It's a bad news. I'm far more familiar with a unix environment and toolchain. And I'm afraid I wasn't clear enough. For example memory of a process running in Wine can surely be read from /proc. Do you mean there is just no easier way?
akamaus wrote:For example memory of a process running in Wine can surely be read from /proc.
Yes of course. But what good will it do it you don't know what's there?
Wine only creates X windows for top level windows, not each individual control. So you can't send mouse/keyboard events that way. Or rather it will be really difficult. This is as far as controlling goes.
akamaus wrote:For example memory of a process running in Wine can surely be read from /proc.
Yes of course. But what good will it do it you don't know what's there?
Well, it's just a matter of doing some reverse engineering. What puzzles me is memory layout of wine processes. Can I find a good description somethere?
vitamin wrote:
Wine only creates X windows for top level windows, not each individual control. So you can't send mouse/keyboard events that way. Or rather it will be really difficult. This is as far as controlling goes.
I'm actually speaking about a game. so it's not a problem. Till now I've been experimenting with X Test extension, it works, but I'd like to find some less intrusive way. XSendEvent seems to be ideal, but looks like Wine ignores messages sent this way. Is there a good reason for this? I suspect it's quite trivial to patch, isn't it?
Answering my own question. The point of interest is function
find_hardware_message_window in server/queue.c. It's responsible for filtering keyboard messages for inactive windows.
akamaus wrote:It's quite straightforward under Windows. But can it be done for a process running under Wine with a controlling script running in a Linux environment?
It is the same on Wine. But no, you can't run script in Linux. It will have to be a Windows program running inside Wine.
Sorry new guy here, but it sounds like what you would need here is AutoIt or AutoHotKey for Windows running. A long side your app. Then you could run your script from there -assuming those are compatible- with whatever it is you are doing... I don't know if you want to learn a new scripting language at this point since you are more into the Linux/Unix style.
Simon of Aragon wrote:
Sorry new guy here, but it sounds like what you would need here is AutoIt or AutoHotKey for Windows running. A long side your app. Then you could run your script from there -assuming those are compatible- with whatever it is you are doing... I don't know if you want to learn a new scripting language at this point since you are more into the Linux/Unix style.
My idea was to rule the process running under wine directly from unixland. That's why I tried to avoid solutions involving launching a separate win32 process. After some research I finally found a way, you just have to patch wineserver a bit to make it pass messages to non-focused windows through. So the problem is solved. Still, thanks for advices, I'll definitely look at AutoIt in the future.
akamaus wrote:
My idea was to rule the process running under wine directly from unixland. That's why I tried to avoid solutions involving launching a separate win32 process. After some research I finally found a way, you just have to patch wineserver a bit to make it pass messages to non-focused windows through. So the problem is solved. Still, thanks for advices, I'll definitely look at AutoIt in the future.
I'll second that. AutoIt is a very polished Win project. The documentation is second to none. I've used it extensively to automate Windows installers. You can write full GUI apps with it - but it starts to get a bit creaky - compared to say Qt.
I am not entirely sure how this will effect wine, but it turns out there is a Linux version of AHK (AutoHotKey) http://www.ironahk.net/ IronHotKey would run in the native Linux env, but I don't know if it will effect apps running under Wine.
I used AutoIt3 and bounced a few tests off of it. I was able to send simple instructions to a program running in Wine as long as they shared the same default environment. However I could not send the commands to the window running in background or minimized. Maybe I am just not very good at coding it.
Well just wanted to keep you updated on your options. ;D