Sign in to follow this  
Followers 0
marko29

Is there a bug with WinActivate()?

6 posts in this topic

#1 ·  Posted (edited)

It brings the window to the front but it doesnt give the focus to a window, for example if you winactivate() notepad to the front and if you press ALT then ENTER it doesnt trigger File menuoption. Probably because window still has no focus and the title bar is still grayed out.

So as result i cant use WinActivate() then apply keyboard presses on the Notepad(for example)

I usually dont ask for alot of help due to programming experience in other languages Autoit is really amazingly simple and smooth language so it feels bit silly to get stuck with something like this

Edited by marko29

Share this post


Link to post
Share on other sites



it doesnt give the focus to a window

How do you open Notepad?

Does this not work for you?

#Include <Array.au3>; Neede to display the Array
Run("notepad")
WinWait("Untitled - Notepad", "", 8)
If WinExists("[CLASS:Notepad]") Then
    MsgBox(0, "Found you", "Notepad Window exists!", 1)
Else
    MsgBox(0, '', 'Could not find NotePad')
    exit
EndIf
WinActivate("Untitled - Notepad")
Send("Hallo my NotePad" & @CRLF)
For $i = 1000 To 1100
    Send($i & @CRLF)
Next
$var = WinList("Untitled - Notepad", "")
_ArrayDisplay($var, "Have " & $var[0][0] & " Windows that exist")

Share this post


Link to post
Share on other sites

What language do you use (english, german ...) for your windows?

I once had a problem with a notepad example caused by the different title when running a german windows.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

And looky look all of sudden it now works on 32bit Windows 7, yesterday i was breaking my head with this and WinMenuSelectItem on vista 64

Any thoughts on this?

Btw thanks for help

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Actually now it all works on 64 vista as well, i feel stupid, no idea what was blocking it but something probably did as i had alot of stuff opened

Edited by marko29

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Actually i see now what the problem was, in the example file from autoit there is an error:

WinMenuSelectItem("[CLASS:Notepad]make sure this empty char doesnt exist ", "", "&File", "Page Set&up..." )

If you use this it wont select notepad because of empty char on the end of "[CLASS:Notepad](THIS EMPTY SPACE HERE)" though "[CLASS:Notepad]" works fine

Same goes if you use titlename and leave empty char on the end.

So i believe the option to get rid of errors like this is to change something in the general option function(forgot its name)

Btw the problem with winactivate was that i was activating the control inside window, not the actual window i needed to activate but i was doing this because it is really hard to get handle of this window, still trying to fix this..

Edited by marko29

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0