Before: After: it doesn't matter if there are small artifacts around the drawing as long as you can clearly see all the lines.
below is the code i'm currently using
Code: Select all
#include %A_ScriptDir%\Gdip_All.ahk
LaunchScreenSketch(A_ScriptDir . "\test.png")
return
LaunchScreenSketch(FileName){
;save clipboard
currentClipboard := clipboardAll
clipboard :=
clipStatus := ""
;launch screen sketch
Run, ms-penworkspace://Capture
CoordMode, Mouse, Screen
;get current mousePos
MouseGetPos, currentX, CurrentY
while(Title != "Windows Ink Workspace"){
;Move mouse ontop of windows ink work space
MouseMove, 10, 10 , 0
;get window HWND
MouseGetPos, , , WindowsInkHWND
;get window title
WinGetTitle, Title, % "Ahk_id " WindowsInkHWND
sleep 50
}
;return Mouse to previous position
MouseMove, %currentX%, %currentY% , 0
while(!clipStatus && winexist("Ahk_id " WindowsInkHWND)){
;wait for clipboard to contain something or windows ink to close
sleep 40
clipStatus := clipboardAll
}
;if something is on the clipboard save it as a png
if(clipStatus){
;send esc to close screen sketch, keep sending until it is closed
while(winexist("Ahk_id " WindowsInkHWND)){
sleep 300
;sendinput {esc}
WinClose , Ahk_id %WindowsInkHWND%
}
;save image from clipboard
pToken := Gdip_Startup()
pBitmap := Gdip_CreateBitmapFromClipboard()
Gdip_SaveBitmapToFile(pBitmap, FileName)
; ************************************************************************
;code here to filter out all colors except the red pen and save it as a different filename
; ************************************************************************
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
clipboard := currentClipboard
return FileName
}
;sleep 500
;reset clipboard
clipboard := currentClipboard
return 0
}
thanks grimboto