Leaderboard
Popular Content
Showing content with the highest reputation on 12/21/2017 in all areas
-
You can do something like this here. ;coded by UEZ build 2017-12-21 #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit Global Const $iW = 1000, $iH = 800, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ Archery Board" AutoItSetOption("GUIOnEventMode", 1) GDIPlus_Archeryboard() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_Archeryboard() $bExit = False $hGUI = GUICreate($sTitle, $iW, $iH) ;, 0, 0, $WS_POPUP) GUISetState(@SW_SHOW, $hGUI) ;~ GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFFC0C0C0), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xF0404040), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 60, 16) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local Const $fRadius = 39.5 Local $hBitmap_AB = BitmapCreate_Archeryboard($iW, $iH, $fRadius) Local $i, $sInfo, $aPos, $fDist, $iRing Do DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, _ "float", $iW, "float", $iH) ;erase canvas background _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap_AB, 0, 0, $iW, $iH) ;check for mouse cursor $aPos = GUIGetCursorInfo($hGUI) $fDist = Pixel_Distance($aPos[0], $aPos[1], $iWh, $iHh) ;get distance to center If (10 * $fRadius - $fDist) > 0.0 Then ;check if mouse is on archery board $iRing = Mod(Int($fDist / $fRadius), $fRadius) ;get actual ring Switch $iRing Case 0 $sInfo = "10 points, yellow / center" Case 1 $sInfo = "9 points, yellow" Case 2 $sInfo = "8 points, red 1" Case 3 $sInfo = "7 points, red 2" Case 4 $sInfo = "6 points, blue 1" Case 5 $sInfo = "5 points, blue 2" Case 6 $sInfo = "4 points, grey 1" Case 7 $sInfo = "3 points, grey 2" Case 8 $sInfo = "2 points, white 1" Case 9 $sInfo = "1 points, white 2" EndSwitch Else $sInfo = "Not on board" EndIf _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS, $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) ;draw fps _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI ToolTip($sInfo, MouseGetPos(0), MouseGetPos(1) + 20) $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(30) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete($hGUI) EndFunc ;==>GDIPlus_Archeryboard Func BitmapCreate_Archeryboard($iW, $iH, $fRadius) Local Const $fDiameter = 2 * $fRadius, $iWh = $iW / 2, $iHh = $iH / 2 Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH), $hCanvas = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush1 = _GDIPlus_BrushCreateSolid(0xFFFFFF55), _ ;yellow $hPen7 = _GDIPlus_PenCreate(0x70FFFFFF), _ ;white with default width $hPen6 = _GDIPlus_PenCreate(0x50505050), _ ;grey $hPen5 = _GDIPlus_PenCreate(0x50202020), _ ;dark grey $hPen4 = _GDIPlus_PenCreate(0xFFFF5443, 2 * $fRadius), _ ;red $hPen3 = _GDIPlus_PenCreate(0xFF66C5FF, 2 * $fRadius), _ ;blue $hPen2 = _GDIPlus_PenCreate(0xFF47433F, 2 * $fRadius), _ ;grey $hPen1 = _GDIPlus_PenCreate(0xFFFEFEFE, 2 * $fRadius), _ ;white $hPath1 = _GDIPlus_PathCreate(), $hPath2 = _GDIPlus_PathCreate(), _ $hPath3 = _GDIPlus_PathCreate(), $hPath4 = _GDIPlus_PathCreate(), _ $hPath5 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath1, $iWh - 9 * $fRadius, $iHh - 9 * $fRadius, 18 * $fRadius, 18 * $fRadius, 0, 360) _GDIPlus_PathAddArc($hPath2, $iWh - 7 * $fRadius, $iHh - 7 * $fRadius, 14 * $fRadius, 14 * $fRadius, 0, 360) _GDIPlus_PathAddArc($hPath3, $iWh - 5 * $fRadius, $iHh - 5 * $fRadius, 10 * $fRadius, 10 * $fRadius, 0, 360) _GDIPlus_PathAddArc($hPath4, $iWh - 3 * $fRadius, $iHh - 3 * $fRadius, 6 * $fRadius, 6 * $fRadius, 0, 360) _GDIPlus_PathAddEllipse($hPath5, $iWh - 2 * $fRadius, $iHh - 2 * $fRadius, 4 * $fRadius, 4 * $fRadius) ;draw board with different colors _GDIPlus_GraphicsDrawPath($hCanvas, $hPath1, $hPen1) _GDIPlus_GraphicsDrawPath($hCanvas, $hPath2, $hPen2) _GDIPlus_GraphicsDrawPath($hCanvas, $hPath3, $hPen3) _GDIPlus_GraphicsDrawPath($hCanvas, $hPath4, $hPen4) _GDIPlus_GraphicsFillPath($hCanvas, $hPath5, $hBrush1) ;draw boarders For $i = 1 to 10 Switch $i Case 7 _GDIPlus_GraphicsDrawEllipse($hCanvas, $iWh - $i * $fRadius, $iHh - $i * $fRadius, $i * $fDiameter, $i * $fDiameter, $hPen7) Case Else _GDIPlus_GraphicsDrawEllipse($hCanvas, $iWh - $i * $fRadius, $iHh - $i * $fRadius, $i * $fDiameter, $i * $fDiameter, $hPen5) EndSwitch Next _GDIPlus_GraphicsDrawEllipse($hCanvas, $iWh - 0.5 * $fRadius, $iHh - 0.5 * $fRadius, $fRadius, $fRadius, $hPen6) ;draw cross-hair _GDIPlus_GraphicsDrawLine($hCanvas, $iWh, $iHh - 4, $iWh, $iHh + 4, $hPen6) _GDIPlus_GraphicsDrawLine($hCanvas, $iWh - 4, $iHh, $iWh + 4, $iHh, $hPen6) ;clean-up resources _GDIPlus_PathDispose($hPath1) _GDIPlus_PathDispose($hPath2) _GDIPlus_PathDispose($hPath3) _GDIPlus_PathDispose($hPath4) _GDIPlus_PathDispose($hPath5) _GDIPlus_PenDispose($hPen1) _GDIPlus_PenDispose($hPen2) _GDIPlus_PenDispose($hPen3) _GDIPlus_PenDispose($hPen4) _GDIPlus_PenDispose($hPen5) _GDIPlus_PenDispose($hPen6) _GDIPlus_PenDispose($hPen7) _GDIPlus_BrushDispose($hBrush1) _GDIPlus_GraphicsDispose($hCanvas) Return $hBitmap EndFunc Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem Local $a, $b If $x2 = $x1 And $y2 = $y1 Then Return 0 $a = $y2 - $y1 $b = $x2 - $x1 Return Sqrt($a * $a + $b * $b) EndFunc ;==>Pixel_Distance Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS I used the path functions which is not necessary because I wanted to use _GDIPlus_PathIsVisiblePoint to check the cursor position but forgot that it will work only for real filled areas!2 points
-
WinClose Not Closing Chrome
Wannabe reacted to Earthshine for a topic
Maybe Junkew can help. I get similar results1 point -
coding a commandline program
Earthshine reacted to careca for a topic
You can skip some checks, if you do something like: If $CmdLine[0] = 2 Then ;2 parameters If $CmdLine[1] = 'subapp1' Then ;sfadggsdg ElseIf $CmdLine[1] = 'subapp2' Then ;asfsgrhrh EndIf EndIf If $CmdLine[0] = 1 Then ;1 parameter If $CmdLine[1] = 'subapp3' Then ;sfadggsdg ElseIf $CmdLine[1] = 'subapp4' Then ;asfsgrhrh EndIf EndIf because you mention you may have sometimes 1 parameter, other times 2, or 3, this way you can avoid a bunch of checks.1 point -
AdlibRegister vs Timer
pixelsearch reacted to mikell for a topic
AdLibRegister is used to run a function repeatedly, and this may slow the script down. As says the helpfile, "The adlib function should be kept simple as it is executed often and during this time the main script is paused. " Same thing using a timer The only way I can think of to avoid this is to use AdLib (or timer) to run a 2nd script (which will not slow down the main script)1 point -
Is it against forum rules to pay a bounty for help here?
232showtime reacted to JLogan3o13 for a topic
We do not accept "Pay for Code" threads. If anyone is interested they can PM you, but this forum is dedicated to people who want to improve their own scripts, not for people who just want someone to do it for them.1 point -
CodeCrypter - Encrypt your Script
Miliardsto reacted to RTFC for a topic
Obviously you need to include the $CCkey definition (in MCFinclude.au3) before you call your encrypted function, not just before the function definition itself (assuming the call precedes the definition). How do you expect your script to be aware of globals if their definition is not encountered before it starts using them? Add if you wish to encrypt only particular parts of your scripts, please study the FAQ (see button "UDFs" under Tab Encrypt).1 point -
Local $hPen2 = _GDIPlus_PenCreate(0xFF00FF00, 3, 2) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MOUSEMOVE $aPos = MouseGetPos() ToolTip("Mouse Position X: " & $aPos[0] & " Y: " & $aPos[1]) Case $GUI_EVENT_PRIMARYDOWN ConsoleWrite('_GDIPlus_GraphicsDrawPie '&@MSEC&@CRLF) _GDIPlus_GraphicsDrawEllipse($hGraphics, $aPos[0] - 9, $aPos[1] - 9, 16, 16, $hPen2) EndSwitch WEnd1 point
-
WinClose Not Closing Chrome
Wannabe reacted to Earthshine for a topic
Going to car dealership. Back later. No problem1 point -
EddieBoy, Then implement the For-loop in assembler. The zip-file below contains a complete set of resources and templates to use flat assembler code in AutoIt scripts. However, you must download FASM.DLL from the flat assembler forum yourself. FASM.DLL is dated 2017-10-20. Contents in zip-file: fasm\ - Top folder fasm\ - Resources FASM.DLL - Save FASM.DLL here *.au3 - 3 AutoIt include files MsgBox\ - Templates based on MessageBoxW function x64\MsgBox-x64.asm - 64 bit assembler source code x64\MsgBox-x64.au3 - Compiles and runs the assembler code x64\MsgBox-x64.bin - Contains the binary code (generated by MsgBox-x64.au3) x64\MsgBox-x64.txt - Binary code as text string (generated by MsgBox-x64.au3) x64\MsgBox-x64.log - Information about compilation (generated by MsgBox-x64.au3) x86\ - 32 bit templates MsgBox-1.au3 - Loads and executes fasm code from binary string MsgBox-2.au3 - Loads and executes fasm code from binary file This is the x64 and x86 source files. MsgBox-x64.asm: ; flat assembler code ; Documentation ; MessageBoxW( hWnd, pText, pCaption, iType ) ; Parameters: ; rcx : hWnd ; rdx : pText ; r8 : pCaption ; r9 : iType ; [rsp + 40] : pMessageBoxW ; Init directive use64 ; 64 bit code ; Function code mov rax, qword [rsp + 40] ; pMessageBoxW -> rax sub rsp, 40 ; Stack space and alignment call rax ; Call MessageBoxW add rsp, 40 ; Restore stack pointer ; Exit code ret ; Return MsgBox-x86.asm: ; flat assembler code ; Documentation ; MessageBoxW( hWnd, pText, pCaption, iType ) ; Parameters: ; [ebp + 08] : hWnd ; [ebp + 12] : pText ; [ebp + 16] : pCaption ; [ebp + 20] : iType ; [ebp + 24] : pMessageBoxW ; Init directive use32 ; 32 bit code ; Entry code push ebp ; Store base pointer on stack mov ebp, esp ; Use stack pointer as base pointer ; Function code push dword [ebp + 20] ; 4. parameter: iType push dword [ebp + 16] ; 3. parameter: pCaption push dword [ebp + 12] ; 2. parameter: pText push dword [ebp + 08] ; 1. parameter: hWnd call dword [ebp + 24] ; Call MessageBoxW ; Exit code pop ebp ; Restore base pointer from stack ret 20 ; Return and cleanup stack You can try to run the AutoIt scripts in MsgBox folder. Make a copy of the entire MsgBox folder and rename it for your own project. Delete bin-, txt- and log-files. Rename asm- and au3-files for your project. Start coding flat assembler. fasm.7z fasm-NoBins.7z (see post 12 and 13 below)1 point
-
_IsUEFIBoot——Detemine the Current OS is boot in UEFI mode or not
coffeeturtle reacted to czyt for a topic
May it helps those who needed. #include <WinAPI.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsUEFIBoot ; Description ...: Detemine the Current OS is boot in UEFI mode or not ; Syntax ........: _IsUEFIBoot() ; Parameters ....: ; Return values .: True:OS is boot in UEFI ; False: OS is boot in Legacy BIOS ; Author ........: czyt ; Modified ......: ; Remarks .......: ; Related .......: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/DllCall~Information+Booted~UEFI~or~BIOS.txt ; Link ..........: ; Example .......: MsgBox(0,'(*^__^*) The OS is in UEFI Boot mode?',_IsUEFIBoot()) ; =============================================================================================================================== #include <WinAPI.au3> Func _IsUEFIBoot() Local Const $ERROR_INVALID_FUNCTION = 0x1 Local $hDLL = DllOpen("Kernel32.dll") If @OSBuild > 8000 Then Local $aCall = DllCall($hDLL, "int", "GetFirmwareType", "int*", 0) DllClose($hDLL) If Not @error And $aCall[0] Then Switch $aCall[1] ; 1 - bios 2- uefi 3-unknown Case 2 Return True Case Else Return False EndSwitch EndIf Return False Else DllCall($hDLL, "dword", "GetFirmwareEnvironmentVariableW", "wstr", "", "wstr", '{00000000-0000-0000-0000-000000000000}', "wstr", Null, "dword", 0) DllClose($hDLL) If _WinAPI_GetLastError() = $ERROR_INVALID_FUNCTION Then Return False Else Return True EndIf EndIf EndFunc ;==>IsUEFIBoot updated at 2021-08-13: fixed check err on windows 8 above OS1 point