Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/12/2012 in all areas

  1. The purpose of this autoit-created game I made is to remove all the lit blocks so that all lights are off. Red = lit and Blue = not lit. You can either click around and light your own and then unlight them OR you can use the randomize button to create yourself a grid without you clicking. Sounds easy right? Well you are not toggling 1 dot.. You are toggling in a pattern like: x xxx x The more steps you tell it to randomize the more difficult it is to solve! I have extensively commented this little project of mine in case anyone is interested. During making it I learned something about detecting mouse clicks inside the interface without needing to register messages! Let me know what you think about this little thing. (This is a picture of the same device I had when I was a kid lol..) Upgraded version 2. Now you can use Ctrl + s and Ctrl + l to save or load the current grid pattern. For example if you have put in a hard level of difficulty like 50 or 100 you can save the current pattern and try multiple times until you get it right, kind of like seeing if you can beat the boss on a game or something lol. I think that is all I added so far. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> AutoItSetOption('MouseCoordMode', 2) Global $hBlock[11][11], $hBlockColour[11][11], $iFreeForm = 0, $iBegun = 0, $iLitCount = 0, $sBlockOff = '0x155098', $sBlockOn = '0xf02424' ;I chose 11 for the limits of the arrays so a zero value won't crash the program. Other checks deal with higher values. $Form1 = GUICreate("Unblock", 311, 350, -1, -1) ; Creates the initial GUI GUISetBkColor('0x000000') ; Sets background of the GUI to black $hButton1 = GUICtrlCreateButton("Randomize!", 5, 318, 85, 25) $hCheckbox1 = GUICtrlCreateCheckbox("", 295, 310, 25, 25) $hHide = GUICtrlCreateLabel('Hide randomization?', 190, 315, 105, 15) GUICtrlSetFont($hHide, 8, 400, 0, "MS Sans Serif") GUICtrlSetColor($hHide, '0xffffff') ; Sets the text on the label to being white coloured. $hRandomSteps = GUICtrlCreateInput(12, 95, 320, 49, 21, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") AdlibRegister('CheckHotkeyRequirement', 100) For $y = 1 To 10 ; Incrimentally increasing the Y axis after all blocks have been created along the X axis. For $x = 1 To 10 ; Incrimentally creating blocks along the X axis. ;Below creates labels, positions them and then assigns the blank (unlit) colour of blue $hBlock[$x][$y] = GUICtrlCreateLabel("", 1 + ($x - 1) + (($x - 1) * 30), 1 + ($y - 1) + (($y - 1) * 30), 30, 30) ; A label acting as a blank block. $hBlockColour[$x][$y] = 0 ; This value of 0 means it is unlit.. a 1 means it is currently lit. GUICtrlSetBkColor(-1, $sBlockOff) ; This colours the block with the "unlit" colour. Next Next GUISetState(@SW_SHOW) ; Shows the interface now that all the blocks have been created. While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE ; Lets the program exit when you hit the X button. Exit Case $GUI_EVENT_PRIMARYDOWN ; Waits till you click and release somewhere on the interface client area. $iPosX = Ceiling(($nMsg[3] - (Ceiling($nMsg[3] / 30))) / 30) ; Compensating for the blank pixles between blocks $iPosY = Ceiling(($nMsg[4] - (Ceiling($nMsg[4] / 30))) / 30) ; Compensating for the blank pixles between blocks If $iPosX < 11 And $iPosY < 11 And $iPosX > 0 And $iPosY > 0 Then ; Checking to make sure we don't exceed the bounds of the array ToggleBlock($iPosX, $iPosY) ; Performs the toggling process If $iBegun = 0 Then $hTimer = TimerInit() ; Begins counting your time taken upon your first click. $iBegun = 1 EndIf Case $hButton1 CreateLevel(GUICtrlRead($hRandomSteps)) $iBegun = 0 ; Resets the variable thus causing the next block press to begin counting your time taken. Case Else ; Anything that does not match above gets checked here. If $iBegun = 1 And $iLitCount = 0 Then ; Here I check to see if the player has clicked a square AND the number of lit blocks. $iBegun = 0 ; Prevents the following message box from recursively firing off until you begin again. ; The below line simply shows you a message box if you have managed to clear all the blocks and tells you how long it took in seconds. MsgBox(0, 'Completed!', 'You unblocked the grid in ' & Round(TimerDiff($hTimer) / 1000, 1) & ' seconds :)') EndIf EndSwitch WEnd Func ToggleBlock($_X, $_Y, $_NotHidden = 1) ; This toggles the lit/unlit status of the blocks. Red = lit, Blue = unlit. If $hBlockColour[$_X][$_Y] = 1 Then ; Central block - Checks if the block is lit or not. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X][$_Y], $sBlockOff) ; Changes the colour of the current block $hBlockColour[$_X][$_Y] = 0 ; Sets the status array element so we know next time it is currently unlit.. $iLitCount -= 1 Else If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X][$_Y], $sBlockOn) ; Changes the colour of the current block $hBlockColour[$_X][$_Y] = 1 ; Sets the status array element so we know next time it is currently lit.. $iLitCount += 1 EndIf If ($_X - 1) >= 1 And $hBlockColour[$_X - 1][$_Y] = 1 Then ; Left block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X - 1][$_Y], $sBlockOff) ; Changes the colour of the current block $hBlockColour[$_X - 1][$_Y] = 0 ; Sets the status array element so we know next time it is currently unlit.. $iLitCount -= 1 ElseIf ($_X - 1) >= 1 And $hBlockColour[$_X - 1][$_Y] = 0 Then ; Left block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X - 1][$_Y], $sBlockOn) ; Changes the colour of the current block $hBlockColour[$_X - 1][$_Y] = 1 ; Sets the status array element so we know next time it is currently lit.. $iLitCount += 1 EndIf If ($_X + 1) < 11 And $hBlockColour[$_X + 1][$_Y] = 1 Then ; Right block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X + 1][$_Y], $sBlockOff) ; Changes the colour of the current block $hBlockColour[$_X + 1][$_Y] = 0 ; Sets the status array element so we know next time it is currently unlit.. $iLitCount -= 1 ElseIf ($_X + 1) < 11 And $hBlockColour[$_X + 1][$_Y] = 0 Then ; Right block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X + 1][$_Y], $sBlockOn) ; Changes the colour of the current block $hBlockColour[$_X + 1][$_Y] = 1 ; Sets the status array element so we know next time it is currently lit.. $iLitCount += 1 EndIf If ($_Y - 1) > 0 And $hBlockColour[$_X][$_Y - 1] = 1 Then ; Upper block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X][$_Y - 1], $sBlockOff) ; Changes the colour of the current block $hBlockColour[$_X][$_Y - 1] = 0 ; Sets the status array element so we know next time it is currently unlit.. $iLitCount -= 1 ElseIf ($_Y - 1) > 0 And $hBlockColour[$_X][$_Y - 1] = 0 Then ; Upper block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X][$_Y - 1], $sBlockOn) ; Changes the colour of the current block $hBlockColour[$_X][$_Y - 1] = 1 ; Sets the status array element so we know next time it is currently lit.. $iLitCount += 1 EndIf If ($_Y + 1) < 11 And $hBlockColour[$_X][$_Y + 1] = 1 Then ; Lower block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X][$_Y + 1], $sBlockOff) ; Changes the colour of the current block $hBlockColour[$_X][$_Y + 1] = 0 ; Sets the status array element so we know next time it is currently unlit.. $iLitCount -= 1 ElseIf ($_Y + 1) < 11 And $hBlockColour[$_X][$_Y + 1] = 0 Then ; Lower block - Checks if the related block is within the grid and current un/lit status. If $_NotHidden Then GUICtrlSetBkColor($hBlock[$_X][$_Y + 1], $sBlockOn) ; Changes the colour of the current block $hBlockColour[$_X][$_Y + 1] = 1 ; Sets the status array element so we know next time it is currently lit.. $iLitCount += 1 EndIf EndFunc ;==>ToggleBlock Func CreateLevel($_NumOfRandomPresses) ; Creates a random grid of lit blocks by pressing blocks the number of times chosen by you. $iLitCount = 0 Local $iNoHide = 1 If $_NumOfRandomPresses = 0 Then Return 1 ; If you chose 0 then this function has nothing to do, so just return 1. If GUICtrlRead($hCheckbox1) = $GUI_CHECKED Then $iNoHide = 0 WipeGrid($sBlockOff, 0) ; Resets the grid to off status with the $sBlockOff colour. For $rnd = 1 To $_NumOfRandomPresses ; Cycles through the number of times you told it to. ToggleBlock(Random(1, 10, 1), Random(1, 10, 1), $iNoHide) ; This does the actual random "pressing" on blocks. If "Hide" ticked, don't show the colour changes yet.. ExitCheck() ; This lets you exit the program even if the script is still randomizing, otherwise it would not exit until it had finished. Sleep((30 * $iNoHide) + 5) Next If Not $iNoHide Then ; If "Hide" is ticked, now that the technical randomizations are done, now light up the correct ones. For $1 = 1 To 10 ; X axis For $2 = 1 To 10 ; Y axis If $hBlockColour[$1][$2] = 1 Then ; If this block is supposed to be "lit" then... GUICtrlSetBkColor($hBlock[$1][$2], $sBlockOn) ; Light this block since it is scheduled to be lit. Else GUICtrlSetBkColor($hBlock[$1][$2], $sBlockOff) ; Turn off this block since it is NOT scheduled to be lit. EndIf Next Next EndIf Return 1 EndFunc ;==>CreateLevel Func ExitCheck() If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit ; This will check if you want to exit the program and do so if you request it by the X button. EndFunc ;==>ExitCheck Func GridSave() ; This saves the current grid status so you can try the same grid later if you fail this time. Global $sCurrent = '' $file = FileOpen(@AppDataDir & '\Morthawt - Block Grid Save File.txt', 2) For $2 = 1 To 10 ; Y axis For $1 = 1 To 10 ; X axis $sCurrent &= $hBlockColour[$1][$2] ; Add the next block's state (1 or 0) to the variable Next Next FileWrite($file, $sCurrent) ; Write the string containing the blocks states to file. EndFunc ;==>GridSave Func GridLoad() Global $sCurrent = '', $iCount = 1, $iLitCount = 0, $iBegun = 0 $file = FileRead(@AppDataDir & '\Morthawt - Block Grid Save File.txt') ; Read the contents of the save file to the $file variable. WipeGrid($sBlockOff, 0) ; Reset the grid to all black. For $2 = 1 To 10 ; Y axis For $1 = 1 To 10 ; X axis $iTemp = StringMid($file, $iCount, 1) ; This is the current block we are working with, it's state is here now. $hBlockColour[$1][$2] = $iTemp ; This saves the state to the correct array element so it can be used. If $iTemp = 1 Then GUICtrlSetBkColor($hBlock[$1][$2], $sBlockOn) ; This turns on a block that is supposed to be on. $iLitCount += 1 Else GUICtrlSetBkColor($hBlock[$1][$2], $sBlockOff) ; This turns a block off that is supposed to be off. EndIf $iCount += 1 ; This is used to get the correct position from the save file to get the relevent save data for the current block. Next Next EndFunc ;==>GridLoad Func CheckHotkeyRequirement() If Not WinActive('Unblock', 'Hide randomization?') Then HotKeySet('^s') ; Ctrl + s hotkey used to save the current grid pattern. HotKeySet('^l') ; Ctrl + l hotkey used to load the saved grid pattern. Else HotKeySet('^s', 'GridSave') ; Ctrl + s hotkey used to save the current grid pattern. HotKeySet('^l', 'GridLoad') ; Ctrl + l hotkey used to load the saved grid pattern. EndIf EndFunc ;==>CheckHotkeyRequirement Func WipeGrid($_ColourChoice, $_Speed = 0) ; This resets the grid to all off, with a specific colour and speed. Local $sColor = $_ColourChoice For $2 = 1 To 10 ; Y axis For $1 = 1 To 10 ; X axis GUICtrlSetBkColor($hBlock[$1][$2], $_ColourChoice) ; Sets the current block to the desired colour. $hBlockColour[$1][$2] = 0 ; Sets the state so we can know if it is on or off (lit or unlit) Sleep($_Speed) ; If a delay is specified it will be performed. Next Next $iLitCount = 0 EndFunc ;==>WipeGrid
    1 point
  2. Function Reference _ComboBoxAutoFill.au3 AutoFill a ComboBox edit control. Sintax: _GUICtrlComboBox_AutoFillCreate( hWnd[, lPartialSearch] ) _GUICtrlComboBox_AutoFillDelete( hWnd ) _GUICtrlComboBox_AutoFillSetContent( hWnd, vData ) _GUICtrlComboBox_AutoFillUpdateContent( hWnd ) Supports: ; Native and UDF combobox functions! Downloads: Version: 0.12 _ComboBoxAutoFill_(RedirectLink).html Note: Usage example is included! Sample: Match from beginning: Match from any string: Fixes: Regards, João Carlos.
    1 point
  3. I am sure my dentist is jealous .... So, when it it going to dawn to you that we need more than "it doesn't work"?What is the returned Error code and have you search on it?
    1 point
  4. Lots of people ask this question, mostly because it has never been answered satisfactorily. Not because no-one has bothered to post the answer but because there isn't one. Do as much of the logic as possible on the server. That's something people often overlook (Aktonius touched on it in his post). If your program was just a web browser with a license key then it would be incredibly secure (they would have to get to the files on the server to get your program code).
    1 point
  5. You should make a special logic in your code where things fall apart if they dont follow license check routines. By adding variables on weird places and just being creative with it. Have those people sent you autoit decompiled? Did you use obfuscator? If they can pass this then you are pretty much out of luck. Also you dont need to access database through client code, you can access it through server calls and they cant access that even if they get your source.
    1 point
  6. ; Splits into groups of three characters $sInput = '56868797689645' $sOutput = StringRegExpReplace($sInput, '(Ad{1,3}(?=(d{3})+z)|d{3}(?=d))', '1 ') MsgBox(0, "Result before and after", $sInput & @LF & $sOutput) I hope it will be more brief and faster than the StringFormat
    1 point
  7. eltorro

    XML DOM wrapper (COM)

    Try using MsgBox(4096, "test", $search[1]) oÝ÷ Ú)ìµæ¡ö®¶­s`¤×6t&÷CbÂgV÷C·FW7BgV÷C²Âb33c·6V&6oÝ÷ Ù«­¢+Ø(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô(ìչѥ½¸9µè}a51ÑY±Õ(ìÍÉ¥ÁÑ¥½¸èÐa50¥±Í½¸aAÑ ¥¹ÁÕÐɽ´É½½Ð¹½¸(ìAɵÑÉÌèÀÌØíÁÑ áµ°ÑÉÁÑ É½´É½½Ð¹½¡É½½Ð½¡¥±½¡¥±¸¸¤(ìMå¹Ñàè}a51ÑY±Õ ÀÌØíÁÑ ¤(ìÕÑ¡½È¡Ì¤èMÑÁ¡¸A½¡©­¤±Ðí¡½ÍÍÑ͹ѵ¹½´Ðì(ìIÑÕɹÌèÉÉä½¥±ÌÑáÐÙ±Õ̴Ľ¸¥±ÕÉ(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô(oÝ÷ Øw«zØ^r^"ëu«­¢+Ø)1½°ÀÌØíÍ¥±ôÅÕ½Ðí½½­Ì¹áµ°ÅÕ½Ðì(%¥±á¥ÍÑÌ ÀÌØíÍ¥±¤Q¡¸(ÀÌØíÉÐô}a51¥±=Á¸ ÀÌØíÍ¥±¤(¥ÀÌØíÉÐôÀÑ¡¸á¥Ð((ÀÌØí ½Èô}a51ÑY±Õ ÅÕ½ÐíMÑÑ¥¹Ì½ ½ÈÅÕ½Ðì¤(ÀÌØíYÉ¥¹ô}a51ÑY±Õ ÅÕ½ÐíMÑÑ¥¹Ì½YÉ¥¹ÅÕ½Ðì¤(ÀÌØíÍÉ ô}a51ÑY±Õ ÅÕ½ÐíMÑÑ¥¹Ì½MÉ ÅÕ½Ðì¤((5Í ½à ÐÀäØ°ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÀÌØíÍÉ¡lÅt¤(5Í ½à ÐÀäØ°ÅÕ½ÐíÉɽÈÅÕ½Ðì°}a51ÉÉ½È ¤¤(¹%( eltorro
    1 point
×
×
  • Create New...