Leaderboard
Popular Content
Showing content with the highest reputation on 03/14/2017 in all areas
-
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $hStatus = _GUICtrlStatusBar_Create($Form1) GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM") _GUICtrlStatusBar_SetText($hStatus, "test", 0, $SBT_OWNERDRAW) Global $global_StatusBar_Text = "Part 1" $Button1 = GUICtrlCreateButton("Button1", 176, 136, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; $d = _FileListToArrayRec(@ScriptDir & "\ico", "*.ico", 0, 1, 0, 1) For $x = 1 To 100 ; ConsoleWrite($d[$x] & @CRLF) Sleep(20) $global_StatusBar_Text = $x _WinAPI_RedrawWindow($hStatus) ; _GUICtrlStatusBar_SetText($hStatus, $x & " " & $x, 0, $SBT_OWNERDRAW) Next EndSwitch WEnd Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam) Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID") ;part number Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $iTop = DllStructGetData($tRect, "top") Local $iLeft = DllStructGetData($tRect, "left") Local $hBrush Switch $itemID Case 0 $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; Backgound Color _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetTextColor($hDC, 0x00FF00) ; Font Color _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, $global_StatusBar_Text, $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch $tDRAWITEMSTRUCT = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM1 point
-
Based on this excellent example by funkey... #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hGUI, $hStatus Global $aParts[3] = [75, 150, -1] $hGUI = GUICreate("StatusBar Set BkColor", 400, 300) GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM") $hStatus = _GUICtrlStatusBar_Create($hGUI) GUISetState() ;~ _GUICtrlStatusBar_SetBkColor($hStatus, 0x5555DD) _GUICtrlStatusBar_SetParts($hStatus, $aParts) _GUICtrlStatusBar_SetText($hStatus, "Part 1", 0, $SBT_OWNERDRAW) _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1, $SBT_OWNERDRAW) _GUICtrlStatusBar_SetText($hStatus, "Part 3", 2, $SBT_OWNERDRAW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam) Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID") ;part number Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $iTop = DllStructGetData($tRect, "top") Local $iLeft = DllStructGetData($tRect, "left") Local $hBrush Switch $itemID Case 0 $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; Backgound Color _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetTextColor($hDC, 0x00FF00) ; Font Color _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, "Part 1", $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) Case 1 $hBrush = _WinAPI_CreateSolidBrush(0x00FF00) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, "Part 2", $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) Case 2 $hBrush = _WinAPI_CreateSolidBrush(0xABCDEF) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush) _WinAPI_SetBkMode($hDC, $TRANSPARENT) DllStructSetData($tRect, "top", $iTop + 1) DllStructSetData($tRect, "left", $iLeft + 1) _WinAPI_DrawText($hDC, "Part 3", $tRect, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch $tDRAWITEMSTRUCT = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM1 point
-
Just set the proper workdir ( current directory for the process) to the directory containing the ncat.exe or add the directory to the PATH. Jos1 point
-
Hi folks! First off, yeah this may be the lamest title. But it made you look anyway! Edit: Now updated! With step-counter, reset button and a few GUI-tweaks. (the step-counter is cheating! It's calculated in advance...) I recently thought a screenshot of a finished maze may be smart to show, instead of only my long story and code. o=path, x=wall. Here it is: I started making my own implementation of the A* pathing script in a larger project, inspired by Toady's work. (But made one from scratch myself anyway ) After the A* pathing script was working (not cleaned up yet) I wanted to test it. Unfortunately I got no good, randomized, maze lying around that also had the format I needed. So I made my own maze generator! I did a few hours of research on the matter and then a few evenings of scripting. For the people who are interested, one of my problems was that I needed 'one-cell' thick walls. Most maze generation have 1 pixel thick walls drawn by a line, that could be opened if a path is needed. The solution is so simple, I needed this guy to tell me. Click here for my inspiration source. This generator can be used with different sizes maze, even uneven ones! Just set the width and height settings. FYI, it must be odd numbers for this maze to work with it's containment walls. It's the 'simple' Depth-First Search, with backtracking. And without further ado; my a-maze-ing generator!: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: A-maze-ing generator Script Function: Generates a maze. In the $xy[$i][4] is the maze in array form. Don't forget to take the size with it, else it's just a string of o's and x's It does not generate an entrance or exit! #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; Set various variables ; width and height must be odd numbers to have a closed, functioning maze. Global $height = 27 ; demo height = 27 Global $width = 43; demo width = 43 ; Check if width & height are an odd number (to get the outer edge an odd number is required) If mod($height, 2) = 0 Or $height < 5 Then msgbox(0,"","Height is not an odd number or a minimum of 5 tall !") Exit ElseIf mod($width, 2) = 0 Or $width < 5 Then msgbox(0,"","Width is not an odd number of a minimum of 5 wide !") Exit EndIf ; Set various variables when script is not exited Global $grid_size = $height * $width Global $numberofsteps = (Ceiling(($height-2) / 2) * (($width-2) - Ceiling(($width-2) / 2))) + (($height-2) - Ceiling(($height-2) / 2)) ; long formula to check the number of steps this maze will take, this is a mathematical given with a fixed number of cells. And yes, I am aware I'm taking a shortcut in this formula. ;) Global $curpos Global $backtrack[1] Global $bt = 0 Local $grid_pixel = 20 ;How many pixels per square ; Initialize main array with all grid data Global $xy[$grid_size + 1][5] Global $reset_xy = $xy ; set the reset array $xy[0][0] = $grid_size ; first entry is the total number of nodes, rest is set with a header name for easy reference in _ArrayDisplay if needed. $xy[0][1] = "ID" $xy[0][2] = "Row" $xy[0][3] = "Column" $xy[0][4] = "Type" ; Fill the grid array with 'walls' For $i = 1 To $xy[0][0] $xy[$i][4] = "x" Next ; Start GUI and create standard buttons Local $gui = GUICreate("A-maze-ing generator", 180 + ($width * $grid_pixel), 80 + ($height * $grid_pixel)) ; Set the main window to the minimum width (IF) needed for the msgbox Local $aPos = WinGetPos($gui) If $aPos[2] < 696 Then $aPos[2] = 696 WinMove($gui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) EndIf GUICtrlCreateLabel("This is a-maze-ing!", 30, 19) Global $progress = GUICtrlCreateLabel("Standing by... " & $numberofsteps & " steps to go.", 150, 15, 550, 30) Local $iOKButton = GUICtrlCreateButton("Start", 45, 50, 60) Local $iResetButton = GUICtrlCreateButton("Reset", 45, 90, 60) Local $iExitButton = GUICtrlCreateButton("Exit", 45, 130, 60) GUICtrlSetFont($progress, 15) GUICtrlSetColor($progress, 0x00AA00) GUICtrlSetState($iResetButton, $GUI_DISABLE) ; Create label-grid and fill the xy array with the positions Local $squarenr = 0 For $i = 0 To ($height * $grid_pixel) - $grid_pixel Step $grid_pixel ; Row For $j = 0 To ($width * $grid_pixel) - $grid_pixel Step $grid_pixel ; Column $squarenr = $squarenr + 1 $xy[$squarenr][0] = GUICtrlCreateLabel('x', 150 + $j, 50 + $i, $grid_pixel, $grid_pixel, BitOr($SS_SUNKEN, $SS_CENTER)) ; if you want debugging numbers, replace 'x' with $squarenr GUICtrlSetBkColor($xy[$squarenr][0], 0x5E87C9) ; lightblue-ish $xy[$squarenr][1] = $squarenr $xy[$squarenr][2] = ($i / $grid_pixel) + 1 $xy[$squarenr][3] = ($j / $grid_pixel) + 1 Next Next $reset_xy = $xy ; Show GUI GUISwitch($gui) GUISetState(@SW_SHOW) ; Start looping and waiting for input Local $aMsg = 0 While 1 $aMsg = GUIGetMsg(1) Select Case $aMsg[0] = $iOKButton GUICtrlSetState($iOKButton, $GUI_DISABLE) GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iExitButton, $GUI_DISABLE) GUICtrlSetColor($progress, 0xFF8C00) ; orange GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $numberofsteps & " steps to go.") make_maze() GUICtrlSetColor($progress, 0xFF0000) ; red GUICtrlSetData($progress, "Maze complete!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetColor($progress, 0x00AA00) ; green-ish GUICtrlSetData($progress, "Maze completed in " & $numberofsteps & " steps.") GUICtrlSetState($iResetButton, $GUI_ENABLE) GUICtrlSetState($iExitButton, $GUI_ENABLE) Case $aMsg[0] = $iResetButton GUICtrlSetData($progress, "Resetting maze...") reset_maze() GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iOKButton, $GUI_ENABLE) GUICtrlSetData($progress, "Maze reset!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetData($progress, "Standing by...") Case $aMsg[0] = $GUI_EVENT_CLOSE Or $aMsg[0] = $iExitButton ExitLoop EndSelect WEnd Exit ; Resetting the maze to default state Func reset_maze() $xy = $reset_xy ; Set the $xy array back to it first-run values For $i = 1 To $xy[0][0] $xy[$i][4] = "x" ; set everything to 'x' GUICtrlSetBkColor($xy[$i][0], 0x5E87C9) ; reset the background color GUICtrlSetData($xy[$i][0], "x") ; (re)set the label to 'x' Next EndFunc ; Main function Func make_maze() Local $heading Local $stepcount = $numberofsteps ; Reset the step counter. Local $timed = TimerInit() ; Start the timer to see how long the maze generation took. $backtrack[0] = 0 $curpos = $width + 2 ; This is the starting position, second row, second column - aka top-left, one in from the sides. open_maze($curpos) ; Set the starter cell to 'open / white' ; Main maze generation loop While 1 Do $heading = direction($curpos) Until $heading <> 0 If $bt = 1 Then $bt = 0 ; reset backtracking-tracker, else the backtracking array keeps adding the current position GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $stepcount & " steps to go.") Sleep(50) ; Slow maze creation down to look at it - relax! (or don't and comment out the sleep) If $heading = -1 Then ExitLoop $stepcount -= 1 ; Count down the steps to finish. ; We got the heading - now which way do we go? After that, set the current position to the last known heading. Switch $heading Case 1 ; north open_maze($curpos - $width) open_maze($curpos - ($width * 2)) $curpos = $curpos - ($width * 2) Case 2 ; east open_maze($curpos + 1) open_maze($curpos + 2) $curpos = $curpos + 2 Case 3 ; south open_maze($curpos + $width) open_maze($curpos + ($width * 2)) $curpos = $curpos + ($width * 2) Case 4 ; west open_maze($curpos - 1) open_maze($curpos - 2) $curpos = $curpos - 2 EndSwitch ;msgbox(0,"","Turn pause") ; for debugging, click every turn. WEnd ConsoleWrite("Maze completed in " & Round(TimerDiff($timed) / 1000, 1) & " seconds." & @CRLF) ; Show the generation time in seconds, rounded up with one decimal Return EndFunc Func open_maze($dest) ; Function set inputted cells to 'open' instead of being an uncool wall. $xy[$dest][4] = "o" GUICtrlSetData($xy[$dest][0], 'o') ; If you want debugging numbers, replace 'o' with $dest GUICtrlSetBkColor($xy[$dest][0], 0xEEEEEE) EndFunc Func direction(ByRef $curpos) ; Insert current position, output next heading for path generation. Local $nesw Local $open_directions[5][2] $open_directions[0][0] = 0 $nesw = $curpos - ($width * 2) ; north side checking If $nesw > $width + 1 Then fill_open_dir($nesw, 1, $open_directions) $nesw = $curpos + 2 ; east side checking If mod($nesw - 1, $width) <> 0 Then fill_open_dir($nesw, 2, $open_directions) $nesw = $curpos + ($width * 2) ; south side checking If $nesw < $grid_size - $width Then fill_open_dir($nesw, 3, $open_directions) $nesw = $curpos - 2 ; west side checking If mod($nesw, $width) <> 0 Then fill_open_dir($nesw, 4, $open_directions) ; Check which (if any) direction(s) are already opened, if so, discard them from the results-array For $i = $open_directions[0][0] To 1 Step -1 If $xy[$open_directions[$i][1]][4] = "o" Then $open_directions[0][0] -= 1 _ArrayDelete($open_directions, $i) EndIf Next ; If there are any results left... If $open_directions[0][0] > 0 Then If $open_directions[0][0] = 1 Then Return $open_directions[1][0] ; Random does not work with min 1 and max 1 (output = 0), so in this case, return only with the only one result. Else If $bt = 0 Then ; If there is not backtracking active, add this crossroad to the backtrack-array. This is only needed if there are two or three possible sides. $backtrack[0] += 1 _ArrayAdd($backtrack, $curpos) EndIf Return $open_directions[Random(1, $open_directions[0][0], 1)][0] ; Random choose between all possible directions and return with the outcome direction. EndIf ElseIf $backtrack[0] > 0 Then ; If there are no results ánd there are entries in the backtrack list, then visit those entries to see if there still is a path possible. $curpos = $backtrack[$backtrack[0]] _ArrayDelete($backtrack, $backtrack[0]) $backtrack[0] -= 1 $bt = 1 Return 0 ; Return with a new current direction ($curpos), from the backtrack array. Else Return -1 ; If there are no paths to explorer, in the pathing, or backtracking, then return with the message that we are finished. EndIf EndFunc Func fill_open_dir($nesw, $direction, ByRef $open_directions) ; Fill the $open_directions array with a new possible way $open_directions[0][0] += 1 $open_directions[$open_directions[0][0]][1] = $nesw $open_directions[$open_directions[0][0]][0] = $direction Return EndFunc P.S. The 'slow' generation is intended because it looks cool. Comment out the Sleep line on line 157 for a fast generation.1 point
-
GDI+ Rotating Earth build 2017-03-17
argumentum reacted to UEZ for a topic
Added v1.5: cloud layer for a slightly better 3D look. Added v1.6: moon orbiting earth without rotation animation Runs at ~9-10 fps on my system.1 point -
Try this: #include-once #include <Inet.au3> #include <JSMN.au3> ; https://github.com/chechelaky/AutoIt/blob/master/JSMN.au3 #include <object_dump.au3> ; https://github.com/chechelaky/AutoIt/blob/master/object_dump.au3 Global $url = "https://api.github.com/repos/rg3/youtube-dl/releases/latest" Global $json = Jsmn_decode( _INetGetSource($url) ) If Not @error And $json.Exists("tag_name") Then MsgBox(0, "json", "tag_name = " & $json.Item("tag_name")) dump( $json ) EndIf1 point
-
AutoIt has a built in application that allows the user to find x and y coordinates. See picture below. Another option is to use this script that displays the coordinates of where the cursor is click on the computer. #include <Misc.au3> HotKeySet("{END}", "_Quit") ; Hit "END" to quit $dll = DllOpen("user32.dll") While 1 If _IsPressed("01", $dll) Then $avMousePos = MouseGetPos() ToolTip("x = " & $avMousePos[0] & " y = " & $avMousePos[1]) EndIf WEnd Func _Quit() DllClose($dll) Exit EndFunc ;==>_Quit And if you want to move the mouse to a certain location and then reset the cursor back in the original position then you can use this piece of code. Sleep(3000) $pos=MouseGetPos() MouseClick("left",200,200,1,0) MouseMove($pos[0],$pos[1],0) Feel free to browse the forums!1 point
-
Here Is a working solution for this. hope it helps someone. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <ProgressConstants.au3> #include <Constants.au3> #include <GuiEdit.au3> #include <Date.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Edit1 = GUICtrlCreateEdit("", 16, 16, 577, 329) GUICtrlSetData(-1, "") $Progress1 = GUICtrlCreateProgress(16, 368, 577, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $somefolder = FileSelectFolder("Select Encode Folder", "") $Afiles = _FileListToArray($somefolder) $sStdErr = "" $iTicksDuration = 0 $iTicksTime = 0 $ffmpeg = $somefolder&"\ffmpeg.exe" for $i = 1 to $Afiles[0] $file = $Afiles[$i] $hPid = Run($ffmpeg & ' -i "' & $file & '" "' & stringtrimright($file , 4) & '_output.mp4"', $somefolder, @SW_HIDE, 0x4) While 1 Sleep(500) $sStdErr &= StderrRead($hPid) If @error Then ExitLoop GUICtrlSetData($Edit1,$sStdErr) If StringLen($sStdErr) > 0 Then If Not $iTicksDuration Then $iTicksDuration = _GetDuration($sStdErr) $iTicksTime = _GetTime($sStdErr) If Not @error Then $sStdErr = "" GUICtrlSetData($Progress1, $iTicksTime * 100 / $iTicksDuration) EndIf WEnd ProgressOff() Next Func _GetDuration($sStdErr) If Not StringInStr($sStdErr, "Duration:") Then Return SetError(1, 0, 0) Local $aRegExp = StringRegExp($sStdErr, "(?i)Duration.+?([0-9:]+)", 3) If @error Or Not IsArray($aRegExp) Then Return SetError(1, 0, 0) Local $sTime = $aRegExp[UBound($aRegExp) - 1] Local $aTime = StringSplit($sTime, ":", 2) If @error Or Not IsArray($aTime) Then Return SetError(1, 0, 0) Return _TimeToTicks($aTime[0], $aTime[1], $aTime[2]) EndFunc ;==>_GetDuration Func _GetTime($sStdErr) If Not StringInStr($sStdErr, "time=") Then Return SetError(1, 0, 0) Local $aRegExp = StringRegExp($sStdErr, "(?i)time.+?([0-9:]+)", 3) If @error Or Not IsArray($aRegExp) Then Return SetError(1, 0, 0) Local $sTime = $aRegExp[UBound($aRegExp) - 1] Local $aTime = StringSplit($sTime, ":", 2) If @error Or Not IsArray($aTime) Then Return SetError(1, 0, 0) Return _TimeToTicks($aTime[0], $aTime[1], $aTime[2]) EndFunc ;==>_GetTime1 point