Sign in to follow this  
Followers 0
T0m4s

Scripts not working on Windows 7 ?

30 posts in this topic

Hi Forum,

i want to automate a setup. Normally it should work without problems but i struggled at the point when i want to start the setup.

When i use

Run("setup.exe");

it will not work. I have to use

Run(@ComSpec & " /c " & "setup.exe")

instead.

Then the Nighmare begins. I want to use

ControlClick()

to simulate the clicks on the Buttons that will continue the Setup Process.

I used Autoit Window Info Tool to examine the correct controll IDs, but with no success, no clicks are processed.

Then i tried to send Keys. I checked the Keys i have to send and try to send them.

WinWaitActive(" Installation", "")
Send("!i")
or
Send("{ENTER}")

But it seems that no keystrokes are send to the setup programm.

Then i read about the AU3Recorder integrated in Scite editor. But this recorder does not record correct.

Output from Au3recorder:

#region ---Au3Recorder generated code Start (v3.3.7.0)  ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc

AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---

#endregion --- Au3Recorder generated code End ---

What happens here? Please help

My System:

Win 7 32 Bit Pro SP1

Autoit 3.3.8.1

Share this post


Link to post
Share on other sites



Which program do you try to setup? Are you sure there is no silent installation switch available?

Can you describe your problem in detail? "What happens here?" is a bit vague.

Your code misses error checking. After each function call you should check for success or error.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It is a setup of a USB driver for german health care terminal, i am sure you will not know it.

"What happens here" is the question regarding the output form AU3recorder. Why do the recorder not record?

also this piece of code :

#region ---Au3Recorder generated code Start (v3.3.7.0) ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc

AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---

#endregion --- Au3Recorder generated code End ---

is the output from AU3recorder. If you miss error checking here, then i can say, that i miss the recorded things also.

If you miss error checking in the other code snipets, then pls have in mind that they are only examples to demonstrate what is not working for me.

I think the problem i have is more general than only missing error checking :)

Are there any issues with WIN 7 and Autoit or should it wourk without any problems?

Edited by T0m4s

Share this post


Link to post
Share on other sites

Which version of AutoIt do you run? Is it 3.3.7.0 as the recorded code shows? 3.3.8.1 is the latest production version.

Au3recorder can only handle Windows controls. If your setup is a java application or uses some non standard windows/controls then this might be the cause of your problems.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Which version of AutoIt do you run? Is it 3.3.7.0 as the recorded code shows? 3.3.8.1 is the latest production version.

Please read the first post. It includes all informations.

Why AU3recorder show version 3.3.7.0 ? Maybe its the version of AU3recorder.

Au3recorder can only handle Windows controls. If your setup is a java application or uses some non standard windows/controls then this might be the cause of your problems.

Please read the first post.

If the setup would be a java application then it would not be an exe file, is this correct?

And as i wrote i use to start the setup :

Run(@ComSpec & " /c " & "setup.exe")

I also wrote in the first Post, that all the Controls are recognized by "Autoit Window Info Tool" so i assume that this is no Java programm.

I have only 2 Posts left now.

Please read the first post!

Edited by T0m4s

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

T0m4s,

You should now be able to post normally as I have lifted the "New Member" restriction from your account. Please let me know if you have any problems. :)

M23

Edited by Melba23
Typo

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

OK, I got it: Read the first post!

Create a short reproducer script that only starts the exe and that tries to click on the first control.

This will be the source we start to play with.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks!

This is my script:

#cs ---------------------------------------------------------
Automatic installation for
CARD STAR /medic2 und CARD STAR /memo3 USB driver
#ce ----------------------------------------------------------

; start programm
Local $result = Run(@ComSpec & " /c " & "setup_USB251.exe")
Local $kTitle = " Installation"

if $result > 0 Then
WinWaitActive(" Installation", "")

$aPos = ControlGetPos($kTitle, "", "[ID:1]")
; Do some errorchecking
If IsArray($aPos) Then
; Now choose one of these and comment out the other
ConsoleWrite($aPos[0] & " - " & $aPos[1] & @CRLF)
$res = ControlClick($kTitle, "", "[ID:1]")
ConsoleWrite("Result of ControlClick: " & $res &@CRLF)
Sleep(5000)
Else
; And then the matching one of these
ConsoleWrite("Error" & @CRLF)
EndIf
Else
MsgBox(0, "Error", "could not Run setup. error = " & @error )
EndIf

Output from SciTe console:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:tempautoItScriptstest1.au3" /UserParams
+>10:49:33 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0407 Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X86)
>Running AU3Check (1.54.22.0) from:C:Program FilesAutoIt3
+>10:49:33 AU3Check ended.rc:0
>Running:(3.3.8.1):C:Program FilesAutoIt3autoit3.exe "C:tempautoItScriptstest1.au3"
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
324 - 327
Result of ControlClick: 1
+>10:49:42 AutoIT3.exe ended.rc:0
>Exit code: 0 Time: 9.818

AutoIt Window Info Tool output:

Posted Image

Uploaded with ImageShack.us

Edited by T0m4s

Share this post


Link to post
Share on other sites

Doesn't look bad.

The expected action is started when the script clicks the button?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Doesn't look bad.

The expected action is started when the script clicks the button?

Nope, and exactly this is the problem. No actions are startet if i use ControlClick() or Send().

It seems that i cant send to this window, but the return of the functions is always ok.

Share this post


Link to post
Share on other sites

I think the problem is related to the way you pass the ControlID. Try:

$res = ControlClick($kTitle, "", 1)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I think the problem is related to the way you pass the ControlID. Try:

$res = ControlClick($kTitle, "", 1)

Doesnt work, i tried several different methods, but no one work.

Share this post


Link to post
Share on other sites

Oops. I just noticed that "[iD:1]" and "1" is the same.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Could you please insert a "Sleep(3000)" before the Controlclick?

Maybe the Control isn't active as soon as the Window is displayed?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

does not help.

$res = ControlClick($kTitle, "", "[ID:1]")
ConsoleWrite("Result of ControlClick: " & $res &@CRLF)
Sleep(5000)
$res = Send("!w")
ConsoleWrite("Result of Send: " & $res &@CRLF)

will result in

324 - 327
Result of ControlClick: 1
Result of Send: 1

So it seems to be that everything is ok, but in the setup program nothing happens.

If nothings helps, i will try it on Windows XP

Edited by T0m4s

Share this post


Link to post
Share on other sites

How many windows with title "Installation" are open when you run the script? Can you please run this code when the installation script is active?

#include <Array.au3>
Global $aWindows = WinList()
_ArrayDisplay($aWindows)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I noticed that the window title set in

Local $kTitle = " Installation"
starts with a space. Are you sure the window title starts with a space? Can you remove the space and try again?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Another idea:

To make sure AutoIt grabs the correct window change the ControlClick statement to:

$res = [url="http://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm"]ControlClick[/url]($kTitle, "CSm2 USB driver", "[ID:1]")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

How many windows with title "Installation" are open when you run the script? Can you please run this code when the installation script is active?

#include <Array.au3>
Global $aWindows = WinList()
_ArrayDisplay($aWindows)

It shows only 1 window running with taht name.

I noticed that the window title set in

Local $kTitle = " Installation"
starts with a space. Are you sure the window title starts with a space? Can you remove the space and try again?

I was wondering also, but the space is correct.

[47]0x0005063C
[48] Installation0x000F076E
[49]C:Windowssystem32cmd.exe0x001806D8
[50]AutoIt v30x001A077E
[51]AutoIt v30x00280768
[52]AutoIt v30x00130746

Another idea:

To make sure AutoIt grabs the correct window change the ControlClick statement to:

$res = [url="http://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm"]ControlClick[/url]($kTitle, "CSm2 USB driver", "[ID:1]")

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