Leaderboard
Popular Content
Showing content with the highest reputation on 09/06/2024 in all areas
-
Actually, no. What I do is to have a virtual machine for each function. Say I need a web server. That goes into a VM. pfsense, another VM. Code in PHP, that goes in my WEB virtual PC. So my attitude is: have a plain hardware PC and run specialized stuff in a VM. Anything goes wrong, load another VM and try there. Win10 pro comes with Hyper-V and does not take many more resources to have VMs running. The thing is that each time I work with something, it's got it's "gotchas" and I don't want to become a specialist of each niche situation each environment/function entails, therefore each goes in it's own VM. Say I code something for an client and it has a setup/environment and two years down the road I need to fix/change/add something, I'll load the VM I used to code that and makes it a whole lot easier The OS goes on the C drive, data on a D drive. Anything goes wrong, reinstall the C drive All that explained above solves most of the "it worked on my machine, don't know why it won't work here" situations. In the case of @Docfxit, I would reinstall that PC.1 point
-
Yes, it's possible... #include <GDIPlus.au3> #include <misc.au3> ; Line Global $Linepoints[3][2] = [[2,0],[584,211],[617,184]] ; Face Global $rightbrowpoints[6][2] = [[5,0],[184,211],[217,184],[274,183],[273,195],[224,197]] Global $leftbrowpoints[6][2] = [[5,0],[335,181],[341,192],[367,190],[388,200],[371,177]] Global $righteyepoints[9][2] = [[8,0],[234,213],[222,219],[212,225],[225,224],[235,225],[252,224],[266,219],[252,214]] Global $lefteyepoints[9][2] = [[8,0],[349,206],[337,209],[330,215],[342,218],[351,218],[364,219],[379,217],[366,209]] Global $mouthpoints[15][2] = [[14,0],[312,323],[291,319],[257,325],[235,337],[247,352],[262,361],[282,370],[306,372],[327,366],[345,354],[354,344],[359,334],[347,323],[328,317]] Global $headpoints[15][2] = [[14,0],[150,130],[136,199],[137,276],[151,346],[213,405],[311,451],[363,406],[387,356],[404,283],[402,197],[388,121],[342,78],[278,63],[203,80]] Local $pt = 0 Global $dll = DllOpen("user32.dll") $gui = GUICreate("", 1024, 768) GUISetState() Opt("MouseCoordMode", 2) ClosedCurveOrPolygon() Func ClosedCurveOrPolygon() Local $0nPoint, $mouseDiffX, $mouseDiffY, $MouseStartPos, $pos _GDIPlus_Startup() Global $hBitmap = _GDIPlus_BitmapCreateFromScan0(1024, 768, $GDIP_PXF32ARGB) Global $hBitmap_clone = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, 1024, 768) Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui) Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) Global $retValue2 = "head" Draw(-1) Do $msg = GUIGetMsg() If $msg = -3 Then ExitLoop If _IsPressed("01", $dll) Then $MouseStartPos = MouseGetPos() $0nPoint = CheckOverPoint($MouseStartPos[0], $MouseStartPos[1]) $mouseDiffX = 0 If $0nPoint >= 0 Then $moveAll = 1 Draw($0nPoint) $GrnPt = $0nPoint While _IsPressed("01", $dll) $pos = MouseGetPos() $mouseDiffX = Int(($pos[0] - $MouseStartPos[0])) $mouseDiffY = Int(($pos[1] - $MouseStartPos[1])) If Abs($mouseDiffX) > 0 Or Abs($mouseDiffY) > 0 Then If $retValue2 = "head" Then $headpoints[$0nPoint][0] = $pos[0] $headpoints[$0nPoint][1] = $pos[1] ElseIf $retValue2 = "mouth" Then $mouthpoints[$0nPoint][0] = $pos[0] $mouthpoints[$0nPoint][1] = $pos[1] ElseIf $retValue2 = "righteye" Then $righteyepoints[$0nPoint][0] = $pos[0] $righteyepoints[$0nPoint][1] = $pos[1] ElseIf $retValue2 = "lefteye" Then $lefteyepoints[$0nPoint][0] = $pos[0] $lefteyepoints[$0nPoint][1] = $pos[1] ElseIf $retValue2 = "rightbrow" Then $rightbrowpoints[$0nPoint][0] = $pos[0] $rightbrowpoints[$0nPoint][1] = $pos[1] ElseIf $retValue2 = "leftbrow" Then $leftbrowpoints[$0nPoint][0] = $pos[0] $leftbrowpoints[$0nPoint][1] = $pos[1] ElseIf $retValue2 = "Line" Then $Linepoints[$0nPoint][0] = $pos[0] $Linepoints[$0nPoint][1] = $pos[1] EndIf Draw($0nPoint) Sleep(20) EndIf Sleep(20) WEnd Else $moveAll = 0 Draw(-1) EndIf EndIf ; mouse BTN 1 pressed?? Sleep(20) Until _IsPressed("1B") ; ESC key DllClose($dll) EndFunc ;==>ClosedCurveOrPolygon Func CheckOverPoint($MouseX, $MouseY) Local $x1, $x2, $x3, $x4, $x5, $x6, $x7, $retValue = -1 For $x1 = 1 To UBound($headpoints) - 1 If $MouseX < $headpoints[$x1][0] + 5 And $MouseX > $headpoints[$x1][0] - 5 And $MouseY < $headpoints[$x1][1] + 5 And $MouseY > $headpoints[$x1][1] - 5 Then $retValue = $x1 $retValue2 = "head" EndIf Next For $x2 = 1 To UBound($mouthpoints) - 1 If $MouseX < $mouthpoints[$x2][0] + 5 And $MouseX > $mouthpoints[$x2][0] - 5 And $MouseY < $mouthpoints[$x2][1] + 5 And $MouseY > $mouthpoints[$x2][1] - 5 Then $retValue = $x2 $retValue2 = "mouth" EndIf Next For $x3 = 1 To UBound($righteyepoints) - 1 If $MouseX < $righteyepoints[$x3][0] + 5 And $MouseX > $righteyepoints[$x3][0] - 5 And $MouseY < $righteyepoints[$x3][1] + 5 And $MouseY > $righteyepoints[$x3][1] - 5 Then $retValue = $x3 $retValue2 = "righteye" EndIf Next For $x4 = 1 To UBound($lefteyepoints) - 1 If $MouseX < $lefteyepoints[$x4][0] + 5 And $MouseX > $lefteyepoints[$x4][0] - 5 And $MouseY < $lefteyepoints[$x4][1] + 5 And $MouseY > $lefteyepoints[$x4][1] - 5 Then $retValue = $x4 $retValue2 = "lefteye" EndIf Next For $x5 = 1 To UBound($rightbrowpoints) - 1 If $MouseX < $rightbrowpoints[$x5][0] + 5 And $MouseX > $rightbrowpoints[$x5][0] - 5 And $MouseY < $rightbrowpoints[$x5][1] + 5 And $MouseY > $rightbrowpoints[$x5][1] - 5 Then $retValue = $x5 $retValue2 = "rightbrow" EndIf Next For $x6 = 1 To UBound($leftbrowpoints) - 1 If $MouseX < $leftbrowpoints[$x6][0] + 5 And $MouseX > $leftbrowpoints[$x6][0] - 5 And $MouseY < $leftbrowpoints[$x6][1] + 5 And $MouseY > $leftbrowpoints[$x6][1] - 5 Then $retValue = $x6 $retValue2 = "leftbrow" EndIf Next For $x7 = 1 To UBound($Linepoints) - 1 If $MouseX < $Linepoints[$x7][0] + 5 And $MouseX > $Linepoints[$x7][0] - 5 And $MouseY < $Linepoints[$x7][1] + 5 And $MouseY > $Linepoints[$x7][1] - 5 Then $retValue = $x7 $retValue2 = "Line" EndIf Next Return $retValue EndFunc ;==>CheckOverPoint Func draw($pt) $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 2); white $hBrushRed = _GDIPlus_BrushCreateSolid(0x8fff0000) ;red $hBrushGreen = _GDIPlus_BrushCreateSolid(0x8f00ff00) ;Green _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2) _GDIPlus_GraphicsClear($backbuffer, 0x00000000) _GDIPLus_GraphicsDrawImageRect($backbuffer, $hBitmap_clone, 0, 0, 1024, 768) _GDIPlus_GraphicsDrawClosedCurve ($backbuffer, $headpoints, $hPen) _GDIPlus_GraphicsDrawClosedCurve ($backbuffer, $mouthpoints, $hPen) _GDIPlus_GraphicsDrawClosedCurve ($backbuffer, $righteyepoints, $hPen) _GDIPlus_GraphicsDrawClosedCurve ($backbuffer, $lefteyepoints, $hPen) _GDIPlus_GraphicsDrawClosedCurve ($backbuffer, $rightbrowpoints, $hPen) _GDIPlus_GraphicsDrawClosedCurve ($backbuffer, $leftbrowpoints, $hPen) _GDIPlus_GraphicsDrawLine ($backbuffer, $Linepoints[1][0],$Linepoints[1][1],$Linepoints[2][0],$Linepoints[2][1], $hPen) $esize = 6 For $x1 = 1 To UBound($headpoints) - 1 If $x1 = $pt AND $retValue2 = "head" Then _GDIPlus_GraphicsFillEllipse($backbuffer, $headpoints[$x1][0] - $esize/2, $headpoints[$x1][1] - $esize/2, $esize, $esize, $hBrushGreen) Else _GDIPlus_GraphicsFillEllipse($backbuffer, $headpoints[$x1][0] - $esize/2, $headpoints[$x1][1] - $esize/2, $esize, $esize, $hBrushRed) EndIf _GDIPlus_GraphicsDrawEllipse($backbuffer, $headpoints[$x1][0] - $esize/2, $headpoints[$x1][1] - $esize/2, $esize, $esize) Next For $x2 = 1 To UBound($mouthpoints) - 1 If $x2 = $pt And $retValue2 = "mouth" Then _GDIPlus_GraphicsFillEllipse($backbuffer, $mouthpoints[$x2][0] - $esize/2, $mouthpoints[$x2][1] - $esize/2, $esize, $esize, $hBrushGreen) Else _GDIPlus_GraphicsFillEllipse($backbuffer, $mouthpoints[$x2][0] - $esize/2, $mouthpoints[$x2][1] - $esize/2, $esize, $esize, $hBrushRed) EndIf _GDIPlus_GraphicsDrawEllipse($backbuffer, $mouthpoints[$x2][0] - $esize/2, $mouthpoints[$x2][1] - $esize/2, $esize, $esize) Next For $x3 = 1 To UBound($righteyepoints) - 1 If $x3 = $pt And $retValue2 = "righteye" Then _GDIPlus_GraphicsFillEllipse($backbuffer, $righteyepoints[$x3][0] - $esize/2, $righteyepoints[$x3][1] - $esize/2, $esize, $esize, $hBrushGreen) Else _GDIPlus_GraphicsFillEllipse($backbuffer, $righteyepoints[$x3][0] - $esize/2, $righteyepoints[$x3][1] - $esize/2, $esize, $esize, $hBrushRed) EndIf _GDIPlus_GraphicsDrawEllipse($backbuffer, $righteyepoints[$x3][0] - $esize/2, $righteyepoints[$x3][1] - $esize/2, $esize, $esize) Next For $x4 = 1 To UBound($lefteyepoints) - 1 If $x4 = $pt And $retValue2 = "lefteye" Then _GDIPlus_GraphicsFillEllipse($backbuffer, $lefteyepoints[$x4][0] - $esize/2, $lefteyepoints[$x4][1] - $esize/2, $esize, $esize, $hBrushGreen) Else _GDIPlus_GraphicsFillEllipse($backbuffer, $lefteyepoints[$x4][0] - $esize/2, $lefteyepoints[$x4][1] - $esize/2, $esize, $esize, $hBrushRed) EndIf _GDIPlus_GraphicsDrawEllipse($backbuffer, $lefteyepoints[$x4][0] - $esize/2, $lefteyepoints[$x4][1] - $esize/2, $esize, $esize) Next For $x5 = 1 To UBound($rightbrowpoints) - 1 If $x5 = $pt And $retValue2 = "rightbrow" Then _GDIPlus_GraphicsFillEllipse($backbuffer, $rightbrowpoints[$x5][0] - $esize/2, $rightbrowpoints[$x5][1] - $esize/2, $esize, $esize, $hBrushGreen) Else _GDIPlus_GraphicsFillEllipse($backbuffer, $rightbrowpoints[$x5][0] - $esize/2, $rightbrowpoints[$x5][1] - $esize/2, $esize, $esize, $hBrushRed) EndIf _GDIPlus_GraphicsDrawEllipse($backbuffer, $rightbrowpoints[$x5][0] - $esize/2, $rightbrowpoints[$x5][1] - $esize/2, $esize, $esize) Next For $x6 = 1 To UBound($leftbrowpoints) - 1 If $x6 = $pt And $retValue2 = "leftbrow" Then _GDIPlus_GraphicsFillEllipse($backbuffer, $leftbrowpoints[$x6][0] - $esize/2, $leftbrowpoints[$x6][1] - $esize/2, $esize, $esize, $hBrushGreen) Else _GDIPlus_GraphicsFillEllipse($backbuffer, $leftbrowpoints[$x6][0] - $esize/2, $leftbrowpoints[$x6][1] - $esize/2, $esize, $esize, $hBrushRed) EndIf _GDIPlus_GraphicsDrawEllipse($backbuffer, $leftbrowpoints[$x6][0] - $esize/2, $leftbrowpoints[$x6][1] - $esize/2, $esize, $esize) Next For $x7 = 1 To UBound($Linepoints) - 1 If $x7 = $pt And $retValue2 = "Line" Then _GDIPlus_GraphicsFillEllipse($backbuffer, $Linepoints[$x7][0] - $esize/2, $Linepoints[$x7][1] - $esize/2, $esize, $esize, $hBrushGreen) Else _GDIPlus_GraphicsFillEllipse($backbuffer, $Linepoints[$x7][0] - $esize/2, $Linepoints[$x7][1] - $esize/2, $esize, $esize, $hBrushRed) EndIf _GDIPlus_GraphicsDrawEllipse($backbuffer, $Linepoints[$x7][0] - $esize/2, $Linepoints[$x7][1] - $esize/2, $esize, $esize) Next _GDIPlus_GraphicsDrawImageRect ($hGraphic, $hBitmap, 0, 0, 1024, 768) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushRed) _GDIPlus_BrushDispose($hBrushGreen) EndFunc1 point
-
imitation GUICtrlSetResizing()1 point
-
donnyh13: Thank you for the update. I have updated SciTE per your links. I can't run this. ConsoleWrite(FileGetVersion("msvcp140.dll") & @CRLF) It needs a console. And of course that's what I can't run. I'm going to try to take a dump and see if that will shed some light on it.1 point
-
Scrollbars Made Easy - New version 27 Jan 22
pixelsearch reacted to Melba23 for a topic
[New Version] - 27 Jan 22 New: The GUIScrollbar_Ex UDF now recognises Win-D and taskbar desktop clearance commands and runs the correct minimize/restore code automatically. The previous UDF _Minimize and _Restore commands have been superceded by a single _EventMonitor function which runs in the script idle loop. This is a script-breaking change, but I hope that the additional functionality is worth the small effort it will take to alter your scripts. New UDFs, examples in zip file below. Previous changes: Changelog.txt Are you bemused by scrollbars? > Do you find them too difficult to use? > Then you need the GUIScrollbars_Ex UDF! Just download the zip at the end of the post and run this short script with the UDF in the same folder. No tricky calculations, no complicated functions to master - just easy to use, accurate scrollbars with one command! [size=5]#include <guiconstantsex.au3> #include "GUIScrollbars_Ex.au3" ; Create GUI with red background $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xFF0000, $hGUI) ; Create a 1000x1000 green label GUICtrlCreateLabel("", 0, 0, 1000, 1000) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState() ; Generate scrollbars - Yes, this is all you need to do!!!!!!!!!!!!!!!!!!!! _GUIScrollbars_Generate($hGUI, 1000, 1000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd[/size] Try it today and see how easy it is! I have been trying for some time to understand how scrollbars work and how to get them closely to match the area I want to display. After much research and headscratching I have come up with 2 UDFs which I hope will be of use to others. Apologies for the length of this post, but scrollbars are complex beasts and as I did this mainly for the less experienced user I want to make sure that they understand what is going on. The 2 UDFs are: GUIScrollbars_Ex.au3 - This gives you scrollbars sized to your GUI in one simple command - with no other includes or commands needed. The UDF is designed for those who would not normally use scrollbars because the whole process looks too complicated. It also includes a command to enable you to scroll page by page, thus making it easy to scroll to anywhere on the GUI with only simple calulations based on the values you used to create the GUIs. [New] Ability to have recalculated scrollbars on resizeable GUIs. GUIScrollbars_Size.au3 - This calculates the Page and Max numbers for the user to feed into the _GUIScrollbar_SetScrollInfoPage/Max commands. The UDF is aimed at the more experienced user and is particularly useful when you have a GUI with a dynamic scroll size (i.e. adding or subtracting controls to the scrollable area as the script runs). First, a short tutorial for those who are interested in how the scrollbars affect your GUI and what it is that the UDFs calculate: All the files mentioned here are in a downloadable zip file at the end of the post. GUIScrollbars_Size.au3 As mentioned previously, the GUIScrollbars_Size.au3 UDF is aimed at the more experienced user who wants to use the full range of _GUIScrollbar comands, but would like a quick way of getting the required Page and Max values. It uses no other include files so you will need to include GUIScrollbars.au3 yourself, as well as the necessary GUIRegisterMsg and procedures for WM_VSCROLL and WM_HSCROLL. The syntax is simple - the size of the scrollable GUI and either the handle of the GUI you have created to hold the scrollbars or the size of the one you are going to create. It returns a 6-element array including the Page and Max values for the scrollbars and factors to compensate for the "shrinkage" of the GUI if you had already drawn some controls and wished to add others. Of interest, the returned Max value is biased not to clip the edges of the GUI - reducing it by 1 makes a tighter fit but can lead to some clipping. (If that does not make sense, please see the tutorial above for more details) The Size_Example_1 script to show the UDF in action - the "Pass Size" button shows the effect of creating the scrollbars BEFORE the controls, the "Pass Handle" button shows what happens if the scrollbars are created AFTER the controls. If you do not understand why there is a difference - go and read the tutorial above ! You will need to have the GUIScrollbar_Size.au3 UDF in the same folder. Where this UDF really helps is if you have a scrollable GUI of variable size - if the number of controls varies with user selections for example. All you need to do is to rerun the UDF with the new size of the scrollable GUI and it produces a new Max value for you to use. The Size_Example_2 script shows how the function enables you to dynamically size your scrollbars depending on the number of controls required. As before it requires the GUIScrollbar_Size.au3 UDF in the same folder. -------- Now the "simple" GUIScrollbars_Ex.au3 (which is actually the more complex internally as you would expect). This UDF is intended to be the single point of call for creating scrollbars on a GUI - it will automatically add the GUIScrollbars UDF and the WM_VSCROLL and WM_HSCROLL GUIRegisterMsg commands and procedures to your script - so you need no commands other than those within the UDF itself. These commands are _GUIScrollbars_Generate and _GUIScrollbars_Scroll_Page. As you might expect, _GUIScrollbars_Generate generates scrollbars for your GUI. It is usually called AFTER you have added all the controls and all you need to use it is the GUI handle and the size of the underlying GUI you want to scroll. If you so wish, you can also decide to generate the scrollbars BEFORE the controls on the scrollable GUI, and you can choose if you want to risk not quite reaching the edge of the GUI when the scrollbars are at the maximum position. So a basic call could be as simple as: _GUIScrollbars_Generate ($hGUI, 1000, 1000) which would put scrollbars on the $hGUI window allowing a 1000x1000 underlying GUI to be displayed. _GUIScrollbars_Scroll_Page lets you scroll a page at a time. If your GUI was 200 pixels wide, you would have 1000/200 = 5 pages to scroll before reaching the edge - no need to know what the actual Page and Max values are, just use this simple division based on the number you use to draw the GUIs. So: _GUIScrollbars_Scroll_Page ($hGUI, 3) would scroll to the third page - it would display the area between 400 and 600 pixels of the full 1000 pixel width. If you ask for a page over the maximum available, you just scroll to the maximum position - asking for page 1 resets you to the origin. Ex_Example_1 shows the UDF working. You can decide whether to have both or just one scrollbar, whether to create the scrollbars before or after the controls, and whether you want the maximum scroll to be tight to the edge or leave a border. Just select the options you want - the script selects a random width and height for both the scrollbar GUI and the underlying GUI - and press the "Scroll" button to show a single page scroll down and/or right followed by a scroll to the bottom right corner of the GUI. There are labels to let you see the size of the GUI and the accuracy of the page scrolls (please read the tutorial above to understand why these are almost certainly inaccurate). The script requires the GUIScrollbars_Ex.au3 UDF in the same folder. Ex_Example_2 is a really simple example to show how easy generating scrollbars can now become! As you can see - no other includes, no GUIRegisterMsg commands, no WM_H/VSCROLL procedure functions. Just accurate scrolling and proportional thumb sizes. Ex_Example_3 shows the automatic calculation of control positions. Ex_Example_4 shows how to initiate the cursor keys to scroll the GUI as well. [New] Ex_Example_5 shows how to use the new _GUIScrollbarsEx_Resizer function. I hope these 2 UDFs are useful to AutoIt users - I certainly find them so. Here is a zip file with the UDFs and examples: Scrollbars.zip My grateful thanks to the authors of the GUIScrollbars and WinAPI UDFs for their code, some of which I have plundered. And as always I welcome constructive criticism and/or effusive congratulations. M231 point