 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Surfer_ix Guest
|
Posted: Fri Nov 10, 2006 7:30 am Post subject: WinActivate : This is not a bug... but |
|
|
Here's what I've asked the author of AutoHotkey :
Go there, download this game :
http://www.bay12games.com/dwarves/
Launch it.
Then create an autohotkey script like aas simple as that :
| Code: | #NoEnv
#SingleInstance ignore
SendMode Input
MyActiveWindow(AFenetre)
{
WinWait, %AFenetre%
IfWinNotActive, %AFenetre%
{
WinActivate, %AFenetre%
WinWaitActive, %AFenetre%
}
}
SetTitleMatchMode, 2 ; doit contenir AU MOINS
MyActiveWindow("Dwarf Fortress")
Exit, |
; you'll notice that sometimes the window goes to front, sometimes it doesn't, and as soon as you've clicked on the "dwarf fortress" window, the autohotkey script end.
This may be a bug in WinActivate I think.
------------------------------------------
And the answer was :
Thanks for the report. Unfortunately, I don’t think there’s much that can be done to improve WinActivate because basically it amounts to only one single call to the Windows API: SetForegroundWindow(). The operating system does not provide any way to guarantee that a window will become active, so the best we can do is keep trying to activate it until it agrees to become active.
If it fails in your case, you could try a loop that continually tries to activate and/or maximize it. Also, if you have DetectHiddenWindows turned on, you could try leaving it turned off (sometimes this helps).
------------------------------------------
This fails in my case.
Any idea how to have this working properly ?  |
|
| Back to top |
|
 |
quicktest
Joined: 30 Jul 2004 Posts: 42
|
Posted: Fri Nov 10, 2006 2:55 pm Post subject: |
|
|
I've run into my share of WinActivate issues, and came up with the rudimentary bandaid of using Sleep & dual activation to help alleviate it. Try the following modified code, see if it works better for you:
| Code: | #NoEnv
#SingleInstance ignore
SendMode Input
MyActiveWindow(AFenetre)
{
WinWait, %AFenetre%
Sleep, 500
IfWinNotActive, %AFenetre%
{
WinActivate, %AFenetre%
WinActivate, %AFenetre%
WinWaitActive, %AFenetre%
}
}
SetTitleMatchMode, 2 ; doit contenir AU MOINS
MyActiveWindow("Dwarf Fortress")
Exit, |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|