Jump to content

can someone please test my code?


Guest
 Share

Recommended Posts

  • Moderators

Pincopanco,

Look in my sig. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@Melba23

thanks for the #include

@gil900

I run your script on this:

AMD Turion 64 X2 Mobile  TL-60

I get an msgbox with this

-1 | -1

bye

Edited by Pincopanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

@Melba23

thanks for the #include

@gil900

I run your script on this:

AMD Turion 64 X2 Mobile  TL-60

I get an msgbox with this

-1 | -1

bye

this output is fine if you leave it like it is and click to "Save Settings"..

this output means that the settings is to do nothing...

this is not the point of the test.. i only need to know how much CPUs you saw in the gui

Edited by Guest
Link to comment
Share on other sites

in the gui i see:

Priority: not flagged

Affinity Settings: not flagged

CPU 1: flagged

CPU 2: flagged

CPU 3: flagged

CPU 4: flagged

... I think too many cpu?

Edited by Pincopanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

in the gui i see:

Priority: not flagged

Affinity Settings: not flagged

CPU 1: flagged

CPU 2: flagged

CPU 3: flagged

CPU 4: flagged

... I think too many cpu?

about flagged and not flagged, this is what you should see ..

about the CPUs it is another matter.

for example

if you have 8 CPUs then you will see 8 CPUs. ( CPU 1 , CPU 2 , CPU 3 , ............. , CPU 8)

if you have 150 CPUs(Most likely not) the you will see 150 CPUs. ( CPU 1 , CPU 2 , CPU3 ....... , CPU 150)

4 CPUs looks ok..

You should know how much CPUs you have..

sorry i don't have power to explain how to know that..

but you can see the number of cpus through Task Manager

Edited by Guest
Link to comment
Share on other sites

I have an P8700 Core2 Duo in my laptop, running this it shows, under the Affinity Settings checkbox, 4 CPUs. This only has a dual core.

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

Link to comment
Share on other sites

I have an P8700 Core2 Duo in my laptop, running this it shows, under the Affinity Settings checkbox, 4 CPUs. This only has a dual core.

Ok .. :(

Can someone help me understand what I did wrong?

Link to comment
Share on other sites

in task Manager I see 2 cpu

if i run an hardware detection software (speccy), under the CPU info I see this:

CPU
        AMD Turion 64 X2 Mobile TL-60
            Cores    2
            Threads    2
            Name    AMD Turion 64 X2 Mobile TL-60
            Code Name    Tyler
            Package    Socket S1 (638)
            Technology    65nm
            Specification    AMD Turion 64 X2 Mobile Technology TL-60
            Family    F
            Extended Family    F
            Model    8
            Extended Model    68
            Stepping    2
            Instructions    MMX (+), 3DNow! (+), SSE, SSE2, SSE3, AMD 64
            Virtualization    Supportato, Disattivato
            Hyperthreading    Non supportato
            Bus Speed    199,5 MHz
            Rated Bus Speed    798,0 MHz
            Stock Core Speed    2000 MHz
            Stock Bus Speed    200 MHz

maybe your script detects 2 CPU + 2 threads

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

I have an P8700 Core2 Duo in my laptop, running this it shows, under the Affinity Settings checkbox, 4 CPUs. This only has a dual core.

More importantly, that CPU does not support HyperThreading either.

http://ark.intel.com/products/37006/Intel-Core2-Duo-Processor-P8700-3M-Cache-2_53-GHz-1066-MHz-FSB?q=P8700

Link to comment
Share on other sites

ok i found the problem..

this is not my fault

the problem is with the function _DecToBinary($iDec) which I found here:

'?do=embed' frameborder='0' data-embedContent>>

when this function get the input 3 then the function return the output 0011.

According to this site:

http://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html

I expected for the output 11

so something here was screwed ..

in case of BrewManNH, this function got the input 3 and returned the output 0011.. it was supposed to be 11.

after that, my gui function counted the length of the output (0011) So it shows 4 CPUs...

Edited by Guest
Link to comment
Share on other sites

ok i found the problem..

......

in case of BrewManNH, this function got the input 3 and returned the output 0011.. it was supposed to be 11.

after that, my gui function counted the length of the output (0011) So it shows 4 CPUs...

 

try to change in this way: line 29 Return Execute($sBinChar)

EDIT: or better line 29 Return $sBinChar * 1

; Decimal To Binary
Func _DecToBinary($iDec)
    Local $i, $sBinChar = ""

    If StringRegExp($iDec,'[[:digit:]]') then
        $i = 1
        Do
            $x = 16^$i
            $i +=1
            ; Determine the Octets
        Until $iDec < $x

        For $n = 4*($i-1) To 1 Step -1
            If BitAND(2 ^ ($n-1), $iDec) Then
                $sBinChar &= "1"
            Else
                $sBinChar &= "0"
            EndIf
        Next
        Return $sBinChar * 1 ; Execute($sBinChar) ; <---- a fast workaround
    Else
        ;MsgBox(0,"Error","Wrong input, try again ...")
        Return
    EndIf
EndFunc
Edited by Pincopanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

 

try to change in this way: line 29 Return Execute($sBinChar)

EDIT: or better line 29 Return $sBinChar * 1

; Decimal To Binary
Func _DecToBinary($iDec)
    Local $i, $sBinChar = ""

    If StringRegExp($iDec,'[[:digit:]]') then
        $i = 1
        Do
            $x = 16^$i
            $i +=1
            ; Determine the Octets
        Until $iDec < $x

        For $n = 4*($i-1) To 1 Step -1
            If BitAND(2 ^ ($n-1), $iDec) Then
                $sBinChar &= "1"
            Else
                $sBinChar &= "0"
            EndIf
        Next
        Return $sBinChar * 1 ; Execute($sBinChar) ; <---- a fast workaround
    Else
        ;MsgBox(0,"Error","Wrong input, try again ...")
        Return
    EndIf
EndFunc

Thank you!

It solved the problem.

Please try again at the updated code:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include "GUIScrollbars_Ex.au3"
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Array.au3>



$affiity = _WinAPI_GetProcessAffinityMask(_WinAPI_GetCurrentProcess())

;$test = _DecToBinary(3)
;MsgBox(0,"",$test)
;Exit
$test = GuiCpuSettings(_DecToBinary($affiity[1]))
;MsgBox(0,"",$test)


Func GuiCpuSettings($NCpuBinary,$Priority = -1 ,$CpuSetBinary = -1)
    If $Priority = -1 Or $Priority = "" Then $PrioritySet = "Normal"
    Local $CPUCheckbox[1] , $output = "-1|-1"
    $NCPUs = StringLen($NCpuBinary)
    For $a = 1 To $NCPUs
        _ArrayAdd($CPUCheckbox,"")
    Next
    $GuiCpuSet = GUICreate("CPU Settings", 211, 245, 491, 283)
    $Label2 = GUICtrlCreateLabel("CPU Settings", 5, 8, 193, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $PrioritySetCheckbox = GUICtrlCreateCheckbox("Priority", 8, 52, 97, 25)
    GUICtrlSetFont(-1, 9.7, 800, 0, "MS Sans Serif")
    $AffinitySetCheckbox = GUICtrlCreateCheckbox("Affinity Settings:", 8, 95, 193, 25)
    GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
    $PriorityCombo = GUICtrlCreateCombo("", 114, 54, 94, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
    GUICtrlSetData(-1,"Realtime|High|Above Normal|Normal|Below Normal|Low", $PrioritySet)
    If $Priority = -1 Then
        $PriorityMode = 0
        GUICtrlSetState(-1, $GUI_DISABLE)
    Else
        $PriorityMode = 1
        GUICtrlSetState($PrioritySetCheckbox, $GUI_CHECKED)
    EndIf
    ;GUICtrlCreateGroup("", -99, -99, 1, 1)

    $Xstart = 8
    $YStart = 120
    Local $ExitLoop = 0 , $Xpos = $Xstart , $Ypos = $YStart , $CPU_NUMBER = 0 , $AffinitySet = 0
    For $a = 1 To $NCPUs
        For $a2 = 1 To 3
            $CPU_NUMBER = $CPU_NUMBER+1
            $CPUCheckbox[$CPU_NUMBER] = GUICtrlCreateCheckbox("CPU "&$CPU_NUMBER, $Xpos, $Ypos, 65, 25)
            If $CpuSetBinary = -1 Then
                GUICtrlSetState(-1, $GUI_CHECKED)
                GUICtrlSetState(-1, $GUI_DISABLE)
            Else
                If StringLeft(StringRight($CpuSetBinary,$CPU_NUMBER),1) = "1" Then GUICtrlSetState(-1, $GUI_CHECKED)
            EndIf
            ;GUISetState(@SW_SHOW)
            ;MsgBox(0,"",$CPU_NUMBER)
            $Xpos = $Xpos+69
            If $CPU_NUMBER = $NCPUs Then
                $ExitLoop = 1
                ExitLoop
            EndIf
        Next
        If $ExitLoop = 1 Then ExitLoop
        $Ypos = $Ypos+30
        $Xpos = $Xstart
    Next
    ;_ArrayDisplay($CPUCheckbox)
    $Ypos = $Ypos+35
    $SaveButton = GUICtrlCreateButton("Save Settings", 43, $Ypos, 129, 41)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")

    If $NCPUs > 6 Then _GUIScrollbars_Generate($GuiCpuSet,0,$Ypos+45)
    GUISetState(@SW_SHOW)

    While 1
        $ReadAffinitySet = GUICtrlRead($AffinitySetCheckbox)
        If $ReadAffinitySet = 1 Then
            If $AffinitySet = 0 Then
                For $a = 1 To $NCPUs
                    GUICtrlSetState($CPUCheckbox[$a], $GUI_ENABLE)
                Next
            EndIf
            $AffinitySet = 1
        ElseIf $ReadAffinitySet = 4 Then
            If $AffinitySet = 1 Then
                For $a = 1 To $NCPUs
                    GUICtrlSetState($CPUCheckbox[$a], $GUI_DISABLE)
                Next
                $AffinitySet = 0
            EndIf
        EndIf
        $ReadPrioritySet = GUICtrlRead($PrioritySetCheckbox)
        
        If $ReadPrioritySet = 1 Then
            If $PriorityMode = 0 Then
                GUICtrlSetState($PriorityCombo, $GUI_ENABLE)
                $PriorityMode = 1
            EndIf
        ElseIf $ReadPrioritySet = 4 Then
            If $PriorityMode = 1 Then
                GUICtrlSetState($PriorityCombo, $GUI_DISABLE)
                $PriorityMode = 0
            EndIf
        EndIf
        
        
        
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($GuiCpuSet)
                ExitLoop
            Case $SaveButton
                Local $error = 0
                If $PriorityMode = 1 Then
                    $PrioritySet = GUICtrlRead($PriorityCombo)
                ElseIf $PriorityMode = 0 Then
                    $PrioritySet = -1
                EndIf
                

                $ReadAffinitySet = GUICtrlRead($AffinitySetCheckbox)
                If $ReadAffinitySet = 4 Then
                    $CpuSetBinary = -1
                ElseIf $ReadAffinitySet = 1 Then
                    $CpuSetBinary = ""
                    For $a = $NCPUs To 1 Step -1
                        $CPUCheckboxReed = GUICtrlRead($CPUCheckbox[$a])
                        If $CPUCheckboxReed = 1 Then
                            $val = "1"
                        ElseIf $CPUCheckboxReed = 4 Then
                            $val = "0"
                        EndIf
                        $CpuSetBinary = $CpuSetBinary&$val
                    Next
                EndIf
                If $error = 0 Then
                    GUIDelete($GuiCpuSet)
                    $output = $PrioritySet&"|"&$CpuSetBinary
                    ExitLoop
                    ;MsgBox(0,"",$output)
                EndIf
        EndSwitch
        Sleep(10)
    WEnd
    Return $output
EndFunc


; Decimal To Binary
Func _DecToBinary($iDec)
    Local $i, $sBinChar = ""

    If StringRegExp($iDec,'[[:digit:]]') then
        $i = 1
        Do
            $x = 16^$i
            $i +=1
            ; Determine the Octets
        Until $iDec < $x

        For $n = 4*($i-1) To 1 Step -1
            If BitAND(2 ^ ($n-1), $iDec) Then
                $sBinChar &= "1"
            Else
                $sBinChar &= "0"
            EndIf
        Next
        Return Execute($sBinChar)
    Else
        ;MsgBox(0,"Error","Wrong input, try again ...")
        Return
    EndIf   
EndFunc
Link to comment
Share on other sites

Another way of stripping leading zeros in a string is doing this.

Return String(Number($sBinChar))

This converts the binary string to a number, which can't have any leading zeros, then converts it back to a string so that the binary isn't inadvertently converted to a number further down the line.

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

Link to comment
Share on other sites

Tripredacus said Important point.

is it true that if the processor does not support Hyper Threading so it is Impossible to select CPU for a process?

if so the i need to know how to check it ..

Does anyone can contribute code that checks this?

Edited by Guest
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...