mchung94 / solitaire-player

Automatically play Pyramid and TriPeaks Solitaire in Microsoft Solitaire Collection for Windows 10
MIT License
39 stars 15 forks source link

"can't detect if we're playing a game of Pyramid Solitaire" #15

Closed rileyjw90 closed 2 years ago

rileyjw90 commented 2 years ago

I am running Windows 10 Pro Version 21H1 OS Build 19043.1202 Windows Feature Experience Pack 120.2212.3530.0

My native screen resolution is 3840x2160. I have a dual monitor setup with a smaller resolution screen, but even when I disconnect that monitor, I get the same error message:

Starting a Pyramid Solitaire Score Challenge: find the maximum possible score...
System Report:
    Window Size (after adjustment) = 1440x977
    Expected Window Size = 1440x900
    DPI = 192
    Expected DPI = 96
    Scaling Factor = 200.0%
    Primary Screen Size (Adjusted for Scaling Factor) = 1920x1080
    Expected Primary Screen Size = 3840x2160
If the scaling factor isn't 100% or the values don't match the expected,
then this program may not work properly.
Can't detect if we're playing a game of Pyramid Solitaire.

Any ideas on how to fix this? I am only able to solve at this point by creating a pyramid-deck.txt and running the solitaire-player.bat pyramid score -f pyramid-deck.txt.

rileyjw90 commented 2 years ago

Ah, typing it out like that let's me see a little clearer that scaling factor is set to 200%. For those who have larger screens, we typically set scaling higher because otherwise everything is really tiny. Setting it back to 100% works to get this program to autorun. However, it does, as I said, make everything on my screen ridiculously small, so I will obviously just need to go back and forth on the scaling factor when I want to run this software. I made this process easy by creating 2 batch files and dropping it into the solitaire-player\bin file. I copied my "cmd.exe" from my C:\Windows\system32 folder into my solitaire-player\bin folder, so I don't have to type "cmd" into the address bar to open a cmd prompt window inside that directory. Double clicking it will open the window up in the appropriate directory. With that cmd window open, I can just type "100" to run the batch file that will scale down my UI, and then just enter "200" when you're finished running the autosolver program of your choice to return your UI scaling to your normal setting. To create this batch file, you will need to open a new file in notepad and paste the following text:

@ECHO OFF

explorer ms-settings:display
ping -n 2 127.0.0.1 > nul

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 2}{UP 4}"                      >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "%%{F4}"                           >>"%TempVBSFile%"

CSCRIPT //nologo "%TempVBSFile%"

Note the "{UP 4} parameter. This is what will bring a 200% scaling factor down to 100%, but even if you are set to 125, 150, or 175, it will still work since no matter how many times the up button is pressed, it stops at 100%. If you do experience problems, however, just change the number after {UP #} to the correct one for your current setting. If you are at 175, it will be {UP 3}. 150 is {UP 2}. 125 is {UP 1}. Now save this file as 100.bat and place it into your solitaire-player\bin subfolder, where your solitaire-player.bat file is located. When your cmd prompt window is open inside your solitaire-player\bin folder, all you need to do is input "100" and press enter to run the command.

To return your scaling to your normal size, you will need to create a new notepad file and paste the following:

@ECHO OFF

explorer ms-settings:display
ping -n 2 127.0.0.1 > nul

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 2}{DOWN 4}"                      >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys "%%{F4}"                           >>"%TempVBSFile%"

CSCRIPT //nologo "%TempVBSFile%"
EXIT

Now, in this instance, the {DOWN #} parameter DOES matter. If you are usually at 125, yours will be {DOWN 1}. For 150, it is {DOWN 2}. 175 is {DOWN 3}. Leave the text as is for 200. Save your file as 125, 150, 175, or 200.bat, in the same location as your 100.bat file. Note the EXIT command at the end. This will automatically close your cmd prompt window once the re-scaling has executed. If you don't want it to exit, just remove EXIT from the text and save.

mchung94 commented 2 years ago

Thanks for finding this issue and for the workaround! I think because of this and other issues people are having, I need to find a better way to have the program recognize cards on the screen.