Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/14/2021 in all areas

  1. Oh, right, I got what you are saying now... that should definitely not work on a saved local copy with modified names. I bet you are right on the money 💰 Most people would be saving pages for their visual content anyway... but there would be some unlucky people like me who would have tried to save an interactive page, or a page with a game (RIP Adobe Flash ). Obviously those types of pages are hard to preserve, especially with an automatic method like a browser.
    3 points
  2. You are not only querying process information but your are also trying to set process information. Try adding $PROCESS_SET_INFORMATION to the _WinAPI_OpenProcess() function. The following line works for me: Change from : $hProc = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION, False, $sPID, True) To $hProc = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION + $PROCESS_SET_INFORMATION, False, $sPID, True)
    2 points
  3. Well at least now we’re talking about your code, instead of registry settings, plugins and mortality
    2 points
  4. Well I did say my code wasn't foolproof, and so anything real tricky, maybe something referenced in a CSS file for example, then my code wouldn't deal with it. My code only deals with a file name, not even a path, though it scans all sub-folders for a same or similar named file, and if more than one instance of the file exists, the renaming does not occur and the user is notified of such. So my code is simplistic in that it only corrects the file name, not path, in the html files. You could of course develop much more complex code to deal with other possibilities, but as I said in my first post, my code works well enough for the situation I am using it ... chiefly GOG game web pages, where the conditions are kind of stable and known. I also mentioned that improvements to the code would be welcome.
    2 points
  5. Good riddance to outdated security ridden nightmare.
    2 points
  6. This is a simple but somewhat tricky to do script, that I whipped up in a few hours due to a need. I share, because it would no doubt be helpful to some others, and one of those might even make improvements. Basically, I sometimes need to save web pages ... for a game etc, so I have something I can check or refer to later, about the game. I store the save(s) in a sub-folder of my game folder, called '_Html'. I backup (archive) my game folders after downloading, to a few external drives. Sometimes, not all that often thankfully, file contents of the saved web page folder result in a too long path ... greater than 255 characters. Usually it is an image file that is the culprit, and clearly web browsers are not smart enough to prevent that. It is a problem however when backing up to another drive, even when you kind of mirror the folder paths. For instance, I download to a folder in My Documents, called Downloads and which contains date folders. i.e. C:\Users\TheSaint\Downloads\2021\02\10 And my backups folders imitate that with a shorter version. i.e. D:\Downloads\2021\02\10 So even though the backup folder path is shorter, the source folder path creates an issue and some files are not backed up. I then have 3 choices. (1) Skip the files, losing them forever. (2) Rename the files to shorter names so they at least exist at the destination. (3) Rename the files and rename the matching file entries in any related htm/html files, so that everything still works. My program does option (3) or at least tries to. It isn't foolproof, as that could get quite complex. Unless you download in a very similar way to me, you will need to modify the script, path wise. A fuller folder download path for me, would be like the following. C:\Users\TheSaint\Downloads\2021\02\10\GoG\Irony Curtain - From Matryoshka with Love - Revolutionary Edition\_Html That last folder name, '_Html' is important to my script. So if you don't use that, you would need to adjust for your scenario. Here is a recent file I had the issue with. This is its shortened version. The fuller version had something like 20 or so more characters to the file name, which made the path too long. C:\Users\TheSaint\Downloads\2021\02\10\GoG\Irony Curtain - From Matryoshka with Love - Revolutionary Edition\_Html\Irony Curtain_ From Matryoshka with Love - Original Soundtrack on GOG.com_files\7ca6665e4e388a8850f76d1a792d47db1abaae3dae7996263fb835d.jpg Most of the files in the same folder were much shorter names. All up though, there was 6 image files that had names too long. There was 7 instances in html files that needed adjusting for the shortened names. My program uses a drop box, and interestingly, the too long file name result (@GUI_DragFile) resulted in a Windows short name, which I then had to cater for. One other thing I should probably make clear. If you discovered the issue after a move process, then you will need to restore web folder contents, from destination to the source folder, that did move successfully, before you use my script. Not an issue with a copy process. Basically you drag & drop the errant file onto my program drop box, and it will start checking and renaming. If an error occurs or renaming isn't needed, you will be told. Result is shown in the drop box. More than one same named problem file somewhere in the folder hierarchy, will cause an error. This is deliberate to prevent internal html path errors, due to _ReplaceStringInFile being used. If someone wants to whip up something smarter, be my guest. Currently for my use, it has been working well enough. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; AutoIt Version: 3.3.14.2 ;; ;; ;; ;; Template AutoIt script. ;; ;; ;; ;; AUTHOR: TheSaint ;; ;; ;; ;; SCRIPT FUNCTION: Rename (shorten) a file name in a too long web folder path ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; GUI FUNCTIONS ; DropboxGUI() #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <Array.au3> #include <File.au3> #include <Misc.au3> _Singleton("shorten-web-filename-thsaint") Global $inifle, $version, $winpos $inifle = @ScriptDir & "\Settings.ini" $version = "v1.0" DropboxGUI() Exit Func DropboxGUI() Local $Label_drop, $Dropbox Local $attrib, $f, $fext, $file, $files, $fldpth, $flepth, $found, $left, $length, $longpth, $name, $p, $pages Local $part, $path, $relpth, $rename, $rep, $result, $right, $success, $target, $top, $webpage ; $right = @DesktopWidth - 87 $left = IniRead($inifle, "Dropbox Window", "left", $right) $top = IniRead($inifle, "Dropbox Window", "top", 27) $Dropbox = GuiCreate("Dropbox", 82, 70, $left, $top, $WS_OVERLAPPED + $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE _ + $WS_CLIPSIBLINGS, $WS_EX_ACCEPTFILES + $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) ; $Label_drop = GUICtrlCreateLabel("", 0, 0, 80, 68, $SS_CENTER + $SS_NOTIFY) GUICtrlSetState($Label_drop, $GUI_DROPACCEPTED) GUICtrlSetFont($Label_drop, 8, 400) GUICtrlSetTip($Label_drop, "Drop a Folder or Drive Here!") ; ; SETTINGS $target = "Drop a Web" & @LF & "File HERE" GUICtrlSetData($Label_drop, @LF & $target) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; Close the Dropbox $winpos = WinGetPos($Dropbox, "") $left = $winpos[0] If $left < 0 Then $left = 2 ElseIf $left > @DesktopWidth - $winpos[2] Then $left = @DesktopWidth - $winpos[2] EndIf IniWrite($inifle, "Dropbox Window", "left", $left) $top = $winpos[1] If $top < 0 Then $top = 2 ElseIf $top > @DesktopHeight - $winpos[3] Then $top = @DesktopHeight - $winpos[3] EndIf IniWrite($inifle, "Dropbox Window", "top", $top) ; GUIDelete($Dropbox) ExitLoop Case $msg = $GUI_EVENT_DROPPED ; Folder added as new destination by drag and drop If @GUI_DragId = -1 Then If FileExists(@GUI_DragFile) Then $attrib = FileGetAttrib(@GUI_DragFile) If StringInStr($attrib, "D") > 0 Then MsgBox(262192, "Drag Error", "Needs to be a file not a folder.", 0, $Dropbox) Else GUICtrlSetData($Label_drop, @LF & $target) GUICtrlSetState($Label_drop, $GUI_DISABLE) SplashTextOn("", "Checking File Name!", 180, 80, -1, -1, 33) $path = @GUI_DragFile $longpth = FileGetLongName($path) $file = StringSplit($longpth, "\", 1) $file = $file[$file[0]] $fldpth = StringTrimRight($longpth, StringLen($file)) $length = StringLen($longpth) If $length > 254 Then $pages = "" $rep = "" $result = 0 $fext = StringSplit($file, ".", 1) If $fext[0] > 1 Then $fext = "." & $fext[$fext[0]] Else $fext = "" EndIf $name = StringTrimRight($file, StringLen($fext)) While 1 $name = StringTrimRight($name, 1) If $name > "" Then $rename = $name & $fext $flepth = $fldpth & $rename $length = StringLen($flepth) If $length < 255 Then If Not FileExists($flepth) Then $part = StringSplit($longpth, "\_Html", 1) $part = $part[1] & "\_Html" $files = _FileListToArrayRec($part, "*" & $fext, 1, 1, 0, 0) For $f = 1 To $files[0] $found = $files[$f] If StringInStr($found, $file, 1) > 0 Then $result = $result + 1 EndIf Next ;MsgBox(262192, "Check Results", "Name = " & $file & @LF & "Rename = " & $rename & @LF & "Length = " & $length & @LF & "Files = " & $result, 0, $Dropbox) If $result = 1 Then $result = 0 ;FileCopy($path, @ScriptDir & "\xxxxx.tmp", 1) ;$shortpth = FileGetShortName($flepth) ;$success = FileCopy($path, $flepth, 0) $success = FileMove($path, $flepth, 0) If $success = 1 Then $files = _FileListToArrayRec($part, "*.htm*", 1, 1, 0, 1) For $f = 1 To $files[0] $relpth = $files[$f] If StringRight($relpth, 4) = ".htm" Or StringRight($relpth, 5) = ".html" Then If $pages = "" Then $pages = $relpth Else $pages = $pages & "|" & $relpth EndIf EndIf Next ;MsgBox(262192, "Page Results", "Pages = " & $pages, 0, $Dropbox) $pages = StringSplit($pages, "|", 1) For $p = 1 To $pages[0] $webpage = $part & "\" & $pages[$p] ;MsgBox(262192, "Web Page", $webpage, 0, $Dropbox) $rep = _ReplaceStringInFile($webpage, $file, $rename) $result = $result + $rep Next Else MsgBox(262192, "File Rename Failure", "Original Path = " & $longpth & @LF & "Rename Path = " & $flepth, 0, $Dropbox) EndIf Else MsgBox(262192, "File Rename Failure", "More than one copy of the file exists or is too similar.", 0, $Dropbox) EndIf ExitLoop EndIf EndIf Else MsgBox(262192, "File Rename Failure", "File name became too short (folder name[s] too long).", 0, $Dropbox) ExitLoop EndIf WEnd Else MsgBox(262192, "File Rename Skipped", $longpth & @LF & @LF & "File name & path is short enough = " & $length, 0, $Dropbox) EndIf GUICtrlSetData($Label_drop, @LF & $target & @LF & $result & " && " & $success) SplashOff() GUICtrlSetState($Label_drop, $GUI_ENABLE) EndIf Else MsgBox(262192, "Drag Error", "Drag & Drop path doesn't exist.", 0, $Dropbox) EndIf Else MsgBox(262192, "Drag Error", "Drag & Drop failed.", 0, $Dropbox) EndIf Case Else ;;; EndSelect WEnd EndFunc ;=> DropboxGUI Enjoy!
    1 point
  7. Unsure if there's a simple way to accomplish this. Found this earlier discussion -- Edit: Found a way using DragDropEvent_Revoke found here. Add this line immediately after the control is created -- DragDropEvent_Revoke($hGlo_WE_Control) The function looks like this -- Func DragDropEvent_Revoke($hWnd) DllCall("ole32.dll", "int", "RevokeDragDrop", "hwnd", $hWnd) EndFunc
    1 point
  8. Luke94

    String To Text-String

    The formatting should be removed from this one line anyway? Global $sString = ClipGet() I'm sure the formatting is stored within the Clipboard, so once you call: ClipPut($sString) The string is passed to the Clipboard as plain text, without formatting. This means your TextString function, as well as the built-in function you're looking for is pointless. The two above lines will do what you need. I tried with the the two above lines and this was the output. I feel like I'm been thick lol? - it's one of those days!
    1 point
  9. The short answer is "you can't". You can use Webdriver to automate the website, but you will still need to use coordinates to control where the click occurs. For lots of detailed discussions, try googling "webdriver canvas html5".
    1 point
  10. Yes, but not all scripts run on page load. Some run only when a button is clicked, which means that saved archive will only have the code to generate the URI, not any modified HTML. Later, if the archive is used, the JS will generates the local call but it would fail if the local filename had been shortened. I could be wrong, but even if I’m not it’s hardly a show-stopper, IMHO @TheSaintis only trying to provide a reasonable facsimile of the site, not a mission critical replica, so I feel like I’m nitpicking to even mention it.
    1 point
  11. Hi Musashi, thanks for your confirmation. I have used _GUICtrlRichEdit_Paste instead of _GUICtrlRichEdit_InsertText, which works fine with the Undo check. thanks for your assistance cheers mike
    1 point
  12. In advance : I am not a proven expert on " Rich Edit controls ", so this is just a guess . Unlike _GUICtrlRichEdit_ReplaceText, _GUICtrlRichEdit_InsertText" apparently does not add anything to the Undo-Queue by default. Here is a small demo script (modified from the Help) : #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60) $idBtnNext = GUICtrlCreateButton("NEXT", 270, 310, 40, 30) GUISetState(@SW_SHOW) _GUICtrlRichEdit_SetText($hRichEdit, "FIRST paragraph") While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Exit Case $iMsg = $idBtnNext $iStep += 1 Switch $iStep Case 1 _GUICtrlRichEdit_SetSel($hRichEdit, 0, 5) GUICtrlSetData($idLblMsg, "FIRST selected") Case 2 _GUICtrlRichEdit_InsertText($hRichEdit, "****") GUICtrlSetData($idLblMsg, "**** is inserted at active point of selection") Case 3 MsgBox(0, "Actions in the UNDO-Queue after 'InsertText'", "UNDO-Queue=" & _GUICtrlRichEdit_CanUndo($hRichEdit)) Case 4 _GUICtrlRichEdit_SetSel($hRichEdit, 0, 5) _GUICtrlRichEdit_ReplaceText($hRichEdit, "SECOND ") GUICtrlSetData($idLblMsg, "FIRST has been replaced by SECOND") MsgBox(0, "1. Actions in the UNDO-Queue after 'ReplaceText'", _ "'FIRST has been replaced by SECOND'" & @CRLF & _ "UNDO-Queue=" & _GUICtrlRichEdit_CanUndo($hRichEdit) & @CRLF & _ "-> CRTL-Z = 'Undo' possible (will empty UNDO-Queue)" & @CRLF & _ "-> just click NEXT (UNDO-Queue remains)" & @CRLF ) Case 5 MsgBox(0, "2. Actions in the UNDO-Queue after 'ReplaceText'", "UNDO-Queue=" & _GUICtrlRichEdit_CanUndo($hRichEdit)) GUICtrlSetData($idLblMsg, "==> Finished") GUICtrlSetData($idBtnNext, "Exit") Case 6 _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndSwitch EndSelect WEnd EndFunc ;==>Example This probably doesn't help you much, but at least confirms your observation.
    1 point
  13. Guess the Regex wasn't clear for you yet as your new defined regex: (\d{5})00([a-z]{2} expects: Capture group1: 5 digits => \d{5} 00 => 00 Capture group2: 2 Letters =>[a-z]{2} Ouput: is missing the second capture group So try understanding what you are doing and try again. Use this website to help you for the proper regex: https://regex101.com/ Jos
    1 point
  14. or just enable long pathnames Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "LongPathsEnabled"=dword:00000001
    1 point
  15. After watching this movie (https://www.youtube.com/watch?v=cPiDHXtM0VA) I wanted to try the test to see how much i could compete with that chimpanzee so i created this script. well, actually passing that test is a lot harder than it sounds. With the difficulty set to seven numbers and a display time of one second, I can only remember 2 or 3 numbers ... (what a disappointment) I can only do better if I reduce the slider to 5 numbers and increase the storage time to 2 seconds (the easyest level), a very poor performance. That chimpanzee is great. The script offers you a sequence of 10 random quizzes. At the end it gives you the percentage of your "level". The chimpanzee resolves on average 8 out of 10 (80%), so you can compare your performance to that of the chimpanzee. How to play: Run the script. At the beginning there are 2 sliders at the bottom of the screen where you can set the difficulty level by varying the memorization time and the amount of numbers to memorize as you like. After setting the difficulty, click the circle on the bottom left to get started. after the first move the sliders are no longer displayed until the next game, (the game lasts 10 attempts, there is a progress bar at the bottom of the screen to see where you are) between one test and the other of the ten, click on the circle to move on to the next test have fun. (here a related interesting video: https://www.youtube.com/watch?v=ktkjUjcZid0 ) #include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <WinAPIMisc.au3> ; HotKeySet("{ESC}", "_EndOfGame") Global $iNumbersToGuess = 7, $iExpositionTime = 1000, $iMatches = 10, $iMatchesWon Global $aNumbers[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Global $aButtons[10], $aControls[5] Global $iWinWidth = @DesktopWidth / 2, $iWinHeight = @DesktopHeight / 2, $iButtonXSide = Int($iWinWidth / UBound($aNumbers)), $iButtonYSide = Int($iWinHeight / UBound($aNumbers)), $sWinTitle = "Beat the Chimp" Global $aX[Int($iWinWidth / $iButtonXSide)], $aY[Int($iWinHeight / $iButtonYSide)], $iNdx = 0, $aPoints[3], $score, $GUIGetMsg, $iDockHeight = 50, $iProgrssHeight = 5 For $i = 0 To (Int($iWinWidth / $iButtonXSide) - 1) * $iButtonXSide Step $iButtonXSide $aX[$iNdx] = $i $iNdx += 1 Next $iNdx = 0 For $i = 0 To (Int($iWinHeight / $iButtonYSide) - 1) * $iButtonYSide Step $iButtonYSide $aY[$iNdx] = $i $iNdx += 1 Next Global Const $iDockLeftBorder = 200, $iForeColor = 0xFFFFFF, $iBackColor = 0x000000 Global $hGUI = GUICreate($sWinTitle, $iWinWidth, $iWinHeight + $iDockHeight + $iProgrssHeight, @DesktopWidth / 4, @DesktopHeight / 5) GUISetBkColor($iBackColor, $hGUI) ; the circle to continue playing $aControls[0] = GUICtrlCreateLabel(ChrW(0x25EF), 0, $iWinHeight + 1, 100, $iDockHeight, 0x01) ; GUICtrlSetTip(-1, "Click the circle," & @CRLF & "then click the squares" & @CRLF & "in numeric order.") GUICtrlSetFont(-1, 24, 900) GUICtrlSetColor(-1, $iForeColor) GUICtrlSetBkColor(-1, $iBackColor) ; slider for the amount of numbers to guess $aControls[2] = GUICtrlCreateSlider($iDockLeftBorder, $iWinHeight, $iWinWidth - $iDockLeftBorder, Int($iDockHeight / 2)) GUICtrlSetLimit(-1, 10, 5) ; 5 steps 5 (easy) to 10 (hard) GUICtrlSetData(-1, $iNumbersToGuess) ; label for the amount of quizzes $aControls[1] = GUICtrlCreateLabel("Numbers : " & GUICtrlRead($aControls[2]), 100, $iWinHeight + 1, 100) GUICtrlSetColor(-1, $iForeColor) ; slider for the exposition time $aControls[4] = GUICtrlCreateSlider($iDockLeftBorder, $iWinHeight + (Int($iDockHeight / 2)), $iWinWidth - $iDockLeftBorder, $iDockHeight / 2) GUICtrlSetLimit(-1, 8, 1) ; 8 steps (0f 250ms each) GUICtrlSetData(-1, $iExpositionTime / 250) ; label for the exposition time $aControls[3] = GUICtrlCreateLabel("ms to show : " & GUICtrlRead($aControls[4]) * 250, 100, $iWinHeight + 1 + (Int($iDockHeight / 2)), 100) GUICtrlSetColor(-1, $iForeColor) ; progress bar of the match Global $idProgressbar = GUICtrlCreateProgress(0, $iWinHeight + $iDockHeight, $iWinWidth, $iProgrssHeight) ; Create buttons For $i = 0 To 9 $aButtons[$i] = GUICtrlCreateLabel($i + 1, $iWinWidth + 5, $iWinHeight + $iDockHeight + $iProgrssHeight + 5, $iButtonXSide, $iButtonYSide, 0x01) GUICtrlSetFont($aButtons[$i], 24) GUICtrlSetColor($aButtons[$i], $iForeColor) GUICtrlSetBkColor($aButtons[$i], $iBackColor) Next GUISetState(@SW_SHOW) ; --- Main loop --- Do ; New game $iMatchesWon = 0 GUICtrlSetData($idProgressbar, 0) For $iRound = 1 To $iMatches ; the game lasts $iMatches rounds $iNdx = 0 ; reset pointer (index to the next correct answer) _HideControls(__get_IDs_by_indexes($aButtons, $aNumbers)) ; remove the numbers from the screen ; show the dock and wait (only in the first round are also shown the sliders) _ShowControls($iRound = 1 ? $aControls : $aControls[0]) ; display the dock's control(s) While 1 Switch GUIGetMsg() Case $aControls[0] ; The circle (play a new quiz) ExitLoop Case $aControls[2] ; slider to choose how many numbers to guess $iNumbersToGuess = GUICtrlRead($aControls[2]) GUICtrlSetData($aControls[1], "Numbers : " & $iNumbersToGuess) Case $aControls[4] ; slider to choose how long (milliseconds) to show the numbers $iExpositionTime = GUICtrlRead($aControls[4]) * 250 ; 8 steps of 250 milliseconds each GUICtrlSetData($aControls[3], "ms to show : " & $iExpositionTime) Case $GUI_EVENT_CLOSE _EndOfGame() EndSwitch WEnd _HideControls($aControls) ; hide the dock Sleep(750) ; wait a bit $aQuiz = _GenerateQuiz($iNumbersToGuess) ; generate random elements to guess _SpreadControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; scatter the numbers on the GUI _ShowControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; display the numbers Sleep($iExpositionTime) ; leave numbers visible for a short time _MaskControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; mask the numbers GUICtrlSetData($idProgressbar, Round($iRound / $iMatches * 100)) ; _ShowControls(__get_IDs_by_indexes($aButtons, $aQuiz)) ; <------------- keep numbers visible FOR DEBUG PURPOSE ONLY! While 1 ; wait for a move $GUIGetMsg = GUIGetMsg() If $GUIGetMsg = $GUI_EVENT_CLOSE Then _EndOfGame() ; scan all quiz buttons to check if one was pressed For $i = 0 To UBound($aQuiz) - 1 ; $aButtons) - 1 If $GUIGetMsg = $aButtons[$aQuiz[$i] - 1] Then If $i = $iNdx Then ; -------------------------- ; actions for a right move ; -------------------------- ; hide the guessed number _HideControls($aButtons[$aQuiz[$i] - 1]) ; --------------------------------- ; check if this round is complete ; --------------------------------- If $iNdx = (UBound($aQuiz) - 1) Then _WinAPI_PlaySound("SystemExclamation", Null, BitOR($SND_ALIAS, $SND_ASYNC)) $iMatchesWon += 1 ExitLoop 2 EndIf ; play a short ok sound ; _WinAPI_PlaySound("FaxBeep", Null, BitOR($SND_ALIAS, $SND_ASYNC)) ; "SystemAsterisk" $iNdx += 1 ; set index to next correct answer Else ; -------------------------- ; actions for a wrong move ; -------------------------- ; show all the right sequence _ShowControls(__get_IDs_by_indexes($aButtons, $aQuiz)) _WinAPI_PlaySound("DeviceFail", Null, BitOR($SND_ALIAS, $SND_ASYNC)) ; give a little time to the user to control it Sleep(1500) ; go to next step ExitLoop 2 EndIf EndIf Next WEnd ; loop till end of match $score = Round($iMatchesWon / $iMatches * 100, 2) ; percentage Select Case $score < 80 $sResult = "The chimp beat you!" Case $score > 80 $sResult = "You beat the chimp!" Case $score = 80 $sResult = "You tied the chimp." EndSelect Next ; next round ; game over? Until MsgBox($MB_YESNO + $MB_ICONINFORMATION + $MB_TASKMODAL + $MB_SETFOREGROUND, _ "Game over", _ "You got " & $score & "% correct." & @CRLF & _ "Ayumu averages 80% correct." & @CRLF & $sResult & @CRLF & @CRLF & _ "do you want to try again?") <> 6 Func _SpreadControls($aTemp) ; place the required numbers scattered on the GUI SRandom(@YEAR + @MON + @MDAY + @HOUR + @MIN + @SEC) _ArrayShuffle($aX) _ArrayShuffle($aY) ; first, place all buttons out of GUI For $i = 0 To UBound($aButtons) - 1 GUICtrlSetPos($aButtons[$i], $iWinWidth + 5, $iWinHeight + $iDockHeight + $iProgrssHeight + 5) GUICtrlSetState($aButtons[$i], $GUI_DISABLE) Next ; Then place only the numbers of this quiz in visible area For $i = 0 To UBound($aTemp) - 1 GUICtrlSetPos($aTemp[$i], $aX[$i], $aY[$i]) GUICtrlSetState($aTemp[$i], $GUI_ENABLE) Next EndFunc ;==>_SpreadControls Func _GenerateQuiz($iNumElements) ; generate an array of required random numbers SRandom(@YEAR + @MON + @MDAY + @HOUR + @MIN + @SEC) Local $aTemp[$iNumElements] _ArrayShuffle($aNumbers) For $i = 0 To $iNumElements - 1 $aTemp[$i] = $aNumbers[$i] Next _ArraySort($aTemp) Return $aTemp EndFunc ;==>_GenerateQuiz Func _ShowControls($aTemp) ; render controls visible (and enabled) $aTemp = _EnforceArray($aTemp) For $i = 0 To UBound($aTemp) - 1 GUICtrlSetState($aTemp[$i], $GUI_SHOW) GUICtrlSetColor($aTemp[$i], $iForeColor) GUICtrlSetBkColor($aTemp[$i], $iBackColor) Next EndFunc ;==>_ShowControls Func _MaskControls($aTemp) ; mask the controls $aTemp = _EnforceArray($aTemp) For $i = 0 To UBound($aTemp) - 1 GUICtrlSetColor($aTemp[$i], $iForeColor) GUICtrlSetBkColor($aTemp[$i], $iForeColor) Next EndFunc ;==>_MaskControls Func _HideControls($aTemp) ; hide the controls (implies disable) $aTemp = _EnforceArray($aTemp) For $i = 0 To UBound($aTemp) - 1 GUICtrlSetState($aTemp[$i], $GUI_HIDE) ; $GUI_DISABLE) ; GUICtrlSetColor($aButtons[$aTemp[$i] - 1], $iBackColor) ; GUICtrlSetBkColor($aButtons[$aTemp[$i] - 1], $iBackColor) Next EndFunc ;==>_HideControls Func _EnforceArray($vParam) ; if only one value is passed, turn it into an array of only 1 element If Not IsArray($vParam) Then Local $aTemp[1] = [$vParam] Return $aTemp EndIf Return $vParam EndFunc ;==>_EnforceArray Func __get_IDs_by_indexes(ByRef $aCtrls, ByRef $aNdxs) ; returns the handles of the controls pointed to by the indexes Local $aTemp[UBound($aNdxs)] For $i = 0 To UBound($aNdxs) - 1 $aTemp[$i] = $aCtrls[$aNdxs[$i] - 1] Next Return $aTemp EndFunc ;==>__get_IDs_by_indexes Func _EndOfGame() ; _WinAPI_PlaySound ("SystemExit" , Null, $SND_ALIAS) GUIDelete() Exit EndFunc ;==>_EndOfGame P.S. At this link (https://web.archive.org/web/20131006161544/http://games.lumosity.com/chimp.html) there is a Flash version of this game.
    1 point
  16. The problem is here: $sText &= $sOutput _GUICtrlEdit_AppendText($editProgress, $sText) You reading new line and combining with old stuff and then appending. (Every single time) Local $sPSScript = @ScriptDir & "\Launch.ps1" Local $sText = "", $sSTDOUT = "" Local $sCMD = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command . '" & $sPSScript & "'" Local $pid = Run($sCMD, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD) StdinWrite($pid) While 1 $sOutput = StdoutRead($pid) If @error Then ExitLoop If $sOutput <> "" Then _GUICtrlEdit_AppendText($editProgress, $sOutput) EndIf WEnd
    1 point
  17. BasementDweller, _ArrayFindAll returns an array - _ArrayDelete requires a delimited string as a range. Therein lies your problem. Convert the array into string using _ArrayToString and setting the $sDelim_Col parameter to ";" will give you a formatted string that _ArrayDelete will accept: #include <Array.au3> Global $aArray[20] For $i = 0 To 19 $aArray[$i] = Random(1, 5, 1) Next _ArrayDisplay($aArray) $vRange =_ArrayFindAll($aArray, "2", Default, Default, Default, Default, 0) _ArrayDisplay ($vRange) $vRange = _ArrayToString($vRange, ";") ConsoleWrite($vRange & @CRLF) _ArrayDelete($aArray, $vRange) _ArrayDisplay($aArray) M23
    1 point
  18. For sure, JavaScript is much better but I will miss all those quirky flash games Such type of games will probably be never made again.
    0 points
×
×
  • Create New...