k4rl3on

[SOLVED] ClipGet() consumes 100% of CPU resources

30 posts in this topic

#1 ·  Posted (edited)

hello

I have problem with ClipGet () function: If the clipboard contains a large amount of data the use of the function pushes the consumption of cpu resources to 100% and my script unresponds until I force it to end.
I tried to work around the problem by limiting the size of the recovered data from the clipboard

 

Local = $ClipBoardData = StringMid(ClipGet (), 1.1024)

I also used:


 

DllCall ("psapi.dll", "int", "EmptyWorkingSet", "long", -1)

to free the memory after each call to ClipGet ()

Edited by k4rl3on

Share this post


Link to post
Share on other sites



Welcome to Autoit and the forum!

A few questions:

  • How large is "a large amount of data"? How many MB?
  • What type of data? Text, picture ...?
  • Which version of Windows do you run?
  • Which version of AutoIt do you run?
Local = $ClipBoardData = StringMid(ClipGet (), 1.1024)

won't work as it has some syntax errors. I think it should be

Local $ClipBoardData = StringMid(ClipGet (), 1, 1024)

to grab the first 1024 bytes of the data from the clipboard. But this will not solve your performance problems as it first retrieves ALL data from the clipboard before StringMid is being executed.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

 

  • the large amount of data: i try to copy 3650 .png files with a size of: 16px = 3650*1.12 = 4088 / 1024 = 3,9 MB
  • type: i want just the list of those files names as ClipGet() returns it = Text
  • version of Windows: XP 500MB RAM.
  • AutoIt (Latest Stable Version) v3.3.14.2

Yes i use

Local $ClipBoardData = StringMid(ClipGet (), 1, 1024)

 

Thank you

Edited by k4rl3on

Share this post


Link to post
Share on other sites

How do you fill the clipboard?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

By a CTRL+C after selecting the files

Share this post


Link to post
Share on other sites

Do I understand you correctly that you just want the names of the selected files, not the files itself?
If this is true then this little script shows how to grab the list of selected files from Windows Explorer:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you for your help, 

But what i need is to get the content of the clipboard, however if its a simple copied text or a list of files names, my problem like is presented above: ClipGet() do correctly that until there is big data in the clipboard, ClipGet() consumes 100% of CPU resources. what i need is an alternative to ClipGet() that dont crash my script when there is big data in the clipboard.

Share this post


Link to post
Share on other sites

You might want to try using _Clipboard_GetData with the text format to see if it's any faster or lighter on your CPU.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

thank you but still slower on my cpu and when i use $CF_HDROP returns the handle to the files list how can i with this handle get the files names?

Share this post


Link to post
Share on other sites

Is it necessary to store data in the clipboard? What are you trying to use the data you copy into clipboard in and how will it interact with the program?


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

my script is a clipboard monitor, it checks clipboard content every second and store it into a log file.

Share this post


Link to post
Share on other sites

Why not post it?

Part of finding a problem is letting other people try it.

So many times I've seen threads like these go on for weeks, then the op says "oops sorry I had spilled iron brew on my laptop and broke it"

1 person likes this

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Seeing your source and what you have already tried would help us figure out the issue.


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Hi,

Following the suggestion from jguinch

about Using _ClipBoard_SetViewer instead of ClipGet()

Here is what i done:

#include <Clipboard.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hNext = 0

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 400, 100)
;~  $hGUI = WinGetHandle(WinGetTitle(""))
;~  $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
;~  GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize clipboard viewer
    $g_hNext = _ClipBoard_SetViewer($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    MemoWrite("GUI handle ....: " & $hGUI)
    MemoWrite("Viewer handle .: " & _ClipBoard_GetViewer())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain($hGUI, $g_hNext)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    ConsoleWrite($sMessage & @CRLF)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $wParam = $g_hNext Then
        $g_hNext = $lParam
        ; Otherwise pass the message to the next viewer
    ElseIf $g_hNext <> 0 Then
        _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Display any text on clipboard
    ;Check clipboard Content type
    If _ClipBoardContentType() = 4 Then
        ; If files copied:
        $Content = _ClipBoard_GetData($CF_HDROP)
    Else
        $Content = _ClipBoard_GetData()
    EndIf
    FileWrite("ClipBoardLog.txt",_TimeStamp()&" - "&$Content&@CRLF)
    ; Pass the message to the next viewer
    If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam)
EndFunc   ;==>WM_DRAWCLIPBOARD

Func _ClipBoardContentType()
    DllCall("User32.dll", "int", "OpenClipboard", "hwnd", "")
    $ret = DllCall("User32.dll", "int", "EnumClipboardFormats", "int", 49158)
    DllCall("User32.dll", "int", "CloseClipboard")
    If $ret[0] = 49159 Then
        Return 4
    Else
        Return 3
    EndIf
EndFunc

Func _TimeStamp()
    Local $Ret
    $Ret = DllCall('CrtDll.dll', 'long:cdecl', 'time', 'ptr', 0)
    If Not @error Then
        Return $Ret[0]
    Else
        Return ""
    EndIf
EndFunc

the code based on the example of _ClipBoard_SetViewer with litte modification to check the clipboard content's type, and log it into a .txt file, and its work without any problem concerning CPU ressources  consumption.

but still two problems to resolve:

  1. In case of files in clipboard _ClipBoard_GetData($CF_HDROP) returns binary data like: 0x14000000000000000000000000000000010000004.... how can i get file name from it?
  2. how can i run this without creating a new GUI: doing something like :
    $hGUI = WinGetHandle(WinGetTitle(""))

and thank you again

Edited by k4rl3on

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

  1. In case of files in clipboard _ClipBoard_GetData($CF_HDROP) returns binary data like: 0x14000000000000000000000000000000010000004.... how can i get file name from it?

Everything you might want to know about this can be found here.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb776902(v=vs.85).aspx#CF_HDROP

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

thank you BrewManNH for the link.

here is what i tried to do:

from the documention of DragQueryFile i created a function:

Func WM_DROPFILES_FUNC($Content)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    ConsoleWrite("["&$nAmt[0]&"]"&@CRLF)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        MemoWrite($gaDropFiles[$i])
        ;If StringInStr(FileGetAttrib($gaDropFiles[$i]), "D") Then $gaDropFiles[$i] = $gaDropFiles[$i] & "\*.*"
        $pFileName = 0
    Next
EndFunc

i gave it the return of _ClipBoard_GetData($CF_HDROP) as parameter as explained in te docuentation of DragQueryFile function:

hDrop [in]

Type: HDROP

Identifier of the structure that contains the file names of the dropped files.

is this the expected value?

DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)

which must return the number of file in clipboard, returns -1 when i'm copying a file :(

the complete code:

#include <Clipboard.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

Global $gaDropFiles[1]
Global $g_idMemo, $g_hNext = 0

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 400, 100)
;~     $hGUI = WinGetHandle(WinGetTitle(""))
;~     $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
;~     GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize clipboard viewer
    $g_hNext = _ClipBoard_SetViewer($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")
;~     GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_FUNC")

    MemoWrite("GUI handle ....: " & $hGUI)
    MemoWrite("Viewer handle .: " & _ClipBoard_GetViewer())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain($hGUI, $g_hNext)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    ConsoleWrite($sMessage & @CRLF)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $wParam = $g_hNext Then
        $g_hNext = $lParam
        ; Otherwise pass the message to the next viewer
    ElseIf $g_hNext <> 0 Then
        _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Display any text on clipboard
    If _ClipBoardContentType() = 4 Then
        $Bin = _ClipBoard_GetData($CF_HDROP)
        WM_DROPFILES_FUNC($Bin)
    Else
        $Content = _ClipBoard_GetData()
    EndIf
    FileWrite("ClipBoardLog.txt",_TimeStamp()&" - "&$Content&@CRLF)
    ; Pass the message to the next viewer
    If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam)
EndFunc   ;==>WM_DRAWCLIPBOARD

Func WM_DROPFILES_FUNC($Content)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    ConsoleWrite("["&$nAmt[0]&"]"&@CRLF)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        MemoWrite($gaDropFiles[$i])
        ;If StringInStr(FileGetAttrib($gaDropFiles[$i]), "D") Then $gaDropFiles[$i] = $gaDropFiles[$i] & "\*.*"
        $pFileName = 0
    Next
EndFunc

Func _ClipBoardContentType()
    DllCall("User32.dll", "int", "OpenClipboard", "hwnd", "")
    $ret = DllCall("User32.dll", "int", "EnumClipboardFormats", "int", 49158)
    DllCall("User32.dll", "int", "CloseClipboard")
    If $ret[0] = 49159 Then
        Return 4
    Else
        Return 3
    EndIf
EndFunc

Func _TimeStamp()
    Local $Ret
    $Ret = DllCall('CrtDll.dll', 'long:cdecl', 'time', 'ptr', 0)
    If Not @error Then
        Return $Ret[0]
    Else
        Return ""
    EndIf
EndFunc
 

 

 

 

 

Edited by k4rl3on

Share this post


Link to post
Share on other sites

Is there something you need the list of files for or is this just something you thought you'd try and get working? If you just need a list of files in a folder, there are easier ways of going about this.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

my script is a clipboard monitor, it checks clipboard content every second and store it into a log file.

i tried with 

$hdrop = _ClipBoard_GetDataEx($CF_HDROP)

which returns a handle of the object in the clipboard call

Func WM_DROPFILES_FUNC($Content)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    ConsoleWrite("["&$nAmt[0]&"]"&@CRLF)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $Content, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        MemoWrite($gaDropFiles[$i])
        ;If StringInStr(FileGetAttrib($gaDropFiles[$i]), "D") Then $gaDropFiles[$i] = $gaDropFiles[$i] & "\*.*"
        $pFileName = 0
    Next
EndFunc

with it as parameter, but still returns -1 as number of files in the clipboard after copying or drag drop some files as test :(

Edit: i also tried to put the created GUI handle as parameter for the function with no result :(

Edited by k4rl3on

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • AndreyS
      By AndreyS
      Developers, can anyone explain this phenomenon to me?
      Run this code and wait for nothing without doing a few minutes and you will start receiving randomly, either one or the second message. But none of them should never appear on the logic of the code!
      As I understand sometimes the function ClipGet () returns an empty value. Why is this happening?
      Dim $ClipGetText ClipPut("12345") While 1 Sleep(5) ;reduced to 5 to better see the problem if ClipGet()<>$ClipGetText And ClipGet()<>"" Then $ClipGetText=ClipGet() Beep(800,100) ConsoleWrite(ClipGet()&"|"&$ClipGetText&@CRLF) ElseIf ClipGet()="" Then Beep(800,100) ConsoleWrite("Empty"&@CRLF) EndIf WEnd  
    • rudi
      By rudi
      Hello.
      I'm too stupid to see my mistake:
      To investigate the internal "dictionary" of TIFF files I'd like to read in the files in binary mode and to check, if there are more than one pages "in" this TIFF.
      Notepad++, "View as Hex" is presenting the first bytes as "49 49 2a 20 08 20 20 20 12" for the TIF attached to this posting
      The "TIFF Header Format" is easy:
      Offset 00h, 2 Byte = Byte Order, "II"=intel, "MM"=motorola. (I = 0x49)
      --> II
      Offset 02h, 2 Byte = Version Nr.
      Offset 04h, 4 Byte = pointer to first IFD entry
      Description of TIFF header: https://www.awaresystems.be/imaging/tiff/faq.html#q3
       

      Howto read and analyse the binary content correctly? This is my messy, not operational code:
       
      $sampleTiff="H:\daten\tif\11\11\111111.TIF" $h=FileOpen($sampleTiff,16) $content=FileRead($h) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console FileClose($h) $type=VarGetType($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $type = ' & $type & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $ToString=BinaryToString($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ToString = ' & $ToString & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & @CRLF) $content=StringTrimLeft($content,2) ; cut off the leading "0x" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console for $i = 1 to 8 step 8 $next=StringMid($content,$i,2) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $next = ' & $next & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Chr=BinaryToString($next) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Chr = ' & $Chr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & "---" & @CRLF) Next Regards, Rudi.
      111111.TIF
    • usmiv4o
      By usmiv4o
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.3 Author: usmiv4o Script Function: AutoIt script to check if files in directory are changed. It is usefull for security contra-inteligense measures. Function Name: LoadTripwireDB() Description: Loads database (text file tripwire.txt) and compare files in /test folder for changes. compares Hash (MD5) checksums. If they are not the same starts Initial() Function Name: Initial() Description: Checks directory and makes index of files and their MD5 checksums in text file (tripwire.txt) Function Name: Hush() Description: Checks file and returns its MD5 checksum. Requirement(s): Windows XP Return Value(s): On Success - Returns true. Files are the same as before. On Failure - return false. Example: LoadTripwireDB() #ce ---------------------------------------------------------------------------- #include <Crypt.au3> #include <File.au3> #include <Array.au3> $sDir = @ScriptDir & "\Test" $sFilePath = @ScriptDir & "\tripwire.txt" Func Hush(ByRef $sFile) $sRead = FileOpen( $sFile) $dHash = _Crypt_HashData($sRead, $CALG_MD5) ; Create a hash of the text entered. ConsoleWrite("Hash of file " & $sFile & " is " & $dHash & @CRLF) EndFunc ;ConsoleWrite("Files in Dir are " & $aScriptDir[0] & @CRLF) ;$sFilePath = @ScriptDir & "\Examples.txt" ;_FileWriteFromArray($sFilePath, $aScriptDir, 1) ;_ArrayDisplay($aScriptDir, "1D display") Func Initial() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 $dHash = _Crypt_HashData($i, $CALG_MD5) ;ConsoleWrite("File " & $aScriptDir[$i] & " is " & $dHash & @CRLF) ConsoleWrite($aScriptDir[$i] & ":" & $dHash & @CRLF) ;Hush($aScriptDir[$i]) ;FileWrite $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") EndIf FileWrite($hFileOpen, $aScriptDir[$i] & ":" & $dHash & @CRLF) Next EndFunc Func Monitor() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 Next EndFunc Func LoadTripwireDB() $comparison_ok = false $dArray = _FileListToArray($sDir) ;directory $dArray0 = UBound($dArray) - 1 $fArray = FileReadToArray($sFilePath) ;file $fArray0 = UBound($fArray) ;_ArrayDisplay($dArray, "files array") if $dArray0 = $fArray0 Then ; are file same as recorded in txt file? ;ConsoleWrite("files in monitoring dir: " & $dArray[0] & " = file recorded: " & $fArray0 & @CRLF & $fArray[0]& @CRLF) for $i = 1 To UBound($dArray) - 1 ;ConsoleWrite("i = " & $i & @CRLF) $dHash = _Crypt_HashData($i, $CALG_MD5) ;binary ;$dHash = BinaryToString($dHash) $ffhash = StringSplit( $fArray[$i-1],":") $fhash = $ffhash[2] ;ConsoleWrite("IsBinary $dHash " & IsBinary($dHash) & @CRLF) if $dHash = $fhash Then ;if compared hashes are equal ;ConsoleWrite($fhash & ":" & $dHash & " equal" & @CRLF) ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: yes " & @CRLF) Else ;if compared hashes are not equal ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: not " & @CRLF) ;MsgBox(0,"hash md5",$fhash & ":" & $dHash & " not equal") EndIf Next ;ConsoleWrite("hashes are equal" & @CRLF) $comparison_ok = true Else ConsoleWrite("number of files in monitoring dir are not same as recorded" & @CRLF) ConsoleWrite("directory: " & $dArray[0] &":"& "files: " & UBound($fArray) - 1 & @CRLF) EndIf Return $comparison_ok EndFunc #main if LoadTripwireDB() = true Then ConsoleWrite(" hashes are equal " & @CRLF) ElseIf LoadTripwireDB() <> true Then ConsoleWrite(" hashes are not equal " & @CRLF) ConsoleWrite(" hashes are not equal " & @CRLF) Initial() EndIf  
      tripwire.au3
      tripwire.txt
    • VIP
      By VIP
      The simple widget shows the percentage of cpu, ram used and the CPU temperature.
      - Sleep Time: 2s for apdate GUI info.
      - Every 30s check, sync and update time for computer.
      - Every 60s auto Reduce Memory.
      - If you want it to run at startup, copy or create shortcut at: "%ProgramData%\Data\Microsoft\Windows\Start Menu\Programs\Startup"
      ;# CPU_Widget_TimeSync.exe ;CRC32: F6640DFA ;MD5: 3283875BA29E7143F1A9AB9018374E08 ;SHA-1: AD85B38BAE15A6962D8E6C1A89B164BE6840C877
      Function code from:
      CPU: 
      RAM:  MemGetStats ( )
      Memory:   _WinAPI_EmptyWorkingSet ()
       
    • 5ervant
      By 5ervant
      What's the best way to receive file from a desktop app?
      app.exe will execute a cmd with "au3file.exe /path/of/the/file.xml" and the au3file.exe will get and delete that. Or else? THE MOST IMPORTANT PART OF THE QUESTION
      And best way to transfer file to a desktop app?
      au3file.exe do a $_POST request and the app.exe MUST HAVE a local HTTP server that can receive $_POST, but it looks heavy 'cause the app must have a server such XAMPP. au3file.exe execute a cmd with "app.exe /path/of/the/file.xml" and the app.exe will now get that file and delete. Or else?