Noob Posted December 5, 2006 Posted December 5, 2006 Sometimes, when a window is minimized, WinActivate() doesn't seem to activate it. This is so infrequent, that I haven't yet found a way to reproduce it. But I noticed that when it happens, I can either click anywhere on empty space on the desktop, and after that WinActivate() will function. I may even click on empty space on the Windows Taskbar, and after that WinActivate() works, too.
realkiller Posted December 5, 2006 Posted December 5, 2006 i got the same expirience Remote 3.1 BetaRemote Media Player ControlUSB Security 1.2
Noob Posted December 5, 2006 Author Posted December 5, 2006 i got the same expirienceI used the WinGetState() function when that happen. According to that function the window existed, was visible, was enabled, was active, and it was minimized. Yet, the WinActivate() didn't work, and nor did @SW_MAXIMIZE, @SW_RESTORE, @SW_SHOW, or @SW_ENABLE do anything.Interestingly, I noticed that when it happens the window 'button' on the Windows Taskbar is pushed-in (indicating the window is in fact active(?), yet the windows is minimized (or at least I cannot see it on the desktop.
herewasplato Posted December 6, 2006 Posted December 6, 2006 ...Interestingly, I noticed that when it happens the window 'button' on the Windows Taskbar is pushed-in (indicating the window is in fact active(?), yet the windows is minimized (or at least I cannot see it on the desktop.I have seen this - but not while running a script. I have never run a WinGetState on the missing window... I wonder what WinGetPos shows?Anyway, I have also seen windows that are partially visible behind other windows, but will not come to the foreground and will not minimize - until you minimize all of the windows that were on top of it and then it will minimize.I just write this off to the OS and all of the things that I do to it.Do you have WinWaitDelay set to 0?Is WinMinimizeAll in your script?Mind posting a script that you seen this happen with? [size="1"][font="Arial"].[u].[/u][/font][/size]
Glyph Posted December 6, 2006 Posted December 6, 2006 Doesn't this goto the bug section of the forums? tolle indicium
herewasplato Posted December 6, 2006 Posted December 6, 2006 Doesn't this goto the bug section of the forums?More than likely it is an OS issue that has nothing to do with AutoIt... other than the fact that AutoIt can be used to demostrate the MS flaw by pushing some operations to the limits....but i could be wrong...If it turns out to be an AutoIt issue, the thread can be moved at that time. [size="1"][font="Arial"].[u].[/u][/font][/size]
Noob Posted December 6, 2006 Author Posted December 6, 2006 I found a way to reproduce the problem, but I've tested this only on one machine so far (WinXP). While 1 HotKeySet("{F2}", "activate_notepad") Sleep(100) WEnd Func activate_notepad() WinActivate("Untitled - Notepad") EndFunc The <F2> shortcut is unable to activate the window when I do the following: 1. Open, and then minimize Notepad 2. Open a few other applications (I tried three: Word, Excel, FrontPage) 3. Minimize them all 4. Leave Notepad minimized, and restore the others one-by-one 3. Close these applications without using your mouse. Do Alt+F4 to close them 4. When all is closed, and only the Notepad is running (minimized), try the <F2> shortcut to activate the notepad window. In my case the window stays minimized, and WinActivate() doesnt seem to have a visible effect.
Bert Posted December 6, 2006 Posted December 6, 2006 I had something like this happen when trying to use the send function. What happens when you try to repeat the command several times to get the window to show up? The Vollatran project My blog: http://www.vollysinterestingshit.com/
Noob Posted December 6, 2006 Author Posted December 6, 2006 I had something like this happen when trying to use the send function. What happens when you try to repeat the command several times to get the window to show up?Nothing happens even if I try repeatedly.
herewasplato Posted December 6, 2006 Posted December 6, 2006 (edited) It might not change anything, but try this code instead:HotKeySet("{F2}", "activate_notepad") While 1 Sleep(100) WEnd Func activate_notepad() $ret1 = WinWait("Untitled - Notepad") $ret2 = WinActivate("Untitled - Notepad") $ret3 = WinWaitActive("Untitled - Notepad") Sleep(200) $pos = WinGetPos("Untitled - Notepad") TrayTip("Window Position", _ "x = " & $pos[0] & @LF & _ "y = " & $pos[1] & @LF & _ "Width = " & $pos[2] & @LF & _ "Height = " & $pos[3] & @LF & @LF & _ "WinWait Returned " & $ret1 & @LF & _ "WinActivate Returned " & $ret2 & @LF & _ "WinWaitActive Returned " & $ret3, 1) EndFunc ;==>activate_notepadEdit: You can add your WinGetState lines... I wonder if the TrayTip will even work in that OS state. Edit2: I have not been able to reproduce this issue via your steps, but my OS build is only a few weeks old - I've not messed it up enough yet :-) Edited December 6, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Noob Posted December 6, 2006 Author Posted December 6, 2006 herewasplato, thanks much. Here's what the tray tool tip showed:Window Positionx = -32000y = -32000Width = 160Height = 31WinWait Returned 1WinActivate Returned 1WinWaitActive Returned 1In the meantime I managed to come up with a satisfactory workaround for my situation. Knowing that by activating another window, (or focusing on something else), fixes my problem, I just added WinActivate("Program Manager") before the WinActivate("Untitled - Notepad").But more importantly I'm glad that you were unable to reproduce the problem. It may just be this machine.
herewasplato Posted December 7, 2006 Posted December 7, 2006 (edited) Can you duplicate your problem via this code:(and play with the WinSetState line in your function named activate_notepad)Requires the beta version of AutoIt.expandcollapse popupAutoItSetOption("WinWaitDelay", 100) AutoItSetOption("WinTitleMatchMode", 2) HotKeySet("{F2}", "activate_notepad") AdlibEnable("TrTp") $speed = 3000 $tip = "Open, and then minimize Notepad" Sleep($speed) Run("notepad") WinWait("Notepad") Sleep($speed) WinSetState("Notepad", "", @SW_MINIMIZE) $tip = "Open a few other applications" Sleep($speed) FileClose(FileOpen("deleteme.doc", 2)) ShellExecute(@ScriptDir & "\deleteme.doc") WinWait("Word") Sleep($speed) FileClose(FileOpen("deleteme.xls", 2)) ShellExecute(@ScriptDir & "\deleteme.xls") WinWait("Excel") Sleep($speed) Run("calc") WinWait("Calcul") Sleep($speed) $tip = "Minimize them all" Sleep($speed) WinSetState("Calcul", "", @SW_MINIMIZE) Sleep($speed) WinSetState("Excel", "", @SW_MINIMIZE) Sleep($speed) WinSetState("Word", "", @SW_MINIMIZE) Sleep($speed) ;WinMinimizeAll() $tip = "Leave Notepad minimized and restore the others one-by-one" Sleep($speed) WinSetState("Word", "", @SW_RESTORE) Sleep($speed) WinSetState("Excel", "", @SW_RESTORE) Sleep($speed) WinSetState("Calcul", "", @SW_RESTORE) Sleep($speed) ; Do Alt+F4 to close them - I used WinClose instead $tip = "Close these applications" Sleep($speed) WinClose("Calcul") Sleep($speed) WinClose("Excel") Sleep($speed) WinClose("Word") Sleep($speed) ;4. When all is closed, ; and only the Notepad is running (minimized), ; try the <F2> shortcut to activate the notepad window. $tip = "...Notepad is running (minimized)" Sleep($speed) $tip = "Attempt to restore the Notepad window via WinActivate" Sleep($speed) AdlibDisable() Send("{F2}") While 1 Sleep($speed) WEnd Func TrTp() TrayTip("", $tip, 1) EndFunc ;==>TrTp Func activate_notepad() ;WinSetState("Untitled - Notepad", "", @SW_RESTORE) $ret1 = WinWait("Untitled - Notepad") $ret2 = WinActivate("Untitled - Notepad") $ret3 = WinWaitActive("Untitled - Notepad") Sleep(200) $pos = WinGetPos("Untitled - Notepad") TrayTip("Notepad's Window Position", _ "The Notepad window should be active." & @LF & @LF & _ "x = " & $pos[0] & @LF & _ "y = " & $pos[1] & @LF & _ "Width = " & $pos[2] & @LF & _ "Height = " & $pos[3] & @LF & @LF & _ "WinWait Returned " & $ret1 & @LF & _ "WinActivate Returned " & $ret2 & @LF & _ "WinWaitActive Returned " & $ret3, 10) EndFunc ;==>activate_notepad Func OnAutoItExit() WinClose("Notepad") FileDelete("deleteme.doc") FileDelete("deleteme.xls") EndFunc ;==>OnAutoItExitEdit: fixed copy/paste error Edited December 7, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Noob Posted December 7, 2006 Author Posted December 7, 2006 Wow, nice work! That's exactly step-by-step how I could reproduce the issue! Now, however, I don't have access to the same machine. I think that WinXP machine didn't have Sevice Pack 2 installed. Now I tried your script on a different (WinXP SP2) machine. I cannot reproduce the problem with or without your script. I will try your script tomorrow on the non-SP2 machine. I'll let you know. Tnx!
herewasplato Posted December 8, 2006 Posted December 8, 2006 You are welcome. You can remark out or delete that WinWaitDelay line. It does very little once I decided to add all of those sleeps instead. I was going for the "simulated human" and it can be done with forcing a long delay after each Window function via that WinWaitDelay setting... but it caused the activate_notepad func to be too slow with those 3 Win... funcs in a row. Anyway, I prefer a script when it comes to chasing down things like this. Happy hunting. [size="1"][font="Arial"].[u].[/u][/font][/size]
Shibuya Posted December 8, 2006 Posted December 8, 2006 it's kinda like an OS issue, commonly happens when involving 2 windows and 1 gets closed. Just a example scenario: 1) Open Notepad 2) Minimize Notepad window 3) Open any other window, eg My Computer 4) Close the new window by clicking the 'x' on the top right corner At this point, you should see the Notepad icon on the Taskbar is depressed, indicating it's activated. I did this on WinXP(32bit w/ SP2) by the way. The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"
Noob Posted December 9, 2006 Author Posted December 9, 2006 I tried the script by herewasplato on the PC I originally experienced the problem. Still the issue is there, but that's okay. Now I have my 'workaround', and I'm glad to know it's an (older) OS issue rather than AutoIt issue.Thanks all who responded in this thread.
WIHedgehog Posted November 14, 2019 Posted November 14, 2019 See this topic (problems discovered / solutions presented): WinExits works, WinActivate fails!? Link: https://www.autoitscript.com/forum/topic/93614-winexits-works-winactivate-fails/
Developers Jos Posted November 14, 2019 Developers Posted November 14, 2019 @WIHedgehog, You have made 3 posts in 3 thread which are already dead and berried for many years. In this case 13 years! Great when you want to help people in our forums, but please stick to the recent ones. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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