Jump to content

Can't activate a window dialogue


coucou
 Share

Recommended Posts

Hi,

I am attempting to automate Diskeeper installation and running into difficulty during the Activation.

I've noticed that the child window "Enter License key" stay always grey (see image here bellow) although my message routine send that it's activated. Consequently, I can't write the serial number into Diskeeper "Enter License key" dialogue.

$title = "Diskeeper 2010 Pro Premier"
$title1 = "Enter License key"

;write serial number into Diskeeper 2010 dialogue 
$ser1 = "12345"
$ser2 = "67890"
$ser3 = "abcde"
$ser4 = "fghij"
$ser5 = "klmno"
$ser6 = "pqrs"


$pid2 = Run(@ProgramFilesDir & "\Diskeeper Corporation\Diskeeper\AppLauncher.exe")
Sleep(1000)
        If WinWait("Diskeeper Notice", "", 10) Then
        ControlClick("Diskeeper Notice", "", "Button1")
        EndIf

Sleep(500)
        If WinExists($title, "Analyze and Defragment Now") Then
            WinActivate($title, "Analyze and Defragment Now")
            Send("!a");Action
            ;Send("{DOWN 9}")
            Send("{ENTER}");Enter License key
        EndIf
    
WinActivate("[CLASS:Edit; INSTANCE:1]", "")
;WinActivate($title1, "")

;The following was for testing that the "Enter License key" child window is activated
;$title3 = WinGetTitle("[CLASS:Edit; INSTANCE:1]", "")
;MsgBox(0, "Full title read was:", $title3)

WinWaitActive("[CLASS:Edit; INSTANCE:1]", "", 5)
Sleep(1500)
ControlSend("[CLASS:Edit; INSTANCE:1]", "", "Edit1", $ser1)
ControlSend("[CLASS:Edit; INSTANCE:1]", "", "Edit2", $ser2)
ControlSend("[CLASS:Edit; INSTANCE:1]", "", "Edit3", $ser3)
ControlSend("[CLASS:Edit; INSTANCE:1]", "", "Edit4", $ser4)
ControlSend("[CLASS:Edit; INSTANCE:1]", "", "Edit5", $ser5)
ControlSend("[CLASS:Edit; INSTANCE:1]", "", "Edit6", $ser6)
Sleep(500)
ControlClick($title1, "", "Button1")

I'll appreciate any help

coucou

post-5679-12657396087105_thumb.jpg

Link to comment
Share on other sites

You are putting the Class/Instance of the control where the window specification belongs. Try "[TITLE:Enter License Key]" for the window title.

:D

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

Yeah... I forgot to tell that I've tested both "[TITLE:Enter License Key]" and Class/Instance without success.

The child window "Enter License key" stay always grey (not selected).

Regards

Edited by coucou
Link to comment
Share on other sites

Some small changes may help to make it work a little better. Some use of Adlib functionality may help to improve the script some but i will not go into that as i am not fully up to date with Adlib changes in the latest AutoIt version yet.

The picture does not show grey unless you are referring to the OK button which may highlight to normal when the whole serial has been sent into the edit controls.

$title = "Diskeeper 2010 Pro Premier"
$title1 = "Enter License key"

;write serial number into Diskeeper 2010 dialogue 
$ser1 = "12345"
$ser2 = "67890"
$ser3 = "abcde"
$ser4 = "fghij"
$ser5 = "klmno"
$ser6 = "pqrs"


$pid2 = Run('"' & @ProgramFilesDir & '\Diskeeper Corporation\Diskeeper\AppLauncher.exe"')
Sleep(1000)
If WinWait("Diskeeper Notice", "", 10) Then
    ControlClick("Diskeeper Notice", "", "Button1")
EndIf

Sleep(500)
If WinExists($title, "Analyze and Defragment Now") Then
    WinActivate($title, "Analyze and Defragment Now")
    Send("!a");Action
    ;Send("{DOWN 9}")
    Send("{ENTER}");Enter License key
EndIf
    
;~ WinActivate("[CLASS:Edit; INSTANCE:1]", "")
;WinActivate($title1, "")

;The following was for testing that the "Enter License key" child window is activated
;$title3 = WinGetTitle("[CLASS:Edit; INSTANCE:1]", "")
;MsgBox(0, "Full title read was:", $title3)

WinWait($title1)
Sleep(1500)
ControlSend($title1, '', 'Edit1', $ser1)
ControlSend($title1, '', 'Edit2', $ser2)
ControlSend($title1, '', 'Edit3', $ser3)
ControlSend($title1, '', 'Edit4', $ser4)
ControlSend($title1, '', 'Edit5', $ser5)
ControlSend($title1, '', 'Edit6', $ser6)
Sleep(500)
ControlClick($title1, "", "Button1")
Link to comment
Share on other sites

TNX MHZ Posted Image

The child window "Enter License key" is selected this time, but the script stop at WinWait($title1)

$title1 = "Enter License key"
...
...
WinWait($title1)
yet it is the window's title Posted Image

To solve that problem I modified

from $title1 = "Enter License key" to $title1 = "[CLASS:#32770; INSTANCE:1]"

I can't exply why but it works. Can you?

$title = "Diskeeper 2010 Pro Premier"
$title1 =  "[CLASS:#32770; INSTANCE:1]"

;write serial number into Diskeeper 2010 dialogue 
$ser1 = "12345"
$ser2 = "67890"
$ser3 = "abcde"
$ser4 = "fghij"
$ser5 = "klmno"
$ser6 = "pqrs"


$pid2 = Run('"' & @ProgramFilesDir & '\Diskeeper Corporation\Diskeeper\AppLauncher.exe"')
Sleep(1000)
If WinWait("Diskeeper Notice", "", 10) Then
    ControlClick("Diskeeper Notice", "", "Button1")
EndIf

Sleep(500)
If WinExists($title, "Analyze and Defragment Now") Then
    WinActivate($title, "Analyze and Defragment Now")
    Send("!a");Action
    ;Send("{DOWN 9}")
    Send("{ENTER}");Enter License key
EndIf
    
;~ WinActivate("[CLASS:Edit; INSTANCE:1]", "")
;WinActivate($title1, "")

;The following was for testing that the "Enter License key" child window is activated
;$title3 = WinGetTitle("[CLASS:Edit; INSTANCE:1]", "")
;MsgBox(0, "Full title read was:", $title3)

WinWait($title1)
Sleep(1500)
ControlSend($title1, '', 'Edit1', $ser1)
ControlSend($title1, '', 'Edit2', $ser2)
ControlSend($title1, '', 'Edit3', $ser3)
ControlSend($title1, '', 'Edit4', $ser4)
ControlSend($title1, '', 'Edit5', $ser5)
ControlSend($title1, '', 'Edit6', $ser6)
Sleep(500)
ControlClick($title1, "", "Button1")

Regards

coucou

Link to comment
Share on other sites

To solve that problem I modified

from $title1 = "Enter License key" to $title1 = "[CLASS:#32770; INSTANCE:1]"

I can't exply why but it works. Can you?

Yes, upon another review

The original code has a small "k" for "key".

$title1 = "Enter License key"

but, your picture has a capital "K" for "Key".

The title parameter is case sensitive so the incorrect case used caused the WinWait() to not recognize the window.

Link to comment
Share on other sites

Well Done MHZ Posted Image

And to think that I spennt 2 days Posted Image

BTW to test the script, I've to install and Uninstall Doskeeper. Then Sometimes I've the "Enter License Key..." command at the top and sometimes it's 9 steps down 'see image bellow).

I couldn't find any direct shrtcut for that command.

Sleep(500)
If WinExists($title, "Analyze and Defragment Now") Then
    WinActivate($title, "Analyze and Defragment Now")
    Send("!a");Action
    ;Send("{DOWN 9}")
    Send("{ENTER}");Enter License key
EndIf

Have any idea how to autoamte that?

Regards

post-5679-12658145926151_thumb.jpg

Link to comment
Share on other sites

Something like this may do. I do not see accelerators keys underlined in your picture so I was unable to add "&" to the menu item string as the string "Action" could be "A&ction" or "&Action"...

$title = "Diskeeper 2010 Pro Premier"

; scan for window
AdlibRegister('_Adlib')

; window may appear here

; some other code here to do something perhaps

; stop scan for window when not needed anymore
AdlibUnRegister('_Adlib')

Func _Adlib()
    If WinExists($title, 'Analyze and Defragment Now') Then
        WinMenuSelectItem($title, 'Analyze and Defragment Now', 'Action', 'Enter Licence Key ...')
        AdlibUnRegister('_Adlib')
    EndIf
EndFunc

If the "Diskeeper Notice" window is the flag for need of registering, then you may want to wrap the code to that condition else you may rerun the script on an already registered program. i am not in a good position to inform on the behavior of Diskeeper with my limited knowledge of it.

Link to comment
Share on other sites

That tries to register a function called "_Adlib", which is there in MHz's post. Did you create that function in your script or point it to another existing function?

:D

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

NOt for this script. Anyway I didn't use that function the last 3 days.

I've some scripts using this function as follow

;Check for pop-up

AdlibEnable('_Adlib', 1000)

AdlibRegister('_Adlib')

is the latest AutoIt3 version of

AdlibEnable('_Adlib')

with some small differences.

Same with

AdlibUnRegister('_Adlib')

is the latest AutoIt3 version of

AdlibDisable()

with some small differences.

Use what suits your version of AutoIt3.

Edit:

Removed parameter from AdlibDisable() as is invalid.

Edited by MHz
Link to comment
Share on other sites

I had 3.3.0.0 installed.

I installed the latest 3.3.4.0, tested the script: No error, but nothing hapens. It stay at the "Analyze and Defragment Now" window, NO "Action/Enter Licence Key ..." and the script continue runing and stop at

WinWait($title1)
Edited by coucou
Link to comment
Share on other sites

Hi Michael,

I've tested with 3.3.4.0 with and without

AdlibRegister('_Adlib')
;----
AdlibUnRegister('_Adlib')
as well as with and wihout adding accelerators keys "&" to the menu item string "Action" " or "&Action" without success.

Diskeeper stay (freeze) at the Main window "Analyze and Defragment Now" and submenu [Action] is NOT selected.

Finally i tested a combination of both Send("!a") and WinMenuSelectItem

Func _Adlib()
    If WinExists($title, 'Analyze and Defragment Now') Then
        Send("!a");Action
        WinMenuSelectItem($title, 'Analyze and Defragment Now', 'Action', 'Enter Licence Key ...')
        AdlibUnRegister('_Adlib')
    EndIf
EndFunc
Diskeeper still stay (freeze) at the Main window "Analyze and Defragment Now" but the submenu [Action] is selected. At that time I noticed the existence of accelerators keys for the submenu like [Enter Licence Key ...].

In other words by pressing [ALT]+A then depressing it, I couldn't see the submenus accelerators keys. Moreover, by REpressing the [ALT] key I went back to the Main window "Analyze and Defragment Now". The solution is to stay pressing the [ALT] key. Therefore everything works as follow.

Func _Adlib()
    If WinExists($title, 'Analyze and Defragment Now') Then
        Send("!ak");Action+Enter Licence Key 
        AdlibUnRegister('_Adlib')
    EndIf
EndFunc

So, everything soung good Posted ImagePosted ImagePosted Image

I'm still cutious to know why WinMenuSelectItem command doesn't works.

TNX again Michael

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