Sign in to follow this  
Followers 0
coucou

How to focus a selected file?

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I'm looking to patch a file.

Although, i copy and run the patch file from an existing folder, I always got a window's message "Choose the directory where is the file to patch" (see image bellow)

How can I automatically patch the selected directory/file without choosing it?

Regards

; Exit if Compare Suite is not installed.
If Not FileExists(@ProgramFilesDir  & "\Compare Suite\comparesuite.exe") Then
MsgBox(0x40030, @ScriptName, @ProgramFilesDir  & "\Compare Suite\comparesuite.exe is not exist", 10)
Exit 1
EndIf

$folder = @ProgramFilesDir  & "\Compare Suite\"
  

FileCopy("Cmp_patch.exe", $folder)

Sleep(1000)
$title= "Compare Suite"
Run($folder & "Cmp_patch.exe")

WinWaitActive($title)
ControlClick($title, "", "Button7"); Patch it
Sleep(1000)
ControlClick($title, "", "Button9"); Exit

Sleep(2000)
FileDelete(@ProgramFilesDir  & "\Compare Suite\Cmp_patch.exe")

post-5679-12668583815212_thumb.jpg

Edited by coucou

Share this post


Link to post
Share on other sites



How can I automatically patch the selected directory/file without choosing it?

It may search in the current working directory.

#RequireAdmin

; Installation folder of Compare Suite
$folder = @ProgramFilesDir  & "\Compare Suite\"

; Exit if Compare Suite is not installed.
If Not FileExists($folder  & "\comparesuite.exe") Then
    MsgBox(0x40030, @ScriptName, $folder  & "\comparesuite.exe is not exist", 10)
    Exit 1
EndIf

;~ FileCopy("Cmp_patch.exe", $folder); seems unneeded

Sleep(1000)

;Patch filename
$patch = "Cmp_patch.exe"

; Use $patch in @ScriptDir if not found in current @WorkingDir
If Not FileExists($patch) And FileExists(@ScriptDir & '\' & $patch) Then
    $patch = @ScriptDir & '\' & $patch
EndIf

; Run $patch. Using $folder for the passed @WorkingDir may help for $patch to
; find the target file to patch if it does search there before prompting.
$pid = Run('"' & $patch & '"', $folder)
If @error Then
    MsgBox(0x40030, @ScriptName, 'Failed to execute ' & $patch, 10)
    Exit 2
Else
    $title = "Compare Suite"
    WinWait($title)
    ControlClick($title, "", "Button7"); Patch it
    Sleep(1000)
    ControlClick($title, "", "Button9"); Exit
    ProcessWaitClose($pid)
EndIf

;~ Sleep(2000); seems unneeded
;~ FileDelete(@ProgramFilesDir  & "\Compare Suite\Cmp_patch.exe"); seems unneeded

; Compare Suite looks similar to WinMerge. If so, then check out
; WinMerge at http://winmerge.org/

Untested as I do not have the program or the patch.

Share this post


Link to post
Share on other sites

Many Thanks MHZ Posted Image

Since I see that you're replying I'm sure that my problem is over. Moreover, I enjoy your comments-explanations Posted Image

Regarding WinMerge, Yes I confirm that Compare Suite looks similar. TNX for the link.

BTW, can you glance at Delete empty files it works on directories only not on subdir.

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