toralf wrote:
Hi 172x,
Thank you for your version. I had a look at it. I do have to remarks:
1) You use MY, MY, MXend and MYend to crop the picture. That is dangerous, since if the user has draged the frame from bottom right to upper left, the values will overlap. Since you have calculate X,Y,w,h already, you can use them and they are the correct values.
2) I didn't use the {PRINTSCREEN} /clippaste way, since it will interfere with the clipboard. Since irfanview supports directly screenshot capabilities, you can use it without this interference.
Just my 2 cents
I have taken from your script the idea to put the screenshot filename and path into "". Thanks. I have edited my post and code
Hi toralf,
Thanks for your sugggestion, here is my latest version which able to crop the picture from any direction.
Code:
Alt & Lbutton::
irfanviewPath=C:\Application\IrfanView\i_view32.exe
Folder=C:\Application\IrfanView\Captures
if IsIrfanViewExist(irfanviewPATH, "i_view32.exe (IrfanView)") = 1
{
CoordMode, Mouse ,Screen
MouseGetPos, Xs, Ys
Gui, 1:Color, EEAA99
Gui, 1:+Lastfound
WinSet, TransColor, EEAA99
Gui, 1:-Caption +Border
Loop
{
If GetKeyState("LButton", "P")
{
MouseGetPos, Xe, Ye
if (Xs < Xe) and (Ys < Ye)
{
X1 := Xs
Y1 := Ys
X2 := Xe
Y2 := Ye
}
if (Xs > Xe) and (Ys < Ye)
{
X1 := Xe
Y1 := Ys
X2 := Xs
Y2 := Ye
}
if (Xs < Xe) and (Ys > Ye)
{
X1 := Xs
Y1 := Ye
X2 := Xe
Y2 := Ys
}
if (Xs > Xe) and (Ys > Ye)
{
X1 := Xe
Y1 := Ye
X2 := Xs
Y2 := Ys
}
w := abs(Xe - Xs)
h := abs(Ye - Ys)
Gui, 1:Show, x%X1% y%Y1% w%w% h%h%
}
Else
Break
}
Gui, 1:Destroy
file_name := GetFileName(Folder, "SCR", "JPG")
TakeScreenShot(irfanviewPath, file_name, X1, Y1, w, h, 0)
}
Return
TakeScreenShot(ProgramPath, TargetPath, sXpos, sYpos, vW, vH, vType)
{
RunWait, `"%ProgramPath%`" /capture=%vType% /crop=(%sXpos%`,%sYpos%`,%vW%`,%vH%) /convert=`"%TargetPath%`", , hide
}
IsIrfanViewExist(FilePath, FileName)
{
IfNotExist, %FilePath%
{
Msgbox File: %FileName% does not exist !
return 0
}
else
return 1
}
GetFileName(FilePath, FilePrefix, FileExt)
{
FileNoCount=1
Loop,
{
IfExist, %FilePath%\%FilePrefix%%FileNoCount%.%FileExt%
{
FileNoCount++
continue
}
else
Break
}
f_name = %FilePath%\%FilePrefix%%FileNoCount%.%FileExt%
return f_name
}
I am new to AHK, I have one out of topic question, hopefully you are able to answer me.
Is it possible to change the mouse speed (e.g. mouse dpi) dynamically with AHK? I have tried "SetDefaultMouseSpeed" but not success. I like the idea of Logitech MX518 which able to change the mouse's dpi with a click of button.
Thanks