Tomjr Posted June 10, 2011 Share Posted June 10, 2011 Is it possible to get a signature effect in a GUI or anything else that will record the mouse drag and display it on the screen. I'm trying to make a program for a tablet computer with a pen so it will be like signing paper. One more thing I'd like to be able to copy the signature to the clip board. So it would probably be an image. Thanks Link to comment Share on other sites More sharing options...
JohnOne Posted June 10, 2011 Share Posted June 10, 2011 Is it possible to get a signature effect in a GUI or anything else that will record the mouse drag and display it on the screen.I'd say yes, perhaps you can create a paint object (Unsure), or use some gdi voodoo.I'm trying to make a program for a tablet computer with a pen so it will be like signing paper. Good for youOne more thing I'd like to be able to copy the signature to the clip board. So it would probably be an image.Thats a lovely storyThanks You're welcome AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Tomjr Posted June 10, 2011 Author Share Posted June 10, 2011 (edited) I'd say yes, perhaps you can create a paint object (Unsure), or use some gdi voodoo.I'll look in to it.Good for youYeah I know Thats a lovely storyThanks.You're welcomeK. Edited June 10, 2011 by Tomjr Link to comment Share on other sites More sharing options...
UEZ Posted June 10, 2011 Share Posted June 10, 2011 (edited) Try this: expandcollapse popup#include <Clipboard.au3> #include <Constants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> Opt("GUIOnEventMode", 1) Opt("MouseCoordMode", 2) _GDIPlus_Startup() Global Const $iW = 800 Global Const $iH = 600 Global Const $hGUI = GUICreate("GDI+ Painting by UEZ 2011", $iW, $iH) Global Const $idButtonExit = GUICtrlCreateButton("Exit", 10, $iH - 40, 50, 30) GUICtrlSetOnEvent(-1, "_Exit") Global Const $idButton2CB = GUICtrlCreateButton("Image 2 Clipboard", 100, $iH - 40, 100, 30) GUICtrlSetOnEvent(-1, "I2CB") Global Const $idClear = GUICtrlCreateButton("Clear Image", 210, $iH - 40, 100, 30) GUICtrlSetOnEvent(-1, "Clear") Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH - 50, $hGraphic) Global Const $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) Global Const $PenWidth = 4 Global Const $hPen = _GDIPlus_PenCreate (0xFFFF0000, $PenWidth) GUISetState() Clear() Global Const $dll = DllOpen("user32.dll") GUISetOnEvent(-3, "_Exit") Global Const $adjust_x = $PenWidth / 2 Global Const $adjust_y = 4 Global $a, $mo, $MX, $MXOld, $MY, $MYOld While Sleep(30) If WinActive($hGUI) Then $a = GUIGetCursorInfo() If $a[2] Then $mo = MouseGetCursor() Paint() GUISetCursor($mo, 1, $hGUI) EndIf EndIf WEnd Func Paint() $MXOld = MouseGetPos(0) + $adjust_x $MYOld = MouseGetPos(1) - $adjust_y While _IsPressed("01", $dll) GUISetCursor(0, 1, $hGUI) $MX = MouseGetPos(0) + $adjust_x $MY = MouseGetPos(1) - $adjust_y _GDIPlus_GraphicsDrawLine($hBackbuffer, $MX, $MY, $MXOld, $MYOld, $hPen) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH - 50) $MXOld = $MX $MYOld = $MY WEnd EndFunc Func I2CB() Local $hBmp, $hHBITMAP If Not _ClipBoard_Open(0) Then Return SetError(1, 0, 0) ;_ClipBoard_Open failed! If Not _ClipBoard_Empty() Then Return SetError(2, 0, 0) ;_ClipBoard_Empty failed! $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) $hBmp = DllCall("User32.dll", "hwnd", "CopyImage", "handle", $hHBITMAP, "UINT", 0, "int", 0, "int", 0,"UINT", $LR_COPYDELETEORG + $LR_COPYRETURNORG) ;http://msdn.microsoft.com/en-us/library/ms648031(v=vs.85).aspx $hBmp = $hBmp[0] _WinAPI_DeleteObject($hHBITMAP) If Not _ClipBoard_SetDataEx($hBmp, $CF_BITMAP) Then _WinAPI_DeleteObject($hBmp) Return SetError(3, 0, 0) ;_ClipBoard_SetDataEx failed! EndIf If Not _ClipBoard_Close() Then Return SetError(4, 0, 0) ;_ClipBoard_Close failed! _WinAPI_DeleteObject($hBmp) Return MsgBox(0, "Information", "Image put to clipboard properly!", 10) EndFunc Func Clear() _GDIPlus_GraphicsClear($hBackbuffer, 0xFFD0D0D0) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH - 50) EndFunc Func _Exit() DllClose($dll) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose ($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit EndFunc You can add some more features like saving, color selection, pen size, etc. Br, UEZ Edit: added clear button Edited June 10, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Tomjr Posted June 10, 2011 Author Share Posted June 10, 2011 Try this: expandcollapse popup#include <Clipboard.au3> #include <Constants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> Opt("GUIOnEventMode", 1) Opt("MouseCoordMode", 2) _GDIPlus_Startup() Global Const $iW = 800 Global Const $iH = 600 Global Const $hGUI = GUICreate("GDI+ Painting by UEZ 2011", $iW, $iH) Global Const $idButtonExit = GUICtrlCreateButton("Exit", 10, $iH - 40, 50, 30) GUICtrlSetOnEvent(-1, "_Exit") Global Const $idButton2CB = GUICtrlCreateButton("Image 2 Clipboard", 100, $iH - 40, 100, 30) GUICtrlSetOnEvent(-1, "I2CB") Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH - 50, $hGraphic) Global Const $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) _GDIPlus_GraphicsClear($hBackbuffer, 0xFFD0D0D0) Global Const $PenWidth = 4 Global Const $hPen = _GDIPlus_PenCreate (0xFFFF0000, $PenWidth) GUISetState() _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH - 50) Global Const $dll = DllOpen("user32.dll") GUISetOnEvent(-3, "_Exit") Global Const $adjust_x = $PenWidth / 2 Global Const $adjust_y = 4 Global $a, $mo, $MX, $MXOld, $MY, $MYOld While Sleep(30) If WinActive($hGUI) Then $a = GUIGetCursorInfo() If $a[2] Then $mo = MouseGetCursor() Paint() GUISetCursor($mo, 1, $hGUI) EndIf EndIf WEnd Func Paint() $MXOld = MouseGetPos(0) + $adjust_x $MYOld = MouseGetPos(1) - $adjust_y While _IsPressed("01", $dll) GUISetCursor(0, 1, $hGUI) $MX = MouseGetPos(0) + $adjust_x $MY = MouseGetPos(1) - $adjust_y _GDIPlus_GraphicsDrawLine($hBackbuffer, $MX, $MY, $MXOld, $MYOld, $hPen) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH - 50) $MXOld = $MX $MYOld = $MY WEnd EndFunc Func I2CB() Local $hBmp, $hHBITMAP If Not _ClipBoard_Open(0) Then Return SetError(1, 0, 0) ;_ClipBoard_Open failed! If Not _ClipBoard_Empty() Then Return SetError(2, 0, 0) ;_ClipBoard_Empty failed! $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) $hBmp = DllCall("User32.dll", "hwnd", "CopyImage", "handle", $hHBITMAP, "UINT", 0, "int", 0, "int", 0,"UINT", $LR_COPYDELETEORG + $LR_COPYRETURNORG) ;http://msdn.microsoft.com/en-us/library/ms648031(v=vs.85).aspx $hBmp = $hBmp[0] _WinAPI_DeleteObject($hHBITMAP) If Not _ClipBoard_SetDataEx($hBmp, $CF_BITMAP) Then _WinAPI_DeleteObject($hBmp) Return SetError(3, 0, 0) ;_ClipBoard_SetDataEx failed! EndIf If Not _ClipBoard_Close() Then Return SetError(4, 0, 0) ;_ClipBoard_Close failed! _WinAPI_DeleteObject($hBmp) Return MsgBox(0, "Information", "Image put to clipboard properly!", 10) EndFunc Func _Exit() DllClose($dll) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose ($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit EndFunc You can add some more features like saving, color selection, pen size, etc. Br, UEZ THANK YOU =D Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now