Page 1 of 1
How to save img name day/time ?
Posted: 15 Sep 2023, 01:42
by z1z123
Code: Select all
#Include C:\Users\admin\Desktop\p\Gdip_All.ahk
; https://github.com/marius-sucan/AHK-GDIp-Library-Compilation/blob/master/ahk-v1-imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
loop
{
index := 0, pToken := Gdip_Startup(), pBitmap := Gdip_BitmapFromScreen("927|0|700|620") ; x|y|w|h
Loop
image := Format(imageDir "C:\Users\admin\Desktop\abc\{:1}.png", ++index)
Until !FileExist(image)
Gdip_SaveBitmapToFile(pBitmap, image), Gdip_DisposeImage(pBitmap), Gdip_Shutdown(pToken)
sleep 5000
}
how i can named img according to the shooting time ?
ex: 0000.png (00:00am)
Re: How to save img name day/time ?
Posted: 15 Sep 2023, 05:58
by mikeyww
Re: How to save img name day/time ?
Posted: 15 Sep 2023, 10:22
by z1z123
Code: Select all
#Include C:\Users\admin\Desktop\p\Gdip_All.ahk
; https://github.com/marius-sucan/AHK-GDIp-Library-Compilation/blob/master/ahk-v1-imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
SaveDir = C:\Users\admin\Desktop\abc
pToken := Gdip_Startup(), pBitmap := Gdip_BitmapFromScreen("10|20|307|204") ; x|y|w|h
FormatTime ts,, yyMMdd-HHmmss
Gdip_SaveBitmapToFile(pBitmap, dir "\image" ts ".png"), Gdip_DisposeImage(pBitmap), Gdip_Shutdown(pToken)
Return
Code: Select all
#Include C:\Users\admin\Desktop\p\Gdip_All.ahk
; https://github.com/marius-sucan/AHK-GDIp-Library-Compilation/blob/master/ahk-v1-imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
loop
{
index := 0, pToken := Gdip_Startup(), pBitmap := Gdip_BitmapFromScreen("927|0|700|620") ; x|y|w|h
SaveDir = C:\Users\admin\Desktop\abc
Loop
FormatTime ts,, yyMMdd-HHmmss
Until !FileExist(image)
Gdip_SaveBitmapToFile(pBitmap, dir "\image" ts ".png"), Gdip_DisposeImage(pBitmap), Gdip_Shutdown(pToken)
sleep 5000
}
Code: Select all
#Include C:\Users\admin\Desktop\p\Gdip_All.ahk
; https://github.com/marius-sucan/AHK-GDIp-Library-Compilation/blob/master/ahk-v1-imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
loop
{
index := 0, pToken := Gdip_Startup(), pBitmap := Gdip_BitmapFromScreen("927|0|700|620") ; x|y|w|h
SaveDir = C:\Users\admin\Desktop\abc
Loop
FormatTime ts,, yyMMdd-HHmmss
Until !FileExist(image)
Gdip_SaveBitmapToFile(pBitmap, image), Gdip_DisposeImage(pBitmap), Gdip_Shutdown(pToken)
sleep 5000
}
nothing happen
Re: How to save img name day/time ?
Posted: 15 Sep 2023, 11:54
by mikeyww
Hello,
You cannot just throw lines together and expect everything to work; actually need to define variables that are used, and so on. To understand your script, follow it
line by line.
Code: Select all
#Requires AutoHotkey v1.1.33
#Include d:\Q\vis2\lib\Gdip_All.ahk
imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
pToken := Gdip_Startup()
Loop 3 {
SoundBeep 2500
pBitmap := Gdip_BitmapFromScreen("927|0|700|620")
FormatTime ts,, yyMMdd-HHmmss
Gdip_SaveBitmapToFile(pBitmap, imageDir "\image" ts ".png")
Sleep 1000
}
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
MsgBox 64, Status, Done!, 1
Run % imageDir
Return
Re: How to save img name day/time ?
Posted: 15 Sep 2023, 18:58
by z1z123
i still don't see any img in folder
Re: How to save img name day/time ?
Posted: 15 Sep 2023, 19:09
by mikeyww
In this case, all you need is a short test script.
Code: Select all
#Requires AutoHotkey v1.1.33
#Include d:\Q\vis2\lib\Gdip_All.ahk ; Replace with your Gdip file's path
gdip := "d:\Q\vis2\lib\Gdip_All.ahk"
If !FileExist(gdip) {
MsgBox 48, Error, % "File not found.`n`n" gdip
Return
}
image := A_ScriptDir "\test3.png"
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromScreen("0|0|900|900")
FileRecycle % image
Gdip_SaveBitmapToFile(pBitmap, image)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
Run % image
Re: How to save img name day/time ?
Posted: 15 Sep 2023, 23:23
by z1z123
Code: Select all
#Include C:\Users\admin\Desktop\p\Gdip_All.ahk
; https://github.com/marius-sucan/AHK-GDIp-Library-Compilation/blob/master/ahk-v1-imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
SaveDir = C:\Users\admin\Desktop\abc
pToken := Gdip_Startup(), pBitmap := Gdip_BitmapFromScreen("10|20|307|204") ; x|y|w|h
FormatTime ts,, yyMMdd-HHmmss
Gdip_SaveBitmapToFile(pBitmap, dir "\image" ts ".png"), Gdip_DisposeImage(pBitmap), Gdip_Shutdown(pToken)
Return
Code: Select all
#Include C:\Users\admin\Desktop\p\Gdip_All.ahk
; https://github.com/marius-sucan/AHK-GDIp-Library-Compilation/blob/master/ahk-v1-imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
loop
{
index := 0, pToken := Gdip_Startup(), pBitmap := Gdip_BitmapFromScreen("927|0|700|620") ; x|y|w|h
SaveDir = C:\Users\admin\Desktop\abc
Loop
FormatTime ts,, yyMMdd-HHmmss
Until !FileExist(image)
Gdip_SaveBitmapToFile(pBitmap, dir "\image" ts ".png"), Gdip_DisposeImage(pBitmap), Gdip_Shutdown(pToken)
sleep 5000
}
Code: Select all
#Requires AutoHotkey v1.1.33
#Include d:\Q\vis2\lib\Gdip_All.ahk
imageDir := A_ScriptDir
F3:: ; F3 = Save screenshot to file
pToken := Gdip_Startup()
Loop 3 {
SoundBeep 2500
pBitmap := Gdip_BitmapFromScreen("927|0|700|620")
FormatTime ts,, yyMMdd-HHmmss
Gdip_SaveBitmapToFile(pBitmap, imageDir "\image" ts ".png")
Sleep 1000
}
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
MsgBox 64, Status, Done!, 1
Run % imageDir
Return
I just found out 3 of this work and imgs were saved in C:\, not in folder have .ahk
Re: How to save img name day/time ?
Posted: 16 Sep 2023, 06:12
by mikeyww
These scripts have bugs. Would just try the test script that I posted.
Re: How to save img name day/time ?
Posted: 16 Sep 2023, 07:09
by z1z123
i didn't find test3 in computer
Re: How to save img name day/time ?
Posted: 16 Sep 2023, 07:22
by mikeyww
My script will open the image that was saved, or will display an error message if the image is not found.
1. What did you see when running the script?
2. In what directory is your script?
3. What script are you running (post it in a new reply)?
Re: How to save img name day/time ?
Posted: 16 Sep 2023, 20:02
by z1z123
Code: Select all
#Requires AutoHotkey v1.1.33
#Include C:\Users\admin\Desktop\abc\Gdip_All.ahk ; Replace with your Gdip file's path
gdip := "C:\Users\admin\Desktop\abc\Gdip_All.ahk"
r::
If !FileExist(gdip) {
MsgBox 48, Error, % "File not found.`n`n" gdip
Return
}
image := A_ScriptDir "\test3.png"
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromScreen("0|0|900|900")
FileRecycle % image
Gdip_SaveBitmapToFile(pBitmap, image)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
Run % image
file not found, sir
![image.png](./download/file.php?style=1&id=23342&sid=99dc2bdb43b66d7330e59e9325bf23d4)
- image.png (17.86 KiB) Viewed 500 times
Re: How to save img name day/time ?
Posted: 16 Sep 2023, 20:14
by DevWithCoffee
Would it be something like that?
Code: Select all
#Requires AutoHotkey v1.1.33
#Include <Gdip_All>
if (!pToken := Gdip_Startup())
{
MsgBox 48, Error, % "File not found.`n`n" gdip
Return
}
r::
image := A_ScriptDir "\" A_Hour "" A_Min ".png"
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromScreen("0|0|900|900")
FileRecycle % image
Gdip_SaveBitmapToFile(pBitmap, image)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
Run % image
Re: How to save img name day/time ?
Posted: 16 Sep 2023, 20:41
by mikeyww
When I provided the test script, I meant that you could run it without any changes other than lines 2 and 3. Just copy and paste the script, and change those two lines to match your Gdip AHK path. Next, run the script.
Re: How to save img name day/time ?
Posted: 16 Sep 2023, 22:35
by z1z123
mikeyww wrote: ↑16 Sep 2023, 20:41
When I provided the test script, I meant that you could run it without any changes other than lines 2 and 3. Just copy and paste the script, and change those
two lines to match your Gdip AHK path. Next, run the script.
then nothing happen, sir
--------------------------------------------------------
DevWithCoffee wrote: ↑16 Sep 2023, 20:14
Would it be something like that?
Code: Select all
#Requires AutoHotkey v1.1.33
#Include <Gdip_All>
if (!pToken := Gdip_Startup())
{
MsgBox 48, Error, % "File not found.`n`n" gdip
Return
}
r::
image := A_ScriptDir "\" A_Hour "" A_Min ".png"
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromScreen("0|0|900|900")
FileRecycle % image
Gdip_SaveBitmapToFile(pBitmap, image)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
Run % image
i'm edit it & it work perfect
Code: Select all
#Requires AutoHotkey v1.1.33
#Include C:\Users\admin\Desktop\p\Gdip_All.ahk
r::
loop
{
image := A_ScriptDir "\" A_Hour "" A_Min "" A_Sec ".png"
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromScreen("0|0|900|900")
FileRecycle % image
Gdip_SaveBitmapToFile(pBitmap, image)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
sleep 5000
}
Re: How to save img name day/time ?
Posted: 17 Sep 2023, 06:31
by mikeyww
What was the key difference or solution that made the script work?