Sign in to follow this  
Followers 0
coucou

How to select an active window among multiple windows

22 posts in this topic

Hi,

I'm looking for how to select an active window among multiple actived(opened) windows. Actually, i'm using WinWaitActive() function without a rel success.

The target is to activate an application during the startup. Therefore, i put my "activation" script in Start/All Programs/Startup.

The problem is, during the startup, my script (Activate_Appz) is launched among many applications, and if i want my script running, i have to click anywhere on the Activate_Appz window to select it, then everything goes fine.

In my opinion, i have either selecting my (Activate_Appz) window, or, launching my script after all process loaded.

Any help will be appreciated

Regards

coucou

Share this post


Link to post
Share on other sites



$winList = WinList()
CheckWindows($winList)

Func CheckWindows($aArray)
    For $i = 1 To Ubound($aArray) - 1
        If WinActive($aArray[$i][1]) Then MsgBox(0, "Window Check", $aArray[$i][0] & " is active.")
    Next
EndFunc


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Hi,

I'm looking for how to select an active window among multiple actived(opened) windows. Actually, i'm using WinWaitActive() function without a rel success.

The target is to activate an application during the startup. Therefore, i put my "activation" script in Start/All Programs/Startup.

The problem is, during the startup, my script (Activate_Appz) is launched among many applications, and if i want my script running, i have to click anywhere on the Activate_Appz window to select it, then everything goes fine.

In my opinion, i have either selecting my (Activate_Appz) window, or, launching my script after all process loaded.

Any help will be appreciated

Regards

coucou

If I'm understanding your message correctly, you have a script in the Startup folder that launches your target window. But since Windows launches other programs before and after your script, your target window isn't the active window. And until you either manually activate your target window or manually launch your script after Windows is fully loaded, it is only then your WinWaitActive and script works the way you want it to.

I'm sure there are better ways of doing this but one idea that comes to mind is using the code AU3Recorder puts into every script:

Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
WinWait(" <your target window's title goes here> ","")
If Not WinActive(" <your target window's title goes here> ","") Then WinActivate(" <your target window's title goes here> ","")
WinWaitActive(" <your target window's title goes here> ","")

Also be sure to look at the Window Titles and Text (Advanced) section in help for more options for the Title special definition.

Hope this help and good luck!

--ss3

...

Share this post


Link to post
Share on other sites

TNX all,

@mikehunt114: I hope you understood my message as well as ssubirias3 described here above.

If so and if your script answer my problem, how do i integrate yr script into mine here bellow?

;ClipPut(FileRead('ClipboardEmpty.txt'))
ClipPut("")

;Variable
Sleep(10000)
$UN = "XXXXXXX"
$EM = "xx@xx.com"
$PID1 = Run("active.exe")
$title2 = ("YYYYYYY")

WinWaitActive($title2)

ControlSetText($title2, "", "TLabeledEdit3", $UN)
ControlSetText($title2, "HEN-HEN", "TLabeledEdit2", $EM)

Sleep(1000)
   If WinWait($title2, $EM) Then
        ClipPut(FileRead('activation.txt'))
   EndIf
$bak = ClipGet()

Sleep(1000)
If WinWait($title2, $bak) Then
    ControlClick($title2, $bak, "TButton3")
EndIf

Sleep(1000)
ControlClick($title2, "", "TButton4")
Sleep(1000)
ControlClick($title2, "", "TButton1")

@ssubirias3: You understood my message 100%. I'll give a try and let you know further.

Regards

coucou

Share this post


Link to post
Share on other sites

All my snippet does is find which window is currently active. If that's not what you're after, disregard my post.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

There's a much easier way to get the active window:

$title = WinGetTitle("") ;returns the title of the active window. Wanna activate it?
WinActivate($title)


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

Hi sandman

Do yr script works even Windows launches other programs before and after my script and my target window isn't the active window???

Regards

coucou

Share this post


Link to post
Share on other sites

What you're proposing isn't plausible. There can only be one active window at a time. It will get the window that is currently selected and active.


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

If you need to keep a single window active, AdlibEnable a WinActivate command on a very short loop, or just make sure it's active before sending commands to the window.

If Not WinActive($hwnd) Then WinActivate($hwnd)

Not a clean way of doing things though since it would have to be checked before each command is executed. ControlClick/ControlSend/etc send commands to an inactive window, if that helps.

Edit: typos

Edited by mikehunt114

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

@sandman: read the here above ssubirias3 ptoposal.

@mikehunt114: May you develop please?

What should be ($hwnd)?

If Not WinActive($hwnd) Then WinActivate($hwnd)

Regards

coucou

Share this post


Link to post
Share on other sites

@mikehunt114: May you develop please?

What should be ($hwnd)?

The window's handle.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

What should be ($hwnd)?

If Not WinActive($hwnd) Then WinActivate($hwnd)
Look up WinGetHandle in the help file. Also as a suggestion if you decide to go with the window's handle I would replace your $title2 with $hwnd or whatever variable you assing the handle to. For example if you wanted to get the window handle of a notepad window that had the text "What's my handle" then you would use the following code:

$hwnd = WinGetHandle("classname=Notepad", "What's my handle")oÝ÷ Øù^jǮ׫²Ö§týËbZkzÛrì-¡«­¢+ZÚk¢
Úh§û®*mx"§z¶¥J讯zl§{Z¶×¦¦Ö­ºZ¶)àÊ«r^!©µ§b±§oj{Zë"Çq©÷öÛ^²ÛazÇ+hl¬ÊË^«­¢+Ù
±¥ÁAÕÐ ÅÕ½ÐìÅÕ½Ðì¤ìì±Ðìô±É¥¹½Õб¥Á½É((íYÉ¥±)M±À ÄÀÀÀÀ¤ìì±ÐìôÁÕͽÈÄÀͽ¹Ì(ÀÌØíU8ôÅÕ½Ðíaaaaaa`ÅÕ½Ðì(ÀÌØí4ôÅÕ½Ðíááá๽´ÅÕ½Ðì(ÀÌØíA%ÄôIÕ¸ ÅÕ½ÐíÑ¥Ù¹áÅÕ½Ðì¤(ÀÌØíѥѱÈôÅÕ½ÐíeeeeeedÅÕ½Ðììì±Ðìôɵ½ÙÑ¡ ¤¥å½Ô¹Ñ¡¥ÌÌÁÉнѡÙÉ¥±¥Ð¹ÌѼÀÌØíѥѱÈôÅÕ½Ðì¡eeeeed¤ÅÕ½Ðì()%9½Ð]¥¹Ñ¥Ù ÀÌØíѥѱȤQ¡¸]¥¹Ñ¥ÙÑ ÀÌØíѥѱȤ)]¥¹]¥ÑÑ¥Ù ÀÌØíѥѱȤ((ìììì¹½ÑÑ¡ÕÑä¡¥¹
½¹Ñɽ±MÑQáнȹ併µ¹¥¹¹¥¹Ý¥Ñ 
½¹Ñɽ°(ìììì¥ÌÑ¡ÐÑ¡Ý¥¹½Ü½Ì¹½Ð¡ÙѼѥÙ(ììììÑ¡ÑáÐÀÌØíU8Ý¥±°ÍÐѼѡѥٽȥ¹Ñ¥ÙÝ¥¹½ÜÁɽ٥ѡɥ̽¹±ä½¹(ììììÝ¥¹½ÜѡеѡÌÀÌØíѥѱȸ%Ñ¡ÉɵձѥÁ±Ý¥¹½ÝÌÝ¥Ñ Ñ¡ÍµÑ¥Ñ±(ììììÑ¡¸¥Ðµ­Ì͹ÍѼÕÍÑ¡Ý¥¹½Ü¡¹±Í¥¹Ñ¡¥ÌÝ¥±°±ÝåÌÕ¹¥ÅÕ()
½¹Ñɽ±MÑQáÐ ÀÌØíѥѱȰÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíQ1±¥ÐÌÅÕ½Ðì°ÀÌØíU8¤)
½¹Ñɽ±MÑQáÐ ÀÌØíѥѱȰÅÕ½Ðí!8µ!8ÅÕ½Ðì°ÅÕ½ÐíQ1±¥ÐÈÅÕ½Ðì°ÀÌØí4¤()M±À ÄÀÀÀ¤)%9½Ð]¥¹Ñ¥Ù ÀÌØíѥѱȤQ¡¸]¥¹Ñ¥ÙÑ ÀÌØíѥѱȤ)]¥¹]¥ÑÑ¥Ù ÀÌØíѥѱȤ)
±¥ÁAÕС¥±I ÌäíÑ¥ÙÑ¥½¸¹ÑáÐÌä줤((ÀÌØí¬ô
±¥ÁÐ ¤()M±À ÄÀÀÀ¤)
½¹Ñɽ±
±¥¬ ÀÌØíѥѱȰÀÌØí¬°ÅÕ½ÐíQ  ÕÑѽ¸ÌÅÕ½Ðì¤()M±À ÄÀÀÀ¤)
½¹Ñɽ±
±¥¬ ÀÌØíѥѱȰÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíQ    ÕÑѽ¸ÐÅÕ½Ðì¤)M±À ÄÀÀÀ¤)
½¹Ñɽ±
±¥¬ ÀÌØíѥѱȰÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíQ    ÕÑѽ¸ÄÅÕ½Ðì

Give that a try and see if it does what you want. If not let us know what its doing or not doing that you wanted.

--ss3

...

Share this post


Link to post
Share on other sites

What should be ($hwnd)?

If Not WinActive($hwnd) Then WinActivate($hwnd)
Look up WinGetHandle in the help file. Also as a suggestion if you decide to go with the window's handle I would replace your $title2 with $hwnd or whatever variable you assign the handle to. For example if you wanted to get the window handle of a notepad window that had the text "What's my handle" then you would use the following code:

$hwnd = WinGetHandle("classname=Notepad", "What's my handle")oÝ÷ Øù^jǮ׫²Ö§týËbZkzÛrì-¡«­¢+ZÚk¢
Úh§û®*mx"§z¶¥J讯zl§{Z¶×¦¦Ö­ºZ¶)àÊ«r^!©µ§b±§oj{Zë"Çq©÷öÛ^²ÛazÇ+hl¬ÊË^«­¢+Ù
±¥ÁAÕÐ ÅÕ½ÐìÅÕ½Ðì¤ìì±Ðìô±É¥¹½Õб¥Á½É((íYÉ¥±)M±À ÄÀÀÀÀ¤ìì±ÐìôÁÕͽÈÄÀͽ¹Ì(ÀÌØíU8ôÅÕ½Ðíaaaaaa`ÅÕ½Ðì(ÀÌØí4ôÅÕ½Ðíááá๽´ÅÕ½Ðì(ÀÌØíA%ÄôIÕ¸ ÅÕ½ÐíÑ¥Ù¹áÅÕ½Ðì¤(ÀÌØíѥѱÈôÅÕ½ÐíeeeeeedÅÕ½Ðììì±Ðìôɵ½ÙÑ¡ ¤¥å½Ô¹Ñ¡¥ÌÌÁÉнѡÙÉ¥±¥Ð¹ÌѼÀÌØíѥѱÈôÅÕ½Ðì¡eeeeed¤ÅÕ½Ðì()%9½Ð]¥¹Ñ¥Ù ÀÌØíѥѱȤQ¡¸]¥¹Ñ¥ÙÑ ÀÌØíѥѱȤ)]¥¹]¥ÑÑ¥Ù ÀÌØíѥѱȤ((ìììì¹½ÑÑ¡ÕÑä¡¥¹
½¹Ñɽ±MÑQáнȹ併µ¹¥¹¹¥¹Ý¥Ñ 
½¹Ñɽ°(ìììì¥ÌÑ¡ÐÑ¡Ý¥¹½Ü½Ì¹½Ð¡ÙѼѥÙ(ììììÑ¡ÑáÐÀÌØíU8Ý¥±°ÍÐѼѡѥٽȥ¹Ñ¥ÙÝ¥¹½ÜÁɽ٥ѡɥ̽¹±ä½¹(ììììÝ¥¹½ÜѡеѡÌÀÌØíѥѱȸ%Ñ¡ÉɵձѥÁ±Ý¥¹½ÝÌÝ¥Ñ Ñ¡ÍµÑ¥Ñ±(ììììÑ¡¸¥Ðµ­Ì͹ÍѼÕÍÑ¡Ý¥¹½Ü¡¹±Í¥¹Ñ¡¥ÌÝ¥±°±ÝåÌÕ¹¥ÅÕ()
½¹Ñɽ±MÑQáÐ ÀÌØíѥѱȰÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíQ1±¥ÐÌÅÕ½Ðì°ÀÌØíU8¤)
½¹Ñɽ±MÑQáÐ ÀÌØíѥѱȰÅÕ½Ðí!8µ!8ÅÕ½Ðì°ÅÕ½ÐíQ1±¥ÐÈÅÕ½Ðì°ÀÌØí4¤()M±À ÄÀÀÀ¤)%9½Ð]¥¹Ñ¥Ù ÀÌØíѥѱȤQ¡¸]¥¹Ñ¥ÙÑ ÀÌØíѥѱȤ)]¥¹]¥ÑÑ¥Ù ÀÌØíѥѱȤ)
±¥ÁAÕС¥±I ÌäíÑ¥ÙÑ¥½¸¹ÑáÐÌä줤((ÀÌØí¬ô
±¥ÁÐ ¤()M±À ÄÀÀÀ¤)
½¹Ñɽ±
±¥¬ ÀÌØíѥѱȰÀÌØí¬°ÅÕ½ÐíQ  ÕÑѽ¸ÌÅÕ½Ðì¤()M±À ÄÀÀÀ¤)
½¹Ñɽ±
±¥¬ ÀÌØíѥѱȰÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíQ    ÕÑѽ¸ÐÅÕ½Ðì¤)M±À ÄÀÀÀ¤)
½¹Ñɽ±
±¥¬ ÀÌØíѥѱȰÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíQ    ÕÑѽ¸ÄÅÕ½Ðì

Give that a try and see if it does what you want. If not let us know what its doing or not doing that you wanted.

--ss3

...

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Hi all,

I gived a try to the new script, it looks working... When It launched alone.

ClipPut("") ;;<= clearing out clipboard

;Variable
Sleep(10000);;<= pause for 10 seconds
$UN = "XXXXXXX"
$EM = "xx@xx.com"
$PID1 = Run("active.exe")
$title2 = "YYYYYYY";;<= removed the ( ) if you need this as part of the variable it needs to be $title2 = "(YYYYYY)"

If Not WinActive($title2) Then WinActivate($title2)
WinWaitActive($title2)

ControlSetText($title2, "", "TLabeledEdit3", $UN)
ControlSetText($title2, "HEN-HEN", "TLabeledEdit2", $EM)

Sleep(1000)
If Not WinActive($title2) Then WinActivate($title2)
WinWaitActive($title2)
ClipPut(FileRead('activation.txt'))

$bak = ClipGet()

Sleep(1000)
ControlClick($title2, $bak, "TButton3")

Sleep(1000)
ControlClick($title2, "", "TButton4")
Sleep(1000)
ControlClick($title2, "", "TButton1")

Then, I wrote a small scrip to launch multiple prog windows

If Our_Script_Test.exe is launched at the end

ProgLaunch

Run(@ProgramFilesDir  & "\SlySoft\AnyDVD\AnyDVD.exe")
Run(@ProgramFilesDir  & "\MSN Messenger\msnmsgr.exe")
Run(@ProgramFilesDir  & "\SlySoft\CloneCD\CloneCD.exe")
Run("Our_Script_Test.exe")
it works :)

but if it launched somewhere elsewhere as

Run(@ProgramFilesDir  & "\SlySoft\AnyDVD\AnyDVD.exe")
Run("Our_Script_Test.exe")
Run(@ProgramFilesDir  & "\MSN Messenger\msnmsgr.exe")
Run(@ProgramFilesDir  & "\SlySoft\CloneCD\CloneCD.exe")
it doesn't :P

UNTIL I manually activate the target window (Our_Script_Test.exe) by click anywhere on the target window the the script works the way i want it to.

Regards

coucou

Edited by coucou

Share this post


Link to post
Share on other sites

Hi all,

I gived a try to the new script, it looks working... When It launched alone.

Then, I wrote a small scrip to launch multiple prog windows

If Our_Script_Test.exe is launched at the end

ProgLaunch it works :)

but if it launched somewhere elsewhere it doesn't :(

Sorry this has been a challenge for you. I'm pretty sure I understand the problem being the use of $title2. As mentioned by MikeHunt114 and me the use of a window handle ($hwnd) can be better than a window title ($title2). Regardless of either method used, I think there's a more basic problem. That being the relationship of all the stuff floating around. Don't give up you'll get this working before you know it! We just need some more information from you.

I'll need you to correct any wrong assumptions and answer the following questions. Then we should be good as gold! I hope

1 -- The script I give you has been compiled and named "Our_Script_Test.exe"

2 -- You've created a seperate script you're calling "ProgLaunch" and "Our_Script_Test.exe" fails only when "ProgLaunch" has the following code:

Run(@ProgramFilesDir  & "\SlySoft\AnyDVD\AnyDVD.exe")
Run("Our_Script_Test.exe")
Run(@ProgramFilesDir  & "\MSN Messenger\msnmsgr.exe")
Run(@ProgramFilesDir  & "\SlySoft\CloneCD\CloneCD.exe")

3 -- Assuming the above is true, I need you to answer the following unknowns for me.

a) .. How does "active.exe" play into this? The purpose of having the variable $PID1 set to Run("active.exe") is what?

B) .. In your mind what program window has the title = "YYYYYYY" ?

c) .. You realize the ControlSetText and ControlClicks are sent to the window with the title of "YYYYYYY" regardless if this window is active or inactive, yes?

d) .. If you have an Opt("WinTitleMatchMode") line in the "Our_Script_Test.exe", what is the exact command you have? This could be the problem.

The WinTitleMatchMode is very important to understand -- read the help file and don't skip over the Window Titles & Text (Advanced) section. I personally like Opt("WinTitleMatchMode", 4) for the advanced feature support.

That said, its time to say good night.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I'll need you to correct any wrong assumptions and answer the following questions. Then we should be good as gold! I hope

First, sorry for the delay, i was out.

1 -- The script I give you has been compiled and named "Our_Script_Test.exe" YES

2 -- You've created a seperate script you're calling "ProgLaunch" and "Our_Script_Test.exe" fails only when "ProgLaunch" has the following code: YES

Run(@ProgramFilesDir  & "\SlySoft\AnyDVD\AnyDVD.exe")
Run("Our_Script_Test.exe")
Run(@ProgramFilesDir  & "\MSN Messenger\msnmsgr.exe")
Run(@ProgramFilesDir  & "\SlySoft\CloneCD\CloneCD.exe")

3 -- Assuming the above is true, I need you to answer the following unknowns for me.

a) .. How does "active.exe" play into this? The purpose of having the variable $PID1 set to Run("active.exe") is what? is the keymaker

b ) .. In your mind what program window has the title = "YYYYYYY" ? is the keymaker title

c) .. You realize the ControlSetText and ControlClicks are sent to the window with the title of "YYYYYYY" regardless if this window is active or inactive, yes? when is Active

d) .. If you have an Opt("WinTitleMatchMode") line in the "Our_Script_Test.exe", what is the exact command you have? This could be the problem. I haven't it

The WinTitleMatchMode is very important to understand -- read the help file and don't skip over the Window Titles & Text (Advanced) section. I personally like Opt("WinTitleMatchMode", 4) for the advanced feature support. I had tested Opt("WinTitleMatchMode", 4) then Opt("WinTitleMatchMode", 3) then without Opt("WinTitleMatchMode")... same problem

Finally the problem not solved yet. May be i have to use window handle ($hwnd)

Regarding yr question 2, the seperate script called "ProgLaunch" is to simulate the startup.

In fact, the script "Our_Script_Test.exe" is launched at the first boot after an unattended (WinXP and softwares) installation.

Regards

coucou

Edited by coucou

Share this post


Link to post
Share on other sites

First off Coucou let me say I love your approach to answer my questions! You my friend will eventually get this stuff in no time. And I think we'll have have your problem solved in a few minutes! Its a beautiful thing when people get on the same page, so much more can be achieved! There's just a few points you need cleared up, my friend!

a) .. How does "active.exe" play into this? The purpose of having the variable $PID1 set to Run("active.exe") is what? is the keymaker

b ) .. In your mind what program window has the title = "YYYYYYY" ? is the keymaker title

Change this part of your code

FROM:

;Variable
Sleep(10000)  ;;<= pause for 10 seconds
$UN = "XXXXXXX"
$EM = "xx@xx.com"
$PID1 = Run("active.exe")
$title2 = "YYYYYYY"  ;;<= removed the ( ) if you need this as part of the variable it needs to be $title2 = "(YYYYYY)"

If Not WinActive($title2) Then WinActivate($title2)
WinWaitActive($title2)oÝ÷ Ù3ºÚ"µÍÜ
    ][ÝÕÚ[^X]Ú[ÙI][ÝË
HÎÈ   ÏOH]]ÜÙ[ÝØÜY[ÝÚ[ÛYIËÝÈÕXXBÛY
L
HÎÉÏH]ÙHÜLÙXÛÛÂÌÍÕSH    ][ÝÖ  ][ÝÂÌÍÑSHH ][ÝÞÛÛI][ÝÂÌÍÔQH   ][ÝØXÝ]K^I][ÝÈÎÈÜÚ][ÝHØ[ÈÈHYÚXXIÌÌÎÂ[ ÌÍÔQ
BØÙÜÕØZ]
    ÌÍÔQ
BÚ[ÙH[ÝHÛÝÈH]HÙHÚ[ÝÈ[ÝHØ[ÈÛÛÛ[ÝHØ[ÙHZ]Ú[Ù]]J
HÜÚ[Ù][HÝ]BÎÈHØ[YHÞ[^^HÚ]Ý[[ÝIÌÎNÛÙYH]Z]ÎÈÛÜÈHÙ[[^[HÚHÚ[Ù][HÈ]ÎÈ[Ú[Ù]]HÈY[ÝH]HÈÜ[ÜHXÝ]K^H[[ÂÎÈÚ[ÙH^H[]HHØ[YHÛÜË]K]Ë^HÚ[]BÎÈ[]YHÚ[ÝÈ[Ë[Y[X   ÌÍÝ]L[   ÌÍÚÛBÎÈXXÈ[Ø[H[][ËÝÙY[ÝÛÙHÛÛÚÝ[ÌÍÝ]LHÚ[Ù]]J  ][ÝÖVVVVVVI][ÝÊHÎÈ    ÏOHÔ  ÌÍÚÛHÚ[Ù][J   ][ÝÖVVVVVVI][ÝÊBYÝÚ[XÝ]J ÌÍÝ]LH[Ú[XÝ]]J ÌÍÝ]LBÚ[ØZ]XÝ]J   ÌÍÝ]L

c) .. You realize the ControlSetText and ControlClicks are sent to the window with the title of "YYYYYYY" regardless if this window is active or inactive, yes? when is Active

No the window does NOT have to be active for ControlClicks to work. The window can be EITHER active or inactive :P

The WinTitleMatchMode is very important to understand -- read the help file and don't skip over the Window Titles & Text (Advanced) section. I personally like Opt("WinTitleMatchMode", 4) for the advanced feature support. I had tested Opt("WinTitleMatchMode", 4) then Opt("WinTitleMatchMode", 3) then without Opt("WinTitleMatchMode")... same problem

Opt("WinTitleMatchMode", 4) is the right one to use and the only one that will work with WinGetHandle or the advanced title stuff. The reason Opt("WinTitleMatchMode", 4) didn't work for you is the reasons stated above in the corrected code. This will work for you I'm pretty sure!

Its been my pleasure helping you with this. I never have a problem helping someone who tries to help themselves first and is willing to read the help file and listen to advice given in the forum! You're all right by me coucou! :) I'll look at the files you sent me later today, but this really should solve your problem.

Share this post


Link to post
Share on other sites

Hi ssubirias3,

Right now i test yr new script... sorry to disappoint you the problem is exactly the same as Here above :)

If Our_Script_Test.exe is launched at the end

ProgLaunchCODERun(@ProgramFilesDir  & "\SlySoft\AnyDVD\AnyDVD.exe")
Run(@ProgramFilesDir  & "\MSN Messenger\msnmsgr.exe")
Run(@ProgramFilesDir  & "\SlySoft\CloneCD\CloneCD.exe")
Run("Our_Script_Test.exe")it works

but if it launched somewhere elsewhere as

Run(@ProgramFilesDir  & "\SlySoft\AnyDVD\AnyDVD.exe")
Run("Our_Script_Test.exe")
Run(@ProgramFilesDir  & "\MSN Messenger\msnmsgr.exe")
Run(@ProgramFilesDir  & "\SlySoft\CloneCD\CloneCD.exe")
it doesn't

UNTIL I manually activate the target window (Our_Script_Test.exe) by click anywhere on the target window the the script works the way i want it to.

Regards

coucou

Share this post


Link to post
Share on other sites

Hi ssubirias3,

Right now i test yr new script... sorry to disappoint you the problem is exactly the same ...

Man this has been crazy! I created my own test scenario to rule out some things. And you know what??!! You are not crazy, I'm not crazy... I believe there's a bug (or undocumented feature) in the ControlSetText() command. If not a bug then the help file needs to have more information that explains WHY the window must be active. Maybe some of the MVPs or Moderators can speak on this point ----^

But not to worry coucou! I've got a workaround for you that WILL ABSOLUTELY WORK!!! I'm serious, if I could recreate your problem and fix the problem then I'm sure this is going to work for you. So in your last version of code I gave you with the correct $PID variable, this is what you want to change:

FROM

Opt("WinTextMatchMode", 4)  ;; <== Put at top of your script after your #include<...> 

;Variable
Sleep(10000)  ;;<= pause for 10 seconds
$UN = "XXXXXXX"
$EM = "xx@xx.com"
$PID = "active.exe"  ;;  For what you want this is the right variable!
Run($PID)
ProcessWait($PID)

$title2 = WinGetTitle("YYYYYYY")  ;; <== OR $hwnd = WinGetHandle("YYYYYYY") same difference.
If Not WinActive($title2) Then WinActivate($title2)
WinWaitActive($title2)

ControlSetText($title2, "", "TLabeledEdit3", $UN)
ControlSetText($title2, "HEN-HEN", "TLabeledEdit2", $EM)oÝ÷ Ù3ºÚ"µÍÜ
    ][ÝÕÚ[^X]Ú[ÙI][ÝË
HÎÈ   ÏOH]]ÜÙ[ÝØÜY[ÝÚ[ÛYIËÝÈÕXXBÌÍÕSH ][ÝÖ  ][ÝÂÌÍÑSHH ][ÝÞÛÛI][ÝÂÌÍÔQH   ][ÝØXÝ]K^I][ÝÈ[    ÌÍÔQ
BØÙÜÕØZ]
    ÌÍÔQ
BÌÍÝ]LHÚ[Ù][J  ][ÝÖVVVVVVI][ÝÊHÎÈ    ÏOHÔ  ÌÍÚÛHÚ[Ù][J   ][ÝÖVVVVVVI][ÝÊHØ[YHY[ÙKÎÈ[[ÝYHÚ[ØZ]ÝYÈÝH]ÛÛÛÛÛ[X[ÈÚÝ[Ù[ÂHÚ[ÝÈY]ÈXÝ]HÜÝÈÈÚHÛÛÛÙ]^ÈÚÙ[[[ÂÛÛÛÙ[
    ÌÍÝ]L    ][ÝÉ][ÝË    ][ÝÕX[YY]É][ÝË ÌÍÕSBÛÛÛÙ[
    ÌÍÝ]L    ][ÝÒSRS][ÝË ][ÝÕX[YY]][ÝË   ÌÍÑSJ

Note you can stay with WinGetHandle or change it back to WinGetTitle doesn't matter. Also know this has been successfully tested not using your exact applications but Windows apps with AU3 v3.2.4.9 on a WinXP computer. That info is only for someone who says, "well your using an old version of AU3 that's why ControlSetText doesn't work." And no I don't want to use the beta, thankyouverymuch! :)

Thanks for the puzzle, I'm just surprised none of the vets said anything about this on this thread. Go Figure, or did I not read that post??

Peace coucou!

Share this post


Link to post
Share on other sites

They are errors on yr both scripts

$title2 = WinGetTitle("YYYYYYY")  ;; <== Can't works below

If Not WinActive($title2) Then WinActivate($title2)
;; it's equal to
If Not WinActive(WinGetTitle("YYYYYYY")) Then WinActivate(WinGetTitle("YYYYYYY"))

WinWaitActive($title2)
;; equal to
WinWaitActive(WinGetTitle("YYYYYYY"))

ControlSetText($title2, "", "TLabeledEdit3", $UN)
;; equal to
ControlSetText(WinGetTitle("YYYYYYY"), "", "TLabeledEdit3", $UN)

;;and so on...
;;same for 
$title2 = WinGetHandle("YYYYYYY")oÝ÷ Ø   òÁ¬¢rëyËm±Êâ¦×«®ìêÞmée£^²×¶¦²Ø¥z-Âä²(Z½ëhiËb½«^¶°whÀZ+ëZn­Ö®¶­sbb33c·FFÆS"ÒgV÷CµgV÷C° ¤bæ÷Bvä7FfRb33c·FFÆS"FVâvä7FfFRb33c·FFÆS"¥våvD7FfRb33c·FFÆS" ¤6öçG&öÅ6WEFWBb33c·FFÆS"ÂgV÷C²gV÷C²ÂgV÷CµDÆ&VÆVDVFC2gV÷C²Âb33cµTâ £³¶æBf÷"FR6V6öæB67&@¢b33c·FFÆS"ÒgV÷CµgV÷C° ¥vävWDæFÆRgV÷CµgV÷C²¤6öçG&öÅ6WEFWBb33c·FFÆS"ÂgV÷C²gV÷C²ÂgV÷CµDÆ&VÆVDVFC2gV÷C²Âb33cµTâ

Regards

coucou

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