How to control a process under Wine?
How to control a process under Wine?
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
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
Re: How to control a process under Wine?
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.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?
Re: How to control a process under 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?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.
Re: How to control a process under Wine?
Yes of course. But what good will it do it you don't know what's there?akamaus wrote:For example memory of a process running in Wine can surely be read from /proc.
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.
Re: How to control a process under Wine?
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:Yes of course. But what good will it do it you don't know what's there?akamaus wrote:For example memory of a process running in Wine can surely be read from /proc.
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?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.
Re: How to control a process under Wine?
Sure: http://source.winehq.org/git/wine.git/treeakamaus wrote:Can I find a good description somethere?
Which one?akamaus wrote:I'm actually speaking about a game.
It might work for keyboard but not for mouse. Wine uses XInput which provides raw device events.akamaus wrote:XSendEvent seems to be ideal, but looks like Wine ignores messages sent this way.
Re: How to control a process under Wine?
XSendEvent works (I tested with xdotool --window), but only for active windows. What's about the background ones? I found this thread: http://forum.winehq.org/viewtopic.php?f=2&t=4135vitamin wrote:It might work for keyboard but not for mouse. Wine uses XInput which provides raw device events.akamaus wrote:XSendEvent seems to be ideal, but looks like Wine ignores messages sent this way.
Now I probably I should reformulate my question a bit. Is there a way to post messages to input queue of a thread from the Unix side?
Re: How to control a process under Wine?
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.
find_hardware_message_window in server/queue.c. It's responsible for filtering keyboard messages for inactive windows.
-
- Level 3
- Posts: 94
- Joined: Sat Sep 08, 2012 3:56 pm
Re: How to control a process under 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.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.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?
Re: How to control a process under Wine?
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.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.
Re: How to control a process under Wine?
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.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.
Bob
-
- Level 3
- Posts: 94
- Joined: Sat Sep 08, 2012 3:56 pm
Re: How to control a process under Wine?
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
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