EvilRubberDuck Posted September 10, 2016 Share Posted September 10, 2016 (edited) #include <GDIPlus.au3> #include <ClipBoard.au3> ; Capture full screen Send("{PRINTSCREEN}") ; Screen ;Send("!{PRINTSCREEN}") ; window _Main() ShellExecute(@ScriptDir & "\Image.jpg") Func _Main() Local $hBmp, $hImage If Not _ClipBoard_Open(0) Then _WinAPI_ShowError("_ClipBoard_Open failed") $hBmp = _ClipBoard_GetDataEx($CF_BITMAP) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) ; Save bitmap to file _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Image.jpg") ;$sNewName) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() _ClipBoard_Close() EndFunc ;==>_Main Hey guys! I got this code from this post: On 6/10/2010 at 11:46 PM, Malkey said: Max Kipness Your example appears to be trying to combine these two methods. #include <ScreenCapture.au3> _ScreenCapture_Capture(@ScriptDir & "\GDIPlus_Image.jpg") ShellExecute(@ScriptDir & "\GDIPlus_Image.jpg") and #include <GDIPlus.au3> #include <ClipBoard.au3> ; Capture full screen Send("{PRINTSCREEN}") ; Screen ;Send("!{PRINTSCREEN}") ; window _Main() ShellExecute(@ScriptDir & "\Image.jpg") Func _Main() Local $hBmp, $hImage If Not _ClipBoard_Open(0) Then _WinAPI_ShowError("_ClipBoard_Open failed") $hBmp = _ClipBoard_GetDataEx($CF_BITMAP) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) ; Save bitmap to file _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Image.jpg") ;$sNewName) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() _ClipBoard_Close() EndFunc ;==>_Main But i get the error: Clipboar open failed. Anyone can help me? Thank you Edited September 10, 2016 by EvilRubberDuck Link to comment Share on other sites More sharing options...
rcmaehl Posted September 10, 2016 Share Posted September 10, 2016 Looks like a bit has changed since 6 years ago code wise. I'm checking https://www.autoitscript.com/autoit3/docs/libfunctions/Clipboard Management.htm for what has and I'll see what I can do. My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
rcmaehl Posted September 10, 2016 Share Posted September 10, 2016 Not seeing anything yet, but if you're really just trying to save a screenshot and nothing else I'd recommend using the example from: https://www.autoitscript.com/autoit3/docs/libfunctions/_ScreenCapture_SaveImage.htm My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
EvilRubberDuck Posted September 10, 2016 Author Share Posted September 10, 2016 I know of that function, but i need it to be using the print screen key. I tried to add more #include, close the clipboard before open it but i couldn't get it to work. :/ Link to comment Share on other sites More sharing options...
EvilRubberDuck Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) I read this: This function fails if another window has the clipboard open. And tried to use this function ( _ClipBoard_GetOpenWindow ) before open clipboard to see if any window has clipboard opened and i got this: 0x00010010. But i don't know how to identify the window with this handle :/ If it is any window. Edited September 10, 2016 by EvilRubberDuck Link to comment Share on other sites More sharing options...
rcmaehl Posted September 10, 2016 Share Posted September 10, 2016 3 minutes ago, EvilRubberDuck said: I read this: This function fails if another window has the clipboard open. And tried to use this function ( _ClipBoard_GetOpenWindow ) before open clipboard to see if any window has clipboard opened and i got this: 0x00010010. But i don't know how to identify the window with this handle :/ If it is any window. You can use Example 2 from https://www.autoitscript.com/autoit3/docs/functions/WinList.htm to find out My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
EvilRubberDuck Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) #include <GDIPlus.au3> #include <ClipBoard.au3> #include <MsgBoxConstants.au3> ; Capture full screen Send("{PRINTSCREEN}") ; Screen ;Send("!{PRINTSCREEN}") ; window _Main() ShellExecute(@ScriptDir & "\Image.jpg") Func _Main() Local $hBmp, $hImage MsgBox(0,"ola", _ClipBoard_GetOpenWindow () ) If Not _ClipBoard_Open(0) Then _WinAPI_ShowError("_ClipBoard_Open failed") $hBmp = _ClipBoard_GetDataEx($CF_BITMAP) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) ; Save bitmap to file _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Image.jpg") ;$sNewName) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() _ClipBoard_Close() EndFunc ;==>_Main I just want to laugh... so if i put the msgbox there to show me the handle of the window wih clipboard open it actually works the whole code. I get the printscreen. If i take ou that line it doesn't work... Maybe if i put a sleep fucntion ... Edit: Yap! If i put sleep(100) before clipboard_open, the code works! Maybe it takes more time to get the print to the clipboard than it gets to autoit to get from line 5 to line 15. It must be it right? Edited September 10, 2016 by EvilRubberDuck Link to comment Share on other sites More sharing options...
EvilRubberDuck Posted September 10, 2016 Author Share Posted September 10, 2016 9 minutes ago, rcmaehl said: You can use Example 2 from https://www.autoitscript.com/autoit3/docs/functions/WinList.htm to find out I used it and didn't get any window with that handle! Link to comment Share on other sites More sharing options...
rcmaehl Posted September 10, 2016 Share Posted September 10, 2016 (edited) 29 minutes ago, EvilRubberDuck said: I used it and didn't get any window with that handle! DRAMATIC MUSIC INTENSIFIES 33 minutes ago, EvilRubberDuck said: I just want to laugh... so if i put the msgbox there to show me the handle of the window wih clipboard open it actually works the whole code. I get the printscreen. If i take ou that line it doesn't work... Maybe if i put a sleep fucntion ... Edit: Yap! If i put sleep(100) before clipboard_open, the code works! Maybe it takes more time to get the print to the clipboard than it gets to autoit to get from line 5 to line 15. It must be it right? Glad your issue got resolved. Perhaps the printscreen button just doesn't like closing early which is what that window handle was. Edited September 10, 2016 by rcmaehl My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF 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