We have a backup app for backing up our business App that needs to be run manually. I'm trying to automate this process. I've ben using AutoIt for a while and for different purposes but this is new kind of problem for me.
App is not accepting Send, ControlSend, ControlClick or MouseClick. Clicking SPC on keyboard and left clicking Apps Start button with the mouse will start the backup process but sending SPC or ControlClicking the Control will not.
here is the App summary:
# Window
Title: 4D Fresh V.15.10.22
Class: ClaWin0400000H_1
Position: 356, 139
Size: 727, 582
Style:0x16CB0000
ExStyle: 0x00000100
Handle: 0x00180E52
#Control
Class:
Instance:
ClassnameNN:
Name:
Advanced (Class):
ID:
Text:
Position:
Size:
ControlClick Coords:
Style:
ExStyle:
Handle:
# Mouse
Position: 626, 155
Cursor ID: 0
Color: 0xFFFFFF
# StatusBar
# ToolsBar
# Visible Text
4D Fresh - Program za osvježavanje informacijskog sustava 4D Wand sa Interneta.
POZOR:
Nositelj autorskih i imovinskih prava programskog rješenja 4D Wand je tvrtka 4th Dimension d.o.o. te pravo korištenja ovog programa posjeduju isključivo slijedeći korisnici:
- korisnici koji pripadaju jamstvenom periodu (12 mjeseci)
- korisnici koji su potpisali ugovor o paušalnom održavanju i redovito podmiruju svoje obveze
Korisnici koji ne pripadaju jamstvenom periodu ili nisu potpisali ugovor o paušalnom održavanju nemaju pravo korištenja ovoga programa. Svako nelegalno korištenje ili distribucija ovog programa, povlači za sobom kaznenu i materijalnu
odgovornost prema pozitivnim propisima Republike Hrvatske.
Startno vrijeme:
Proteklo vrijeme:
Predviđeno trajanje:
Server:
0:00:00
0:00:00
0:00:00
4D Server
&Start
S&etiranje
Upu&te
I&zlaz
Zadnje uspješno snimanje 3.02.2016 u 12:01:03
Zadnje neuspješno snimanje 3.11.2015 u 7:21:05
Prije snimanja nove verzije napravite rezervne kopije podataka!!!
Pritisnite Start za početak obrade!
# Hidden Text
And here is my code:
#include <Debug.au3>
#include <MsgBoxConstants.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
_DebugSetup("Debugw", True)
;_DebugSetup("Debugw", False, 4, "wFlash.txt", True)
WinMove("Debugw", "", 7, 100, 427, 319)
_DebugOut("Opening Fresh")
$hFreshPID = ShellExecute ("W:\4d\Wand\Fresh4D\Fresh4D.exe","", "W:\4d\Wand\Fresh4D")
If $hFreshPID == 0 Then
_DebugOut("!!! Error starting Fresh !!!")
Exit
EndIf
_DebugOut("hFreshPID: " & $hFreshPID)
_DebugOut("Waiting for 4D Fresh window ...")
WinWait("4D Fresh")
$hWnd = WinGetHandle("4D Fresh", "")
If $hWnd == 0 Or $hWnd == 0x0000000000000000 Then
_DebugOut("!!! Did not get Fresh handle !!!")
Exit
EndIf
_DebugOut("hWnd: " & $hWnd)
WinWaitActive($hWnd, "Pritisnite Start za početak obrade!")
If WinActive($hWnd) Then ; Check if Fresh is currently active.
_DebugOut("Fresh is active.")
$hWndCtrl = ControlGetHandle($hWnd, "", 16408) ; Start button ID=16408
If $hWndCtrl == 0 Then
_DebugOut("Control not found. Exiting.")
Exit
EndIf
ControlFocus($hWnd, "", $hWndCtrl)
;Send("{SPACE}")
;Send("{ASC 0061}")
;Send("{ASC 115}")
;Send("{s}")
;$ctrlClc = ControlSend ($hWnd, "", "", "{s}")
;$ctrlClc = ControlSend("[CLASS:ClaWin0400000H_1]", "", 16408, "{SPACE}")
;$ctrlClc = ControlClick ($hWnd, "", $hWndCtrl)
;$ctrlClc = ControlClick ($hWnd, "", "&Start")
$ctrlClc = ControlClick ($hWnd, "", $hWndCtrl, "", "", 38, 41)
If $ctrlClc == 0 Then
_DebugOut("Control not found. Exiting")
Exit
EndIf
Else
_DebugOut("!!!Fresh is not active.!!!")
Exit
EndIf
Exit
You can see that i have lot's of testing lines but just ignore them.
I've tested if controls exist and and they do. I've tried to change focus from one Control to another (There is Start, Settings, Help and Exit button) and that's not working.
i do not know what else to try.
here is the Start control info:
Control
Class: ClaButton_0400000H
Instance: 1
ClassnameNN: ClaButton_0400000H1
Name:
Advanced (Class): [CLASS:ClaButton_0400000H; INSTANCE:1]
ID: 16408
Text: &Start
Position: 7, 458
Size: 81, 62
ControlClick Coords: 56, 31
Style: 0x50034000
ExStyle: 0x00000000
Handle: 0x00660B4E
I've solved with this sentence by reddit user StarterFluid :
Try a #RequireAdmin at the top of your script to make your script run as administrator, and recompile.
( https://www.reddit.com/r/autoit/comments/2l6d6f/controlclick_not_clicking/ )
User contributions licensed under CC BY-SA 3.0