ViciousXUSMC

Irfanview Right Click Context Menu Batch Processing

6 posts in this topic

This is a script I put together to make it as fast and as easy as possible for a user to batch process image files using the free program Irfanview.

The program itself is already really great with a batch processing feature, but it also has CMD interfacing so that just screamed "Do an Autoit Script!" at me.

 

I ended up going for context menu integration so that I could have any folder auto populate its path to the script rather than relying on the user to type it or something.

There could be some better/smarter ways to do this, but this way is working for me.

It consists of two scripts, one to install the context menu and other needed things, and the other is the actual work script for processing the files.

You would need to change some of these things a bit probably for your use.

The .bat file is the file being run.

The .ini is the settings for the batch conversion

The .bat File

"i_view32.exe" "replace\*.jpg" /ini="C:\IT Automation" /advancedbatch /convert="replace\processed images\*.jpg"

The Install Script

#RequireAdmin


If FileExists("C:\Program Files (x86)\IrfanView\i_view32.exe") Then

$key = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$val = "PATH"
$PATH = RegRead($key, $val)

$sAddThisPath = "C:\Program Files (x86)\IrfanView"
$PATH = $PATH & ";" & $sAddThisPath

RegWrite($key,$val,"REG_EXPAND_SZ",$PATH)
EnvUpdate()

ElseIf FileExists("C:\Program Files\IrfanView\i_view32.exe") Then

$key = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$val = "PATH"
$PATH = RegRead($key, $val)

$sAddThisPath = "C:\Program Files\IrfanView"
$PATH = $PATH & ";" & $sAddThisPath

RegWrite($key,$val,"REG_EXPAND_SZ",$PATH)
EnvUpdate()

Else
    MsgBox(0, "Black Magic Automation", "Irfanview is not Detected, Install Aborted")
    Exit
EndIf



DirCreate("C:\IT Automation")

FileInstall("C:\My Places\Scripting\AutoIT\My Scripts\Context Menu Adding\RiskProcessReplace.bat", "C:\IT Automation\RiskProcessReplace.bat", 1)
FileInstall("C:\My Places\Scripting\AutoIT\My Scripts\Context Menu Adding\IV-INI\i_view32.ini", "C:\IT Automation\i_view32.ini", 1)
FileInstall("C:\My Places\Scripting\AutoIT\My Scripts\Context Menu Adding\BatchConvert.exe", "C:\IT Automation\BatchConvert.exe", 1)

RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Auto Batch Convert")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Auto Batch Convert", "", "REG_SZ", "Auto Batch Convert")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Auto Batch Convert", "Extended", "REG_SZ", "")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Auto Batch Convert", "Icon", "REG_SZ", '"C:\IT Automation\BatchConvert.exe"')
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Auto Batch Convert\command")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Auto Batch Convert\command", "", "REG_SZ", 'C:\Windows\explorer.exe "C:\IT Automation\BatchConvert.exe"')

MsgBox(0, "Black Magic Automation", "Install is Completed, Shift Right Click Folders to use.")

And the actual working script 

#include <file.au3>


$saveClip = ClipGet()
Send("^c")
Sleep(150)
$filesfolders = ClipGet()
ClipPut($saveClip)

DirCreate($filesfolders & "\Processed Images")
FileCopy("C:\IT Automation\RiskProcessReplace.bat", @TempDir & "\RiskProcessReplace.bat", 1)
_ReplaceStringInFile(@TempDir & "\RiskProcessReplace.bat", "replace", $filesfolders)
ShellExecute(@TempDir & "\RiskProcessReplace.bat")

Feedback is welcome, if you know a way to do this better let me know!

Of late I like  using .bat files with replace strings rather than trying any @ComSpec scripts makes life so much easier!

Share this post


Link to post
Share on other sites



Hi ViciousXUSMC,

cool Idea ! I use Irfan all the time with AutoIT because of the above mentioned reasons, your absolutely right !

couple of ideas for your your project:

  • offer a zip download with the bat's and such to make it easier for the user to install / use. 
  • your FileInstall ('s) will not work like that for anyone but you) ;)
  • anytime you (your program) install and/or change the registry you should offer an uninstall which cleans up in case the user decides to bail

Just my  $0.02 

cya,

Bill

1 person likes this

Share this post


Link to post
Share on other sites

Bill is right.

IrfanView is an excellent program I have used for many years.

Several of my programs use it.

You could do all you want in one script. A bat file is not required either.

As for registry entries, either have a checkbox in your program to set/unset them, or have shortcuts created that do that.

I tend to use both these days and provide an uninstall routine.

Basically you need a SET function and an UNSET function in your program, accessible via command-line.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Ok, was just sharing the concept more than anything but I will try to clean it up and package it for use by others.

As far as "all in one file" I suppose I could but it made sense to have an install and a run routine.

I know I can skip the .bat file but I have had a terrible time with ' " quote issues with @ComSpec if that is what you were intending, and this way where my .bat lives I or a user can easily make minor changes to the bat file to change how it functions without having to recompile the .exe

Any examples of what you recommended would be appreciated though, would like to see what I can learn. 

Share this post


Link to post
Share on other sites

First off, Thanks !  Your idea has pushed me to go ahead and make something I have needed for a while.

Second, be warned. I tend to oversimplify things . :ermm:

This is my version ( for my needs ) definitely a one trick pony but easily adaptable with any of the many options available in Irfan's Command Line

Does: Right click on any folder and resize all jpg's to 35 % and save to different folder on Desktop.

Add this to your registry here:  HKEY_CLASSES_ROOTDirectoryshell

post-56351-0-77691000-1426882549_thumb.j

Modify the default command (changing the desktop path to your own $$$$$)

C:\Program Files\IrfanView\i_view32.exe %1\*.jpg /resize=(35p,35p) /convert=C:\Users\$$$$$\Desktop\test2\*.jpg

cya,

Bill

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here's something to give you an idea.

$warn = ""

$reg = IniRead($inifle, "Context Entry", "registry", "")
If $reg = "" Then
    ; Create Registry context menu entries.
    $reg = 1
    IniWrite($inifle, "Context Entry", "registry", $reg)
    ContextEntries("set", ".azw", "Scan Ebook", @ScriptFullPath)
    ContextEntries("set", ".mobi", "Scan Ebook", @ScriptFullPath)
EndIf


If $CmdLine[0] <> "" Then
    $cmdlne = $CmdLine[1]
    If $cmdlne = "/unreg" Then
        If $reg = 1 Then
            UnregisterAssociations()
        EndIf
    Else
        ; put whatever you require here
    EndIf
EndIf

; This is not required, except for testing your script.
If $reg = 1 And (@Compiled = 0 Or StringInStr(@ScriptDir, "\AutoIt\") > 0) Then
    ;MsgBox(262192, "Error Check", "Some Text", 0)
    $warn = 1
    UnregisterAssociations()
EndIf

Exit


Func ContextEntries($job, $fext, $progname, $progpth)
    $extkey = "HKEY_CLASSES_ROOT\" & $fext
    $defval = RegRead($extkey, "")
    If $defval = "" And $job = "unset" Then
        MsgBox(262192, "Association Error", "Nothing is registered for the file extension passed.", 3)
    Else
        ; NOTE - If progran is not installed yet and thus associated, and is being run as an uncompiled
        ; script or from a path that includes '\AutoIt\' in the name, then Registry entry is created at
        ; program start, and then deleted at program exit. This is for script testing purposes only.
        ; NOTE 2 - Strictly speaking, in this instance, because both file extensions are using the same
        ; Amazon program, setup of Registry entry only needs to be run once, though it happens twice by
        ; current default code, for both create and delete. Without devoting too much thought to this,
        ; I have decided it is best to leave code as is, just in case.
        $keyname = "File." & StringReplace($progname, " ", ".")
        ;MsgBox(262192, "$keyname", $keyname, 0)
        If $defval = "" Then
            ; File extension is not associated with a program, so create association for current program.
            $ext = StringMid($fext, 2)
            $extfle = $ext & "file"
            RegWrite($extkey, "", "REG_SZ", $extfle)
        Else
            ; File extension is associated with a program already.
            $extfle = $defval
        EndIf
        $regkey = "HKEY_CLASSES_ROOT\" & $extfle & "\shell\" & $keyname
        $entry = "Use " & $progname
        $progpth = '"' & $progpth & '" ' & '"' & "%1" & '"'
        $defval = RegRead($regkey, "")
        ;
        If $job = "set" And $defval = "" Then
            ; Try to create a Registry entry for this program.
            $comkey = $regkey & "\command"
            $defval = RegRead($comkey, "")
            If $defval = $progpth Or $defval = "" Then
                ; Create a Registry entry for this program.
                RegWrite($regkey, "", "REG_SZ", $entry)
                RegWrite($comkey, "", "REG_SZ", $progpth)
            Else
                MsgBox(262192, "Association Failed", "Path of associated Program is for another location!" & @LF & "(auto exit in 3 seconds)", 3)
            EndIf
        ElseIf $job = "unset" And $defval = $entry Then
            ; Try to remove a Registry entry for this program.
            $comkey = $regkey & "\command"
            $defval = RegRead($comkey, "")
            If $defval = $progpth Then
                ; Remove a Registry entry for this program.
                RegDelete($regkey)
            Else
                ; Show warning only once, when using a script or running in AutoIt projects folder.
                If $warn = 1 Or $warn = "" Then
                    If $warn = 1 Then $warn = 2
                    MsgBox(262192, "Unset Association Failed", "Path of associated Program is for another location!" & @LF & "(auto exit in 3 seconds)", 3)
                EndIf
            EndIf
        Else
            ; Could not create or remove a Registry entry.
            If $defval <> $entry And $defval <> "" Then
                MsgBox(262192, "Association Failed", "Keyname belongs to another program! " & @LF & $defval & @LF & "(auto exit in 4 seconds)", 4)
            EndIf
        EndIf
    EndIf
EndFunc ; => ContextEntries


Func UnregisterAssociations()
    $reg = ""
    IniWrite($inifle, "Context Entry", "registry", $reg)
    ContextEntries("unset", ".azw", "Scan Ebook", @ScriptFullPath)
    ContextEntries("unset", ".mobi", "Scan Ebook", @ScriptFullPath)
EndFunc ;=> UnregisterAssociations

Hopefully I didn't miss anything or overlook something, when extracting it from a much larger script.

This is for automatically setting registry associations for two ebook extensions only (adjust as needed).

To unset, you just use the command-line, either by a shortcut with the '/unreg' parameter or some uninstaller script.

You could also have a checkbox in your program, to do the set or unset.

Comments hopefully explain well enough, why some things are the way they are.

WARNING - Obviously you need to sort out declarations (Global, etc) for variables yourself.

And don't presume the code will work without checking it first and making any required adjustments for your situational need.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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

  • Similar Content

    • Luigi
      By Luigi
      Greetings forum,
      Hi develop this script, to use context menu with listview.
      It's work fine, run and click with left or right mouse button, you see on Console the id from item.
      If you click none, the id is -1, like this:
      $NM_RCLICK[-1] $NM_RCLICK[-1] $NM_RCLICK[2] $NM_RCLICK[1] $NM_RCLICK[0] $NM_RCLICK[1] That is correct.
      But if you uncoment the line:
      GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")
      You have to click with left button (over item or none) and after click with right button.
      LeftButton is to update $HOSTS_INDEX.
      RightButton is to open ContextMenu.
       
      Exist another way to update $HOSTS_INDEX?
      Example:
      Call WM_NOTIFY every time WM_CONTEXTMENU is called?
      I ask this, becouse i cant understanding why $HOSTS_INDEX is not updated when WM_CONTEXTMENU is uncomented.
      Someone can explain or help me?
       
      Best regards.
      ;~ #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ;~ #Tidy_Parameters=/sf #include-once #include-once #include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiMenu.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <SendMessage.au3> #include <Timers.au3> #include <AutoItConstants.au3> #include <EditConstants.au3> #include <File.au3> #include <FontConstants.au3> #include <GuiComboBoxEx.au3> #include <GuiImageList.au3> #include <GuiTreeView.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <TreeViewConstants.au3> #include <String.au3> OnAutoItExitRegister("OnExit") Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) Opt("MustDeclareVars", 1) Global Enum $eCREATE = 1000, $eUPDATE, $eDELETE, $eICON_TABLE, $eDEFAULT, $eEXPORT_HTML Global Const $EMPTY = -1 Global $HOSTS_INDEX = -1 Global $HOST_Host Global $aGuiSize[2] = [800, 600] Global $sGuiTitle = "GuiTitle" Global $hGui Global $iList, $hList $hGui = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1]) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") $iList = GUICtrlCreateListView("nome", 20, 50, 240, 490) $hList = GUICtrlGetHandle($iList) _GUICtrlListView_SetColumnWidth($hList, 0, 236) Populate() GUISetState(@SW_SHOW, $hGui) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;~ GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") While Sleep(25) WEnd Func OnExit() GUISetState($hGui, @SW_HIDE) GUIDelete($hGui) EndFunc ;==>OnExit Func Quit() Exit EndFunc ;==>Quit Func Populate() Local $arr[4] = [3, "nome 1", "nome 2", "nome 3"] _GUICtrlListView_BeginUpdate($hList) _GUICtrlListView_DeleteAllItems($hList) For $ii = 1 To $arr[0] _GUICtrlListView_AddItem($hList, $arr[$ii]) Next _GUICtrlListView_SetItemSelected($hList, 0, True, True) _GUICtrlListView_EndUpdate($hList) EndFunc ;==>Populate Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ConsoleWrite("WM_CONTEXTMENU..( $hWnd=" & $hWnd & ", $iMsg=" & $iMsg & ", $wParam=" & $wParam & ", $lParam=" & $lParam & " )" & @LF) Local $exec = 0 Local $hMenu Switch $wParam Case $hList Local $TRY_ID = _GUICtrlListView_GetHotItem($hList) If Not ($TRY_ID = $HOSTS_INDEX) Then $HOSTS_INDEX = $TRY_ID Local $aOrigin = _GUICtrlListView_GetOrigin($hList) ConsoleWrite("WM_CONTEXTMENU $HOSTS_INDEX[" & $HOSTS_INDEX & "] $aOrigin[" & _GUICtrlListView_GetOriginX($iList) & "]" & @LF) $hMenu = _GUICtrlMenu_CreatePopup() If $HOSTS_INDEX = $EMPTY Then _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Add", $eCREATE) Else _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Rename", $eUPDATE) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Del", $eDELETE) EndIf _GUICtrlMenu_SetMenu($hGui, $hMenu) $exec = _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam, -1, -1, 1, 1, 2, 1) _GUICtrlMenu_DestroyMenu($hMenu) EndSwitch Return True EndFunc ;==>WM_CONTEXTMENU Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Local $TRY_ID Switch $hWndFrom Case $hList $TRY_ID = _GUICtrlListView_GetHotItem($hList) If Not ($TRY_ID = $HOSTS_INDEX) Then $HOSTS_INDEX = $TRY_ID Switch $iCode Case $NM_CLICK ConsoleWrite("$NM_CLICK[" & $TRY_ID & "]" & @LF) If $HOSTS_INDEX = $EMPTY Or $HOST_Host Then ;~ HOSTS_Clear() ;~ HOSTS_ListView_ItemCancel() ;~ GUICtrlSetState($HOSTS_ITEM_DEL, $GUI_DISABLE) ;~ GUICtrlSetState($HOSTS_ITEM_UPD, $GUI_DISABLE) Else Local $name = _GUICtrlListView_GetItemText($hList, $HOSTS_INDEX) ;~ HOSTS_FieldLoad($name) ;~ GUICtrlSetState($HOSTS_ITEM_DEL, $GUI_ENABLE) ;~ GUICtrlSetState($HOSTS_ITEM_UPD, $GUI_ENABLE) EndIf Return 0 ; allow the default processing Case $NM_RCLICK ConsoleWrite("$NM_RCLICK[" & $TRY_ID & "]" & @LF) Return 0 ; allow the default processing EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY  
    • TheSaint
      By TheSaint
      TeraCopy Timer - A program of mine, front end really, that I have been working on (on & off) for some time, but not shared here before, that I recall. Third party program TeraCopy is required.
      Many of you will be familiar with TeraCopy, and it has been discussed here at AF on several occasions, in various sub forums, including Chat.
      BE ADVISED - I still use an older version of TeraCopy (v2.27), a goody but an oldy, so have only tested my program with that. It may work with the newer v3.xx, or may be easily adjusted to do so, but I have not yet gone that route. Likewise, I only use it with Win 7 and Win XP, but I don't imagine there should be any issues with newer Windows. Add to that, my program being devised and created in AutoIt v3.3.0.0.
      So what is TeraCopy Timer and why might you need it?
      I devised my program for two main reasons really, based on giving me greater control, using the Free version of TeraCopy, which has some limitations (perhaps even with the paid full version). My program utilizes the features of the TeraCopy command-line.
      1. I was fed up with Thumbs.db files regularly halting the process in Win XP or preventing a folder being deleted after a move. Only happens with Win XP.
      2. I wanted to automate delays between jobs, allowing all HDD's to rest periodically when doing large and lengthy jobs. Letting HDD's heat up too much, can have tragic results or considerably shorten their lifespan. Prevention is better than cure or just relying on monitoring software etc.
      --------------------------------------------------------------------------------------
      Those familiar with TeraCopy use, know you can run multiple copy or move jobs either simultaneously or concurrently (one immediately after another has finished). With the free version at least, you have no control over precise order or timing, and no way to deal (without manual interaction) with the pesky Thumbs.db files in Win XP. TeraCopy Timer allows you to do all those things, and in a batch fashion.
      --------------------------------------------------------------------------------------
      Some screenshots and brief explanation
      Main Window

      You can browse to set the Source and Destination paths, or like me, just use Drag & Drop to those inputs.
      Once the Destination path has been set, the MIN (minimalist GUI) button becomes available. In Minimal mode, you get a further level of automation, once initial options are set, and thus less prompts ... none in fact, as jobs are created automatically based on either COPY or MOVE.
      Minimalist Window

      In the Minimalist mode, you can only use Drag & Drop to add a source file or folder, and COPY or MOVE is permanently set when the window first opens, via a choice prompt.
      Assigning a WAIT is simple and easy, and is the latest feature added to the program ... I used a much more complex variant before that (see Advanced Delay).

      The program now displays three file size reports.
      Individual Size of the current (last added) job (Blue label).
      Total Size of all jobs combined (Black label).
      Subtotal Size for each grouping of jobs, defined by a WAIT selection (Red label).
      You toggle between Black and Red, by just clicking that label. If no WAIT has been set, then the values will be the same.
      The wait of 5 minutes in the screenshot above is set for the source shown. It means wait 5 minutes before copying (or moving) that source.
      More sources added from that point, add to a new subtotal. To see the previous subtotal, you need to be at the main (MAX) window, and select the prior job.
      So every time a WAIT is clicked for a source a new subtotal count is started.

      In the screenshot above, you can see the Job name, and that it is Job number 5 order wise. MOVE has been set for that job.
      Selecting Job 4, you will see the previous (complete) Subtotal. Selecting job 3 (in this instance), you would see the subtotal up to that job.
      Click the red Total label and it will change to Black, and show you the total size over all, as shown in the second screenshot above.
      This new WAIT feature is the simplest and best way to use the program generally (in my view) ... but check out the following, as it is not always the case.
      Advanced Delay Window

      The Advanced Delay Options, are a further level of automation, added during the early stages of development, before I thought to create the Minimalist window and show Sizes. It was before I decided to put a lot more effort into the program. As with all my programs though, it is continual use that eventually dictates what I ultimately want to happen, to make my life easier ... simpler, better, smarter, quicker.
      The main difference between this older method, and the new WAIT one, where you specify delays precisely, is that the program attempts to determine the best moments to pause, based on various factors, which you setup and can vary between different types of Job sessions.
      The chief purpose for all the advanced options, is an attempt to cater for the difference between moving a small number of big files and a lot of small files. Moving or Copying lots of small files (hundreds or thousands), as many would know, can heat up a HDD far quicker and to a much higher temperature than a small number of (even very) large files. I guess that is primarily due to the sheer number of indexes that need to be created, and with small files are done at a staggering rate.
      Which method you use, is up to you, and should be governed by the type of job. Both methods can be used together, but not advised if you don't want the possibility of unnecessary extra long delays. EDIT - That said, you could use the WAIT option just for a delayed start of the first job ... perhaps your PC is busy doing something else until then, but you want to go and do something else for a bit, and have it all done by the time you return (i.e. watch a movie).
      WARNING - It should go without saying, that you take all the usual precautions. For instance, don't use move with the only copy you have of precious files. BACKUP BACKUP BACKUP! Don't hold me liable for anything, except for being a nice guy who likes to share.
      TeraCopy Timer v2.0.zip
      Enjoy!
      P.S. I am not affiliated in any way with those who created and provide the excellent third party program - TeraCopy.
    • Earthshine
      By Earthshine
      This is pretty useful to me at least, I hope to others. Whenever you need to poke a button or such on a GUI, you can just make calls to this UDF and instruct it how long to wait, 0 is forever, anyway, let the code to the explaining. Feel free to help expand this UDF. I plan to create new ones as I go along that support all the Win32 and .NET Controls. Ultimately, I would like to be able to fully control any type of control, this works well with most. Just an example of what you can do.
       
      The test installs and can uninstall 7-Zip 15.14 (x64) Setup.exe
      NOTE: Logger Author(s) .....: Michael Mims (zorphnog)
      ;                    the logging script can be obtained here
      ;                   https://www.autoitscript.com/forum/topic/156196-log4a-a-logging-udf/
       
       
      install_7zip_test.au3
      WaitForControls.au3
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I worked a bit on a little project of mine, and I managed to do what I was trying to do, or, automate a quiz in AutoIt.
      Now, everything works fine but, in order to achieve what I'm trying to achive, I'd like to make this script run faster.
      I'll attach a portion of the code in order to let you understand what my script does.
      $objIE_h1 = _IETagNameGetCollection($objIE, "h1") ; Take the text of the answer If @error Then ConsoleWrite("Errore durante la lettura degli h1 nella pagina. - Errore: " & @error & @CRLF) Else For $objElement In $objIE_h1 $strInnerText = $objElement.innerText Next Select Case StringInStr($strInnerText, "QUESTION") ; Here is the question ; PS4 PRO $objSpans = _IETagNameGetCollection($objIE, "span") ; Answers are stored here For $objElement In $objSpans If $i >= 4 Then $strAnswer = $objElement.innerText ; Take the text of the answer n° 0, 1, 2, 3 If StringInStr($strAnswer, "CORRECT ANSWER") Then ; If I match the correct answer, then, I have to click on the input with answer id = answer_i $j = $i - 4 $objInput = _IEGetObjById($objIE, "answer_" & $j) If @error Then ConsoleWrite("Errore durante la lettura della risposta #" & $i & " - Errore: " & @error & @CRLF) Else _IEAction($objInput, "click") If @error Then ConsoleWrite("Errore durante il click sull'elemento. - Errore: " & @error) Else ConsoleWrite($j & ") Risposta: " & $strAnswer & @CRLF) ExitLoop EndIf EndIf EndIf $i+=1 Else $i+=1 EndIf Next $i = 0 $j = 0 This is what my script does.
      Questions are 20, in which I have 15 multiple choice question, 2 images ( on which I use _IEImgClick() ), and 3 text inputs ( a simple send with the text I have to enter ).
      How can I make all of these, faster?
      If I reach this goal, I've probably done one of my best goals in life, and I'd like to share my happiness with you, giving a huge donation to this fantastic community!
      Thanks for your help
    • ChrisL
      By ChrisL
      #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> Global $g_hTreeView Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo Example() Func Example() Local $hGUI, $hItem Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $hGUI = GUICreate("(UDF Created) TreeView Create", 400, 300) $g_hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") _GUICtrlTreeView_BeginUpdate($g_hTreeView) For $x = 1 To Random(2, 10, 1) $hItem = _GUICtrlTreeView_Add($g_hTreeView, 0, StringFormat("[%02d] New Item", $x)) For $y = 1 To Random(2, 10, 1) _GUICtrlTreeView_AddChild($g_hTreeView, $hItem, StringFormat("[%02d] New Child", $y)) Next Next _GUICtrlTreeView_EndUpdate($g_hTreeView) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam ;ConsoleWrite($GUI_RUNDEFMSG & @CRLF) ;Switch $wParam ; Case $hTreeView Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True ;EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_CONTEXTMENU Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case $e_idOpen _DebugPrint("WM_COMMAND " & $wParam & " Open") Case $e_idSave _DebugPrint("WM_COMMAND " & $wParam & " Save") Case $e_idInfo _DebugPrint("WM_COMMAND " & $wParam & " Info") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = $g_hTreeView If Not IsHWnd($g_hTreeView) Then $hWndTreeview = GUICtrlGetHandle($g_hTreeView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeview Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint In the example code I have a treeview and a context/popup menu, I can't use a conventional context menu because I need to use the treeview UDF functions.
      The WM_COMMAND never fires from the context/popup menu selection while there is a treeview using  _GuiCtrlTreeview_Create
      If you comment out _GuiCtrlTreeview_Create line you will then see the right click selection works as expected and the debug is written to the console on selection.
      Autoit Ver 3.3.14.2
      Any ideas why this combination won't work together?
      Thanks