Jump to content

Recommended Posts

Posted (edited)

I can't figure out why I can't get the line numbers to show.

I have a function that is called with:

_ShowStep("Checking for Version..." & $Version)

The script does not stop when it reaches the above line.

This is the full script:

;#include <dbug.au3>
;AutoIt_Debugger_Command:Disable_Debug
Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 1) ;0=relative, 1=absolute(default), 2=client
Opt("PixelCoordMode", 1) ;0=relative, 1=absolute(default), 2=client
#RequireAdmin
#include <AutoItConstants.au3>
#include-once
#include "StringSize.au3"
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

;AutoIt_Debugger_Command:Enable_Debug
If Not FileExists('C:\Dnload') Then
    DirCreate('C:\Dnload')
EndIf
If Not FileExists('C:\Dnload\Macrium') Then
    DirCreate('C:\Dnload\Macrium')
EndIf
Local $Version = "Paid"
Global $LineLabel

If $Version = "Paid" Then
    Local $Reflectdl = "Reflectdlfull.exe"
Else
    Local $Reflectdl = "ReflectDLHF.exe"
EndIf
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
_ShowStep("Checking for Version..." & $Version)
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
; Why aren't I getting this _ShowStep to work?
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


If Not FileExists("C:\Dnload\Macrium\" & $Reflectdl) Then
    FileCopy(@ScriptDir & "\" & $Reflectdl, "C:\Dnload\Macrium\" & $Reflectdl)
EndIf
;MsgBox($MB_SYSTEMMODAL, "", "From folder = " & @ScriptDir & "\" & $Reflectdl)


If FileExists("C:\Dnload\Macrium\" & $Reflectdl) Then
    Run("C:\Dnload\Macrium\" & $Reflectdl)
ElseIf FileExists("D:\Dnload\Macrium\" & $Reflectdl) Then
    Run("D:\Dnload\Macrium\" & $Reflectdl)
Else
    MsgBox(4096, "Error:", "Error: Unable to find " & $Reflectdl)
    Exit
EndIf
Sleep(100)
If $Version = "Paid" Then
    WinWait("Macrium Reflect Download Agent", " Download Location")
    If Not WinActive("Macrium Reflect Download Agent", " Download Location") Then WinActivate("Macrium Reflect Download Agent", " Download Location")
    WinWaitActive("Macrium Reflect Download Agent", " Download Location")
    ControlClick("Macrium Reflect Download Agent", "", "Button3")     ;click Enter License Key button
    ControlClick("Macrium Reflect Download Agent", "", "Edit1")     ;click Enter License
    Send("Insert License Here")                        ;My License
    Sleep(100)
EndIf
WinWait("Macrium Reflect Download Agent", " Download Location")
If Not WinActive("Macrium Reflect Download Agent", " Download Location") Then WinActivate("Macrium Reflect Download Agent", " Download Location")
WinWaitActive("Macrium Reflect Download Agent", " Download Location")
ControlClick("Macrium Reflect Download Agent", "", "Edit2")     ;click Download button
Send("{CTRLDOWN}a{CTRLUP}C:\Dnload\Macrium\")
Sleep(100)
WinWait("Macrium Reflect Download Agent", " Select Installation")
If Not WinActive("Macrium Reflect Download Agent", " Select Installation") Then WinActivate("Macrium Reflect Download Agent", " Select Installation")
WinWaitActive("Macrium Reflect Download Agent", " Select Installation")
ControlClick("Macrium Reflect Download Agent", "", "Button10")     ;click Download button
Sleep(100)
WinWait("Macrium Reflect Download Agent", "")
;WinWaitActive("Macrium Reflect Download Agent", "&Yes")
If WinExists("Macrium Reflect Download Agent") Then     ;Macrium Reflect Download Agent File Exists
    ControlClick("Macrium Reflect Download Agent", "&Yes", "Button1")     ;click Yes button
EndIf
;~ Script Compiled as 32-Bit to target both x86/x64 OS
;#NoTrayIcon
#RequireAdmin
;~ Select the correct Msi based upon the OS Architecture
;Global $s7ZipMsi = @OSArch = "x64" ? @ScriptDir & "\7z1805-x64.msi" : @ScriptDir & "\7z1805.msi"

If @OSArch = "x64" Then
;~ Install 64-bit version for 64-bit OS Versions
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1)
EndIf
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
_ShowStep("Checking for Macrium Reflect Installer...")
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
;        RunWait("MsiExec.exe /i " & $s7ZipMsi & " /QN RESTART=ReallySuppress")
WinWait("Macrium Reflect Installer", "Click 'Next' to continue")
If Not WinActive("Macrium Reflect Installer", "Click 'Next' to continue") Then WinActivate("Macrium Reflect Installer", "")
WinWaitActive("Macrium Reflect Installer", "Click 'Next' to continue")
Sleep(5000)
ControlClick("Macrium Reflect Installer", "Click 'Next' to continue", "&Next")

GetHandle()

ControlCommand("Macrium Reflect Installer", "Click 'Next' to extract the setup files and begin", "Button2", "Check", "")
If @OSArch = "x64" Then
;~ Install 64-bit version for 64-bit OS Versions
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0)
EndIf
WinWait("Macrium Reflect", "Welcome to the Macri")
If Not WinActive("Macrium Reflect", "Welcome to the Macri") Then WinActivate("Macrium Reflect", "Welcome to the Macri")
WinWaitActive("Macrium Reflect", "Welcome to the Macri")
Send("{ENTER}")
WinWait("Macrium Reflect", "I &accept the terms ")
If Not WinActive("Macrium Reflect", "I &accept the terms ") Then WinActivate("Macrium Reflect", "I &accept the terms ")
WinWaitActive("Macrium Reflect", "I &accept the terms ")
Send("{UP}{ENTER}")
WinWait("Macrium Reflect", "Please enter your li")
If Not WinActive("Macrium Reflect", "Please enter your li") Then WinActivate("Macrium Reflect", "Please enter your li")
WinWaitActive("Macrium Reflect", "Please enter your li")
ControlClick("Macrium Reflect", "", "Button5")     ;click Home button to Activate
ControlClick("Macrium Reflect", "", "&Next >")
WinWait("Macrium Reflect", "")
If Not WinActive("Macrium Reflect", "") Then WinActivate("Macrium Reflect", "")
WinWaitActive("Macrium Reflect", "")
Send("{SPACE}{ENTER}")
If $Version = "Paid" Then
    ;MsgBox(0, @ScriptName, "Line " & @ScriptLineNumber & @CRLF & "---" & " (" & @ScriptLineNumber & ") " & "---")
    WinWait("Macrium Reflect", "License key")
    If Not WinActive("Macrium Reflect", "License key") Then WinActivate("Macrium Reflect", "License key")
    WinWaitActive("Macrium Reflect", "License key")
    ControlClick("Macrium Reflect", "License key", "Button7")     ;click Next button to Select
    WinWait("Macrium Reflect", "License information")
    If Not WinActive("Macrium Reflect", "License information") Then WinActivate("Macrium Reflect", "License information")
    WinWaitActive("Macrium Reflect", "License information")
    ControlClick("Macrium Reflect", "License information", "Button1")     ;click Next button to Select
    WinWait("Macrium Reflect", "Custom Setup")
    If Not WinActive("Macrium Reflect", "Custom Setup") Then WinActivate("Macrium Reflect", "Custom Setup")
    WinWaitActive("Macrium Reflect", "Custom Setup")
    ControlClick("Macrium Reflect", "Custom Setup", "Button6")     ;click Next button to Select
EndIf
WinWait("Macrium Reflect", "Install CBT (Not ava")
If Not WinActive("Macrium Reflect", "Install CBT (Not ava") Then WinActivate("Macrium Reflect", "Install CBT (Not ava")
WinWaitActive("Macrium Reflect", "Install CBT (Not ava")
Send("{ENTER}")
If $Version = "Paid" Then
    WinWait("Macrium Reflect", "Ready to Install")
    If Not WinActive("Macrium Reflect", "Ready to Install") Then WinActivate("Macrium Reflect", "Ready to Install")
    WinWaitActive("Macrium Reflect", "Ready to Install")
    ControlClick("Macrium Reflect", "Ready to Install", "Button1")     ;click Next button to Select
EndIf

WinWait("Macrium Reflect", "The Setup Wizard is ")
If Not WinActive("Macrium Reflect", "The Setup Wizard is ") Then WinActivate("Macrium Reflect", "The Setup Wizard is ")
WinWaitActive("Macrium Reflect", "The Setup Wizard is ")
Send("{ENTER}")
WinWait("Macrium Reflect", "Launch Macrium Refle")
If Not WinActive("Macrium Reflect", "Launch Macrium Refle") Then WinActivate("Macrium Reflect", "Launch Macrium Refle")
WinWaitActive("Macrium Reflect", "Launch Macrium Refle")
Send("{SPACE}{ENTER}")
Local $iFileExists = FileExists("C:\Windows\UpdateMacriumRun.bat")
If $iFileExists Then FileDelete("C:\Windows\UpdateMacriumRun.bat")
;$sMessage = "Update complete."
;SplashTextOn("Title", $sMessage, -1, 100, -1, -1, $DLG_TEXTLEFT, "", 34)
;Sleep(3000)
;SplashOff()

;WEnd

;#####################  EXAMPLE  ###############################
$sText = "Update complete."
$aStringSize = _StringSize($sText, 12, Default, Default, "Verdana")

SplashTextOn("Splash", $sText, $aStringSize[2] + 15, 50, -1, -1, 1, "Verdana")     ; See end of post for explanation of + 15
;For $i = 5 To 0 Step -1
;   ControlSetText("Splash", "", "Static1", "Automation starting in " & $i & " seconds.")
;   Sleep(1000)
;Next
Sleep(3000)
SplashOff()


Func GetHandle()
    Local $hHandle = WinGetHandle("Macrium Reflect Installer", "Click 'Next' to extract the setup files and begin")
    ConsoleWrite("$hHandle = " & $hHandle & @CRLF)
    WinActivate($hHandle)
    ControlClick($hHandle, "", "[CLASS:Button;INSTANCE:2]")
EndFunc   ;==>GetHandle

Func _ShowStep($msg, $sLineNo = @ScriptLineNumber)
    GUICtrlSetData($LineLabel, "Line: " & $sLineNo & " -" & $msg)
EndFunc   ;==>_ShowStep

I'm running this in Windows 10 with AutoIt 3.3.16.1

What do I need to do to see the LineNumber when I call the function?

 

Edited by Docfxit
  • Docfxit changed the title to How to Show the current line number
Posted (edited)

It's like you put them in a blender and mixed them well.  :lol:

Let's start from this.

Func _ShowStep($msg, $sLineNo = @ScriptLineNumber)
    GUICtrlSetData($LineLabel, "Line: " & $sLineNo & " -" & $msg)
EndFunc   ;==>_ShowStep

What does the help say about this?
GUICtrlSetData ( controlID, data [, default] )   --- Modifies the data for a control.

but you have no control
so we will send it to the console

Func _ShowStep($msg, $sLineNo = @ScriptLineNumber)
    ; GUICtrlSetData($LineLabel, "Line: " & $sLineNo & " -" & $msg)
    ConsoleWrite("Line: " & $sLineNo & " -" & $msg & @CRLF)
EndFunc   ;==>_ShowStep

so you don't even need the

;~ Global $LineLabel

one #RequireAdmin is enough, delete the second one

these are not needed both,  DirCreate('C:\Dnload\Macrium')  are enough, because if it does it,  automatically, 'C:\Dnload' also exists

;~ If Not FileExists('C:\Dnload') Then
;~  DirCreate('C:\Dnload')
;~ EndIf

If Not FileExists('C:\Dnload\Macrium') Then
    DirCreate('C:\Dnload\Macrium')
EndIf

 

Edited by ioa747

I know that I know nothing

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...