Jump to content

naming a key with $var


Recommended Posts

#include <Misc.au3>


While 1
    If _IsPressed('01') Then
        Do
            Sleep(1)
        Until Not _IsPressed('01')
        $pos = MouseGetPos()
        $color = sample_color($pos)
        parse_color($color)
        
    EndIf
    Sleep(1)
WEnd


Func sample_color($pos)
    $color = PixelGetColor ( $pos[0], $pos[1] )
    Return $color
    EndFunc


Func parse_color($color)
    $loop = 0
    $number_of_colors_on_record = IniRead ( "color.ini", "0", "colors_on_record", "default" )
    Do 
    $color_on_record = IniRead ( "color.ini", "1", "color_1", "default" )
                        ; how do I name the "color" like   "color_$var"  ? )
    If $color = $color_on_record Then
        Return
        EndIf
    $loop = $loop + 1
    Until $loop = $number_of_colors_on_record

    ;$color is a new color!

    IniWrite ( "color.ini", 1, "color_$$number_of_colors_on_record + 1", $color )
    IniWrite ( "color.ini", 0, "number_of_colors_on_record", ( $number_of_colors_on_record+1 ) )
    Return

how do I name the "color" like "color_$var" ?

Link to comment
Share on other sites

Run ( "mspaint.exe problem 'screenshot' & $i & '.jpg'.bmp" )

I want open pictures with mspaint, how do do that with screenshot & $var ?

I don't understand what the word "problem" is doing in there... is it part of the file name? And is the file extension .jpg, or .bmp or .jpg.bmp?

On the assumption that this is just a bunch of typos:

; This will open screenshot1.bmp thru screenshot3.bmp
For $i = 1 To 3
    Run('mspaint.exe screenshot' & $i & '.bmp')
Next
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't understand what the word "problem" is doing in there... is it part of the file name? And is the file extension .jpg, or .bmp or .jpg.bmp?

On the assumption that this is just a bunch of typos:

; This will open screenshot1.bmp thru screenshot3.bmp
For $i = 1 To 3
    Run('mspaint.exe screenshot' & $i & '.bmp')
Next

that's what I meant, thank you.

Link to comment
Share on other sites

how about this ?

$color_on_record = IniRead ( "color.ini", "1", 'color' & $loop & , "default" )
                        ; how do I name the "color" like   "color_$var"  ? )oÝ÷ Ûú®¢×¢×èZ0x2¢ç«`-j²ÉÉ·­+0YazZQy§l¶¢Z+~º&¶¤{*®¢×(ýªê-jëh×6$var = 9
$color_on_record = IniRead ("color.ini", "1", "color" & $var)

If this is not what you meant, provide an example ini file with a few entries and what you want from it.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

oh doh, pasted a wrong section

IniWrite ( "color.ini", 1, "color_" & $var , $color )

is what I need; naming keys that begin with color_ with $var.

That was close, if the name of the section is '[1]'. The section name has to be a string an you technically made it an integer one by not putting quotes around it, but AutoIt is very forgiving and that would probably work anyway. If the section name is not '[1]' then you need to fix that second parameter. i.e. for a section name of '[Color List]':

; Saves the color as color_9:
$color = 0x00FF00 ; Green
$var = 9
IniWrite("color.ini", "Color List", "color_" & $var, $color )

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...