-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apologies For opening an Issue: Fantastic Script - Thankyou #7
Comments
Thanks for All. You can do like in this file : PS4Macro.PES2018Lite/MyClub/Match/AcceptNewContract.cs using System.Threading;
...
// Cost and kind of money
while (!script.MatchTemplate(script.CaptureFrame(), extension2Focus, 98))
{
Thread.Sleep(1000);
Log.LogMessage(Name, "Waiting for 'Pay with GP money'");
} |
I will give this a go now!. Thank you so much for replying!. I'm in Australia so apologies for any delay in replying. |
Using System Threading works great!, thank you so much!. I seem to be having another problem and wondered if you could take a look for me. When an image is detected and the interactionMenu script starts, it skips this part of the script: script.Press(new DualShockState() { Cross = true }); Here is the full InterationMenu.cs script: using System; namespace ExampleScript
Any help would be most gratefully received. |
That's ok to communicate in this issue. No problem. For your issue, are sure that it skip last Cross/Triangle/DPad_Down or it has no effect on your game ? PS4Macro.PES2018Lite/MyClub/Sim/ManageTeamScreen.cs Are you sure that when you press key, PS4 is waiting for this key ? Good luck to find the bug. Don't worry to reply in time. :) |
I think it may be analyzing and finding the same hashed image in more than one screen update, this is the only explanation I can think of why its repeating part of the button press. I will have to run some tests. Is there a way to turn the analyzing off once its found the correct image and then turn it back on once the button sequence has been completed?. |
I do not know if the matching process is looking for hash while you process a treatment. May be you can improve the match by combination of detail of screenshot. Then you match by :
In this case, you have to give XY Offset in HeaderBarDetailX and give the XY size of detail. Or you can reduce the sleep instructions to achieve treatment before the screen change. |
Hi Leguims, Could you tell me how I create more than one image search. for example: class InteractionMenu : Scene
Both RectMaps are on different pages, I wish the script to react to each one differently ( private static RectMap LiveSearch = new RectMap() Causes script.Press(new DualShockState() { Cross = true }); and Appreciate your help! |
I found out that the interaction script is running through a second time because it returns to the original screen, and the matching process picks up the same hash. Is there a way to either bypass or ignore the second time it detects it?. |
Hi, I think I found the solution to one problem: private static RectMap PurchaseItem = new RectMap()
Is this the way to do it?, it seems to work. |
I don't think the above script is reacting to the Hashes, so I think I need help :) |
You can combine many details of a screenshot to prevent "miss match" on many different pages. By this way, you use AND between each HASH you use. You can use the same treatment for different pages, in this case, you use OR between each HASH you use. If you need to memorize that you already process a treatment, the easier way is to memorize it in variable like a boolean. Public static bool HeaderBarDone = False;
...
public override bool Match(ScriptBase script)
{
if(!HeaderBarDone)
return script.MatchTemplate(Search, 98)
|| script.MatchTemplate(BOption, 98)
|| script.MatchTemplate(PItem, 98);
else
return False;
}
public override void OnMatched(ScriptBase script)
{
HeaderBarDone = True;
...
} |
Hi Leguims, Could you show me where in my script I should put:
Here is my Script:
|
I have two screens the same, I just want it to react once on the first loop. |
Hi Baggy, Good Luck, i'm sure you will improve your program and your skill with C#. I'll be back in one week. |
You are brave to learn C# with PS4Macro. |
Thank you. I will wait for you to return from off your holiday. Have a good time. |
Why not read a short book on C# like C# Succinctly. It's for C# 6.0 but it's good enough for you to get started quickly. |
Thanks for the reply. I have C# 7.0 In A Nutshell which has taught me many of the fundamentals. However from time to time we all need a little help for one reason or another. Considering I'm a Graphic Artist by profession and only been learning C# for the past week I don't think I'm doing too badly. |
If I want to search for an image anywhere instead of x = .... y = .... , how would I do this? |
You cannot do this or you change x;y yourself before the matching method. |
Is it possible to do it via C#? |
Make 2 for loop and inside them, you modify the x;y values. It will be very slow. This is probably not a good idea. |
How would I write the code for that to try? |
Hi Again!
I used photoshop color picker which gives me "e53212" for the color, however I get an error saying "e53212" does not exist in the current context... |
|
I just figured out I have to include "0x" at the start - 0xe53212 |
@baggypants71 you have to prefix by 0x (zero and x) the color value. |
Ok, next Time, I will read every comment before answer. |
Thanks for reopening it Leguims! 👍 |
I want the Thread.sleep method value to be randomized between a range (1-3seconds) how would I implement that into my script?. Help is most appreciated @leguims
|
You already ask it on another thread. The answer is with the question. |
@leguims Hi Again!, If I want the script to do something else if it does not find the following, how would I do it?:
I want it to do something else if it returns false to any of the Positions.
Would I need to change this part of the script?:
|
If matching is false on this method, the treatment method won't be called. public override bool Match(ScriptBase script) So, you cannot apply default treatment. You can write it, but it will not executed. |
So what would I need to do to make it do something else if Position 1,2,3 is not found?, or is this not possible? |
Do the images that have been cropped and hashed inside PS4Macro_0_5_2 / screenshots folder, do they have to be kept, or is it ok to delete them?. |
Images is used only to have checksum and write it on C#. |
Yes it is possible, but I won't encourage this. 2 cases :
|
The problem I have is that position 1,2,3 could be one of thousands of possible differences. I'm looking to make the program look for something other than what is normally in Position 1,2,3. I will upload some screenshots tomorrow (your evening!) to further explain. bonne nuit! :) |
Hi leguims, I just tried using the Automation program "WinAutomation" with Remote Play. I was thinking that it would work but it doesn't. What is it that allows PS4Macro to work with Remote Play but not other Automation programs?. |
@leguims You wrote: If you need to memorize that you already process a treatment, the easier way is to memorize it in variable like a boolean.
Could you explain further where in the program these statements should go. I have tried, but its returning errors?. |
I think I should explain better!. I have an identical image that appears on two pages. I wish the script to only react once to the image and then ignore the same image upon the second detection on another page. Once it has done that I want it to reset so the process is repeated.
|
@leguims I am still confused: You wrote:
And here is my new script with what you said to do but it does not work, I am doing something wrong. Can you please help, Its so frustrating!.
|
Sorry, I do not know, i'm just a PS4Macro user. |
I add "Public static bool xxxxDone = False;" Here is your Script modified: using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using PS4MacroAPI;
namespace PS4Macro
{
class InteractionMenu : Scene
{
public override string Name ="Interaction Menu";
public static RectMap LiveSearch = new RectMap()
{
X = 239,
Y = 199,
Width = 120,
Height = 18,
Hash = 9223090703630925951
};
Public static bool LiveSearchDone = False; // Add this
public static RectMap AssignNow = new RectMap()
{
X = 287,
Y = 317,
Width = 428,
Height = 47,
Hash = 35887505487722528
};
Public static bool AssignNowDone = False; // Add this
public static RectMap MainMenu = new RectMap()
{
X = 294,
Y = 234,
Width = 62,
Height = 28,
Hash = 9169114436558946303
};
Public static bool MainMenuDone = False; // Add this
public static RectMap NoResult = new RectMap()
{
X = 289,
Y = 349,
Width = 46,
Height = 21,
Hash = 18129295318662912
};
Public static bool NoResultDone = False; // Add this
public static RectMap PlaceOnTL = new RectMap()
{
X = 372,
Y = 231,
Width = 129,
Height = 24,
Hash = 17802464409370431
};
Public static bool PlaceOnTLDone = False; // Add this
public static RectMap BackToMENU1 = new RectMap()
{
X = 67,
Y = 231,
Width = 112,
Height = 26,
Hash = 213852855729920
};
Public static bool BackToMENU1Done = False; // Add this
public override bool Match(ScriptBase script) // Modify all the method
{
if(!LiveSearchDone)
return script.MatchTemplate(LiveSearch, 90);
if(!AssignNowDone)
return script.MatchTemplate(AssignNow, 90);
if(!MainMenuDone)
return script.MatchTemplate(MainMenu, 98);
if(!NoResultDone)
return script.MatchTemplate(NoResult, 98);
if(!PlaceOnTLDone)
return script.MatchTemplate(PlaceOnTL, 98);
if(!BackToMENU1Done)
return script.MatchTemplate(BackToMENU1, 98);
return False;
}
public override void OnMatched(ScriptBase script) // Modify if condition + set to true boolean before treatment
{
if (!LiveSearchDone && (script.MatchTemplate(LiveSearch, 90))) // Live Search Result
{
LiveSearchDone = True;
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(100);
script.Press(new DualShockState() { DPad_Down = true });
Thread.Sleep(100);
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(100);
script.Press(new DualShockState() { DPad_Up = true });
Thread.Sleep(1000);
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(1000);
}
else if (!MainMenuDone && (script.MatchTemplate(MainMenu, 98))) // Main Menu Loop
{
MainMenuDone = True;
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(100);
script.Press(new DualShockState() { DPad_Left = true });
Thread.Sleep(100);
script.Press(new DualShockState() { Circle = true });
Thread.Sleep(100);
script.Press(new DualShockState() { Triangle = true });
Thread.Sleep(10);
}
else if (!NoResultDone && (script.MatchTemplate(NoResult, 98))) // Main Menu Loop - No Search Result
{
NoResultDone = True;
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(100);
}
else if (!AssignNowDone && (script.MatchTemplate(AssignNow, 90))
{
AssignNowDone = True;
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(10);
}
else if (!PlaceOnTLDone && (script.MatchTemplate(PlaceOnTL, 98)))
{
PlaceOnTLDone = True;
script.Press(new DualShockState() { Triangle = true });
Thread.Sleep(3500);
script.Press(new DualShockState() { Circle = true });
Thread.Sleep(10);
}
else if (!BackToMENU1Done && (script.MatchTemplate(BackToMENU1, 98))
{
BackToMENU1Done = True;
script.Press(new DualShockState() { DPad_Down = true });
Thread.Sleep(1000);
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(1000);
script.Press(new DualShockState() { DPad_Down = true });
Thread.Sleep(1000);
script.Press(new DualShockState() { Circle = true });
Thread.Sleep(100);
}
}
}
} |
If you need to "keep searching" for stage 1, you have to set the boolean with the treatment to do when you find the "TM". Something looks like : public override void OnMatched(ScriptBase script)
{
//Stage One - Keep searching until Item found
if (script.MatchTemplate(TM, 90))
{
LiveSearch = true; // Set to true only if TM is found.
script.Press(new DualShockState() { Cross = true });
Thread.Sleep(500);
script.Press(new DualShockState() { DPad_Left = true });
Thread.Sleep(500);
script.Press(new DualShockState() { Circle = true });
Thread.Sleep(500);
script.Press(new DualShockState() { Triangle = true });
Thread.Sleep(500);
}
... Remember that when 'LiveSearch' is true, the 'match' method will always return 'false'. So, you will never execute again 'OnMatched' method. If you need several step of treatment, you have to use several boolean variables. Each one is use to prevent previous treatment to not repeat and memorize what left to do. |
Sorry to answer so late, but I was in holydays and in my return have so much things to do. I hope it will help you and boost your motivation to finish your project. :) |
Hi Leguims,
You clearly know how to use the PS4Macro library by the looks of your script for it!. Is there any chnce you could help me out on my project. I need some direction on a few issues I'm having. Using PS4Macro library how do I add a delay between each button press?. I know you can use "int waitDelay = 100;" but this would apply the same value to all presses. I wish to assign a value to each button individually.
Once again, thanks for sharing your talent for scripting and coding!.
The text was updated successfully, but these errors were encountered: