is there a way if label = ? do this

This is a discussion on is there a way if label = ? do this within the C# Programming forums, part of the General Programming Boards category; Hey all I have a level named labelEVdiffVal. Now the app updates this level with text either +0.1% +0.2% etc ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    6

    is there a way if label = ? do this

    Hey all

    I have a level named labelEVdiffVal. Now the app updates this level with text either +0.1% +0.2% etc

    I basiacly want to do if (labelEVdiffVal = "+0.1%) or +0.2% or +0.3% etc etc then { do this }

    or it can be if label > +0.1%, but the text is written as +0.1% and cannot be changed to just text as also had -0.1% + numbers which i need to execute different code for if its -%

    If i try the code above it sais cannot impicitly convert type 'string' to 'system.windows.forms.label'

    basiacly its a program is text is +0.1% or greater I want to send an f1 key to the handle of the window if its 0.0 or -0.1% or greater then it will send f2 key to window

    its a poker bot so when a table comes to top it currently calculates weather its a + or - ev move and writes the EV in that label and now i want to sendkeys if + or - to let a hotkey program either raise or fold (hotkey program if you press f1 it folds)

    Code:
    private void GetActiveWindow()
            {
                const int nChars = 256;
                int handle = 0;
                StringBuilder Buff = new StringBuilder(nChars);
                handle = GetForegroundWindow();
    
                if (GetWindowText(handle, Buff, nChars) > 0)
                {
                    this.textBox1.Text = handle.ToString();
    
                    for (int i = 0; i < listBoxTables.Items.Count; i++)
                        if (((PokerTable)listBoxTables.Items[i]).HWND.ToInt32() == handle)
    
                    {
                        listBoxTables.SelectedIndex = i;
                        setFormsAndDoCalc(true, null);
                        SetForegroundWindow(handle);
                        if (labelEVdiffVal = "+0.1%")
                        {
                            SendKeys.SendWait("({F2})");
                        };
                        return;
                    }
    
                }
            }
    What this code is doing is when pokertable comes to the top it then finds it in the list of poker tables then it makes calculations and displays EV value then it brings table back to foreground (All works fine). I just now need the if label = this value then sendkeys to that window (which will be foreground now anyway)?

    Is there anyway to do this and will it work as I would like?

    Thanks!!

  2. #2
    Registered User
    Join Date
    Jul 2010
    Posts
    6
    also is there some code that i can add there to simulate a keypress on that handle(a much better way)

    I just added the sendkeys function after bringing the window to foreground to make it press f1 every time (which when f1 is pressed on the window a autohotkey makes player fold) and it didnt work?? what is wrong with that sendkeys code?

    basiacly need if label = +0.1% then simulate pressing f1 on that window handle
    Last edited by mxadam; 07-15-2010 at 06:35 AM.

  3. #3
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Code:
    if (labelEVdiffVal.Text == "+0.1%")
    Usually though your UI layer just displays a representation of some data object you have (the actual data member that is .1% in this case). So you're usually better off testing against this data object.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problems with quicksort!
    By coni in forum C Programming
    Replies: 3
    Last Post: 10-03-2009, 03:29 AM
  2. Label within a label?
    By Manaxter in forum C# Programming
    Replies: 0
    Last Post: 11-04-2006, 09:49 AM
  3. updating a label with a timer event
    By luigi40 in forum C# Programming
    Replies: 4
    Last Post: 03-31-2005, 08:19 AM
  4. Wierd Segmentation Faults on Global Variable
    By cbranje in forum C Programming
    Replies: 6
    Last Post: 02-19-2005, 12:25 PM
  5. Jump to Case Label error
    By curlious in forum C++ Programming
    Replies: 3
    Last Post: 09-29-2003, 02:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21