Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Compare string

Hello (edited this post since its just sitting here)

I need to compare content from clipboard.

In my program when a trade is opened there are only 2 names in this room, mine and an unknown.

I will click in an area to send name to clipboard. I want to comapare this name to the name of mine.
If it IS mine then click the second name and send to clipboard.
If it is NOT mine then goto another part of code.

How can I compare the name in clipboard to see if it is mine or not??

Thank you.
«1

Comments

  • zibadianzibadian Member Posts: 6,349
    : Figured it out sorry
    You can delete and edit your own posts.
  • caspert_ghostcaspert_ghost Member Posts: 53
    : : Figured it out sorry
    : You can delete and edit your own posts.
    edit yes, no option to delete.
  • caspert_ghostcaspert_ghost Member Posts: 53
    : Hello (edited this post since its just sitting here)
    :
    : I need to compare content from clipboard.
    :
    : In my program when a trade is opened there are only 2 names in this
    : room, mine and an unknown.
    :
    : I will click in an area to send name to clipboard. I want to
    : comapare this name to the name of mine.
    : If it IS mine then click the second name and send to clipboard.
    : If it is NOT mine then goto another part of code.
    :
    : How can I compare the name in clipboard to see if it is mine or not??
    :
    : Thank you.
    changed post from delete me to usable post. thank you
  • caspert_ghostcaspert_ghost Member Posts: 53
    : : Hello (edited this post since its just sitting here)
    : :
    : : I need to compare content from clipboard.
    : :
    : : In my program when a trade is opened there are only 2 names in this
    : : room, mine and an unknown.
    : :
    : : I will click in an area to send name to clipboard. I want to
    : : comapare this name to the name of mine.
    : : If it IS mine then click the second name and send to clipboard.
    : : If it is NOT mine then goto another part of code.
    : :
    : : How can I compare the name in clipboard to see if it is mine or not??
    : :
    : : Thank you.
    : changed post from delete me to usable post. thank you
    :
    Anyone, this is bugging the hell out of me :(
  • zibadianzibadian Member Posts: 6,349
    : : : Hello (edited this post since its just sitting here)
    : : :
    : : : I need to compare content from clipboard.
    : : :
    : : : In my program when a trade is opened there are only 2 names in this
    : : : room, mine and an unknown.
    : : :
    : : : I will click in an area to send name to clipboard. I want to
    : : : comapare this name to the name of mine.
    : : : If it IS mine then click the second name and send to clipboard.
    : : : If it is NOT mine then goto another part of code.
    : : :
    : : : How can I compare the name in clipboard to see if it is mine or not??
    : : :
    : : : Thank you.
    : : changed post from delete me to usable post. thank you
    : :
    : Anyone, this is bugging the hell out of me :(
    :
    With the TClipboard object you can get the string from the clipboard. Then you can use whichever method you like to compare those two strings.
  • caspert_ghostcaspert_ghost Member Posts: 53
    : With the TClipboard object you can get the string from the
    : clipboard. Then you can use whichever method you like to compare
    : those two strings.

    Thank you, however I am using Turbo Delphi 2006 and I do not have a TClipboard in my tool palette.

    my code now:
    [code]procedure Tcontrol_panel.Trade();
    begin
    TimerTrd.Enabled:=False;
    inifile:=Tinifile.Create('./OH_BOT.ini');
    accountname:=inifile.ReadString('UserInfo','Accountname','');
    trdmessage:=inifile.ReadString('Messages','Welcome','');
    trdtime:=inifile.ReadString('Trade','MaxTime','');
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename:=Clipboard.Astext;
    if tradename<>accountname then
    begin
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end
    else if tradename=accountname then
    begin
    AU3_MousEClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end;
    end;[/code]
    however with this code it is selecting first name and going to next step, it is not comparing them to see if it IS the name in ini file or not.
  • zibadianzibadian Member Posts: 6,349
    : : With the TClipboard object you can get the string from the
    : : clipboard. Then you can use whichever method you like to compare
    : : those two strings.
    :
    : Thank you, however I am using Turbo Delphi 2006 and I do not have a
    : TClipboard in my tool palette.
    :
    : my code now:
    : [code]: procedure Tcontrol_panel.Trade();
    : begin
    : TimerTrd.Enabled:=False;
    : inifile:=Tinifile.Create('./OH_BOT.ini');
    : accountname:=inifile.ReadString('UserInfo','Accountname','');
    : trdmessage:=inifile.ReadString('Messages','Welcome','');
    : trdtime:=inifile.ReadString('Trade','MaxTime','');
    : AU3_MousEClick ('left', 835,645,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : tradename:=Clipboard.Astext;
    : if tradename<>accountname then
    : begin
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end
    : else [red]if tradename=accountname then[/red]
    : begin
    : AU3_MousEClick ('left', 835,660,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end;
    : end;[/code]:
    : however with this code it is selecting first name and going to next
    : step, it is not comparing them to see if it IS the name in ini file
    : or not.

    The red part is not necessary because the else already takes care of that. The TClipboard is not a component but an object (see help files for more info on the difference). I see you already use the TClipboard object, since you're using the Clipboard() function.
    You might want to check the value of tradename and accountname by either using the debugger, or placing a MessageDialog() just before the if-then statement.
    Also remember that the <>-operator and =-operator will check string case sensitive, thus "Hello world!" is not equal to "hello world!". If you want to compare them without case sensitivity, use the CompareText() function instead.
  • caspert_ghostcaspert_ghost Member Posts: 53
    : The red part is not necessary because the else already takes care of
    : that. The TClipboard is not a component but an object (see help
    : files for more info on the difference). I see you already use the
    : TClipboard object, since you're using the Clipboard() function.
    : You might want to check the value of tradename and accountname by
    : either using the debugger, or placing a MessageDialog() just before
    : the if-then statement.
    : Also remember that the <>-operator and =-operator will check string
    : case sensitive, thus "Hello world!" is not equal to "hello world!".
    : If you want to compare them without case sensitivity, use the
    : CompareText() function instead.

    I removed what you selected as red.
    It still selects the first name which is the bot name. it selects it and send the message.
    ie:
    bot name= captain
    trader name= casper
    the names are placed in the box alphabetically therefore placing captain as the first name.
    [code]procedure Tcontrol_panel.Trade();
    begin
    TimerTrd.Enabled:=False;
    inifile:=Tinifile.Create('./OH_BOT.ini');
    accountname:=inifile.ReadString('UserInfo','Accountname','');
    trdmessage:=inifile.ReadString('Messages','Welcome','');
    trdtime:=inifile.ReadString('Trade','MaxTime','');
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename:=Clipboard.Astext;
    if tradename<>accountname then
    begin
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end
    else
    begin
    AU3_MousEClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end;
    end;
    [/code]
  • zibadianzibadian Member Posts: 6,349
    : : The red part is not necessary because the else already takes care of
    : : that. The TClipboard is not a component but an object (see help
    : : files for more info on the difference). I see you already use the
    : : TClipboard object, since you're using the Clipboard() function.
    : : You might want to check the value of tradename and accountname by
    : : either using the debugger, or placing a MessageDialog() just before
    : : the if-then statement.
    : : Also remember that the <>-operator and =-operator will check string
    : : case sensitive, thus "Hello world!" is not equal to "hello world!".
    : : If you want to compare them without case sensitivity, use the
    : : CompareText() function instead.
    :
    : I removed what you selected as red.
    : It still selects the first name which is the bot name. it selects it
    : and send the message.
    : ie:
    : bot name= captain
    : trader name= casper
    : the names are placed in the box alphabetically therefore placing
    : captain as the first name.
    : [code]: procedure Tcontrol_panel.Trade();
    : begin
    : TimerTrd.Enabled:=False;
    : inifile:=Tinifile.Create('./OH_BOT.ini');
    : accountname:=inifile.ReadString('UserInfo','Accountname','');
    : trdmessage:=inifile.ReadString('Messages','Welcome','');
    : trdtime:=inifile.ReadString('Trade','MaxTime','');
    : AU3_MousEClick ('left', 835,645,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : tradename:=Clipboard.Astext;
    : if tradename<>accountname then
    : begin
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end
    : else
    : begin
    : AU3_MousEClick ('left', 835,660,1,5);
    : AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    : AU3_MouseClick ('left',297,711,1,5);
    : AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    : end;
    : end;
    : [/code]:
    :
    If the accountname is the bot name, then the then-part of the if-then-else is executed. What exactly are you trying to do?
  • caspert_ghostcaspert_ghost Member Posts: 53
    I got IT... Thank you for pointing me in the right direction:

    [code]begin
    TimerTrd.Enabled:=False;
    inifile:=Tinifile.Create('./OH_BOT.ini');
    trdmessage:=inifile.ReadString('Messages','Welcome','');
    trdtime:=inifile.ReadString('Trade','MaxTime','');
    AU3_MousEClick ('left', 835,645,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    tradename:=Clipboard.Astext;
    accountname:=inifile.ReadString('UserInfo','Accountname','');
    [color=Red]result:=AnsiCompareText(accountname,tradename);[/color]
    if result=-1 then [color=Red]{this number MUST be -1 I thought it would be 0}[/color]
    begin
    AU3_MousEClick ('left', 835,660,1,5);
    AU3_Send ('{CTRLDOWN}c{CTRLUP}',0);
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end
    else if result<>0 then
    begin
    AU3_MouseClick ('left',297,711,1,5);
    AU3_Send ('Welcome {CTRLDOWN}v{CTRLUP} ' + ' you have ' + trdtime + ' minutes to complete this trade {ENTER}',0);
    end;[/code]
«1
Sign In or Register to comment.