Jump to content
marlon89

MouseClickDrag doesn't work?

Recommended Posts

marlon89

Hi dear members,

I nearly finished a script that opens a program called 'Irfan View',  which goes to a specific folder on my desktop, selects all files and it should drag and drop finally the files into 'Irfan View'.

Somehow the last step doesn't work properly? The files get moved a little bit, the 'Irfan View' window opens,
but it seems the files are dropped to early or so? I made also a drag delay and tried the 'MouseMove' function instead of drag & drop...but no success

I would be happy if you can have a look into my script-code...maybe you can see the error?

Code:

Run ( "C:\Program Files (x86)\IrfanView\i_view32.exe")
AutoItSetOption('MouseCoordMode', 0)

WinWait('IrfanView')
WinActivate('IrfanView')

MouseClick("left",32,36,1)
MouseClick("left",82,242,1)

WinWait("Batch/Stapel-Konvertierung","")
WinActivate("Batch/Stapel-Konvertierung","")

Send("{LWINDOWN}d{LWINUP}")


ShellExecute("C:\Users\-\Desktop\pictures\1")
WinWait('1')
WinActivate('1')

WinSetState ( "1", "", @SW_MAXIMIZE )

Send("{CTRLDOWN}a{CTRLUP}")


MouseClickDrag("left", 468, 237, 649, 493 )
AutoItSetOption ( "MouseClickDragDelay", 100)
WinWait("Batch/Stapel-Konvertierung","")
WinActivate("Batch/Stapel-Konvertierung","")
WinSetState ( "Batch/Stapel-Konvertierung", "", @SW_MAXIMIZE )

Greetings,
Marlon

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Jos

It seems you want to make a batch conversion of pictures...right?
This  can be done by using commandline options of i_view32.exe. 

I've played with this for myself and came up with this script which you might want to modify.
You add files by drag-drop onto the gui.

#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <file.au3>

Global $gaDropFiles[1]

$Form1 = GUICreate("Picure conversion", 560, 500, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_DLGMODALFRAME))
;Main listview which accepts droped items
GUICtrlCreateLabel("Size longest side of output picture:", 10, 10, 190, 20)
$hSize = GUICtrlCreateEdit("800", 200, 8, 80)
$ListView1 = GUICtrlCreateListView("Files", 10, 50, 680, 410, -1)
_GUICtrlListView_SetColumnWidth(-1, 0, 400)
GUICtrlSetState($ListView1, $GUI_DROPACCEPTED)
GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC')
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$hOk = GUICtrlCreateButton("Stop", 140, 470)
$hConvert = GUICtrlCreateButton("Create Small Pictures", 240, 470)
GUISetState()

While 1
    $msg = GUIGetMsg()

    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hOk
            Exit
        Case $hConvert
            Do_Convert()
            Exit
        Case $GUI_EVENT_DROPPED
            $str = ""
            For $i = 0 To UBound($gaDropFiles) - 1
                GUICtrlCreateListViewItem($gaDropFiles[$i], $ListView1)
            Next
    EndSwitch
WEnd

Func Do_Convert()
    Local $sDrive, $sDir, $sFileName, $sExtension
    ProgressOn("Foto conversie", " converteren van:")
    $Rows = _GUICtrlListView_GetItemCount($ListView1)
    $iSize = StringStripWS(GUICtrlRead($hSize), 8)
    For $x = 0 To $Rows - 1
        $aItem = _GUICtrlListView_GetItem($ListView1, $x)
        Local $iFile = $aItem[3]
        _PathSplit($iFile, $sDrive, $sDir, $sFileName, $sExtension)
        ConsoleWrite(@error & ' File=' & $aItem[3] & @CRLF)
        ; i_view32.exe c:\*.jpg /resize_long=300 /aspectratio /resample /convert=d:\temp\outimage_###.jpg
        Local $oFile = $sDrive & $sDir & "Klein\" & $sFileName & "_Klein" & $sExtension
        Local $oPath = $sDrive & $sDir & "Klein"
        If StringInStr(FileGetAttrib($iFile), "d") Then
            ConsoleWrite("Found directory as input:" & $iFile & @CRLF)
            ContinueLoop
        EndIf
        DirCreate($oPath)
        ProgressSet(($x + 1) / $Rows * 100, $iFile)
;~      ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : ($x + 1) / $rows * 100 = ' & ($x + 1) / $Rows * 100 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
        RunWait('"D:\Program Files (x86)\IrfanView\i_view32.exe" "' & $iFile & '" /resize_long=' & $iSize & ' /aspectratio /resample /jpgq=75 /convert="' & $oFile & '"', "D:\Program Files (x86)\IrfanView")
        ConsoleWrite('"D:\Program Files (x86)\IrfanView\i_view32.exe" "' & $iFile & '" /resize_long=' & $iSize & ' /aspectratio /resample /jpgq=75 /convert="' & $oFile & '"' & @CRLF) ;### Debug Console
        Sleep(200)
    Next
    ProgressOff()
EndFunc   ;==>Do_Convert

Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc   ;==>WM_DROPFILES_FUNC

Jos

  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
marlon89
48 minutes ago, Jos said:

It seems you want to make a batch conversion of pictures...right?
This  can be done by using commandline options of i_view32.exe.

Jos

Thanks for your answer. Yeah right. I wanna add all my pictures into one folder and let irfan view downsize 50% of the pixel-size into a new folder. I'll look step by step into your code, as I'm just at the beginning working with AutoIT :)

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

×