Jump to content
k4rl3on

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

Recommended Posts

k4rl3on

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
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
k4rl3on

 

  • 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
water

How do you fill the clipboard?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
k4rl3on

By a CTRL+C after selecting the files

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
k4rl3on

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
BrewManNH

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
k4rl3on

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
BetaLeaf

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
k4rl3on

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
JohnOne

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"

  • Like 1

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
BetaLeaf

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
k4rl3on

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
BrewManNH
  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
k4rl3on

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
BrewManNH

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
k4rl3on

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

    • argumentum
      By argumentum
      The back story:
      I've got a Dell XPS w/ i7-8700K. The fastest, by single core, I could get, by well known PC maker.
      The problem is that the fan can get so loud, like, REALLY LOUD, I can not use the CPU at its max. clock speed.
      I could leave it at 90% all the time and not use this but I want to have the full 4.x Ghz and no parked cores, at all times, if I can.
      But as room temperature and CPU load changes, a set throttle, may still make fan noise.
      The solution:
      To avoid the fan from going "airplane turbine mode", the utility gets the temp. from "Core Temp" ( you can google it )
      It has a"plug-in" called "Core Temp Remote Server". The utility gets the values via TCP.
      When it "feels" it's gonna get hot, drops the CPU throttle to a selected value, lets say 99% ( where is quieter ) and back up to 100% when it "feels" is ok to go back.
      Now temperature can creep up to higher than expected if load is sustained or room temperature changes. So there is an "anti creep up" feature, to temporarily set the throttle even lower, 5% at a time, until the known quiet temperature is achieved.
      If don't know how to find the temperature you should use, check out these videos. They will tell you how.
      https://www.youtube.com/watch?v=p3B5WCJZTuw&ab_channel=SergeantPope-KomadaComputerRepair
      https://www.youtube.com/watch?v=VuP6I0mOb1s&ab_channel=Techquickie
      https://www.google.com/search?q=find+max+cpu+temperature
      The end result:
      Any thermal problem, is a hardware problem. No way around that, other than attending to the CPU cooling and case ventilation. Software can not fix that.
      But without this utility, the PC would slow down the CPU anyway, to keep it from melting.
      This software preemptively slow down the CPU, keeping the CPU related fan speeds from going to maximum RPM. Hence having a slower, but a quieter box.
    • red0fireus
      By red0fireus
      Hello, I'm very stumped with finding the decimal place for the CPU %.
      I found some example code online
      #include <Array.au3> $aProcess_Info = GetCPU("RzSynapse") _ArrayDisplay($aProcess_Info) Func GetCPU($sProcess = "") Local $aAllProcess_Info[1000][3] = [[0]], $aOneProcess_Info[3] $oWinMgmts = ObjGet("winmgmts:\\.\root\cimv2") $aCPU_Usage = $oWinMgmts.ExecQuery("SELECT Name, IDProcess, PercentProcessorTime FROM Win32_PerfFormattedData_PerfProc_Process") For $vCPU_Info In $aCPU_Usage If $sProcess Then If $vCPU_Info.Name = $sProcess Then $aOneProcess_Info[0] = $sProcess $aOneProcess_Info[1] = $vCPU_Info.IDProcess $aOneProcess_Info[2] = $vCPU_Info.PercentProcessorTime & " %" Return $aOneProcess_Info EndIf Else $aAllProcess_Info[0][0] += 1 $aAllProcess_Info[$aAllProcess_Info[0][0]][0] = $vCPU_Info.Name $aAllProcess_Info[$aAllProcess_Info[0][0]][1] = $vCPU_Info.IDProcess $aAllProcess_Info[$aAllProcess_Info[0][0]][2] = $vCPU_Info.PercentProcessorTime & " %.1f" EndIf Next ReDim $aAllProcess_Info[$aAllProcess_Info[0][0] +1][3] Return $aAllProcess_Info EndFunc ;==>GetCPU Currently the code shows the CPU % as 0 % and I want to show 0.0 % I found this online for strings "%.1f" but i'm not sure how to incorporate it.
    • Trisha
      By Trisha
      Hello,
      I Have clicked on save as option to save a file, while doing that I need to rename a file appending with sysdate. I have searched in google find the below one line of code:
      FileMove("C:\somefile.txt", "C:\somefile1.txt"), When I am trying to append with sysdate. It is not happening. Please help me out  with the small issue.
    • francoiste
      By francoiste
      in AutoIt we have:
      _WinAPI_IsProcessorFeaturePresent($iFeature) this internally just calls what is provided by microsoft: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724482(v=vs.85).aspx
      unfortunately this is completely outdated as we can only check for features like MMX and up to a maximum of SSE2 or SSE3 - which have been introduced back in 2001 / 2004.
      but nowadays there is stuff like AVX, AVX2, AVX-512 ...
      for example see: https://en.wikipedia.org/wiki/Template:Multimedia_extensions
      well, for CPP we have the FeatureDetector (by Mysticial): https://github.com/Mysticial/FeatureDetector
      it calls __cpuid / __cpuidex from <intrin.h>.
      for additional details see: https://msdn.microsoft.com/en-us/library/hskdteyh.aspx
       
      has anyone tried to determine such SIMD features and related CPU capabilites with AutoIt?
    • lewisg
      By lewisg
      Suddenly a RunWait command has stop working after 2 years of no errors, issues, or problems. The code uses RunWait to start Plink.exe, a command-line remote connection tool similar to UNIX ssh. I'm using it to ssh to a linux (Centos) machine, run a Perl script, and redirect the output to a file on a PC running the AutoIt script.  
       
      $FilePath = "C:\AutoIT\LED" $FilePathPlus = $FilePath & "\plink.exe" $Code1 = RunWait(@ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt ", @SW_SHOW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " = ' & @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console The ConsoleWrite output when cut-n-pasted into a DOS box produces the expected file so I know it works. I've also tried many variations of the function moving, adding, and changing the " and ' (quote) marks. Also tried it without the @ComSpec macro and other related functions...e.g.  ShellExecuteWait , etc.
      The PC is a Windows 10 64bit and AutoIT is version 3.3.14.2.
      Searching here and Google has not yielded any clues that helped. 
×