Leaderboard
Popular Content
Showing content with the highest reputation since 01/18/2025 in all areas
-
Visual Studio Code Extension currently available and future plans for SciTE?
BinaryBrother and 8 others reacted to Jos for a topic
All, I see that there are multiple efforts to create/maintain an AutoIt3 Visual Studio Code extension, and I would like to open a discussion to see how that can be streamlined/merged/done more effectively so we can come up with the one that's preferred. I have been toying with the idea to stop the development of all the LUA extra's used by SciTE and start using VSCode for the more advanced way of developing AutoIt3 scripts, as many things a way after when the extension supports it, like running au3check on save so you just click the problems tab to see the warnings/errors of the currently opened scripts. So I have been working on making the utilities packaged with SciTE4AutoIt3 suitable to run stand-alone without the need for wrapping them with AutoIt3Wrapper, with the plan to be able to make them all more generic usable for any editor. They need to support UTF8 & ANSI encoded files, even when through includes the encoding is mixed. I have modified AutoIt3Wrapper to stop renaming and changing encoding of script/include files, and updated Tidy/Au3check/Au3stripper to support special characters in filenames and mixed ANSI/UTF8 file encoding and the generated console output is UTF8. I have been toying a bit with the VSCODE extension maintained by Damian (just picked one without looking at any others) and made some modifications locally for testing. Run au3check (Ctrl+F5), Tidy (Ctrl+t), Au3Stripper (Ctrl+Shift+o) without using AutoIt3Wrapper. Other already standardly available option (Run/Compile) still run via AutoIt3Wrapper as there is an added value doing it that way. I really like what I see and think this is a good way forward. So... I like to hear how you all think about this and possibly your preferred VSCode autoIt3 extension with reasons why. Also feels as a waste of effort when so many are making their own version of an extension instead of bundling the effort making one really nice one with all required features. Thoughts/Opinions?9 points -
BETA: SciTE v5x & lua Dynamic_include and "Smart" AutoComplete for Vars/UDFs/Abbrevs
argumentum and 4 others reacted to Jos for a topic
I am getting ready to publish a production update for SciTE4AutoI3, so have a SciTE4AutoIt3 v25.205.1420.0 release candidate ready and uploaded to Beta for those willing to test this installer before releasing it. Would appreciate hearing whether there are still issues with it as it has been a major overhaul since the last production version back in 2021. My main drives at this moment are to get the setup ready for better supporting Visual Studio Code as the default editor for AutoIt3, as I am convinced that there is an added benefit using VSC over SciTE. I have no intent to drop the SciTE upgrades, but do prefer to stop development & support of all the written LUA script functionalities. This is a list of the current changes at a high level: SciTE updated from v4.4.6 to v5.5.4 and includes both the x86 and x64 version selectable at install time Include the major LUA changes for Dynamic add Variables & Functions & #Include functionality. See here for details. This can be Simply disabled when old behavior is preferred by settings dynamic.include=n Utilities (Tidy.exe/au3Stripper/Au3check) can now process mixed encoded files and special characters in the filenames, so they do not require AutoIt3Wrappper anymore. The Included au3check v3.3.17.1 is an update of the standard latest au3check v3.3.16.1 included in the AutoIt3 installer. The new au3check now also supports mixed encoded files and special characters in the filenames and can be used without AutoIt3Wrapper for those cases. The installer will check the current version and replace it with this version when it is < v3.3.17.1. A copy of the old version will be made to AutoIt3\SciTE\Au3Check The installer will prompt for SciTE.exe x86 or x64 version Whether you want to change to VSCode as your default Editor for the "Edit" & "Open" options for AU3 files. What to do with Double Click, either Open or Run with AutoIt3. (also an option to change in SciTE Config) For those few that are currently using the Dynamic Beta version: There are a few minor changes since the last version published: AutoComplete #include lines wasn't working when dynamic.include=n was set. I have added the option to limited the number of entries shown in the AutoComplete dropdown to make it much more responsive when e.g. typing $a : # Define the max entries is a Variable/Func dropdown autocomplete list for speed reasons. autocomplete_dropdown_max=2005 points -
Visual Studio Code Extension currently available and future plans for SciTE?
seadoggie01 and 4 others reacted to Jos for a topic
Let's not make this topic more difficult than it is and stick for now to VSCode/SciTE. One can always decide to go down an alternative path later when VSCode is working.5 points -
BETA: SciTE v5x & lua Dynamic_include and "Smart" AutoComplete for Vars/UDFs/Abbrevs
BinaryBrother and 4 others reacted to Jos for a topic
Updated SciTE: Fixed UTF8 BOM detection.5 points -
Version 1.8.2 has just been released! I should have been 1.8.0, but issues with deployment pipeline after bigger changes to how the parser code and types are generated (internally) meant that i had to increment patch version 2 times, to successfully be able to release to the extension marketplaces. Notable changes: Added au3 DocBlock `@link` tag support Added syntax highlighting for au3 DocBlock and legacy UDF headers 2 things i would like feedback on, if possible: About the new syntax highlighting: Let me know if and/or how you like or dislike it. Performance: small changes to how the parser worked with some parser rules, to better generate types. Smaller tests indicated it was same or faster, but it can very much depend how it traverses through the code. Let me know if you notice any slow down, so I can look into fixing it ASAP! Feedback can be here, via an issue or via the discussion for the release.4 points
-
I guess I'm mixing too many different program languages these days, so goofed up pretty much with that last version. Anyway, it should be fixed with the latest Beta installer containing an update for AutoIt3Wrapper v25.205.1420.2 ... and did test properly this time.4 points
-
[SOLVED] - help, add right click option on header of active file/window/program
pixelsearch and 3 others reacted to ioa747 for a topic
Here's a script that does it with the Ctrl + Win + T hotkey. #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_Res_ProductName=WinTogleOnTop.au3 #AutoIt3Wrapper_Res_Description=Togle Window OnTop with 'Ctrl + Win + T' #AutoIt3Wrapper_Res_Fileversion=0.0.0.1 #AutoIt3Wrapper_Icon=WinTogleOnTop.ICO #include <WindowsConstants.au3> #include <WinAPISys.au3> TraySetIcon("WinTogleOnTop.ico") Opt("TrayAutoPause", 0) Global $g_ActWnd HotKeySet("#^t", "Cmd_WinTogleOnTop") ; Ctrl + Win + T" & @CRLF ;********************************** While Sleep(50) _GetActiveWindow() WEnd ;********************************** ;---------------------------------------------------------------------------------------- Func _GetActiveWindow() Local $AnyWindow = WinGetHandle("[ACTIVE]") If $g_ActWnd <> $AnyWindow Then $g_ActWnd = $AnyWindow ;ConsoleWrite("$g_ActWnd=" & $g_ActWnd & "; " & WinGetTitle($g_ActWnd) & @CRLF) EndIf EndFunc ;==>_GetActiveWindow ;---------------------------------------------------------------------------------------- Func Cmd_WinTogleOnTop() Local $iStyle = _WinAPI_GetWindowLong($g_ActWnd, $GWL_EXSTYLE) Local $iStyleTopMost = BitOR($iStyle, $WS_EX_TOPMOST) Local $aWPos = WinGetPos($g_ActWnd) If $iStyle = $iStyleTopMost Then WinSetOnTop($g_ActWnd, "", 0) ToolTip(" ", $aWPos[0], $aWPos[1], "Normal", 1) Else WinSetOnTop($g_ActWnd, "", 1) ToolTip(" ", $aWPos[0], $aWPos[1], "On top", 3) EndIf Sleep(1000) ToolTip("") EndFunc ;==>Cmd_WinTogleOnTop ;----------------------------------------------------------------------------------------4 points -
Here's the pic from the first thread.... Imagine the first column of each number is a BYTE, with Most Significant Bit being 128, then 64, 32 16 8 4 2 1, we dont need the 128 as each number is only 7 imaginary bits tall, then the loop starts at the top left corner and reads the first bit, if it's lit it adds $value=64 to $code[0], if unlit nothing is added, then the next DllStructGetData reads the next number, and so on, when it gets to the end (last number) then $value is divided by 2 so it's 32 which is the next significant bit and the STEP in the loop goes to next line/bit, if it finds any lit bits it adds $value to $code, and so on.... The $code's now have values, which we then look up in the lookup table, like 114 is 5, the last in the lookup as it's the largest number, while 4 is located at 12'th place. (Damn my explanation and graphics skills suck, it would have been much easier in real life just pointing with the finger and explaining, if there's something you didnt get I'll try to explain it again, but I'm sure you can figure it out now 😛 )3 points
-
AutoIt parser in AutoIt
ValentinM and 2 others reacted to SOLVE-SMART for a topic
Please don't. Please do not apologize for your great work. Yes it does not work in the first place, but to me it does not matter that much. What matters, and this is the point what I appriciate the most, your answers, your code and your explanations (here or on GitHub) makes me a better programmer and lead me to learn new things. I will test the new parser example tomorrow (or in the next days) and will let you know about possible questions etc 🤝 . Best regards Sven3 points -
Visual Studio Code Extension currently available and future plans for SciTE?
donnyh13 and 2 others reacted to argumentum for a topic
...at times ( quite often ), I do disagree with the better angels of my nature and, pay the price 😭 But, 60 years later am slowly identifying the pattern and can say, that am starting to be more mindful of the advisor. If I continue paying good attention, I figure I'll be wise at about the age of 1203 points -
Visual Studio Code Extension currently available and future plans for SciTE?
seadoggie01 and 2 others reacted to SOLVE-SMART for a topic
Many thanks to everyone, especially to @genius257 for your well written assessment and your explanation 👌 . A few pros and cons were already mentioned which is great. I really looking forward to @LoganCHs opinion and to his statements about his VSCode extension (origin by Damien, "damien.autoit"). I believe he is pretty busy and maybe cannot work on the extension much more. At least that's my impression over the last few months or maybe even the last two years. The GitHub "issue" area is relatively full and only a few of the requests were processed promptly. 💡 Important: This is really not meant to be a criticism, as I really enjoy working with VSCode with the extension, it's just an statement. Hence the question of how he sees the future in this regard or if he would like support with further development. Best regards Sven3 points -
I did originally use the Damien.autoit extension in vscode myself, and found issues I wanted to fix via pull requests. But after looking at the usage of regular expression and the reliance on AutoIt executables (nothing wrong with that as such, I mean it works), I wanted to try a entirely different approach. I started implementing my own extension after I experienced inconsistent behavior from the Damien.autoit version. For example: sometimes the suggestions did not work as expected, with no error messages. I was also working on a AutoIt parser in Pegjs grammer syntax (now Peggyjs) and saw it as the perfect opportunity for testing it's capabilities. My extension does not depend on any files from AutoIt installations, and therefore works in web (test here: https://vscode.dev/) and on on non windows environments, like Linux (I use Ubuntu from time to time). The Damien.autoit extension uses regular expressions to parse the file (for completions and such), where I use my parser as mentioned before. My extension also runs via LSP, Damien.autoit does not. There are also small differences like incorrect syntax highlighting for nested comments on the Damien.autoit extension (this issue can be fixed by looking at my tmLanguage implementation). Try this between the two extensions as an example: #cs #cs #cs #ce #ce #ce $a To be clear I am not saying my extension is superior. My extension is currently slower at parsing scripts, the parser i am using/developing is in active development and incomplete (with code blocks are currently not implemented) and since I don't use AutoIt executables for error checking there is currenly little to no error checking, besides the syntax check (and recently error messages for include statements that fail to resolve). This also means that to run AutoIt scripts with my extension, a secondary extension is needed (https://marketplace.visualstudio.com/items?itemName=genius257.autoit3-debug) My extension is also made to move towards what I want for the AutoIt development experience. This means support for a new, more standardized doc-block way of documenting function and variable declarations. The standard UDF documentation format is supported for backwards compatibility, but is currently not great, and will only ever be implemented by me to "good enough" standard. I am unsure what you mean by "azure" dependencies? The only azure i am using that i know of, is for auto deploying to vscode extension marketplace and Open VSX Registry automatically, when a new release is created on GitHub, via GitHub actions?3 points
-
Visual Studio Code Extension currently available and future plans for SciTE?
IronFine and 2 others reacted to argumentum for a topic
Love SciTE. Don't understand VSCode. Tried for over an hour and, love SciTE4AutoIt3. Now, VSCode is an editor and I should be able to get used to it. If an extension removes the need for having to maintain all these utilities + a full fledged editor, I guess is a solution for that. And people abroad are very familiar with it ( VSCode ) so, it would not be a bad idea. Did I say that I love SciTE4AutoIt3 ?..., yes I did. And like @IronFine, is all I used for AutoIt since 2005. VSCode would be an interesting move for me.3 points -
Uploaded a new beta for au3check, which will now also allow mixed encoding for include files, which was also an issue. This should now allow for use of au3check in VSCode without any wrapper showing a valid filename in Problems. Let me know when there are still issues with its use in VSCode.3 points
-
[SOLVED] - help, add right click option on header of active file/window/program
232showtime and 2 others reacted to Nine for a topic
FWIW, I felt that the tool (mentioned above) would be kind of fun to make, so there you go : #include <WinAPISysWin.au3> #include <WinAPISys.au3> #include <WinAPIConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <GuiMenu.au3> #include <GUIConstants.au3> #include <ColorConstants.au3> Opt("MustDeclareVars", True) Global Const $tagTITLEBARINFOEX = "int cbSize;" & $tagRECT & ";dword rgstate[6];dword rgrect[24]" Global $bRight, $hMSHook, $hMSProc, $hWnd If Not _Singleton("AutoIt SetOnTop Tool", 1) Then Exit MsgBox($MB_OK, "Error", "Tool already loaded") HotKeySet("{END}", Terminate) Example() Func Example() $hMSProc = DllCallbackRegister(MouseProc, "long", "int;wparam;lparam") $hMSHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMSProc), _WinAPI_GetModuleHandle(0)) OnAutoItExitRegister(CleanUP) While Sleep(100) If $bRight Then $bRight = False ToggleSetOnTop() EndIf WEnd EndFunc ;==>Example Func MouseProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hMSHook, $nCode, $wParam, $lParam) If ($wParam = $WM_RBUTTONDOWN Or $wParam = $WM_RBUTTONUP) And _IsPressed("11") Then $hWnd = GetWindow() If $hWnd Then $bRight = $wParam = $WM_RBUTTONUP Return 1 EndIf EndIf Return _WinAPI_CallNextHookEx($hMSHook, $nCode, $wParam, $lParam) EndFunc ;==>MouseProc Func ToggleSetOnTop() Local $iTop = BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $WS_EX_TOPMOST) Local $aPos = MouseGetPos() Local $hGUI = GUICreate("", 200, 32, $aPos[0], $aPos[1], $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0xD0D0D0) Local $idLabel = GUICtrlCreateLabel($iTop ? "Topmost OFF" : "Topmost ON", 0, 0, 200, 32, $SS_CENTERIMAGE + $SS_CENTER) GUICtrlSetFont(-1, 18, Default, Default, "Arial") GUICtrlSetColor(-1, $iTop ? $COLOR_RED : $COLOR_GREEN) GUISetState() While WinActive($hGUI) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idLabel WinSetOnTop($hWnd, "", $iTop ? $WINDOWS_NOONTOP : $WINDOWS_ONTOP) ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>ToggleSetOnTop Func CleanUP() _WinAPI_UnhookWindowsHookEx($hMSHook) DllCallbackFree($hMSProc) EndFunc ;==>CleanUP Func Terminate() Exit EndFunc ;==>Terminate Func GetWindow() Local Static $tPoint = DllStructCreate($tagPOINT) Local Static $tTITLEBARINFOEX = DllStructCreate($tagTITLEBARINFOEX) DllStructSetData($tTITLEBARINFOEX, "cbSize", DllStructGetSize($tTITLEBARINFOEX)) $tPoint.X = MouseGetPos(0) $tPoint.Y = MouseGetPos(1) Local $hWin = _WinAPI_GetAncestor(_WinAPI_WindowFromPoint($tPoint), $GA_ROOT) _SendMessage($hWin, $WM_GETTITLEBARINFOEX, 0, DllStructGetPtr($tTITLEBARINFOEX)) If $tTITLEBARINFOEX.top + $tTITLEBARINFOEX.bottom + $tTITLEBARINFOEX.left + $tTITLEBARINFOEX.right = 0 Then Return 0 If $tTITLEBARINFOEX.bottom <= $tTITLEBARINFOEX.top Then $tTITLEBARINFOEX.bottom = $tTITLEBARINFOEX.top + 35 If $tPoint.X >= $tTITLEBARINFOEX.left And $tPoint.X <= $tTITLEBARINFOEX.right And $tPoint.Y >= $tTITLEBARINFOEX.top And $tPoint.Y <= $tTITLEBARINFOEX.bottom Then Return $hWin EndIf Return 0 EndFunc ;==>GetWindow Latest version : 2025-02-01 07:013 points -
It is a common belief that AdlibRegister will interrupt itself if the delay is too short for the function to complete. But it will not. It will simply pass to the next cycle. Here a simple example of it. HotKeySet("{ESC}", Terminate) AdlibRegister(Test, 1000) While Sleep(500) WEnd Func Test() For $i = 1 To 10 Sleep(300) Next ConsoleWrite(@SEC & @CRLF) EndFunc Func Terminate() Exit EndFunc Even if the delay is 1 sec and the function takes 3 secs, it does not interrupt itself. So there is not much need, IMO to unregister and reregister the function.3 points
-
So here some partial recognition based on the png files. As its italic it will be more complicated to properly first cut the characters nicely. I hope the script gives you some insights on how to do the analysis. When thats done you could directly bitblit line11 and 27 and 41 from the screen as that seems to be a proper discriminator to identify the number. From the screen you can probably directly bitblt with black/white pixels directly which should speed up even more. Due to italic it seems a little harder to calculate the exact position for each digit calculated (maybe even easier to just hardcode them as it seems to be off by 1 or 2 bytes for each digit. #Region includes Opt('MustDeclareVars', 1) ;#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> #include <string.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #EndRegion _GDIPlus_Startup() Dim $BitmapFilename Dim $BMPData="", $BMPWidth=0, $BMPHeight=0, $BMPLineWidth=0, $imgBytes=2 dim $binaryLine, $startColumn ;~ for each picture file for $i=1 to 4 $BitmapFilename = @TempDir & "\" & "pic" & string($i) & ".png" $BMPData="" $BMPWidth=0 $BMPHeight=0 $BMPLineWidth=0 $imgBytes=1 consolewrite($bitmapFileName) ; Load the bitmap to find getImage($BitmapFilename, $BMPData, $BMPWidth, $BMPHeight, $BMPLineWidth, $imgBytes) ;~ See the height and width and dump the data on screen consolewrite($BMPHeight & " ; ") consolewrite($BMPWidth &@CRLF ) consolewrite(" 0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite(" 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 ;~ From the screenshots we can ignore the first 16 bytes (remember in text its 2 characters ;~ $binaryLine=BinaryMid($bmp1Data,($i*$BMP1LineWidth)+16,$BMP1LineWidth) ;~ and we only need 4 digits which takes about 28 characters and 1 character separator = $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16,60) ;~ $binaryLine=$bmpData ;~ Lets make it readable $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ lets recognise for $iNumber=1 to 4 consolewrite(@crlf) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) ;~ Its hard to determine the column for each digit in a formula if $iNumber=1 then $startColumn=16 if $iNumber=2 then $startColumn=30 if $iNumber=3 then $startColumn=45 if $iNumber=4 then $startColumn=59 ;~ Only a few lines in the png are of interest For $iLine = 11 To $BMPHeight-12 ;~ $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16+(($iNumber-1)*14),15) $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+$startColumn,15) $binaryLine=StringReplace($binaryLine,"0"," ") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ if on line 11 at position 28 I have a B it can be a 4 ;~ It seems to be easier to revert back to a string when we have the data local $lineData11=stringstripws(StringRegExpReplace(binaryMid($bmpData,(11*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) local $lineData27=stringstripws(StringRegExpReplace(binaryMid($bmpData,(27*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) local $lineData41=stringstripws(StringRegExpReplace(binaryMid($bmpData,(41*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) consolewrite(string($lineData11) & " - ") consolewrite(string($lineData27) & " - ") consolewrite(string($lineData41) & @crlf) ;~ And here determine the magic lines if (($lineData11="BBB") and ($lineData27="B222B B222B")) then consolewrite("Ita a 4" & @CRLF) if (($lineData11="BBB BBB") and ($lineData27="B222BB222BB222BB222B")) then consolewrite("Ita a 6" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222BB222BB222B")) then consolewrite("Ita a 9" & @CRLF) if (($lineData11="BBB") and ($lineData27="B222B")) then consolewrite("Ita a 1" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222BB222B")) then consolewrite("Ita a 8" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222B B222B B222B")) then consolewrite("Ita a 0" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222B") and ($lineData41="BBB BBB BBB")) then consolewrite("Ita a 3" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222B") and ($lineData41="BBB BBB BBB BBB BBB")) then consolewrite("Ita a 2" & @CRLF) if (($lineData11="BBB BBB BBB BBB BBB") and ($lineData27="B222B") and ($lineData41="BBB")) then consolewrite("Ita a 7" & @CRLF) if (($lineData11="BBB BBB BBB BBB BBB") and ($lineData27="B222B") and ($lineData41="BBB BBB BBB")) then consolewrite("Ita a 5" & @CRLF) Next Next _GDIPlus_Shutdown() Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle, $bitMapdata, $pixelFormat ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) ;~ $hBitmap = _GDIPlus_ImageLoadFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;Get $tagGDIPBITMAPDATA structure ConsoleWrite("Bitmap Width: " & _GDIPlus_ImageGetWidth($pBitmap) & @CRLF ) ConsoleWrite("Bitmap Height: " & _GDIPlus_ImageGetHeight($pBitmap) & @CRLF) ;~ 24 bits (3 bytes) or 16 bits (2 bytes) comparison if ($imgBytes=1) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF04INDEXED) Endif if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) EndIf if ($imgBytes=3) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) endIf If @ERROR Then MsgBox(0,"","Error locking region " & @error) $Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $Width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap. $Height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap. $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixelData = DllStructCreate("ubyte lData[" & (abs($Stride) * $Height-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect #EndRegion3 points
-
_RunWaitEx() UDF
SOLVE-SMART and 2 others reacted to argumentum for a topic
,,in the help area I gave some advice and oops !, ..it works for me because I extended the code but did not share it 😅 So here is the extended code that I call "UDF". Is not up to AutoIt UDF standards but, it runs. ( anyone willing to bring it up to standards, I'll edit this and place your version 😇 ) and here is the demo code #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "_RunWaitEx.au3" ; https://www.autoitscript.com/forum/topic/212643-_runwaitex-udf/ ConsoleWriteWLineNumber('Version: ' & _RunWaitEx_Version() & @TAB & @error & @TAB & @extended & @CRLF) ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- Example_InTheLoop() Func Example_InTheLoop() ConsoleWrite(@CRLF & '+ Example_InTheLoop' & @CRLF & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc(Example_InTheLoop) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc("") & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc("Example_InTheLoop") & '"' & @TAB & @error & @TAB & @extended & @CRLF) ;~ ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc(DontExtst) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc(MyLoopOrYours) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) _RunWaitEx("Dir") _RunWaitEx_DefaultLoopFunc("") EndFunc ;==>Example_InTheLoop Func MyLoopOrYours($WhateverYouMayUseThisFor, $sStringFromCmdLine = "") ; the func needs to have 2 parameters #forceref $WhateverYouMayUseThisFor ConsoleWriteWLineNumber('' & @MIN & ':' & @SEC & '.' & @MSEC & @TAB & $sStringFromCmdLine & @CRLF) ;~ ProcessClose(_RunWaitEx_Last_iPID()) ;~ _RunWaitEx_ProcessClose(1) ; ..remember to set to zero afterwards EndFunc ;==>MyLoopOrYours ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- Example_InTheEditCtrl() Func Example_InTheEditCtrl() ConsoleWrite(@CRLF & '+ Example_InTheEditCtrl' & @CRLF & @CRLF) Local $iW = 600, $iH = 400 Local $hGUI = GUICreate("Example_InTheEditCtrl", $iW, $iH, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) Local $idEdit = GUICtrlCreateEdit("", 0, 0, $iW, $iH) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW) ConsoleWriteWLineNumber('DefaultConsoleWrite: "' & _RunWaitEx_DefaultConsoleWrite() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultConsoleWrite: "' & _RunWaitEx_DefaultConsoleWrite(0) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultCtrlEdit: "' & _RunWaitEx_DefaultCtrlEdit() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultCtrlEdit: "' & _RunWaitEx_DefaultCtrlEdit($idEdit) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultCtrlEdit: "' & _RunWaitEx_DefaultCtrlEdit() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ; ..remember to set to zero afterwards _RunWaitEx("Dir") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGUI) ExitLoop EndSwitch WEnd EndFunc ;==>Example_InTheEditCtrl ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- Func ConsoleWriteWLineNumber($sStr, $iLine = @ScriptLineNumber, $iError = @error, $iExtended = @extended) Local $iRet = ConsoleWrite('@@ (' & $iLine & ') : ' & $sStr) Return SetError($iError, $iExtended, $iRet) EndFunc ;==>ConsoleWriteWLineNumber so @daledale , please pardon my oops. On the bright side, you may find this ( what I meant ) useful, and hope it serves you in your project PS: there may be some comments that were true in the original snippet but not longer true/relevant. This is a spur-of-the-moment kind of post. Do uncomment and re-comment lines to mess with it, as a learning tool. You're gonna have to read the UDF to know what functions are available ( given my laziness ).3 points -
Regarding speed maybe it makes a difference with stretchblt directly going to a smaller size instead of bitblt Example for screenshot in a smaller size. #include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Func CaptureAndResize($savePath, $newWidth, $newHeight) ; GDI+ initialiseren _GDIPlus_Startup() ; Schermresolutie ophalen Local $iScreenWidth = @DesktopWidth Local $iScreenHeight = @DesktopHeight ; HDC's ophalen Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) ; Bitmap maken Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iScreenWidth, $iScreenHeight) Local $hOldObj = _WinAPI_SelectObject($hMemDC, $hBitmap) ; Scherminhoud kopiëren met StretchBlt (resize mogelijk) _WinAPI_StretchBlt($hMemDC, 0, 0, $newWidth, $newHeight, $hDC, 0, 0, $iScreenWidth, $iScreenHeight, $SRCCOPY) ; Screenshot opslaan als bestand _ScreenCapture_SaveImage($savePath, $hBitmap) ; Opruimen _WinAPI_SelectObject($hMemDC, $hOldObj) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC(0, $hDC) _GDIPlus_Shutdown() EndFunc ; Gebruik de functie om een screenshot te maken en te resizen naar 800x600 CaptureAndResize(@UserProfileDir & "\downloads\examples\" & "screenshot_resized.jpg", 800, 600)2 points
-
Uploaded a new beta installer that has the following updates: Added VSCode wrapper to show output in user tasks Added example user tasks Fixed some /AddIncludes issues with constants and duplicate local includes Just take a look at the tasks.json included in the autoit3Wrapper directory, which will allow you to add AutoIt3Wrapper tasks like /addincludes and /au3stripper to the tasks in VScode. These tasks will shell an already included powershell script (see below) in the AutoIt3Wrapper directory that will ensure that the output will be shown in the VScode terminal window. The powershell wrapper included with some more detailed description: # # # # powershell script to wrap AutoIt3Wrapper to use in VSCODE and show the console output when ran as Task # # # When you get: File C:\Program Files (x86)\AutoIt3\SciTE\run_autoit.ps1 cannot be loaded # because running scripts is disabled on this system. For more information...... # The error message indicates that PowerShell script execution is disabled on your system. # You need to enable script execution by setting the execution policy. # You can do this by # 1. running PowerShell as an administrator and executing the following command: # 2. Do command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser # This command sets the execution policy to RemoteSigned for the current user, allowing locally created scripts to run. param ( [string]$AutoitPath, [string]$Options, [string]$ScriptFile ) # Run AutoIt3 Wrapper & "$autoitPath\Autoit3.exe" "$autoitPath\Scite\AutoIt3Wrapper\AutoIt3Wrapper.au3" $options /in "$scriptfile" | Write-Output echo "--Done--" Thoughts?2 points
-
Interesting usage of Security Descriptor/Attribute. I wouldn't have thought of using it this way. I need to dig a bit more to fully understand the intrinsic. But in any case, at first glance, there is no need to have a DLL or C++ to perform the task. All I have seen is simple calls to WinAPI. Everything could be performed inside AutoIt (like I said at first glance). I will look into this later today and come back.2 points
-
Visual Studio Code Extension currently available and future plans for SciTE?
WildByDesign and one other reacted to ValentinM for a topic
FYI, this feature doesn't come from VSCode itself but from GitHub Copilot, which is an AI helper using GPT-4 that predicts code based on your files (I can't remember if it sticks to the current file or more, but it was originally supposed to only read the current one). It not only predicts the right includes but is also excellent at making loops, filling arrays, etc. However, it can be quite bad at other tasks. It learns from your code and can read your comments, so you can implicitly give it directives. For example: So keep in mind that it could mess with the includes as well. But I use it daily, and it helps me more than it hurts my brain 😀 In the past, you had to be a student, teacher, or pay for access to Copilot, but I can see on their website that it has become free. To use it, you have to install this extension and probably sign in or sign up for a GitHub account. EDIT : Autocompletion is made by pressing TAB.2 points -
Visual Studio Code Extension currently available and future plans for SciTE?
WildByDesign and one other reacted to Jos for a topic
But you could still use the initial version I made with AutoIt3Wrapper, which is implemented in AutoIt3Wrapper and still there: I am not fully up-to-speed on the best way to add own stuff to VSCode but this works fine for me: // filepath: vscode-userdata:/c%3A/Users/.../AppData/Roaming/Code/User/tasks.json { "version": "2.0.0", "tasks": [ { "label": "Add AutoIt Includes", "type": "shell", "command": "${config:autoit.aiPath}\\Autoit3.exe", "args": [ "${config:autoit.aiPath}\\SciTE\\AutoIt3Wrapper\\AutoIt3Wrapper.au3", "/addincludes", "/in", "${file}" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": [], "detail": "Add missing includes to the AutoIt script" } ] } // keybindings.json [{ "key": "ctrl+shift+z", "command": "workbench.action.tasks.runTask", "args": "Add AutoIt Includes", "when": "editorTextFocus && editorLangId == 'autoit'" }]2 points -
Great catch again, I've now implemented both solutions. Minor nitpick is that WriteFileFromArray doesn't currently support LF line endings so I have to use dos2unix on the output, which I reported as a bug here, but apart from that it works perfectly. Just out of interest, if in the future I wanted to use this to brute-force a larger range of serial numbers (7, 8 or 9 digits instead of 6) the amount of failed cases might get a little too much to handle manually like I am now, and this also requires that I run the script with two different methods and diff both files. Is there an easy way of making it so that the script does fallback to returning nothing instead of 0000 when nothing is recognised, so that I can then bring back the Do Until loop to take a little more time on those particular numbers? If this would require too much work don't worry about it, but if it's an easy change it would be a huge improvement to the robustness of the script. Also as requested I have now donated to AutoIt, thanks once again everyone.2 points
-
Good morning, I would love to contribute to either of the extensions. As I mentioned, I have been using VSCode with the Damian/Loganch extension for quite some time, and having the "Problems" tab really speeds up development. What do I love about the genius257 extension? IntelliSense is context-aware. So, if I am typing a variable, it lists everything that is valid in the current context. Combining the best features of both extensions would be amazing!2 points
-
Visual Studio Code Extension currently available and future plans for SciTE?
genius257 and one other reacted to argumentum for a topic
Am using both. Why, how, ..even added a "genius257.autoit3-debug". What am I doing ?, ..just F5 ( to run ) and clicking around. I tend to learn that way ..20 minutes later.. ok, I see that Damian has ">AutoIt: command" and if I remove it that's not there. I'll play around a bit more2 points -
Glad you found a solution. If you feel like donating, Just send it to AutoIt.2 points
-
Hi all, I just wanted to write about the current WIP release and future extension plans. For the 1.8 release: For anyone interested in the new DocBlock format, I've implemented support for @link tags, both as a stand alone tag and inline tag. I also plan to implement syntax highlighting for both DockBlock format and the legacy UDF format. I've been busy working on issues with the parser and auto-generated typescript types. This is, and my AutoIt3 parser in AutoIt3 project are the reason for the slow release of 1.8. When i resolve the last issues with type generation, i will finish and release 1.8! 🙂 For future releases: The function signature helper for parameters in functions is currently too flaky for me, and i will spend time to try and improve the experience. I will look into partial code AST object updates with the parser. I am not 100% sure how well i will be able to implement it, but i hope to improve performance when working in big script files. I want to add a static typing to functions and variables. Type hinting or casting will be supported via a new comment syntax. Built-in functions and variables will be supported right away, when typing resolution is released. This should help with general development and allow warnings with for example, when doing implicit variable type casting via operators. I also want to implement a formatter/linter. For now, the plan is to add it to this extension, but may end up being it's own thing, depending on configuration complexity and performance overhead. Also, completion suggestions for DllStruct object members. DllStruct's (and maybe some COM objects) will be analyzed and allow completion suggestions and errors for use of non existing members. This MAY also include Map and Array objects, but it is unclear how easy it will be to infer size and members of those. And finally for now, syntax highlighting and attempted analysis of strings given to Eval, Execute and Assign. I cannot guarantee all will be implemented. Most will be exploratory implementations when the time comes, but hopefully it will result in the best editor experience i can offer!2 points
-
QuickLaunch alternative for Windows 11
TomTheGeek and one other reacted to dv8 for a topic
Hello everyone! Apparently, the last time I've been here was 13 years ago! How time flies... What made me come back is the Microsoft's stupid decision to remove the QuickLaunch from Windows 11. On all the previous versions I used to have a QuickLaunch toolbar on my taskbar and had all the shortcuts for my different projects neatly arranged in sub-folders. After this feature was removed, I tried the ExplorerPatcher but at some point it started getting flagged by the Defender. And it added a lot more things that were not necessary for me. I only needed the QuickLaunch. So after a lot of frustration i decided to make my own and remembered the dear old AutoIt! The script below uses an INI file with the same name to get which folder you want to use as a QuickLaunch and creates a 5px by 5px simple GUI at the top left corner of the screen, which sits on top of the other windows. The GUI has a menu with sub-menus and items corresponding to the sub-folders and the .lnk files in the QuickLaunch folder. It tracks the position of the mouse and when it gets to the top-left corner it clicks on the GUI to display the menu. Since it loads the folder only once at the start, there is a CRTL+ALT+R hotkey combination to quickly restart the app and reload the shortcuts if you have made any changes. CTRL+ALT+X is for exiting the app. When compiled, the executable is a little over 1MB and uses about 8-9MB of RAM I'm sharing it here hoping it would be as useful to you as it is to me. Best wishes for the new 2025 from Bulgaria! Edit: Forgot to mention it uses the ModernMenu UDF by Holger Kotsch QuickLaunch.ico QuickLaunch.ini QuickLaunch.au3 ModernMenuRaw.au32 points -
AutoIt parser in AutoIt
SOLVE-SMART and one other reacted to genius257 for a topic
Hi @SOLVE-SMART, I am sorry for the problems you found, that's my bad. 😞 The warning with $TYPES_TO_PROPERTY_NAMES possibly being used before declaration, i have fixed with a #forcedef. The error with "Statement cannot be just an expression", will pass at runtime, but would not work as expected, so I've fixed it with a new helper method "__setKeyValue" The warning/error with $a being an undeclared global variable and possibly used before declaration, was an oversight by me and have been fixed. No problem at all My vscode-autoit3-debug extension simply does not use the Au3Check tool, and therefore i only notice issues at runtime, currently (I should have manually used Au3Check before uploading 🤡). If i had reached the non declared variable area, the code would have crashed and I would have noticed, but had not yet, and the AutoIt runtime itself therefore does not care But I've updated the uploaded files, after fixing the issues. You only need the parser.au3 file for testing, the autoit3-modified.pegjs is just for showing the source grammar that generated the AutoIt3 code Thanks for the heads up, and once again my apologies for my lack of quality control 😅2 points -
3D array ; 3D array [table][row][column] Local $aProducts[3][4][4] = [ _ [ _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-MB\1.0", "showInteractiveHelp", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-MB\1.0", "showWelcomeHint", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-MB\1.0", "LicenseText", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-MB\1.0", "Product", "REG_DWORD", "00000000"] _ ], [ _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-Q\3.0", "showInteractiveHelp", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-Q\3.0", "showWelcomeHint", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-Q\3.0", "LicenseText", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-Q\3.0", "Product", "REG_DWORD", "00000000"] _ ], [ _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-R\2.0", "showInteractiveHelp", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-R\2.0", "showWelcomeHint", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-R\2.0", "LicenseText", "REG_DWORD", "00000000"], _ ["HKEY_CURRENT_USER\Software\FabFilter\Pro-R\2.0", "Product", "REG_DWORD", "00000000"] _ ]] For $t = 0 To UBound($aProducts) - 1 ;table ConsoleWrite("Part" & $t & @CRLF) For $r = 0 To UBound($aProducts, 2) - 1 ;row For $c = 0 To UBound($aProducts, 3) - 1 ;column ConsoleWrite($aProducts[$t][$r][$c] & " - ") Next ConsoleWrite(@CRLF) Next Next2 points
-
BETA: SciTE v5x & lua Dynamic_include and "Smart" AutoComplete for Vars/UDFs/Abbrevs
SOLVE-SMART and one other reacted to Jos for a topic
Only use this latest version.... All the other stuff will be closed soon. This latest version has everything in it that was developed/changed in the last couple of years, including the Dynamic stuff. As soon as the release candidate is proven to be working, then all webinfo and links will be updated.2 points -
I have uploaded an updated version that supports these optional parameters: SciTE4AutoIt3.exe [/S] [/SCITE=x64 or X86] [/EDITOR=SCITE or VSCODE] [/ONOPEN=EDIT or RUN] When not provided, they will default to what is in the registry currently. When not defined in the registry, the defaults are: X86, SCITE, RUN. Also added an extra config option to SciTEConfig, which allows for swapping between SciTE & VSCode, which will be shown when VSCode is installed:2 points
-
Visual Studio Code Extension currently available and future plans for SciTE?
SOLVE-SMART and one other reacted to ValentinM for a topic
The power of VS Code is in extensions. You want bookmarks ? Install Bookmarks. Or maybe you would like a "session" system just like in SciTE ? Install Save and restore tabs. You also can open .csv files, and color them with Rainbow CSV for a better reading experience, or even use Git(hub/lab) straight into it. Copilot can help too, and since it reads your open files, we have to admit that it works pretty well. These are some extensions I am using, I hope it will be useful for someone.2 points -
Based on the input string provided by OP, it seems that the list is already pre-sorted, so shouldn't be just : Local $sValue = "'133.0.3','133.0','133.0b7','133.0b8','133.0b9','134.0.1','134.0.2','134.0','134.0b1','134.0b3','134.0b5','134.0b9','135.0','135.0.1','135.0.2','135.0b1','135.0b3','135.0b5','135.0b9','136.0b1'" Local $aVersion = StringRegExp($sValue, "(?>\d+\.)+\d+\b", 3) ConsoleWrite($aVersion[UBound($aVersion) - 1] & @CRLF) But if it is not the case, here my take on it : Local $sValue = "'133.0.3','133.0','133.0b7','133.0b8','133.0b9','134.0.1','134.0.2','134.0','134.0b1','134.0b3','134.0b5','134.0b9','135.0','135.0.1','135.0.2','135.0b1','135.0b3','135.0b5','135.0b9','136.0b1'" Local $aVersion = StringRegExp($sValue, "(?>\d+\.)+\d+\b", 3) ConsoleWrite(GetLatestVersion($aVersion, 3, 3) & @CRLF) Func GetLatestVersion(ByRef $aList, $iNum, $iWidth) Local $sVal, $sMax, $aMax, $iMax For $i = 0 To UBound($aList) - 1 $aMax = StringSplit($aList[$i], ".") For $j = 1 To $iNum $sVal &= StringFormat("%0" & $iWidth & "i.", $j > $aMax[0] ? 0 : Int($aMax[$j])) Next If $sVal > $sMax Then $sMax = $sVal $iMax = $i EndIf $sVal = "" Next Return $aList[$iMax] EndFunc2 points
-
Visual Studio Code Extension currently available and future plans for SciTE?
SOLVE-SMART and one other reacted to genius257 for a topic
Look at your current selected language mode: If it says "AutoIt" then it's Damien.autoit, if it says "AutoIt3" then it's my extension running. I just tested it myself, and it does not seem like any functionality overlap between the extensions, because of this. Multiple extensions can be active at the same time, even for the same language. It requires that the same activation requirements are met, like the language mode. It can however introduce unexpected issues. Some functionality might be merged (like suggestions), but others depend on the order, the extensions are loaded and register features/events with the extension. Mostly it's best to stick with one, when it comes to things like IntelliSense, to avoid inconsistent user experience.2 points -
Get Maximum number that has digits to get stable latest version
Davidyese and one other reacted to AspirinJunkie for a topic
1. To extract only the version numbers without beta or anything else, you can use the following pattern (there are many alternative approaches for such a pattern, but this is based on your specific example): (?>\d+\.)+\d+\b 2. A normal _ArrayMax/_ArraySort etc. is not sufficient to determine the actual maximum including all secondary versions. The elements are strings and a classic AutoIt string comparison, on which _ArrayMax/_ArraySort is based, compares character by character. In this specific case, this would even work, but if you imagine that you now have the elements '135.0.3' and '135.0.20' in the list, then '135.0.3' would still be returned as the result. You have tried to get around this by setting the size comparison for _ArrayMax to “numeric”, but that doesn't help here either, as it means that the strings are first converted into a number. And that means that “135.0.2” simply becomes 135. So you either need a function that sorts the array with its own comparison function or returns the maximum, or you create a value for each value yourself that can be correctly compared by _ArrayMax. For the former, there are already UDFs such as >>this<<. The solution to your question would look like this: #include "ArrayPlus.au3" ; input string $sValue = "'133.0.3','133.0','133.0b7','133.0b8','133.0b9','134.0.1','134.0.2','134.0','134.0b1','134.0b3','134.0b5','134.0b9','135.0','135.0.1','135.0.2','135.0b1','135.0b3','135.0b5','135.0b9','136.0b1'" ; extract stable versions $aStables = StringRegExp($sValue, "(?>\d+\.)+\d+\b", 3) ; determine max version number $sMax = _ArrayGetMax($aStables, __ap_cb_comp_Natural) ; present result MsgBox(0,"max stable version", $sMax) 3. _ArraySort($sValue, 1) does nothing at all. As the name suggests, it sorts arrays. $sValue, on the other hand, is a string. (What @error also tells you, if it had been analyzed.)2 points -
Visual Studio Code Extension currently available and future plans for SciTE?
genius257 and one other reacted to WildByDesign for a topic
I think that this is a great idea. My productivity is much higher in VSCode. I have used the AutoIt extension from genius257 for about a year now. When working with AutoIt code, I always have the Au3 files open in SciTE4AutoIt3 and VSCode at the same time and continuously switching back and forth. For doing things such as large numbers of Search/Replace, VSCode is far superior here. Just the Search/Replace functionality alone is quite significant of a difference. I would imagine that maintaining the old code from SciTE4AutoIt3 is also likely cumbersome. This thread made my day.2 points -
Visual Studio Code Extension currently available and future plans for SciTE?
genius257 and one other reacted to argumentum for a topic
I'd say that am new to it but to be frank, am a step behind new I saw in "package-lock.json" a bunch of "@azure" entries and the other repo. does not have those entries, hence my assumption. Saw a bunch of arm(CPU) entries and imagined that "he is coding in a raspberryPi AutoIt via Azure Extensions, interesting" but is just my imagination as I see now. Maybe I should write "Mr.Robot v2.0, the re-incarnation" given my dream like, tech-fy brain2 points -
Visual Studio Code Extension currently available and future plans for SciTE?
SOLVE-SMART and one other reacted to ValentinM for a topic
I’ve been using PhpStorm and VSCode for a few years now, and I couldn't get used to SciTE (although I use it occasionally because of its lightweight nature). That’s why I managed to make things work with @genius257's extension, as Damien’s version was old (not updated since a long time when I tried it) and highlighting all our base code in red (since we’re using OOP and multiple files in my team). The extension fits my needs perfectly. Additionally, I developed my own extension to open the AutoIt Help when I press a shortcut, with the function under the cursor automatically selected in the Help GUI. I also released an update today (what a coincidence !) to support UDF .chm files: AutoIt Tools (not a big work as a debugger, but I needed it). EDIT : (add) -> I managed to use VSCode's tasks, preLaunchTasks and launch settings to automatically start Au3Check before compiling so I have no issues.2 points -
Visual Studio Code Extension currently available and future plans for SciTE?
SOLVE-SMART and one other reacted to seadoggie01 for a topic
While I've been moving away from using AutoIt lately, I started using Visual Studio Extensions about a year ago. I started with Damien/LoganCH's extension because it was the only available option at the time (I think). That said, there were a few issues (I think mostly Code Folding issue #89 - that's still open) with it at the time that caused me to start using genius's extension as soon as it came out. It was slightly choppy at the start, but considering my reduced usage of AutoIt, it's been fairly smooth sailing. Lately, I can't find a single issue with it despite it being "less mature" But I also use AutoIt for fairly simple things now like making a GUI wrapper for a command line program written in C#. Perhaps the other thing to consider is that LoganCH's extension requires the full SciTE install to function, per the ReadMe Obviously I'm biased; I don't want to change my extension2 points -
Thanks for your detailed views! I wasn't referring to forks, just the fact that there are multiple published extensions for Autoi3. I made my own fork for testing, as I wanted to add the direct execution of Tidy, Au3Check and Au3stripper into the extension without running AutoIt3Wrapper and using the same shortcuts as currently within SciTE4AutoIt3. Really wondering why @genius257 decided to start his own version and what are the Pros & Cons of either version. In general, I do not have the desire to "take any lead" or "take over" any of these project, just like to support one of them with the utilities I developed over the years to support one of these projects. When the outcome is that the 2 separate extensions remain, that is fine with me too, but I will only select one to use and possibly support with pull requests. So what are the differences between these 2 projects, and what makes the one better than the other? (Positive comments please and no pissing contest! )2 points
-
WebDriver: I can't find an element with h1 title
ioa747 and one other reacted to SOLVE-SMART for a topic
Hi @taylansan 👋 , please notice ⚠ I assume such a structure: you use _WD_FindElement() in the multi element way. The fifth parameter is set to true which means you want to get all occurences of the <h1> elements (with the specific text). 1. Either you change your XPath to only search the first element like (//h1[contains(text(),'Welcome to BSS')])[1] or 2. simply set false as fifth parameter _WD_FindElement($sSession, $mConfig.LocatorStrategy, $sSelector, Default, False) or 3, without the fifth parameter because the default value is false _WD_FindElement($sSession, $mConfig.LocatorStrategy, $sSelector, Default) ... and try again 🙂 . ----------------------------------------- ⚠ In case you are searching within an iframe, you first have to enter the frame and do your locator strategy (search) their. Func _EnterIFrame($sSelector) _WD_FrameEnter($sSession, _FindElement($sSelector)) EndFunc Best regards Sven2 points -
Also made the changes to this beta Au3Stripper v23.402.1150.2 to support input files with special characters in their name and include files. On top of that, it supports merging include files that have different encoding. The output file will be the same encoding as the Master file, and all other included files will be converted to that encoding. This makes it possible to run Au3Stripper without the need for AutoIt3Wrapper to preprocess all used files. In the process of stripping out all the preprocessing stuff and come up with the best way to redistribute au3check with the next version of the Installer package.2 points
-
AutoIt Extension for Visual Studio Code
SOLVE-SMART and one other reacted to LoganCH for a topic
Released v1.0.13 today! Added Command to remove Debug to Console and MsgBox lines added by the extension Commands to add and remove debug Trace lines Refined syntax check, with ability to set options through #AutoIt3Wrapper_AU3Check_Parameters Completions and Hovers for AutoIt3Wrapper Directives Changed Changes to autoit.includePaths setting now gets written to Windows Registry Fixed Go To Definition regression Output colors not showing due to other extensions (e.g., Github Copilot) Icons missing for some Const and Enum variables in the outline/Symbol search Detection of nested Regions outputCodePage setting not working Au3Check/Problems tab now works with includePaths setting Contributors @Danp2, @vanowm, @Sunev View and Rate on VSCode Marketplace Star, Submit Issues, and Contribute on GitHub2 points -
Alright one last attempt : #include <GUIConstants.au3> #include <WinAPIGdi.au3> #include <ColorConstants.au3> Example() Func Example() Local $hGUI1 = GUICreate('Move region 1', 300, 300, 300, 200, -1, $WS_EX_CONTROLPARENT) GUISetBkColor($COLOR_RED) GUISetState() Local $hRgn1 = _WinAPI_CreateRectRgn(0, 0, 80, 80) _WinAPI_SetWindowRgn($hGUI1, $hRgn1) Local $hGUI2 = GUICreate('Move region 2', 300, 300, 420, 320, -1, $WS_EX_CONTROLPARENT) GUISetBkColor($COLOR_RED, $hGUI2) GUISetState(@SW_SHOW, $hGUI2) $hRgn2 = _WinAPI_CreateRectRgn(30, 30, 110, 110) _WinAPI_SetWindowRgn($hGUI2, $hRgn2) Sleep(2000) WinMove($hGUI1, "", 500, 500) _WinAPI_DeleteObject($hRgn1) _WinAPI_DeleteObject($hRgn2) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example You can also drag each square (button ?) independently...2 points
-
@Schnuffellets continue this discussion in PM to keep it clean and consise so we are able to tackle 1 part of you steps at a time starting with your x64 option for a3x so you fully understand how things work. Please PM me with an simple answer whether you have understood what I've explained on that topic!2 points
-
Maybe this helps a little in understanding. Its just manipulation of pixels in a certan layout (PNG). Look at the output and zoom in/out, you can see almost the numbers yourself #Region includes Opt('MustDeclareVars', 1) ;#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> #include <string.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #EndRegion _GDIPlus_Startup() Dim $BitmapFilename Dim $BMPData="", $BMPWidth=0, $BMPHeight=0, $BMPLineWidth=0, $imgBytes=1 dim $binaryLine for $i=1 to 4 $BitmapFilename = @TempDir & "\" & "pic" & string($i) & ".png" $BMPData="" $BMPWidth=0 $BMPHeight=0 $BMPLineWidth=0 $imgBytes=1 consolewrite($bitmapFileName) ; Load the bitmap to find getImage($BitmapFilename, $BMPData, $BMPWidth, $BMPHeight, $BMPLineWidth, $imgBytes) ;~ See the height and width and dump the data on screen consolewrite($BMPHeight & " ; ") consolewrite($BMPWidth &@CRLF ) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 ;~ From the screenshots we can ignore the first 16 bytes (remember in text its 2 characters ;~ $binaryLine=BinaryMid($bmp1Data,($i*$BMP1LineWidth)+16,$BMP1LineWidth) ;~ and we only need 4 digits which takes about 28 characters and 1 character separator = $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16,60) ;~ Lets make it readable $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ lets recognise for $iNumber=1 to 4 consolewrite(@crlf) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16+(($iNumber-1)*15),14) $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next Next Next _GDIPlus_Shutdown() Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle, $bitMapdata, $pixelFormat ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) ;~ $hBitmap = _GDIPlus_ImageLoadFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;Get $tagGDIPBITMAPDATA structure ConsoleWrite("Bitmap Width: " & _GDIPlus_ImageGetWidth($pBitmap) & @CRLF ) ConsoleWrite("Bitmap Height: " & _GDIPlus_ImageGetHeight($pBitmap) & @CRLF) ;~ 24 bits (3 bytes) or 16 bits (2 bytes) comparison if ($imgBytes=1) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF04INDEXED) Endif if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) EndIf if ($imgBytes=3) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) endIf If @ERROR Then MsgBox(0,"","Error locking region " & @error) $Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $Width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap. $Height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap. $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixelData = DllStructCreate("ubyte lData[" & (abs($Stride) * $Height-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect #EndRegion I assume you refer to2 points
-
Taquin The Taquin is a solitary puzzle game, popular since the late 19th century, that challenges the player's logic and patience. This code implements a digital version of the Taquin, where the goal is to rearrange a set of 15 numbered tiles from 1 to 15 into ascending order by moving the tiles one at a time, in a frame of 16 spaces. The game is played on a simple and intuitive graphical interface. Goal of the Game The goal of Taquin is to rearrange the 15 tiles into numerical order (from 1 to 15), with an empty space, starting from a randomly shuffled configuration. The player must move the tiles using the empty space by clicking on tiles adjacent to the empty space. Game Features Graphical Interface (GUI): The game uses AutoIt to create a simple graphical interface, where the game board consists of 15 numbered tiles. The interface allows the user to see the tiles and easily move them to solve the puzzle. Game Mechanics: Tiles can only be moved if they are adjacent to the empty space. By clicking on a tile, it moves into the empty space, and the game updates the display after each move. Solution Verification: The game continuously checks if the tiles are in the correct order, and a victory notification is displayed when the tiles are correctly arranged. Random Shuffle: At the start of the game, the tiles are randomly arranged to create a different challenge with each game. Ease of Use: The game is designed to be simple to use, with controls based on mouse clicks to move the tiles. Game Rules Tile Movement: A player can move a tile by clicking on it if it is adjacent to the empty space. The objective is to move the tiles into ascending order. Solution: The game ends when the tiles are arranged in the following order: 1, 2, 3, ..., 15, with the empty space at the end. History of the Game The Taquin was invented in the United States around 1870, before being popularized in Europe and becoming widely recognized. The invention was claimed by Sam Loyd in 1891, when the game became a global phenomenon. It is now a classic among puzzle games. #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include "AutoItObject.au3" #include <Array.au3> ; #INDEX# ======================================================================================================================= ; Title .........: Puzzle Game ; AutoIt Version : 3.3 ; AutoItObject Version : v1.2.8.2 ; Language ......: English ; Description ...: This script implements a puzzle game using AutoIt and AutoItObject.au3. ; Dependencies ..: AutoItObject.au3, GDIPlus.au3 ; Author ........: Numeric ; ======================================================================================================================= ; Game Overview: ; - The game consists of a grid of tiles. ; - The objective is to arrange the tiles in numerical order by swapping them. ; - The game ends when all tiles are correctly arranged. ; - Tiles are shuffled randomly at the start, and the player can interact with them via mouse clicks. ; Controls: ; - Mouse Click: Select a tile to move. ; - Tiles swap when an adjacent empty tile is clicked. ; Enjoy solving the puzzle! ; ======================================================================================================================= _AutoItObject_Startup() _GDIPlus_Startup() ; Classe Ligne Func CreateLine($startX, $startY, $endX, $endY, $color = 0xFF00FF00, $thickness = 1) If $color = Default Or $color = "" Or Not $color Then $color = 0xFF00FF00 Local $lineObject = _AutoItObject_Class() With $lineObject .AddProperty("StartX", $ELSCOPE_PUBLIC, $startX) .AddProperty("StartY", $ELSCOPE_PUBLIC, $startY) .AddProperty("EndX", $ELSCOPE_PUBLIC, $endX) .AddProperty("EndY", $ELSCOPE_PUBLIC, $endY) .AddProperty("Color", $ELSCOPE_PUBLIC, $color) .AddProperty("Thickness", $ELSCOPE_PUBLIC, $thickness) EndWith Return $lineObject.Object EndFunc ;==>CreateLine Func CreateTile($xPosition, $yPosition, $size, $color = 0xFFFFFFFF) Local $squareObject = _AutoItObject_Class() Local $radius = $size / 2 Local $lines[0] With $squareObject .Create() .AddProperty("Lines", $ELSCOPE_PUBLIC, $lines) .AddProperty("Type", $ELSCOPE_PUBLIC, "Square") .AddProperty("Number", $ELSCOPE_PUBLIC, 0) .AddProperty("X", $ELSCOPE_PUBLIC, $xPosition) .AddProperty("Y", $ELSCOPE_PUBLIC, $yPosition) .AddProperty("Size", $ELSCOPE_PUBLIC, $size) .AddProperty("Color", $ELSCOPE_PUBLIC, $color) .AddProperty("CircleRadius", $ELSCOPE_PUBLIC, $radius) .AddMethod("AddLine", "AddLineToSquare") .AddMethod("DisplayNumber", "DisplayNumberOnSquare") .AddMethod("Move", "MoveSquare") .AddMethod("Resize", "ResizeSquare") .AddMethod("CheckCollision", "CheckSquareCollision") .AddMethod("ContainsPoint", "PointInsideSquare") EndWith Return $squareObject.Object EndFunc ;==>CreateTile Func AddLineToSquare($this, $line) Local $lineArray = $this.Lines _ArrayAdd($lineArray, $line) $this.Lines = $lineArray EndFunc ;==>AddLineToSquare Func DisplayNumberOnSquare($this, $number) Local $lineArray[0] $this.Lines = $lineArray If $number = 0 Then $number = "" Local $segmentSize = $this.Size / 3 Local $centerX = $this.X + ($this.Size / 2) Local $centerY = $this.Y + ($this.Size / 2) Local $segmentPatterns[10][7] = [ _ [1, 1, 1, 1, 1, 1, 0], _ ; 0 [0, 1, 1, 0, 0, 0, 0], _ ; 1 [1, 1, 0, 1, 1, 0, 1], _ ; 2 [1, 1, 1, 1, 0, 0, 1], _ ; 3 [0, 1, 1, 0, 0, 1, 1], _ ; 4 [1, 0, 1, 1, 0, 1, 1], _ ; 5 [1, 0, 1, 1, 1, 1, 1], _ ; 6 [1, 1, 1, 0, 0, 0, 0], _ ; 7 [1, 1, 1, 1, 1, 1, 1], _ ; 8 [1, 1, 1, 1, 0, 1, 1] _ ; 9 ] Local $segmentCoords[7][4] = [ _ [-0.4, -0.4, 0.4, -0.4], _ ; Haut [0.4, -0.4, 0.4, 0.0], _ ; Haut-droite [0.4, 0.0, 0.4, 0.4], _ ; Bas-droite [-0.4, 0.4, 0.4, 0.4], _ ; Bas [-0.4, 0.0, -0.4, 0.4], _ ; Bas-gauche [-0.4, -0.4, -0.4, 0.0], _ ; Haut-gauche [-0.4, 0.0, 0.4, 0.0] _ ; Milieu ] Local $currentOffsetX = -($segmentSize * (StringLen($number) - 1) / 2) For $digitIndex = 0 To StringLen($number) - 1 Local $digit = Number(StringMid($number, $digitIndex + 1, 1)) For $segmentIndex = 0 To 6 If $segmentPatterns[$digit][$segmentIndex] Then Local $x1 = $centerX + $currentOffsetX + $segmentCoords[$segmentIndex][0] * $segmentSize Local $y1 = $centerY + $segmentCoords[$segmentIndex][1] * $segmentSize Local $x2 = $centerX + $currentOffsetX + $segmentCoords[$segmentIndex][2] * $segmentSize Local $y2 = $centerY + $segmentCoords[$segmentIndex][3] * $segmentSize $this.AddLine(CreateLine($x1, $y1, $x2, $y2, Default, 2)) EndIf Next $currentOffsetX += $segmentSize * 1.2 Next EndFunc ;==>DisplayNumberOnSquare Func PointInsideSquare($this, $pointX, $pointY) Return ($pointX >= $this.X And $pointX <= $this.X + $this.Size) And _ ($pointY >= $this.Y And $pointY <= $this.Y + $this.Size) EndFunc ;==>PointInsideSquare Func CheckSquareCollision($this, $otherSquare) If $this.Type = "Square" And $otherSquare.Type = "Square" Then Local $isAdjacentHorizontally = ($this.Y = $otherSquare.Y And $this.Size = $otherSquare.Size) And _ (($this.X + $this.Size = $otherSquare.X) Or ($this.X = $otherSquare.X + $otherSquare.Size)) Local $isAdjacentVertically = ($this.X = $otherSquare.X And $this.Size = $otherSquare.Size) And _ (($this.Y + $this.Size = $otherSquare.Y) Or ($this.Y = $otherSquare.Y + $otherSquare.Size)) Return $isAdjacentHorizontally Or $isAdjacentVertically EndIf Return False EndFunc ;==>CheckSquareCollision Func CreatePuzzleGame($backgroundColor = 0xFF0000FF) Local $window = GUICreate("Puzzle Game", 400, 400) GUISetState() Local $windowSize = WinGetClientSize($window) Local $windowWidth = $windowSize[0] Local $windowHeight = $windowSize[1] Local $graphicsContext[] $graphicsContext["Graphics"] = _GDIPlus_GraphicsCreateFromHWND($window) $graphicsContext["Bitmap"] = _GDIPlus_BitmapCreateFromGraphics($windowWidth, $windowHeight, $graphicsContext["Graphics"]) $graphicsContext["GraphicsObject"] = _GDIPlus_ImageGetGraphicsContext($graphicsContext["Bitmap"]) $graphicsContext["BackgroundBrush"] = _GDIPlus_BrushCreateSolid($backgroundColor) Local $tileSize = Int($windowWidth / 4) Local $tiles[] Local $index = 0 Local $numbers[16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15] _ArrayShuffle($numbers) For $row = 0 To 3 For $col = 0 To 3 Local $tile = CreateTile($col * $tileSize, $row * $tileSize, $tileSize) $tile.Number = $numbers[$index] $tile.DisplayNumber($tile.Number) $index += 1 $tiles[$index] = $tile Next Next Local $game = _AutoItObject_Class() With $game .Create() .AddProperty("Tiles", $ELSCOPE_PUBLIC, $tiles) .AddProperty("GraphicsContext", $ELSCOPE_PUBLIC, $graphicsContext) .AddProperty("Window", $ELSCOPE_PUBLIC, $window) .AddProperty("WindowWidth", $ELSCOPE_PUBLIC, $windowWidth) .AddProperty("WindowHeight", $ELSCOPE_PUBLIC, $windowHeight) .AddMethod("Render", "RenderPuzzle") .AddMethod("Reset", "ResetPuzzle") .AddMethod("CheckVictory", "VerifyWinCondition") .AddMethod("Run", "StartGameLoop") .AddMethod("HandleClick", "ProcessMouseClick") .AddMethod("GetTileAtPosition", "FindTileAtCoordinates") .AddMethod("GetEmptyAdjacentTile", "FindEmptyNeighbor") .AddMethod("SwapTiles", "ExchangeTiles") .AddMethod("UpdateDisplay", "RefreshDisplay") .AddDestructor("ReleaseResources") EndWith Return $game.Object EndFunc ;==>CreatePuzzleGame Func StartGameLoop($this) Local $msg While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN $this.HandleClick($msg[3], $msg[4]) $this.Render() EndSwitch $this.Render() WEnd EndFunc ;==>StartGameLoop ; Gestion des clics de souris Func ProcessMouseClick($this, $x, $y) Local $clickedTileIndex = $this.GetTileAtPosition($x, $y) If Not $clickedTileIndex Then Return Local $emptyTileIndex = $this.GetEmptyAdjacentTile($clickedTileIndex) If $emptyTileIndex Then $this.SwapTiles($clickedTileIndex, $emptyTileIndex) $this.UpdateDisplay() If $this.CheckVictory() Then MsgBox(0, "Congratulations!", "You have solved the puzzle") $this.Reset() EndIf EndIf EndFunc ;==>ProcessMouseClick ; Trouve une tuile à une position donnée Func FindTileAtCoordinates($this, $x, $y) For $tileKey In MapKeys($this.Tiles) Local $tile = $this.Tiles[$tileKey] If $tile.ContainsPoint($x, $y) Then Return $tileKey EndIf Next Return Null EndFunc ;==>FindTileAtCoordinates ; Trouve une tuile vide adjacente Func FindEmptyNeighbor($this, $tileKey) Local $currentTile = $this.Tiles[$tileKey] Local $tileKeys = MapKeys($this.Tiles) For $key In $tileKeys Local $neighbor = $this.Tiles[$key] If $neighbor.Number = 0 And _ $neighbor <> $currentTile And _ $currentTile.CheckCollision($neighbor) Then Return $key EndIf Next Return Null EndFunc ;==>FindEmptyNeighbor ; Échange les numéros entre deux tuiles Func ExchangeTiles($this, $tile1Key, $tile2Key) Local $tiles = $this.Tiles Local $temp = $tiles[$tile1Key].Number $tiles[$tile2Key].Number = $temp $tiles[$tile1Key].Number = 0 $this.Tiles = $tiles EndFunc ;==>ExchangeTiles ; Met à jour l'affichage des tuiles Func RefreshDisplay($this) For $tile In $this.Tiles $tile.DisplayNumber($tile.Number) Next EndFunc ;==>RefreshDisplay ; Affiche le plateau de jeu Func RenderPuzzle($this) Local $graphicsContext = $this.GraphicsContext Local $graphics = $graphicsContext["GraphicsObject"] Local $pen = _GDIPlus_PenCreate(0xFFFF0000, 2) _GDIPlus_GraphicsClear($graphics, 0xFF000000) Local $tiles = $this.Tiles For $tile In $tiles _GDIPlus_GraphicsDrawRect($graphics, $tile.X, $tile.Y, $tile.Size, $tile.Size, $pen) For $line In $tile.Lines Local $linePen = _GDIPlus_PenCreate($line.Color, $line.Thickness) _GDIPlus_GraphicsDrawLine($graphics, $line.StartX, $line.StartY, $line.EndX, $line.EndY, $linePen) _GDIPlus_PenDispose($linePen) Next Next _GDIPlus_PenDispose($pen) _GDIPlus_GraphicsDrawImageRect($graphicsContext["Graphics"], $graphicsContext["Bitmap"], 0, 0, $this.WindowWidth, $this.WindowHeight) EndFunc ;==>RenderPuzzle Func ResetPuzzle($this) Local $numbers[16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15] _ArrayShuffle($numbers) Local $tiles = $this.Tiles For $i = 0 To UBound($tiles) - 1 $tiles[$i].Number = $numbers[$i] $tiles[$i].DisplayNumber($tiles[$i].Number) Next EndFunc ;==>ResetPuzzle ; Vérifie la condition de victoire Func VerifyWinCondition($this) Local $tiles = $this.Tiles For $i = 1 To UBound($tiles) - 1 ; Les cases doivent être triées de 1 à 15, avec la dernière case vide (0) If $tiles[$i].Number <> $i Then Return False EndIf Next Return True EndFunc ;==>VerifyWinCondition ; Libère les ressources Func ReleaseResources($this) Local $graphicsContext = $this.GraphicsContext _GDIPlus_BrushDispose($graphicsContext["BackgroundBrush"]) _GDIPlus_GraphicsDispose($graphicsContext["Graphics"]) _GDIPlus_BitmapDispose($graphicsContext["Bitmap"]) GUIDelete($graphicsContext["BoardWindow"]) _GDIPlus_Shutdown() EndFunc ;==>ReleaseResources Global $game = CreatePuzzleGame() $game.Run() $game = 0 Have fun!2 points