Page 1 of 1

Is it possible to use printscreen to save an image

Posted: 22 Apr 2019, 07:27
by songdg
I want to use printscreen key to capture the screen and then save an image file.

Re: Is it possible to use printscreen to save an image

Posted: 22 Apr 2019, 09:03
by zayntheboss
Here's a script I wrote that does just that

Code: Select all

^q::
sleep, 100
send {PrintScreen}
sleep, 500
run MSPaint
Sleep, 1000
Send, #{Up}
Sleep, 500
Mouseclick, left, 250, 250, 5
Sleep, 200
send ^v
sleep, 500
Send ^s
Random, filename, 10000, 99999
Sleep, 500
Send %filename%
Sleep, 500
Send ^l
Sleep, 200
Send, desktop
Loop, 5 {
Send, {enter}
Sleep, 300
}

Re: Is it possible to use printscreen to save an image  Topic is solved

Posted: 22 Apr 2019, 09:12
by Ridwan
I use Gdip.ahk by tic to save the screenshot as file.
btw, you can use other Hotkey, not just PrintScreen

Code: Select all

#Include Gdip.ahk

PrintScreen::
    CurrentDate := A_YYYY "-" A_MM "-" A_DD
    CurrentTime := A_Hour "-" A_Min "-" A_Sec "." A_MSec

    Screenshot(CurrentDate "_" CurrentTime ".png")
Return

Screenshot(OutFile)
{
    pToken := Gdip_Startup()

    screen=0|0|%A_ScreenWidth%|%A_ScreenHeight%
    pBitmap := Gdip_BitmapFromScreen(screen)

    Gdip_SaveBitmapToFile(pBitmap, OutFile, 100)
    Gdip_DisposeImage(pBitmap)
    Gdip_Shutdown(pToken)
}
Here is the link:
https://github.com/tariqporter/Gdip/
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6517

Re: Is it possible to use printscreen to save an image

Posted: 26 Apr 2019, 01:42
by songdg
zayntheboss wrote:
22 Apr 2019, 09:03
Here's a script I wrote that does just that

Code: Select all

^q::
sleep, 100
send {PrintScreen}
sleep, 500
run MSPaint
Sleep, 1000
Send, #{Up}
Sleep, 500
Mouseclick, left, 250, 250, 5
Sleep, 200
send ^v
sleep, 500
Send ^s
Random, filename, 10000, 99999
Sleep, 500
Send %filename%
Sleep, 500
Send ^l
Sleep, 200
Send, desktop
Loop, 5 {
Send, {enter}
Sleep, 300
}
Thank you very much.

Re: Is it possible to use printscreen to save an image

Posted: 26 Apr 2019, 01:44
by songdg
Ridwan wrote:
22 Apr 2019, 09:12
I use Gdip.ahk by tic to save the screenshot as file.
btw, you can use other Hotkey, not just PrintScreen

Code: Select all

#Include Gdip.ahk

PrintScreen::
    CurrentDate := A_YYYY "-" A_MM "-" A_DD
    CurrentTime := A_Hour "-" A_Min "-" A_Sec "." A_MSec

    Screenshot(CurrentDate "_" CurrentTime ".png")
Return

Screenshot(OutFile)
{
    pToken := Gdip_Startup()

    screen=0|0|%A_ScreenWidth%|%A_ScreenHeight%
    pBitmap := Gdip_BitmapFromScreen(screen)

    Gdip_SaveBitmapToFile(pBitmap, OutFile, 100)
    Gdip_DisposeImage(pBitmap)
    Gdip_Shutdown(pToken)
}
Here is the link:
https://github.com/tariqporter/Gdip/
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6517
Thanks for your direction.

Re: Is it possible to use printscreen to save an image

Posted: 13 Jun 2019, 20:38
by songdg
If I want to use Gdip.ahk to select a rectangle area of the screen manually and save it as an image, how to do that, thanks.

Re: Is it possible to use printscreen to save an image

Posted: 13 Jun 2019, 20:49
by Hellbent
songdg wrote:
13 Jun 2019, 20:38
If I want to use Gdip.ahk to select a rectangle area of the screen manually and save it as an image, how to do that, thanks.
I just posted a script here that has that written into it.


https://www.autohotkey.com/boards/viewtopic.php?f=6&t=60949

It only draws on the main monitor, but can be tweaked to work on any monitor, in fact, I just wrote a class yesterday that I intend to use for these tasks.
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=65366


There are a few functions in that first script that use my own custom gdip functions. They can be found in the lower part of the script.

If you need help picking out the code let me know.

Good luck.

Re: Is it possible to use printscreen to save an image

Posted: 17 Jun 2019, 01:57
by songdg
Hellbent wrote:
13 Jun 2019, 20:49
songdg wrote:
13 Jun 2019, 20:38
If I want to use Gdip.ahk to select a rectangle area of the screen manually and save it as an image, how to do that, thanks.
I just posted a script here that has that written into it.


https://www.autohotkey.com/boards/viewtopic.php?f=6&t=60949

It only draws on the main monitor, but can be tweaked to work on any monitor, in fact, I just wrote a class yesterday that I intend to use for these tasks.
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=65366


There are a few functions in that first script that use my own custom gdip functions. They can be found in the lower part of the script.

If you need help picking out the code let me know.

Good luck.
Thanks for your help, your scrip is a bit complex for a newbie like me.
Use that function?
Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h){
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
}

Re: Is it possible to use printscreen to save an image

Posted: 17 Jun 2019, 02:17
by Hellbent
songdg wrote:
17 Jun 2019, 01:57
Thanks for your help, your scrip is a bit complex for a newbie like me.
Use that function?
Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h){
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
}
Yes that function is what you use to draw your rectangle.

The other day I took the scripts I linked you to and created a little script that does a image search. It might be helpful to you.
Once again it is a bit complex but it has drawing a rectangle, taking a screenshot, setting a search area and running a search.

https://www.autohotkey.com/boards/viewtopic.php?f=76&t=65438

A few months ago someone had asked me how to draw a rectangle to their screen so I made a little video that covers it step by step.
If you find the script in the thread I posted to complex, this should make things easy for you.

https://www.youtube.com/watch?v=80FhzIm9IQQ

Let me know how it works out for you.

Re: Is it possible to use printscreen to save an image

Posted: 17 Jun 2019, 03:21
by DonTutti
Hello, is it possible to change mouse cursor to square about 10x10 pixels and take screenshot when I click mouse buton in mouse position?