Jump to content

Need a _WinGetPriority function


 Share

Recommended Posts

Hi,

Is there any way to get a priority for different windows? Or, to be more specific, i need it for the controls's (many of them) handles, so i can check wich one of the handles (i get it via ControlGetHandle("Title", "", "CLASSNN")) is having the top most priority (wich one is "more active"? :o).

We have _ProcessGetPriority(), but is there a way to get the same for windows? :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Hi,

Is there any way to get a priority for different windows? Or, to be more specific, i need it for the controls's (many of them) handles, so i can check wich one of the handles (i get it via ControlGetHandle("Title", "", "CLASSNN")) is having the top most priority (wich one is "more active"? :D).

We have _ProcessGetPriority(), but is there a way to get the same for windows? :o

I don't think the concept of priority applies to windows, only to their underlying process. Windows (and controls in a window) do have a Z-order (the "on top" order or layers).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

@MrCreatoR

Hi friend!

If I understand right the your question:

Run("notepad.exe")
WinWait("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")

ControlSetText($hWnd, "", "Edit1", "Hello world!")

$hResult = _GetTopWindow($hWnd)
MsgBox(0, "Result", "Topmost (top of the Z order) handle: " & $hResult & @LF & @LF & _
        "Window or control text: " & WinGetTitle($hResult) & @LF)

Func _GetTopWindow($hWnd = 0) ;If parameter is NULL the function returns a handle to the window at the top of the Z order.
    Local $aRet = DllCall("User32.dll", "hwnd", "GetTopWindow", _
                                                "hwnd", $hWnd)
    Return $aRet[0]
EndFunc   ;==>_GetTopWindow

MSDN

:)

Edited by rasim
Link to comment
Share on other sites

PsaltyDS

I don't think the concept of priority applies to windows, only to their underlying process

I see, thanks for the info, i also had that feeling...

If I understand right the your question:

Run("notepad.exe")
WinWait("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")

ControlSetText($hWnd, "", "Edit1", "Hello world!")

$hResult = _GetTopWindow($hWnd)
MsgBox(0, "Result", "Topmost (top of the Z order) handle: " & $hResult & @LF & @LF & _
        "Window or control text: " & WinGetTitle($hResult) & @LF)

Func _GetTopWindow($hWnd = 0) ;If parameter is NULL the function returns a handle to the window at the top of the Z order.
    Local $aRet = DllCall("User32.dll", "hwnd", "GetTopWindow", _
                                                "hwnd", $hWnd)
    Return $aRet[0]
EndFunc   ;==>_GetTopWindow

MSDN

:)

That's a start, thank you.

But lets say i have a list (in array) of controls (they class names), and now i need to check wich one of theese controls is having the top most priority. In generaly, a perfect solution would be to go through the list (with the controls), and comparing the current control with the next one ([1] vs [2] if exists), so eventualy i will have one(!) control handle that is top most between the all others from that list.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Or, if it would be possible, to get the handle with specific ClassNN, something like this:

$hResult = _GetTopWindow($hWnd, "OperaWindowClass")
MsgBox(0, "Result", "Topmost (top of the Z order) handle: " & $hResult)

Func _GetTopWindow($hWnd = 0, $sCtrlClassName)
    Local $aRet = DllCall("User32.dll", "hwnd", "GetTopWindow", "hwnd", $hWnd)
    Return $aRet[0]
EndFunc

So the returned handle will be chosen (by the function :) ) only from a child handles that have specific ClassName.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Or, if it would be possible, to get the handle with specific ClassNN, something like this:

$hResult = _GetTopWindow($hWnd, "OperaWindowClass")
MsgBox(0, "Result", "Topmost (top of the Z order) handle: " & $hResult)

Func _GetTopWindow($hWnd = 0, $sCtrlClassName)
    Local $aRet = DllCall("User32.dll", "hwnd", "GetTopWindow", "hwnd", $hWnd)
    Return $aRet[0]
EndFunc

So the returned handle will be chosen (by the function :) ) only from a child handles that have specific ClassName.

Doesn't your function _WinGetNumeratedClassList do what you want? If not I think that enumchildwindows enumerates in z order so this might help.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Or, if it would be possible, to get the handle with specific ClassNN, something like this:

$hResult = _GetTopWindow($hWnd, "OperaWindowClass")
MsgBox(0, "Result", "Topmost (top of the Z order) handle: " & $hResult)

Func _GetTopWindow($hWnd = 0, $sCtrlClassName)
    Local $aRet = DllCall("User32.dll", "hwnd", "GetTopWindow", "hwnd", $hWnd)
    Return $aRet[0]
EndFuncoÝ÷ Ù*-êÞ¶êçyØZÙ^Â)emç!¢Ç§o+ayû§rبåÉúè§!WajwezËajØZ½ë)yÈÀ¥jË
jg¿ªê-y*ºÚ"µÍ[   ][ÝÛÝY^I][ÝÊBÚ[ØZ]
    ][ÝÖÐÓTÔÎÝYI][ÝÊBÌÍÚÛHÚ[Ù][J ][ÝÖÐÓTÔÎÝYI][ÝÊBÛÛÛÙ]^
    ÌÍÚÛ    ][ÝÉ][ÝË    ][ÝÑY]I][ÝË ][ÝÒ[ÈÛÜ   ÌÌÎÉ][ÝÊBÌÍÚÝ[HÑÙ]ÜÚ[ÝÊ ÌÍÚÛ    ][ÝÑY]    ][ÝÊBÙÐÞ
    ][ÝÔÝ[   ][ÝË  ][ÝÕÜ[ÜÝ
ÜÙHÜH[N  ][ÝÈ  [È ÌÍÚÝ[   [È [È [ÈÂ   ][ÝÕÚ[ÝÈÜÛÛÛ^  ][ÝÈ  [ÈÚ[Ù]]J ÌÍÚÝ[
H   [ÈB[ÈÑÙ]ÜÚ[ÝÊ   ÌÍÚÛ    ÌÍÜÐÝÛÜÓ[YJBSØØ[  ÌÍØT]    ÌÍÜÐÛÜÓ[YBB  ÌÍØT]HØ[
    ][ÝÕÙÌ  ][ÝË  ][ÝÚÛ    ][ÝË  ][ÝÑÙ]ÜÚ[ÝÉ][ÝË  ][ÝÚÛ    ][ÝË  ÌÍÚÛ
BRYÑÙ]ÛÜÓ[YJ   ÌÍØT]ÌJHH   ÌÍÜÐÝÛÜÓ[YH[]   ÌÍØT]ÌB[[ÈÏOIÝ×ÑÙ]ÜÚ[ÝÂ[ÈÑÙ]ÛÜÓ[YJ  ÌÍÚÛ
BSØØ[ ÌÍØT]HØ[
    ][ÝÕÙÌ  ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÑÙ]ÛÜÓ[YI][ÝËÂBBBBBBBBBBBI][ÝÚÛ  ][ÝË  ÌÍÚÛÂBBBBBBBBBBBI][ÝÜÝ][ÝË    ][ÝÉ][ÝËÂBBBBBBBBBBBI][ÝÚ[   ][ÝË
MBT]    ÌÍØT]ÌB[[ÈÏOIÝ×ÑÙ]ÛÜÓ[Y
Link to comment
Share on other sites

@martin

Doesn't your function _WinGetNumeratedClassList do what you want?

No, it's returning in the alphabetic order :)

If not I think that enumchildwindows enumerates in z order so this might help

It just might... Thanks, i will try to play with it...

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

So?

:) - No, i need to get it from a list (of classes), not check if returned handle having specific class name...

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Try experimenting with this function. It may help.

#include <WinAPI.au3>
#include <Array.au3>

; Ensure AutoIt Help is running

$WinTitle = "AutoIt Help"
$aInfo = _CtrlInfo($WinTitle)

_ArrayDisplay($aInfo)

Func _CtrlInfo($WinTitle)
    Local $sString = "," ; Add coma to start of string for RegExp to get 1st word
    Local $sDupl, $iIndex
    $text = StringTrimRight(WinGetClassList($WinTitle, ""), 1) ; "Untitled ", "") ;
    $aTest = StringSplit($text, @LF)

    For $i = 1 To UBound($aTest) - 1
        If StringRegExp($sString, "," & $aTest[$i] & ",", 0) = 0 Then
            $sString &= $aTest[$i] & ","
        Else
            $sDupl &= $aTest[$i] & ","
        EndIf
    Next
    $sString = StringTrimLeft(StringTrimRight($sString, 1), 1) ; Remove 1st and last comas.
    $sDuplCopy = $sDupl
    Dim $aDulpChk[1][3]
    Local $count = 0
    While StringInStr($sDupl, ",") <> 0
        
        ReDim $aDulpChk[UBound($aDulpChk) + 1][3]
        $count = UBound($aDulpChk) - 1
        $aDulp = StringSplit($sDupl, ",")
        $aD = StringRegExp($sDupl, $aDulp[1], 3)
        $sDupl = StringReplace($sDupl, $aDulp[1] & ",", "", UBound($aD))
        $aDulpChk[$count][0] = $aDulp[1]
        $aDulpChk[$count][1] = UBound($aD) + 1
        $aDulpChk[$count][2] = 0
    WEnd

    Dim $ClssnmNN[$aTest[0] + 1]

    For $i = 1 To $aTest[0]
        If StringInStr($sDuplCopy, $aTest[$i]) = 0 Then
            $ClssnmNN[$i] = $aTest[$i] & "1"
        Else
            For $k = 1 To UBound($aDulpChk) - 1
                If $aTest[$i] = $aDulpChk[$k][0] Then $iIndex = $k
            Next
            $aDulpChk[$iIndex][2] += 1
            $ClssnmNN[$i] = $aTest[$i] & $aDulpChk[$iIndex][2]
        EndIf
    Next

    WinActivate($WinTitle)

    Dim $aCtrlInfo[$aTest[0] + 1][8]
    $aCtrlInfo[0][0] = "Control Class"
    $aCtrlInfo[0][1] = "Control Handle"
    $aCtrlInfo[0][2] = "ClassnameNN"
    $aCtrlInfo[0][3] = "ControlID"
    $aCtrlInfo[0][4] = "Position X"
    $aCtrlInfo[0][5] = "Position Y"
    $aCtrlInfo[0][6] = "Width"
    $aCtrlInfo[0][7] = "Height"
    
    For $CtrlClass = 1 To $aTest[0]
        $aCtrlInfo[$CtrlClass][2] = $ClssnmNN[$CtrlClass] ; ClassnameNN
        $aCtrlInfo[$CtrlClass][0] = $aTest[$CtrlClass]
        $aCtrlInfo[$CtrlClass][1] = ControlGetHandle($WinTitle, "", $aCtrlInfo[$CtrlClass][2])
        Local $ID = _WinAPI_GetDlgCtrlID($aCtrlInfo[$CtrlClass][1])
        If $ID <> "" Then $aCtrlInfo[$CtrlClass][3] = Dec(Hex($ID))
        $aPosC = ControlGetPos($WinTitle, "", $aCtrlInfo[$CtrlClass][2])
        $aCtrlInfo[$CtrlClass][4] = $aPosC[0]
        $aCtrlInfo[$CtrlClass][5] = $aPosC[1]
        $aCtrlInfo[$CtrlClass][6] = $aPosC[2]
        $aCtrlInfo[$CtrlClass][7] = $aPosC[3]
        
    Next
    Return $aCtrlInfo
EndFunc   ;==>_CtrlInfo
Link to comment
Share on other sites

But lets say i have a list (in array) of controls (they class names), and now i need to check wich one of theese controls is having the top most priority. In generaly, a perfect solution would be to go through the list (with the controls), and comparing the current control with the next one ([1] vs [2] if exists), so eventualy i will have one(!) control handle that is top most between the all others from that list.

You still have the same conceptual problem. There is no "priority" between controls, only Z-order. And for controls, the Z-order is only significant if they overlap.

So when you say "...one(!) control handle that is top most", what does that mean?

Please define "top most" and "priority" in what you are trying to do.

If you were manually poking at the GUI, how would notice the difference in "priority" among the controls?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

So when you say "...one(!) control handle that is top most", what does that mean?

Please define "top most" and "priority" in what you are trying to do.

It's meaning the control that is most visible to me. If for example i have two windows with «OnTop» attribute, and one of them is active, then this active window is having the most priority (to the front of the screen, if one can say that). But when i will activate some other window (not one of theese two), then the priority stays with the last active windows of those two (if it's a controls, then i need to check them as childs and get the most fronted of them, wich is the last one that was active between them).

If you were manually poking at the GUI, how would notice the difference in "priority" among the controls?

Lets say just most active between them (last active?)... :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Ok, here is what i got so far... Theese functions helping to return numerated window classes list with preserving the “z-order” (i think/hope so):

Global $aChild_Wins

ConsoleWrite(_WinGetNumeratedClassListEx("[ACTIVE]", ""))

Func _WinGetNumeratedClassListEx($sTitle, $sText)
    If IsInt($sText) Then
        $aChild_Wins[0] += 1
        ReDim $aChild_Wins[$aChild_Wins[0]+1]
        
        $aChild_Wins[$aChild_Wins[0]] = $sTitle
        
        Return True ; To get next window
    EndIf
    
    Local $sRetClassList = ""
    Local $hWndParent = WinGetHandle($sTitle, $sText)
    Local $hCallBack_ChildWnds = DllCallbackRegister("_WinGetNumeratedClassListEx", "int", "hwnd;lparam")
    
    Dim $aChild_Wins[1]
    
    DllCall("User32.dll", "int", "EnumChildWindows", "hwnd", $hWndParent, "int", _
        DllCallbackGetPtr($hCallBack_ChildWnds), "int", 1)
    
    For $hWndChild In $aChild_Wins
        If Not IsHWnd($hWndChild) Then ContinueLoop
        
        $sRetClassList &= _WinGetClassNameNN($hWndChild, $hWndParent) & @CRLF
    Next
    
    DllCallbackFree($hCallBack_ChildWnds)
    
    Return StringStripWS($sRetClassList, 2)
EndFunc

Func _WinGetClassNameNN($hCtrlWnd, $hWinWnd="")
    $hCtrlWnd = ControlGetHandle($hWinWnd, "", $hCtrlWnd)
    $sClassName = _WinGetClassName($hCtrlWnd)
    $aClassList = StringSplit(WinGetClassList($hWinWnd), @CRLF)
    
    For $iC in StringSplit(WinGetClassList($hWinWnd), @CRLF)
        If $iC = $sClassName Then
            For $x = 1 To UBound($aClassList)
                If ControlGetHandle($hWinWnd, "", $iC & $x) = $hCtrlWnd Then Return $iC & $x
            Next
        EndIf
    Next
    
    Return $sClassName
EndFunc

Func _WinGetClassName($hWndControl)
    Local $aRet = DllCall('user32.dll', 'int', 'GetClassName', 'hwnd', $hWndControl, 'str', "", 'int', 256)
    Return $aRet[2]
EndFunc

It helps me in some way i think, not have much time to test it more carefully right now, but i think that this is ...a begining of wonderful friendship... the right way :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Ok, here is what i got so far... Theese functions helping to return numerated window classes list with preserving the “z-order” (i think/hope so):

Hmm... strange use of the EnumChildWindows function :)

My solution:

$hEnumChildProc = DllCallbackRegister("_EnumChildProc", "int", "hwnd;lparam")
$sWindowClass = ""
$sResult = ""

_EnumChildWindows(WinGetHandle("[ACTIVE]"))

MsgBox(0, "", $sResult)

Func _EnumChildWindows($hWnd = 0, $lParam = 0)
    DllCall("User32.dll", "int", "EnumChildWindows", _
                                 "hwnd", $hWnd, _
                                 "ptr", DllCallbackGetPtr($hEnumChildProc), _
                                 "lparam", $lParam)
EndFunc   ;==>EnumChildWindows

Func _EnumChildProc($hWnd, $lParam)
    Local $sClass = _GetClassName($hWnd)
    $sWindowClass &= $sClass
    
    Local $iMatch = StringRegExp($sWindowClass, $sClass, 3)
    $sResult &= $sClass & UBound($iMatch) & @CRLF
    
    Return 1
EndFunc   ;==>_EnumChildProc

Func _GetClassName($hWnd)
    Local $aRet = DllCall("User32.dll", "int", "GetClassName", _
                                                "hwnd", $hWnd, _
                                                "str", "", _
                                                "int", 256)
    Return $aRet[2]
EndFunc

DllCallbackFree($hEnumChildProc)

:o

Link to comment
Share on other sites

strange use of the EnumChildWindows function

Yes i know, but it's to prevent of creating many "helping functions", don't sure why :)

My solution:

Nice one, thanks.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

@rasim

strange use of the EnumChildWindows function

Here is another one (with your implementation of numbering classes) :) ...

#include <Array.au3>

Global $sWins_Class_List

$aNumeratedClassList = _WinGetNumeratedClassListEx("[ACTIVE]", "", 1)

If IsString($aNumeratedClassList) Then
    ConsoleWrite($aNumeratedClassList & @CRLF)
Else
    _ArrayDisplay($aNumeratedClassList)
EndIf

; Description: Retrieves the numerated classes (preserving the z-order) from a window.
; Author: MsCreatoR (numbering method idea by @rasim).
Func _WinGetNumeratedClassListEx($sTitle, $sText, $iRet_Array)
    If IsInt($sText) Then
        Local $hWnd_Child = $sTitle
        If Not IsHWnd($hWnd_Child) Then Return 1
        
        Local $sClassName = DllCall("User32.dll", "int", "GetClassName", "hwnd", $hWnd_Child, "str", "", "int", 256)
        $sClassName = $sClassName[2]
        
        StringRegExpReplace($sWins_Class_List, "(\r\n|)" & $sClassName & "(\d+|\r\n|):", "")
        $sWins_Class_List &= $sClassName & @extended+1 & ":" & $hWnd_Child & @CRLF
        
        Return 1 ;To get next window
    EndIf
    
    Local $hWndParent = WinGetHandle($sTitle, $sText)
    Local $hCallBack_ChildWnds = DllCallbackRegister("_WinGetNumeratedClassListEx", "int", "hwnd;lparam")
    
    DllCall("User32.dll", "int", "EnumChildWindows", "hwnd", $hWndParent, "int", DllCallbackGetPtr($hCallBack_ChildWnds), "int", 1)
    DllCallbackFree($hCallBack_ChildWnds)
    
    $sWins_Class_List = StringStripWS($sWins_Class_List, 2)
    
    If $iRet_Array Then
        Local $aSplit_Array = StringSplit($sWins_Class_List, @CRLF, 1)
        Local $aRet_Array[$aSplit_Array[0]+1][2]
        Local $aTmp_Split_Arr
        
        For $i = 1 To $aSplit_Array[0]
            $aTmp_Split_Arr = StringSplit($aSplit_Array[$i], ":")
            If $aTmp_Split_Arr[0] < 2 Then ContinueLoop
            
            $aRet_Array[$i][0] = $aTmp_Split_Arr[1]
            $aRet_Array[$i][1] = $aTmp_Split_Arr[2]
        Next
        
        $aRet_Array[0][0] = $aSplit_Array[0]
        Return $aRet_Array
    EndIf
    
    Return $sWins_Class_List
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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