Jump to content

AutoIt get Window focus


Blueing
 Share

Recommended Posts

Hi,

im new to AutoIt and writing my first script - I want to click some buttons in a programm but it needs to get in the foreground/focus before.

Im trying this since 2 hours, experimenting with WinActive, WinActivate, using [REGEXPCLASS:HwndWrapper.*] but couldnt get it work for me. The problem for me is all this functions require a title, but my program doesnt have one, just a class which is "HwndWrapper[svchost.exe;;0a3fe4dd-408b-43f0-949f-92765f609024]".

Can anyone help me how i can acces the program to bring it in focus/foreground?

Thanks and greetz,

blue

Link to comment
Share on other sites

Maybe WinGetTitle then use the title for winactivate.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

4 hours ago, careca said:

Maybe WinGetTitle then use the title for winactivate.

WinGetTitle results in NULL (is NULL existing in AutoIt?) or in simply no value; Its an exe without title.

3 hours ago, aa2zz6 said:

Does this work for you? Be sure to place your Class ID where I said below.

_ActiveWindow()


Func _ActiveWindow()
    $hWnd1 = WinGetHandle("[CLASS: PUT CLASS ID HERE ]")
    If IsHWnd($hWnd1) Then
        WinActivate($hWnd1)
    EndIf
EndFunc   ;==>_ActiveWindow

 

Sadly its not, I think because I cant really acces the class of it, as its changing everytime I restart the programm. Got here two screens from different startups, as you can see no title and changing classes:

1.PNG

2.PNG

I tried it with regular expressions "WinActivate("[REGEXPCLASS:(?i)HwndWrapper[svchost.exe;;.*7285bba9-8e46-4420-a43f-5a157005c8b4]]")" but still couldnt get it to work. The "Window Active/Activate by Exe ; Author - SmOke_N" isnt working for me as there are alot of svchost.exe on the machine running, but just one which I want to access or has a GUI in general.

Thanks for the answers!

Greetz

Link to comment
Share on other sites

I found a little Workaround as im just using the position and size of the window now (WinActivate("[X:578\Y:470\W:764\H:100]") - AND IT WORKS! im happy af now, because something works for me now :D

But with this comes the next problem; now the window has the same size and position, but I it will change as it gets more data. And yeah, with all the problems before, I cant access the new x/y width and height without a title or right class..

Is there a option (may from the OS or a extern program) which opens a program everytime in the SAME size and on the same position?

Greetz again! :)

Link to comment
Share on other sites

You could add a bit to your script to save to ini for example, the current size of the window for the next time.

Then the script reads the ini values of the window, the last time it ran, and it detects it everytime.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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...