Jump to content

Is there a bug with WinActivate()?


marko29
 Share

Recommended Posts

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
Link to comment
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")
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...