Jump to content

Anyone Got an idea ?


Recommended Posts

Ok in this code it gets a Window title for procces ID.

But it get's only from 1.

If there is more than one procces called sro_client.exe can it get the title of all proccesses and show them in the combobox .

Cuz now it shows only for 1 procces ;)

#Include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <Array.au3>
#include <Constants.au3>
#include <GUIConstants.au3>


$exe_name = "sro_client.exe"
$winlist = ProcessList ($exe_name)
Opt("TrayMenuMode", 1)

$GUI = GUICreate("Client", 180, 60)
$combo = GUICtrlCreateCombo ("", 4,4,170,20)

For $i = 1 To $winlist[0][0]
    GUICtrlSetData ($combo, WinGetTitle(_ProcessGetWinEx($winlist[$i][0],"","","",True)))
Next

GUISetState()

While 1   
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_Close Then
            Exit
        EndIf
    WEnd
    
Func _ProcessGetWinEx($ivPid, $svClass = "", $svTitle = "", $svText = "", $ivReturnOnlyFirstMatch = False)
    $ivPid = ProcessExists($ivPid)
    If Not $ivPid Then Return(SetError(1, 0, 0))
   
    Local $avwArray = WinList()
    Local $avRet[1] = [0]
 
    For $i = 1 To $avwArray[0][0]
        $avClass = DllCall("User32.dll", "int", "GetClassName", "hwnd", $avwArray[$i][1], "str", "", "int", 4096)
        If WinGetProcess($avwArray[$i][1]) = $ivPid Then
            If $svClass = "" Or (IsArray($avClass) And $avClass[2] = $svClass) Then
                If ($svTitle = "" Or StringInStr($avwArray[$i][0], $svTitle)) And ($svText = "" Or StringInStr(WinGetText($avwArray[$i][1]), $svText)) Then
                    $avRet[0] += 1
                    ReDim $avRet[$avRet[0]+1]
                    $avRet[$avRet[0]] = $avwArray[$i][1]
                    If $ivReturnOnlyFirstMatch Then
                        $avRet = $avret[1]
                        ExitLoop
                    EndIf
                EndIf
            EndIf
        EndIf
    Next
 
    Return $avRet

EndFunc

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

umm don't quite understand those for more than one :S

uff i'm never gonna get this right ;(

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

  • Moderators

That function returns an array for one. And your treating it as if it returns a string. It also says "$ivPid", indicating it expects a integer for the PID (meaning it only accepts 1 executable).

When things like this happen, you have to mod these udfs to do what you need:

#include <array.au3>
Local $a_hwnds = _ProcessGetWinEx("Notepad.exe")
Local $a_titles[UBound($a_hwnds)] = [UBound($a_hwnds) - 1]
For $i = 1 To UBound($a_hwnds) - 1
    $a_titles[$i] = WinGetTitle(HWnd($a_hwnds[$i]))
Next
_ArrayDisplay($a_titles)


Func _ProcessGetWinEx($svExe, $svClass = "", $svTitle = "", $svText = "", $ivReturnOnlyFirstMatch = False)
    Local $a_pl[2][2] = [[1]]
    If IsInt($svExe) Or StringIsInt($svExe) Then
        $a_pl[1][1] = ProcessExists($svExe)
    Else
        $a_pl = ProcessList($svExe)
    EndIf
   
    Local $avwArray = WinList()
    Local $avRet[1] = [0]
    
    For $x = 1 To $a_pl[0][0]
        For $i = 1 To $avwArray[0][0]
            $avClass = DllCall("User32.dll", "int", "GetClassName", "hwnd", $avwArray[$i][1], "str", "", "int", 4096)
            If WinGetProcess($avwArray[$i][1]) = $a_pl[$x][1] Then
                If $svClass = "" Or (IsArray($avClass) And $avClass[2] = $svClass) Then
                    If ($svTitle = "" Or StringInStr($avwArray[$i][0], $svTitle)) And ($svText = "" Or StringInStr(WinGetText($avwArray[$i][1]), $svText)) Then
                        $avRet[0] += 1
                        ReDim $avRet[$avRet[0]+1]
                        $avRet[$avRet[0]] = $avwArray[$i][1]
                        If $ivReturnOnlyFirstMatch Then
                            $avRet = $avret[1]
                            ExitLoop
                        EndIf
                    EndIf
                EndIf
            EndIf
        Next
    Next
 
    Return $avRet

EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

well how can that be used in my program when i try to use it.

It dousnt return anything :S

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

  • Moderators

well how can that be used in my program when i try to use it.

It dousnt return anything :S

Then either "A" there are no windows to that executable, or "B" you don't know how to use an array: http://www.autoitscript.com/wiki/Arrays ?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

umm probably the second .... i'm doing something wrons ;)

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

  • Moderators

umm probably the second .... i'm doing something wrons ;)

I gave you the wiki on arrays, now all you have to do is read that and understand how to use them :D ...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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