#๐ help
52 messages ยท Page 1 of 1 (latest)
@autumn raven
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
I don't understand why you are using pickle here.
also is there a reason you need to use both pyautogui and pydirectinput?
coz pydirectinput is used with directinput but is limited so i use puautogui
im not sure if i can use only pyautogui
coz i thought there was a bug with looping white_or_blue() so i asked how to store the value and someone said json or pickle
I know e-kreten mentioned pickle before but the only time you really need to use pickle is if you are storing data to remember it between stopping the program and starting it again
then how can i save the value of white_or_blue() while in a loop?
a few things though: you don't need to do if file == True:, you can just do if file:. You can also just do if Path('temp').unlink(): so you don't need to store that value to file anyways.
hang on let me look at the white_or_blue function
oh, you're just calling it in click_value
Do you know how to return values from functions?
!e ```py
def f():
return "Hello"
s = f()
print(s)
@unreal bison :white_check_mark: Your 3.12 eval job has completed with return code 0.
Hello
like this ?
if Path('temp').unlink():
pass
if that returns True or False sure
yea but i cant return it coz it would run the code and give a false value
it needs to be run while in the loop
What do you mean? You're calling it within the click_value function, writing to the file, then after you exit the white_or_blue function you are almost immediately just reading the value from the file again
white_or_blue() looks for a pixel if i run it before a pixel exists its gonna be wrong
There's literally maybe four lines of code from when you return from that function and the next code that is executed is when you read the value you dumped to file. Is the delay between writing to and reading from disk what's making it work for you?
Oh I think I see what you're doing
i mean it works but if you know of a better way ill do it
anyways there is still this problem
what the code does is alt if its white key up wait key down then if blue then right click then get a value of where to click if the file exists take the value of not get it it looks for a white pixel then gets it then move to the area and click this works the 1st time but 2nd 3rd and more just right click and key up alt then restart then loop but if i alt tab and go back it works 1 more time then dies
So you mean nothing happens? Does the program exit?
no it just does the loop but doesnt move and click
Do you see any of your error messages printing?
I'd suggest putting a print statement before each time you click something so you can know the control flow is reaching that point in your program.
tried that didnt really work
no and thats what makes it hard
no they all did
So your program is clicking
no it should but it isnt
So inside click(location) if you put a print statement before and after pyautogui.leftClick(location, duration=0.3) and they both print, that means the code is working (maybe not as you intended. So if it's not, then perhaps your location is incorrect. Is it possible when you alt-tab between the windows that the actual spot you want to click is changing?
if it clicked? you aren't printing an error message if it clicks are you?
It looks like you've got two hardcoded locations you are telling it to click. Is it possible the game window itself (I'm assuming this is a game) is changing so it no longer displays what you think it is?
therefore it will read the wrong color and you will click at the wrong location?
Does that happen? Does the screen change at all?
no its doesnt change
Ok. Maybe somebody else has an idea then. Sorry I couldn't help you.
np thanks anyways
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.