palindrome Posted September 24, 2007 Share Posted September 24, 2007 I have a script that interacts with a window through pixel reads, mouse activity and keyboard activity. Is there a way to easily make sure that the target window is active at every interaction without a lot of cumbersome extra code? Ideally, I want to pause when the target window loses focus and resume when it resumes focus. Link to comment Share on other sites More sharing options...
herewasplato Posted September 24, 2007 Share Posted September 24, 2007 (edited) WinWaitActive() ahead of each action Edit: or if it is always the same window/title - perhaps an adlib function with a WinWaitActive line in it... Edited September 24, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
JSunn Posted September 24, 2007 Share Posted September 24, 2007 I have a script that interacts with a window through pixel reads, mouse activity and keyboard activity. Is there a way to easily make sure that the target window is active at every interaction without a lot of cumbersome extra code? Ideally, I want to pause when the target window loses focus and resume when it resumes focus.Can you post the affected code?-John Link to comment Share on other sites More sharing options...
palindrome Posted September 24, 2007 Author Share Posted September 24, 2007 WinWaitActive() ahead of each actionEdit: or if it is always the same window/title - perhaps an adlib function with a WinWaitActive line in it...The first solution would be quite tedious to code and make the script slower. I'm going to try the second solution. Is there a way to somehow watch for the windows message that says the window is losing focus and IMMEDIATELY react to that? This would be something that adlib functions can't do, since they are run only periodically. Link to comment Share on other sites More sharing options...
JBeef Posted September 24, 2007 Share Posted September 24, 2007 Adlib() - ~Jap Link to comment Share on other sites More sharing options...
aslani Posted September 24, 2007 Share Posted September 24, 2007 Try this; While WinActive($title) ...your-scripts-here WEnd [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
herewasplato Posted September 24, 2007 Share Posted September 24, 2007 ...make the script slower......not so that you would notice with a WinWaitDelay of 0 or 1 via the Opt() function. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 24, 2007 Share Posted September 24, 2007 The first solution would be quite tedious to code and make the script slower. I'm going to try the second solution. Is there a way to somehow watch for the windows message that says the window is losing focus and IMMEDIATELY react to that? This would be something that adlib functions can't do, since they are run only periodically.Define "IMMEDIATELY". Your AdLibEnable() function could run every 100 or 50 milliseconds, for example. Is that really too slow? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
palindrome Posted September 24, 2007 Author Share Posted September 24, 2007 (edited) Define "IMMEDIATELY". Your AdLibEnable() function could run every 100 or 50 milliseconds, for example. Is that really too slow? Well, there's logic like this: if A() then B()If the window gets deactivated after the A() check but before the B() action, I would still like to to pause immediately and not perform B() on the wrong window. Specifically, A() checks for stuff on the client area with pixel checking code, in a DX game.Of course, checking whether the window is activated at EVERY action will work, but my main concern with that is code elegance and simplicity.Since my code performs pauses in between actions in takes anyway, adlib will probably work with at most one action done on the wrong window. However, I'm wondering if there's a way for the originally running code to continue where it left off when I go back to the original window. Edited September 24, 2007 by palindrome Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now