Our members are dedicated to PASSION and PURPOSE without drama!

re-targetting framework

Started by Stepkevh, December 07, 2012, 11:38:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stepkevh

I want my bot to be able to run on XP also.
If i set the target framework from 4.5 to 4.0 it runs, that's not the problem.

If the bot starts in 4.5 it positions itself at the 0,0 corner of the screen.
The problem is that my bot(form) isn't at the same 0,0 corner anymore when i use 4.0.
Its like that my 0,0 corner of my screen is out of screen then.

Somebody knows an answer to that ?

Stef
Skype :    stepke_vh@hotmail.com

Ophis

what hapens if u put:

Form1.onCreate

Form1.Top:=0;
Form1.Left:=0;

?
Multi Systems Tracker
➨ *Link Removed*

Stepkevh

there is the problem in fact.

the form is already set to 0,0 position at startup.

isn't it weird that changing framework does this.

I just tested it to see when the form is at the right position again
and if i set the startup position at 5,5 for framework 4 then its okay.
Skype :    stepke_vh@hotmail.com

Ophis

and is this relevant to further funcionality?
Multi Systems Tracker
➨ *Link Removed*

Stepkevh

yes because the pixel function depends on the location

i have just set the form location for an xp bot to (5,5) and targetted 4.0.
rebuilded the exe and it runs perfect.

but it still bothers me why the forms desktoplocation is not the same for 4.5 and 4.0.
Skype :    stepke_vh@hotmail.com

Ophis

so if I move the window bot will not work?
Multi Systems Tracker
➨ *Link Removed*

Stepkevh

Quote from: Ophis on December 07, 2012, 02:16:40 PM
so if I move the window bot will not work?

you can't move the bots window because it will return from where it came :-)
Skype :    stepke_vh@hotmail.com

Ophis

ok so i have different solution for you.

what you need to do is use function:
Windows.ClientToScreen

you should be able to use it with form or with any component

Code (delphi) Select

...
//TPoint type variable consist of 2 values: X and Y
var v_pt: TPoint;
    x:=0;
    y:=0;
    //x and y are coordinates you want to move your mouse to
    //assing them to TPoint variable
    v_pt.x:=x;
    v_pt.y:=y;

    //call CTS function to modify those variables feeding it with handle of the component
    Windows.ClientToScreen(Panel1.Handle, v_pt);

    //move cursor to position
    SetCursorPos(v_pt.x,v_pt.y);
...


After using something like that if you want to move your cursor to x0 y0 then it will be here:
and x0y0 will be ALWAYS there regardless where have you move your form OR component with casino table.


[attachimg=1]


Not sure what function do you use to read screen but if its BitBlt then you can also use:
Windows.GetDC(Panel1.Handle)
...
feed it into BitBlt function and you will get the same relation....
x0,y0 will also be there like on screen shot.

Code (delphi) Select

...
var DC: HDC;
...
      DC := GetDC(CasinoHANDLE);
      ...
      BitBlt(Bmp.Canvas.Handle, 0, 0, Width, Height, DC, x1, y1, SRCCOPY);
Multi Systems Tracker
➨ *Link Removed*

Stepkevh

Ophis, thx fr the info  :thumbsup:

and i use the built in getpixel function not an API.
Skype :    stepke_vh@hotmail.com

Ralph

I fast way to solve it is to  take the global coordinates  and the top and left for the form, sometimes the margin, and then it does not matter where the form is on screen.


Thr forms coordinates addet to the global form top and left.

Ophis

margin is very important... same as the title bar... because they change if you switch window styles.

ClientToScreen return always Work area of a form or component. so you coordinates does not change if user change windows styles....

btw why do you all use internal webbrowser.... for what?
Multi Systems Tracker
➨ *Link Removed*

Stepkevh

the guy that tested the xp bot made a movie of the problem and i noticed something else.

I set my form border style for win7 to fixeddialog.

But if this runs on xp it converts to some ugly square standard dialog.
Skype :    stepke_vh@hotmail.com

Ophis

seems like not all the styles are backward compatible.

maybe try to use some custom components.
Multi Systems Tracker
➨ *Link Removed*