semedboy Posted May 17, 2010 Share Posted May 17, 2010 This UDF checks if there is a file in the clipboard or not, it is only tested on windwos xp SP2.... if you find any bugs let me knowFunc _file_in_clipboard() DllCall("User32.dll", "int", "OpenClipboard", "hwnd", "") $file=DllCall("User32.dll", "int", "EnumClipboardFormats", "int", 49158) DllCall("User32.dll", "int", "CloseClipboard") If $file[0]=49159 Then Return 1 Else Return 0 EndIf EndFunc krasnoshtan 1 0x5748415420444F20594F552057414E543F Link to comment Share on other sites More sharing options...
Kealper Posted May 17, 2010 Share Posted May 17, 2010 Tried with a multitude of different file types, including folders, and it seems to work flawlessly from what I could tell. I could see this being quite useful as a safety-checking function (or error handling/prevention) for lots of different scripts that rely on the clipboard in some way or another; Nice work. krasnoshtan 1 Link to comment Share on other sites More sharing options...
JohnOne Posted May 17, 2010 Share Posted May 17, 2010 Just for my education, does this do the same? Func _ClipCheck() $Clip = ClipGet() If $Clip = "" Then Return False Return True EndFunc 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...
KaFu Posted May 17, 2010 Share Posted May 17, 2010 Just for my education, does this do the same?Nope, it doesn't. You're checking if there's anything on the clipboard to paste to a variable. He's checking wether the clipboard content is of a specific format, in this case a file... see also standard UDF _ClipBoard_EnumFormats(). What I don't know is, what format 49159 should be ... I would've assumed $CF_HDROP, but that's defined as 15. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
JohnOne Posted May 17, 2010 Share Posted May 17, 2010 I see, it checks if its some sort of file as opposed to just anything like text. 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...
KaFu Posted May 17, 2010 Share Posted May 17, 2010 Copied to clipboard files are also plain text, but of a special format so that Windows knows they're meant for a copy/cut & paste operation. Start this and copy a plain text to clipboard (text / your function will trigger), a file or more files (text / both function will trigger) and finally copy picture content (Bitmap(?) / no function will trigger). ClipPut("") While 1 Sleep(1000) ConsoleWrite(TimerInit() & @tab & "_ClipCheck()" & @TAB & @TAB & _ClipCheck() & @CRLF) ConsoleWrite(TimerInit() & @tab & "_file_in_clipboard()" & @TAB & _file_in_clipboard() & @CRLF) WEnd Func _ClipCheck() $Clip = ClipGet() If $Clip = "" Then Return 0 Return 1 EndFunc ;==>_ClipCheck Func _file_in_clipboard() DllCall("User32.dll", "int", "OpenClipboard", "hwnd", "") $file=DllCall("User32.dll", "int", "EnumClipboardFormats", "int", 49158) DllCall("User32.dll", "int", "CloseClipboard") If $file[0]=49159 Then Return 1 Else Return 0 EndIf EndFunc krasnoshtan 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
JohnOne Posted May 17, 2010 Share Posted May 17, 2010 cheers I was looking at the numbers on MSDN text = 1 and so forth Perhaps that number is some calculation of all the filetypes, much like they are in msgbox flags. 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...
Kealper Posted May 17, 2010 Share Posted May 17, 2010 Perhaps that number is some calculation of all the filetypes, much like they are in msgbox flags.Could be, ya never know with those crazy Microsoft devs >.> Link to comment Share on other sites More sharing options...
semedboy Posted May 18, 2010 Author Share Posted May 18, 2010 thanks for the comments .... and can anyone tell me how to post on example scripts 0x5748415420444F20594F552057414E543F Link to comment Share on other sites More sharing options...
JohnOne Posted May 18, 2010 Share Posted May 18, 2010 Just post the same as anywhere else now you have 5 posts. 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...
semedboy Posted May 18, 2010 Author Share Posted May 18, 2010 Just post the same as anywhere else now you have 5 posts.thanks 0x5748415420444F20594F552057414E543F Link to comment Share on other sites More sharing options...
JohnOne Posted May 18, 2010 Share Posted May 18, 2010 (edited) Can you explain where you got "49158" format from, and what it means ?Edit: dosent matter I got it"Format ID #49158: Format Name = "FileName""So it identifies that the data in the clipboard has a filename, hence it is a file rather than just a chunck of text copied from somewhere etc...some othersFormat ID #49161: Format Name = "DataObject"Format ID #49267: Format Name = "Shell IDList Array"Format ID #15: Format Name = ""Format ID #49314: Format Name = "Preferred DropEffect"Format ID #49305: Format Name = "Shell Object Offsets"Format ID #49158: Format Name = "FileName"Format ID #49159: Format Name = "FileNameW" ;Next available I assume.Format ID #49171: Format Name = "Ole Private Data"moreFormat ID #49166: Format Name = "Object Descriptor"Format ID #49272: Format Name = "Rich Text Format"Format ID #49457: Format Name = "HTML Format"Format ID #49156: Format Name = "Native"Format ID #49167: Format Name = "Link Source Descriptor"Format ID #49154: Format Name = "ObjectLink"Format ID #49545: Format Name = "Hyperlink" Edited May 18, 2010 by JohnOne 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...
Ascend4nt Posted May 18, 2010 Share Posted May 18, 2010 (edited) To be on the safe side, you might want to do this first before checking (in case number values change): $iCF_FileNameW=_ClipBoard_RegisterFormat("FileNameW") If _ClipBoard_IsFormatAvailable($iCF_FileNameW) Then $bFileInClipboard=True Also, a slightly modified version of the Help file script for Function _ClipBoard_EnumFormats which will show the numbers of the formats: expandcollapse popup#include <GuiConstantsEx.au3> #include <ClipBoard.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $iMemo _Main() Func _Main() Local $hGUI, $iFormat, $iCount ; Create GUI $hGUI = GUICreate("Clipboard", 600, 400) $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Open the clipboard If Not _ClipBoard_Open ($hGUI) Then _WinAPI_ShowError ("_ClipBoard_Open failed") ; Show clipboard formats available MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats ()) ; Enumerate clipboard formats Do $iFormat = _ClipBoard_EnumFormats ($iFormat) If $iFormat <> 0 Then $iCount += 1 MemoWrite("Clipboard format " & $iCount & " Number:"&$iFormat&" String: " & _ClipBoard_FormatStr ($iFormat)) EndIf Until $iFormat = 0 ; Close the clipboard _ClipBoard_Close () ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Write message to memo Func MemoWrite($sMessage = "") GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Edited May 18, 2010 by Ascend4nt krasnoshtan 1 My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) 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