Jump to content
Chimerians

Need help with my variables

Recommended Posts

Chimerians

Hello guys,

So I developed a small program, but I am having trouble to associate my input variables to a table of variables and use it on my code.

So basically I want the use to instet on the input lets say $r50 and $p50 and these input is associated with a pixel, then use this variables on my If/Else condition with GUICtrlRead.

The problem is that I cant get it to work, am I doing anything wrong in here?

 

#include "misc.au3"
;_sendEx("keys");$keys will not be sent until CTRL, ALT, SHIFT are released back into the wild
Func _SendEx($keys)
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
      sleep(50)
    WEnd
    Send($keys)
EndFunc;==>_SendEx


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\jmvpe\Desktop\autoit test menu\form3.kxf
Global $Form1_1 = GUICreate("Form1", 458, 303, -1, -1)
Global $startb = GUICtrlCreateButton("Start", 200, 192, 107, 33)
Global $pauseb = GUICtrlCreateButton("Pause", 312, 192, 107, 33)
Global $exitb = GUICtrlCreateButton("Exit", 256, 232, 107, 33)
Global $percentages = GUICtrlCreateLabel("% Legend", 72, 24, 51, 17)
Global $Label1 = GUICtrlCreateLabel("60% - $p60", 24, 152, 65, 17)
Global $Label2 = GUICtrlCreateLabel("30% - $p30", 24, 80, 65, 17)
Global $Label3 = GUICtrlCreateLabel("40% - $p40", 24, 104, 65, 17)
Global $Label4 = GUICtrlCreateLabel("50% - $p50", 24, 128, 65, 17)
Global $Label5 = GUICtrlCreateLabel("20% - $p20", 24, 56, 65, 17)
Global $Label6 = GUICtrlCreateLabel("75% - $p75", 24, 176, 65, 17)
Global $Label7 = GUICtrlCreateLabel("85% - $p85", 24, 200, 65, 17)
Global $Label8 = GUICtrlCreateLabel("90% - $p90", 24, 224, 65, 17)
Global $Label9 = GUICtrlCreateLabel("95% - $p95", 24, 248, 65, 17)
Global $Label10 = GUICtrlCreateLabel("60% - $r60", 112, 152, 66, 17)
Global $Label11 = GUICtrlCreateLabel("30% - $r30", 112, 80, 66, 17)
Global $Label12 = GUICtrlCreateLabel("40% - $r40", 112, 104, 66, 17)
Global $Label13 = GUICtrlCreateLabel("50% - $r50", 112, 128, 66, 17)
Global $Label14 = GUICtrlCreateLabel("20% - $r20", 112, 56, 66, 17)
Global $Label15 = GUICtrlCreateLabel("75% - $r75", 112, 176, 66, 17)
Global $Label16 = GUICtrlCreateLabel("85% - $r85", 112, 200, 66, 17)
Global $Label17 = GUICtrlCreateLabel("90% - $r90", 112, 224, 66, 17)
Global $Label18 = GUICtrlCreateLabel("95% - $r95", 112, 248, 66, 17)
Global $Label19 = GUICtrlCreateLabel("Leve ", 232, 48, 64, 17)
Global $Label20 = GUICtrlCreateLabel("Pesado ", 232, 80, 72, 17)
Global $LeveP = GUICtrlCreateInput("", 304, 48, 121, 21)
Global $PesadoP = GUICtrlCreateInput("", 304, 80, 121, 21)
Global $Label21 = GUICtrlCreateLabel("Roxa", 232, 120, 50, 17)
Global $RoxaP = GUICtrlCreateInput("", 304, 120, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$p20 = PixelGetColor(1238, 125)
$p30 = PixelGetColor(1243, 125)
$p40 = PixelGetColor(1251, 125)
$p50 = PixelGetColor(1259, 125)
$p60 = PixelGetColor(1268, 125)
$p75 = PixelGetColor(1280, 125)
$p85 = PixelGetColor(1288, 125)
$p90 = PixelGetColor(1291, 128)
$p95 = PixelGetColor(1296, 125)


$r20 = PixelGetColor(1238, 141)
$r30 = PixelGetColor(1243, 141)
$r40 = PixelGetColor(1251, 141)
$r50 = PixelGetColor(1259, 141)
$r60 = PixelGetColor(1268, 141)
$r75 = PixelGetColor(1280, 141)
$r85 = PixelGetColor(1288, 141)
$r90 = PixelGetColor(1291, 141)
$r95 = PixelGetColor(1296, 141)

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $nMsg = $startb

            $verificarv = GUICtrlRead($PesadoP)
            $verificarm = GUICtrlRead($RoxaP)

            While 1

              If ($verificarv <> "0xDB4F4F") And ($verificarm = "0x807DFF") Then 
        _SendEx("{F5}")
        sleep(400)

    Else
        If ($verificarv = "0xDB4F4F") And ($verificarm <> "0x807DFF") Then 
        _SendEx("{F8}")
        sleep(600)

    Else
        If ($verificarv <> "0xDB4F4F") And ($verificarm <> "0x807DFF") Then 
        _SendEx("{F5}")
        sleep(600)



    EndIf
    EndIf
    EndIf

            WEnd




        Case $nMsg = $exitb

            Exit


        Case $nMsg = $pauseb

    EndSwitch
WEnd

 

 

 

Share this post


Link to post
Share on other sites
Bilgus

I'm not sure exactly what you are trying to do here like color the labels or save a color pattern as a password??

This will allow you to set the background color of the labels

GUICtrlSetBkColor ( $Label1, $p60 )

this will allow you to set the label text to the color value
GUICtrlSetData ( $PesadoP, Int($p30))

 

Share this post


Link to post
Share on other sites
Chimerians
3 minutes ago, JohnOne said:
;Case $nMsg = $startb
Case $startb

 

Just tried,still doesnt work... is it proprely associated, the variables?

 

 

2 minutes ago, Bilgus said:

I'm not sure exactly what you are trying to do here like color the labels or save a color pattern as a password??

This will allow you to set the background color of the labels

GUICtrlSetBkColor ( $Label1, $p60 )

this will allow you to set the label text to the color value
GUICtrlSetData ( $PesadoP, Int($p30))

 

I want the used to insert lets say $p95 and $r95

and

$p95 = PixelGetColor(1296, 125)

then I created another variable to read the GUI input 
 

$verificarv = GUICtrlRead($PesadoP)

Then I want this used input to be used on my code:

 

If ($verificarv <> "0xDB4F4F") And ($verificarm = "0x807DFF") Then 
        _SendEx("{F5}")
        sleep(400)


Therefore everytime I want to change from $p95 to $p60 (or other p) I dont have to edit the script

Share this post


Link to post
Share on other sites
Bilgus

Also I think I'd group my variables into a table for easier access to them 

Global Enum $eCL10, $eCL20, $eCL30, $aCL_LAST
Global $aCL[$aCL_LAST]
For $i = 0 To UBound($aCL) - 1
$aCL[$i] = GUICtrlCreateLabel($i * 10 & "%", 24, 100 + Mod($i, 5) * 25, 65, 17)
Next

 

Share this post


Link to post
Share on other sites
Bilgus

You are trying to get autoit to redefine what $p60 is then?

 Global $Label1 = GUICtrlCreateLabel("60% - $p60", 24, 152, 65, 17)

like here it displays 60% - $p60

you want to define $p60 = "SOMENUMBER" 

and then have it display 60% - SOMENUMBER

you can't do that directly you need to do

GUICtrlSetData ( $Label1, "60 % - " & $p60)

otherwise you need to parse out the $p60 and fill it in a similar method but store all the "%60 - $p60" in another place and use the values to fill the labels

Share this post


Link to post
Share on other sites
Chimerians
25 minutes ago, Bilgus said:

You are trying to get autoit to redefine what $p60 is then?

 Global $Label1 = GUICtrlCreateLabel("60% - $p60", 24, 152, 65, 17)

like here it displays 60% - $p60

you want to define $p60 = "SOMENUMBER" 

and then have it display 60% - SOMENUMBER

you can't do that directly you need to do

GUICtrlSetData ( $Label1, "60 % - " & $p60)

otherwise you need to parse out the $p60 and fill it in a similar method but store all the "%60 - $p60" in another place and use the values to fill the labels

I think I got it mate, ill try!
Thanks

Share this post


Link to post
Share on other sites
Subz

You can use something like the following, you also need to be exitloop in your while-wend otherwise your script won't allow you to proceed, personally I'd drop the while-wend or use GuiCtrlSetOnEvent mode then it won't cause any issues.

#include "misc.au3"
;_sendEx("keys");$keys will not be sent until CTRL, ALT, SHIFT are released back into the wild
Func _SendEx($keys)
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
      sleep(50)
    WEnd
    Send($keys)
EndFunc;==>_SendEx


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


Opt("ExpandVarStrings", 1)

$p20 = PixelGetColor(1238, 125)
$p30 = PixelGetColor(1243, 125)
$p40 = PixelGetColor(1251, 125)
$p50 = PixelGetColor(1259, 125)
$p60 = PixelGetColor(1268, 125)
$p75 = PixelGetColor(1280, 125)
$p85 = PixelGetColor(1288, 125)
$p90 = PixelGetColor(1291, 128)
$p95 = PixelGetColor(1296, 125)


$r20 = PixelGetColor(1238, 141)
$r30 = PixelGetColor(1243, 141)
$r40 = PixelGetColor(1251, 141)
$r50 = PixelGetColor(1259, 141)
$r60 = PixelGetColor(1268, 141)
$r75 = PixelGetColor(1280, 141)
$r85 = PixelGetColor(1288, 141)
$r90 = PixelGetColor(1291, 141)
$r95 = PixelGetColor(1296, 141)

#Region ### START Koda GUI section ### Form=C:\Users\jmvpe\Desktop\autoit test menu\form3.kxf
Global $Form1_1 = GUICreate("Form1", 458, 303, -1, -1)
Global $startb = GUICtrlCreateButton("Start", 200, 192, 107, 33)
Global $pauseb = GUICtrlCreateButton("Pause", 312, 192, 107, 33)
Global $exitb = GUICtrlCreateButton("Exit", 256, 232, 107, 33)
Global $percentages = GUICtrlCreateLabel("% Legend", 72, 24, 51, 17)
Global $Label1 = GUICtrlCreateLabel("60% - $p60$", 24, 152, 65, 17)
Global $Label2 = GUICtrlCreateLabel("30% - $p30$", 24, 80, 65, 17)
Global $Label3 = GUICtrlCreateLabel("40% - $p40$", 24, 104, 65, 17)
Global $Label4 = GUICtrlCreateLabel("50% - $p50$", 24, 128, 65, 17)
Global $Label5 = GUICtrlCreateLabel("20% - $p20$", 24, 56, 65, 17)
Global $Label6 = GUICtrlCreateLabel("75% - $p75$", 24, 176, 65, 17)
Global $Label7 = GUICtrlCreateLabel("85% - $p85$", 24, 200, 65, 17)
Global $Label8 = GUICtrlCreateLabel("90% - $p90$", 24, 224, 65, 17)
Global $Label9 = GUICtrlCreateLabel("95% - $p95$", 24, 248, 65, 17)
Global $Label10 = GUICtrlCreateLabel("60% - $r60$", 112, 152, 66, 17)
Global $Label11 = GUICtrlCreateLabel("30% - $r30$", 112, 80, 66, 17)
Global $Label12 = GUICtrlCreateLabel("40% - $r40$", 112, 104, 66, 17)
Global $Label13 = GUICtrlCreateLabel("50% - $r50$", 112, 128, 66, 17)
Global $Label14 = GUICtrlCreateLabel("20% - $r20$", 112, 56, 66, 17)
Global $Label15 = GUICtrlCreateLabel("75% - $r75$", 112, 176, 66, 17)
Global $Label16 = GUICtrlCreateLabel("85% - $r85$", 112, 200, 66, 17)
Global $Label17 = GUICtrlCreateLabel("90% - $r90$", 112, 224, 66, 17)
Global $Label18 = GUICtrlCreateLabel("95% - $r95$", 112, 248, 66, 17)
Global $Label19 = GUICtrlCreateLabel("Leve ", 232, 48, 64, 17)
Global $Label20 = GUICtrlCreateLabel("Pesado ", 232, 80, 72, 17)
Global $LeveP = GUICtrlCreateInput("", 304, 48, 121, 21)
Global $PesadoP = GUICtrlCreateInput("", 304, 80, 121, 21)
Global $Label21 = GUICtrlCreateLabel("Roxa", 232, 120, 50, 17)
Global $RoxaP = GUICtrlCreateInput("", 304, 120, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $startb
            $verificarv = GUICtrlRead($PesadoP)
            $verificarm = GUICtrlRead($RoxaP)
            While 1
                If ($verificarv <> "0xDB4F4F") And ($verificarm = "0x807DFF") Then
                    _SendEx("{F5}")
                    sleep(400)
                ElseIf ($verificarv = "0xDB4F4F") And ($verificarm <> "0x807DFF") Then
                    _SendEx("{F8}")
                    sleep(600)
                Else
                    If ($verificarv <> "0xDB4F4F") And ($verificarm <> "0x807DFF") Then
                        _SendEx("{F5}")
                        sleep(600)
                    EndIf
                EndIf
            WEnd
        Case $exitb
            Exit
        Case $pauseb
    EndSwitch
WEnd

 

  • Like 1

Share this post


Link to post
Share on other sites
Bilgus
52 minutes ago, Subz said:

You can use something like the following, you also need to be exitloop in your while-wend otherwise your script won't allow you to proceed, personally I'd drop the while-wend or use GuiCtrlSetOnEvent mode then it won't cause any issues.

Opt("ExpandVarStrings", 1)

 

I forgot about ExpandVarStrings that will work perfectly for him the first time through I think thats probably what he wants

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

×