Sign in to follow this  
Followers 0
trynhyty

Retrieve the name of the window that is on top

10 posts in this topic

Hi everybody, 

 

As I explained in a previous topic, I'm trying to make a program that will be a Window with a text input field.

If I write "chrome" and press enter in that field, it should open chrome.exe

What I'm trying to do is to check when the window of Chrome is on top of screen. 

I used pixelsearch, but I find it really inadequate.

Is there a way to mess around with WinAPI.au3 to retrieve the name of the current top window ? 

Thanks by advance.

Share this post


Link to post
Share on other sites



Have a look at:

WinList

 


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Have a look at:

WinList

 

As usual, thanks MikahS :P 

By the way, I finally made a function to erase last char in my historic txtfile, works like a charm, thank you :)

Share this post


Link to post
Share on other sites

If you could help me with WinList, that'd be cool :) 

I'm trying to understand the function, and I don't two things : 

I don't achieve to interprete " For $i = 1 To $aList[0][0] " 

I understand this as it was a cursor that went from the last window to the first ($aList[0][0] if I understand correctly) 

With the example I achieve to get the name of all the windows open on my computer, but if I just write MsgBox (0, "", "Title : " & $aList[1][0]), I have no value shown :( 

And I don't get why yet.

The second problem is linked to the fist, I need to know how to get only the first title of the array that WinList make for me :) 

Thanks in advance :)

Share this post


Link to post
Share on other sites

It's hard to help when you lack basic understanding. You can expect expect people to start re-hashing tutorials on something that you yourself should read about e.g. arrays, loops etc. My suggestion, get the fundamentals understood and then start building something.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Winlist lists all windows including these without a title
Example #1 in the helpfile shows exactly how to get "only visible windows with a title"
Then you could use it like this

#include <MsgBoxConstants.au3>

Local $aList = WinList()

; Loop through the array displaying only visible windows with a title.
For $i = 1 To $aList[0][0]
     If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
             $title = $aList[$i][0]
             $handle = $aList[$i][1]
             Exitloop
     EndIf
Next
MsgBox($MB_SYSTEMMODAL, "", "Title: " & $title & @CRLF & "Handle: " & $handle)

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

 

WinWaitActive ?

I tried it, and works like a charm. 

But I find the WinList() option more fun to apply, atleast it learns me some things about programmation :P 


At the moment, I wrote this : 

 

$x = 0
 global $array[1]
 
 For $i = 1 To $aList [0][0]

    If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
         MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList [$i][0] & @CRLF)
         $array[$x] = $aList[$i][0]
         $x = $x+1
         ReDim $value[UBound($array) + 1]
    EndIf
Next

ReDim $array[UBound($array) - 1]

_ArrayDisplay ($array)

 

And I get an array with only windows that have a title.

I'm trying to get the first row of the array, I've not looked for it yet, don't spoil me :P 

 

Edited by trynhyty

Share this post


Link to post
Share on other sites

As usual, thanks MikahS :P 

By the way, I finally made a function to erase last char in my historic txtfile, works like a charm, thank you :)

My pleasure, as always. ^_^

Glad you got a solution figured out to your other problem as well!


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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