C
C#2y ago
Cringel

❔ Some image detecting thing

So, I took this script from talkai and I want to use it from the main script https://paste.mod.gg/zonjixwvtmzk/0 Does it work with png and how do I use it from the main script? This thing is in a form and the main script is the main script.
BlazeBin - zonjixwvtmzk
A tool for sharing your source code with the world!
No description
No description
No description
71 Replies
Thinker
Thinker2y ago
You have to create an instance of the form and then call FindMatchingImage on it.
Cringel
CringelOP2y ago
And how can I integrate that in my code?
No description
SinFluxx
SinFluxx2y ago
It tells you there?
Thinker
Thinker2y ago
By not asking chatgpt of all things
TheRanger
TheRanger2y ago
did you create a new winform project from here?
No description
Cringel
CringelOP2y ago
its Visual Studio I use Rider
TheRanger
TheRanger2y ago
ah rider cant create a winform project?
Cringel
CringelOP2y ago
But I use windows forms it can
TheRanger
TheRanger2y ago
through a template because its suppose to generate some code in Program.cs
Cringel
CringelOP2y ago
creates some code, yes
TheRanger
TheRanger2y ago
there is suppose to be something like Application.Run(new Form1()); in the Program.cs which basically will run your form instance when the app runs
Cringel
CringelOP2y ago
uhh
Cringel
CringelOP2y ago
I have that
No description
Cringel
CringelOP2y ago
The template start thing is that
No description
TheRanger
TheRanger2y ago
can u comment out line 26 and run ur program? does a form open? what is UI.MyFunction is it a method u created?
Cringel
CringelOP2y ago
yes
No description
Cringel
CringelOP2y ago
a yellow square
TheRanger
TheRanger2y ago
can u show me that method
TheRanger
TheRanger2y ago
ok so FindMatchingImage is part of Form1 not Form it looks like ur app only opens for 2 seconds then closes, correct?
Cringel
CringelOP2y ago
yes, because I set it in the function
Cringel
CringelOP2y ago
But my actual problem is with this thing https://paste.mod.gg/zonjixwvtmzk/0, image detection
BlazeBin - zonjixwvtmzk
A tool for sharing your source code with the world!
TheRanger
TheRanger2y ago
isnt this ur problem atm?
Cringel
CringelOP2y ago
my problem is this atm Ui.MyFunction thing is totally ok
TheRanger
TheRanger2y ago
so whats the problem in that code?
Cringel
CringelOP2y ago
BlazeBin - zonjixwvtmzk
A tool for sharing your source code with the world!
TheRanger
TheRanger2y ago
?? whats the problem in this code?
Cringel
CringelOP2y ago
well, I want to make a function that does this code process and use it in the main script
TheRanger
TheRanger2y ago
do it then
Cringel
CringelOP2y ago
but I dont know how to
TheRanger
TheRanger2y ago
imagine ur calling a method called Walk() who exactly will Walk?
Cringel
CringelOP2y ago
method
TheRanger
TheRanger2y ago
a human? a bear? and which human
Cringel
CringelOP2y ago
human
TheRanger
TheRanger2y ago
which human tho imagine a game, where there are 1000 humans
Cringel
CringelOP2y ago
human number 1
TheRanger
TheRanger2y ago
exactly right now ur trying to call the FindMatchingImage method but it doesnt know who will do that action
Cringel
CringelOP2y ago
so I need to make a class?
TheRanger
TheRanger2y ago
No, that action belongs to Form1 class, correct?
Cringel
CringelOP2y ago
yes
TheRanger
TheRanger2y ago
so you dont need to make one
Cringel
CringelOP2y ago
I meant static class line
Cringel
CringelOP2y ago
like that
No description
Cringel
CringelOP2y ago
or?
TheRanger
TheRanger2y ago
well no, because you require the form to call its messagebox
Cringel
CringelOP2y ago
oh, I need to make the function public
TheRanger
TheRanger2y ago
well thats 1 fix
Cringel
CringelOP2y ago
Form1 is already a class thing?
TheRanger
TheRanger2y ago
u see this code in ur detect position.cs
form.BackColor = Color.Yellow;
form.BackColor = Color.Yellow;
doing BackColor = Color.Yellow; wont work it needs to know which object to change its backcolor
Cringel
CringelOP2y ago
No description
TheRanger
TheRanger2y ago
close, but Form1 here is like a blue print of an object
Cringel
CringelOP2y ago
like class of a class?
TheRanger
TheRanger2y ago
no, Form1 is the class like Human, human is a class and you're an instance of a Human doing Human.Walk() wouldnt make sense, because Human here is a type see this code for example its form.BackColor = Color.Yellow; not Form.BackColor = Color.Yellow;
Cringel
CringelOP2y ago
yes I need to make it not capital?
TheRanger
TheRanger2y ago
that's not the issue, form is an object of Form because of this line Form form = new Form(); imagine we are in a game
Cringel
CringelOP2y ago
I think I dont have that line in the script
TheRanger
TheRanger2y ago
Human theRanger = new Human();
Human cringel = new Human();
theRanger.Run();
cringel.Walk();
Human theRanger = new Human();
Human cringel = new Human();
theRanger.Run();
cringel.Walk();
i literally copy pasted it from ur code
Cringel
CringelOP2y ago
in the other one
TheRanger
TheRanger2y ago
well ofcourse, the reference of your new form is in the detect position.cs so it would make sense to call your method in that file
Cringel
CringelOP2y ago
how?
TheRanger
TheRanger2y ago
like this form.FindMatchingImage(); this is calling a method of an instance note that i am really busy right now so how about going through the fundamentals in the links below $helloworld
Cringel
CringelOP2y ago
No description
TheRanger
TheRanger2y ago
. its not a global variable, its a local variable when you say My PC ur obviously refering to your own computer right? the variable only exists within its scope in the detect position.cs anyway g2g, those links above will help you
Cringel
CringelOP2y ago
Thats what I can only make
No description
SinFluxx
SinFluxx2y ago
it's a new Form1() you would need, not a new FindMatchingImage() Did you work through the course that was linked above? As it seems a bit like you're stumbling through things rather than understanding how they all piece together
Cringel
CringelOP2y ago
I didnt see the same thing from the links above
SinFluxx
SinFluxx2y ago
There won't be strictly the same thing in there, I think the point was you probably need to try and learn the fundamentals of C# first to get an understanding of how things work, as you're kind of jumping around/asking chatgpt for things that you don't fully understand and getting a bit lost in it all
Cringel
CringelOP2y ago
Yes, but I think I already know the fundamentals on like 30% of all
SinFluxx
SinFluxx2y ago
ok, well, good luck
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?