Leaderboard
Popular Content
Showing content with the highest reputation on 05/14/2020 in all areas
-
RdpShadow utility
Gideonx90x reacted to argumentum for a file
Version 0.2024.3.2
1,559 downloads
..so I have to help someone and remember how to get the session ID, then remember how to shadow. All from a command prompt. Not cool. So I wrote this, Is coded for Windows in English. May work in other languages too. ( as long as "qwinsta" runs, this should work ) It now calls wtsapi32.dll For this to work as intended, uncheck "noPrompt", or make the changes to the group policy, only if you know what you are doing. ( I will not aid anyone on how what, as I'm not qualified ) This is for when all works as you wish, but have to use the command line to shadow a user ( and everyone is in a hurry ). This gives you a list of users to just click to help the user on a remote session, by guiding them ( view ) or interacting with the desktop ( control ). I do not advise to change anything on your system, nor to use this, but if you find it useful, then, it is a very practical utility. I did not post in the examples forum as is not an example worth posting. It grabs the text out of qwinsta Calls wtsapi32.dll and runs mstsc. Not a noteworthy example.1 point -
I'm not sure if I have the patience to get you up to speed on structs, dll calls, and pointers as it relates to how to implement them in AutoIt but I'm willing to try. Some people will get it and some won't. I will take the first step by showing you a working example that you can use to ask questions and to build upon. In the example below, it makes a call to the wimlib_open_wim function. Note that as it is written it will fail with an error code of 47, unless you happen to have a test.wim file in the script's directory. Error code 47 is WIMLIB_ERR_OPEN, which means it cannot open the specified file. But the point is that it is a working example that you can play with. You will also notice that if the DllCall is successful, it display the array that is returned from the function call. That is there solely for debugging purposes. It's a good technique to use when debugging to see if you are getting good data back from the call, what the data is, and how it is formatted. Of course you can comment it out or delete it if/when it isn't need. For the record, I don't deal with WIM files and do not really care to. However, I am quite familiar with DLL calls, structs, and pointers. So if I can manage to help you without having to get into creating WIM files, I will try to do so. At least I will up to a point. The more effort you show in truly wanting to learn, and how well you are able to absorb the information, will determine how willing I will be to continue helping. Let the fun begin! #include <Constants.au3> #include <Debug.au3> Global $gpWimStruct = 0 ;Open WIM file $gpWimStruct = wimlib_open_wim("test.wim") If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Function failed with @error = " & @error & " @extended = " & @extended) ConsoleWrite("WIMStruct pointer = " & String($gpWimStruct) & @CRLF) ;Release WinStruct structure resources wimlib_free($gpWimStruct) ; #FUNCTION# ==================================================================================================================== ; Name ..........: wimlib_open_wim ; Description ...: Open a WIM file and create a WIMStruct for it. ; Syntax ........: wimlib_open_wim($sWimFilePath, $iOpenFlags = 0) ; Parameters ....: $WimFilePath A string containing the path to the WIM file to open. ; $iOptionFlags [optional] An integer containing the option flags. Default = 0 ; Return values .: Success: Pointer to a WimStruct structure. ; Failure: 0 and sets @error flag to non-zero. ; @extended is set to the function's return code. ; @error: 1 - wimlib_open_wim returned an error, @extended = return code ; Author ........: TheXman ; Related .......: https://wimlib.net/apidoc/group__G__creating__and__opening__wims.html#ga5c28905bda14c8969ac504f1526d0ae9 ; =============================================================================================================================== Func wimlib_open_wim($sWimFilePath, $iOpenFlags = 0) Local $aReturn ;Open WIM $aReturn = DllCall("libwim-15.dll", "int:cdecl", "wimlib_open_wim", _ "wstr", $sWimFilePath, _ "int", $iOpenFlags, _ "ptr*", Null) If @error Then ;Handle DllCall error Exit MsgBox($MB_ICONERROR, "ERROR", "wimlib_open_wim DllCall failed with @error " & @error) ElseIf $aReturn[0] <> 0 Then ;Handle bad return code from function Return SetError(1, $aReturn[0], 0) EndIf _DebugArrayDisplay($aReturn, "wimlib_open_wim $aReturn") ;All is good, return pointer Return $aReturn[3] ;Pointer to WIMStruct structure EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: wimlib_free ; Description ...: Release a reference to a WIMStruct. ; Syntax ........: wim_open_wim_example($pWimStruct) ; Parameters ....: $pWimStruct Pointer to the WIMStruct to release. ; Return values .: None ; Author ........: TheXman ; Related .......: https://wimlib.net/apidoc/group__G__creating__and__opening__wims.html#ga5c28905bda14c8969ac504f1526d0ae9 ; =============================================================================================================================== Func wimlib_free($pWimStruct) ;Free winstruct resources DllCall("libwim-15.dll", "none", "wimlib_free", _ "ptr", $pWimStruct) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "wimlib_free DllCall failed with @error " & @error) ;All is good Return EndFunc Why did you create a new topic with the same questions when you could have just added another post to the old one?1 point
-
Did you use the installer for Autoit3 or the ZIP? With the installer it should work fine as that does all the needed stuff for you. Jos1 point
-
AutoIT and Linux (Wine)
HurleyShanabarger reacted to Melba23 for a topic
Mike25de, Always a pleasure to see old members come back. You are arriving at an interesting time with the new release not too far off (we hope)! M231 point -
IAHIM, https://www.autoitscript.com/trac/autoit/wiki/AutoItNotOnToDoList M23 Edit: Sorry, I see you mentioned Wine. Apparently you can run AutoIt under Wine, although some of the functions do not work correctly. Certainly there is no intention of changing anything in AutoIt to make it more compatible - development time is, as you have I hope now noticed, hard enough to come by for the main package.1 point
-
CMD Pipe demo
argumentum reacted to Dan_555 for a topic
Hi, this is not my script. I have used the Autoit Examples\GUI\Advanced\_NamedPipes_Server.au3 script and stripped down everything unneeded. Now it functions like what both Client and Server script did, just in one file: It captures the command-line output directly, using the pipe, and puts it into its own edit field. #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <NamedPipes.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; =============================================================================================================================== ; Description ...: This was the server side of the pipe demo ; Author ........: Paul Campbell (PaulIA) ; Notes .........: CMD-Mod by dan_555 ; =============================================================================================================================== ; =============================================================================================================================== ; Global constants ; =============================================================================================================================== Global Const $BUFSIZE = 1024 * 4 Global Const $PIPE_NAME = "\\.\\pipe\\AutoIt3PipeTest" Global Const $TIMEOUT = 5000 Global Const $WAIT_TIMEOUT = 250 Global Const $ERROR_IO_PENDING = 997 Global Const $ERROR_PIPE_CONNECTED = 535 Global $locktimer = 0, $lockexit = 0, $inp1Txt Global $h_PID = 0 Global $closingdelay = 1000, $closecounter = 0, $TimeHandle = TimerInit(), $TimeDiff = TimerDiff($TimeHandle) ;Used for CloseGuiOnDoubleClick() Global $formTitle = "Pipe CMD Test" ; =============================================================================================================================== ; Global variables ; =============================================================================================================================== Global $g_hEvent, $g_idMemo, $g_pOverlap, $g_tOverlap, $g_hPipe, $g_hReadPipe, $g_iState, $g_iToWrite ; =============================================================================================================================== ; Main ; =============================================================================================================================== GUIRegisterMsg($WM_SIZE, "WM_SIZE") CreateGUI() InitPipe() MsgLoop() ; =============================================================================================================================== ; Creates a GUI ; =============================================================================================================================== Func CreateGUI() Global $hGUI = GUICreate($formTitle, 500, 400, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) Global $Button1 = GUICtrlCreateButton("Go", 2, 1, 37, 29) GUICtrlSetTip(-1, "Execute the command from the input box") Global $StatusBar1 = _GUICtrlStatusBar_Create($hGUI) Global $g_idMemo = GUICtrlCreateEdit("", 0, 31, 499, 349) Global $Input1 = GUICtrlCreateInput("", 40, 4, 380, 24) GUICtrlSetTip(-1, "Command to execute. Enter to start!" & @CRLF & "Needs user input to accept enter key!") Global $Button2 = GUICtrlCreateButton("CLS", 421, 1, 30, 29) GUICtrlSetTip(-1, "Clear the output") Global $Button3 = GUICtrlCreateButton("STOP", 461, 1, 35, 29) GUICtrlSetTip(-1, "Emergency stop, works only if a command is running." & @CRLF & "This will close the running Proccess !!!") GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState() GUICtrlSetLimit($g_idMemo, 555555555) GuiCtrlSetState ($Button3,$GUI_DISABLE) EndFunc ;==>CreateGUI ; =============================================================================================================================== ; This function creates an instance of a named pipe ; =============================================================================================================================== Func InitPipe() ; Create an event object for the instance $g_tOverlap = DllStructCreate($tagOVERLAPPED) $g_pOverlap = DllStructGetPtr($g_tOverlap) $g_hEvent = _WinAPI_CreateEvent() If $g_hEvent = 0 Then LogMSG("ERR:InitPipe ..........: API_CreateEvent failed") Return EndIf DllStructSetData($g_tOverlap, "hEvent", $g_hEvent) ; Create a named pipe $g_hPipe = _NamedPipes_CreateNamedPipe($PIPE_NAME, _ ; Pipe name 2, _ ; The pipe is bi-directional 2, _ ; Overlapped mode is enabled 0, _ ; No security ACL flags 1, _ ; Data is written to the pipe as a stream of messages 1, _ ; Data is read from the pipe as a stream of messages 0, _ ; Blocking mode is enabled 1, _ ; Maximum number of instances $BUFSIZE, _ ; Output buffer size $BUFSIZE, _ ; Input buffer size $TIMEOUT, _ ; Client time out 0) ; Default security attributes If $g_hPipe = -1 Then LogMSG("ERR:InitPipe ..........: _NamedPipes_CreateNamedPipe failed") EndIf EndFunc ;==>InitPipe ; =============================================================================================================================== ; This function loops, waiting for user input or the GUI to close ; =============================================================================================================================== Func MsgLoop() GUICtrlSetData ($Input1,"cmd.exe /c dir C:\ /oN") While 1 CloseGuiOnDoubleClick("loop") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE CloseGuiOnDoubleClick("button") Case $Input1 Go() Case $Button1 ;Execute the command from the edit field Go() Case $Button2 ;Clear the Edit field MemoWrite("", 1) EndSwitch WEnd EndFunc ;==>MsgLoop Func Go() $inp1Txt = GUICtrlRead($Input1) If $inp1Txt <> "" Then If ExecuteCmd($inp1Txt) Then GuiCtrlSetState ($Button3,$GUI_ENABLE) While $lockexit = 0 ;Exits the loop when the ReadOutput() stops receiving data. If GUIGetMsg() = $Button3 Then ProcessClose($h_PID) ;Stop Button, closes the proccess id - in case it is stuck _GUICtrlEdit_BeginUpdate($g_idMemo) ;This allows the edit field to be scrolled via scrollbars, while getting data. ReadOutput() ;Read the pipe and set the output into the edit field _GUICtrlEdit_EndUpdate($g_idMemo) WEnd $lockexit = 0 GuiCtrlSetState ($Button3,$GUI_DISABLE) LogMsg("done") EndIf EndIf EndFunc ;==>Go Func ReadOutput() Local $pBuffer, $tBuffer, $sLine, $iRead, $bSuccess, $iWritten $tBuffer = DllStructCreate("char Text[" & $BUFSIZE & "]") $pBuffer = DllStructGetPtr($tBuffer) ; Read data from console pipe _WinAPI_ReadFile($g_hReadPipe, $pBuffer, $BUFSIZE, $iRead) If $iRead = 0 Then _WinAPI_CloseHandle($g_hReadPipe) _WinAPI_FlushFileBuffers($g_hPipe) $lockexit = 1 $h_PID = 0 Return EndIf ; Get the data and strip out the extra carriage returns $sLine = StringLeft(DllStructGetData($tBuffer, "Text"), $iRead) $sLine = StringReplace($sLine, @CR & @CR, @CR) If $sLine <> "" Then MemoWrite($sLine) EndFunc ;==>ReadOutput ; =============================================================================================================================== ; Executes a command and returns the results ; =============================================================================================================================== Func ExecuteCmd($sCmd) Local $tProcess, $tSecurity, $tStartup, $hWritePipe ; Set up security attributes $tSecurity = DllStructCreate($tagSECURITY_ATTRIBUTES) DllStructSetData($tSecurity, "Length", DllStructGetSize($tSecurity)) DllStructSetData($tSecurity, "InheritHandle", True) ; Create a pipe for the child process's STDOUT If Not _NamedPipes_CreatePipe($g_hReadPipe, $hWritePipe, $tSecurity) Then LogMSG("ERR: ExecuteCmd ........: _NamedPipes_CreatePipe failed") Return False EndIf ; Create child process $tProcess = DllStructCreate($tagPROCESS_INFORMATION) $tStartup = DllStructCreate($tagSTARTUPINFO) DllStructSetData($tStartup, "Size", DllStructGetSize($tStartup)) DllStructSetData($tStartup, "Flags", BitOR($STARTF_USESTDHANDLES, $STARTF_USESHOWWINDOW)) DllStructSetData($tStartup, "StdOutput", $hWritePipe) DllStructSetData($tStartup, "StdError", $hWritePipe) If Not _WinAPI_CreateProcess("", $sCmd, 0, 0, True, 0, 0, "", DllStructGetPtr($tStartup), DllStructGetPtr($tProcess)) Then LogMSG("ERR: ExecuteCmd ........: _WinAPI_CreateProcess failed") _WinAPI_CloseHandle($g_hReadPipe) _WinAPI_CloseHandle($hWritePipe) Return False EndIf $h_PID = DllStructGetData($tProcess, "ProcessID") _WinAPI_CloseHandle(DllStructGetData($tProcess, "hProcess")) _WinAPI_CloseHandle(DllStructGetData($tProcess, "hThread")) ; Close the write end of the pipe so that we can read from the read end _WinAPI_CloseHandle($hWritePipe) LogMsg("ExecuteCommand ....: " & $sCmd) Return True EndFunc ;==>ExecuteCmd Func MemoWrite($sMessage = "", $clr = 0) local $CRLF="" If $clr = 1 Then GUICtrlSetData($g_idMemo, "") Else $CRLF=@CRLF EndIf GUICtrlSetData($g_idMemo, $sMessage & $CRLF, 0) EndFunc ;==>MemoWrite Func LogMsg($msg) _GUICtrlStatusBar_SetText($StatusBar1, $msg) EndFunc ;==>LogMsg ; Resize the status bar when GUI size changes Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GUICtrlStatusBar_Resize($StatusBar1) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func CloseGuiOnDoubleClick($typ) $typ = StringLower($typ) Select Case $typ = "button" If $closecounter = 1 And TimerDiff($TimeHandle) <= $closingdelay Then GUIDelete() Exit EndIf If $closecounter = 0 Then $closecounter = 1 $TimeHandle = TimerInit() WinSetTitle($hGUI, "", "To close, use Slow doubleclick on the X ! Or (2* Alt F4) or (2*Esc)") EndIf Case $typ = "loop" If $closecounter = 1 And TimerDiff($TimeHandle) > $closingdelay Then $closecounter = 0 WinSetTitle($hGUI, "", $formTitle) EndIf EndSelect EndFunc ;==>CloseGuiOnDoubleClick Edit: The script may freeze, if the executed command waits for input.1 point -
Hi everyone, Some good news for you among all the gloom of these virus-ridden times: Nine, Subz and Danyfirex have accepted the invitation to become MVPs. Please join me in congratulating them on their new status in our community. Keep safe out there, M231 point
-
Issue with Autoitobject UDF
MattHiggs reacted to seadoggie01 for a topic
It sounds like it might be Windows changing it for you... see here. They want you to update to video mixing render 9, as you can see here Can you change the value to 0 to fix it for now? A hacky solution might be to throw a RegDelete into the beginning of the script1 point -
now this code work ; this script will read data from an access database ; By Greencan ;Prerequisites: ; Using ODBC ; You need to create a system DSN (or file DSN) that points to the .mdb that you want to access. #include <Array.au3> Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info Opt("ExpandEnvStrings", 1) ;0=don't expand, 1=do expand Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand Opt("GUIDataSeparatorChar","|") ;"|" is the default ; ODBC System DSN definition $DSN="DSN=Microsoft Access db"; MSAccess database as defined in ODBC ;$DSN="DSN=Microsoft Access Driver (*.mdb, *.accdb)"; MSAccess database as defined in ODBC ; call SQL $out=getData($DSN) ; display array ; array element 0 will hold the row titles _ArrayDisplay($out,"Result of query") Exit #FUNCTION# ============================================================== Func getData($DSN) ; ODBC $adoCon = ObjCreate ("ADODB.Connection") $adoCon.Open ($DSN) $adoRs = ObjCreate ("ADODB.Recordset") ; Create a Record Set to handles SQL Records - SELECT SQL $adoRs2 = ObjCreate ("ADODB.Recordset") ; Create a Record Set to handles SQL Records - UPDATE SQL ; create the SQL statement ;$adoSQL = "SELECT CODE, SHORT_EXPLANATION, LONG_EXPLANATION FROM tabella1" $adoSQL = "SELECT * FROM tabella1" $adoRs.CursorType = 2 $adoRs.LockType = 3 ; execute the SQL $adoRs.Open($adoSql, $adoCon) DIM $Result_Array[1][1] With $adoRs $dimension = .Fields.Count ConsoleWrite($dimension & @cr) ReDim $Result_Array[1][$dimension] ; Column header $Title = "" For $i = 0 To .Fields.Count - 1 $Title = $Title & .Fields( $i ).Name & @TAB $Result_Array[0][$i] = .Fields( $i ).Name ; set the array elements Next ConsoleWrite($Title & @CR & "----------------------------------" & @CR) ; loop through the records $element = 1 If .RecordCount Then While Not .EOF $element = $element + 1 ReDim $Result_Array[$element][$dimension] $Item = "" For $i = 0 To .Fields.Count - 1 $Item = $Item & .Fields( $i ).Value & @TAB $Result_Array[$element - 1][$i] = .Fields( $i ).Value ; set the array element Next ConsoleWrite($Item & @CR) .MoveNext WEnd EndIf EndWith $adoCon.Close ; close connection return $Result_Array EndFunc #FUNCTION# ============================================================== ; Com Error Handler Func MyErrFunc() dim $oMyRet[4] $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description,3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc #FUNCTION# ============================================================== after install adodb you must create a system DSN and call Microsoft Access db (if you want run my code witout modify databese call Database11.accdb, and table call tabella1 ) after create a system DSN you must attach a database in system data source , cclick in configure , database box click in selection and select your database (in my case i select Database11.accdb)1 point
-
Coding Autoit & RESPECT
noellarkin reacted to iamtheky for a topic
1 point -
Check if a point is within various defined closed shapes.
jaberwacky reacted to Malkey for a topic
This is an example showing the use of, and accuracy of the following functions. _PointInEllipse() _WinAPI_PtInRectEx() _PointInPoly() All functions return true if the specified point is witin the closed area of the shape, And, False if the specified point is outside the shape. A circle can be used with _PointInEllipse() function. A circle being an equal sided ellipse. A triangle can be used with _PointInPoly(). A triangle being a three sided polygon. For right angle rectangle shape use _WinAPI_PtInRectEx(). Similar to the one in WinAPI.au3, include file. For a parallelogram, rhombus, or any other quadrilateral shape or other multi-straight-line-sided closed figure use _PointInPoly() function. In the example the graphics area on the GUI has been shorten. This shows that the graphics displaying the shapes are not necessary for the functions to work. Although, the graphics are necessary for checking their accuracy. The tool tip will show true for the shape the cursor is inside, and false for all the other shapes. The shapes are clickable. Notice the tool tip when the the cursor is over the button.. The button is within the circle, The button, when pressed, shows the button pressed message as opposed to the 'in cirlce shape' message. Cllick below or above the button, but still within the cirle area, and the 'in cirlce shape' message works. The two functions The _CentroidPoly() function which returns the x, y position of the centroid of a polygon, and the _AreaPoly() function which returns the area of a closed polygon, have been included. Someone might find a use for them oneday. If nothing else, this example will tell you the names of different shapes. Although that is not its purpose. Hopefully, you can find a use for these functions in your own script. #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client Global $hGUI, $hBMPBuff, $hGraphicGUI, $hGraphic _Main() Func _Main() Local $msg, $aPos, $GuiSizeX = 400, $GuiSizeY = 300 Local $aPoints[7][2], $aTriangle[5][2] Local $hButton ; Create GUI $hGUI = GUICreate("GDI+", $GuiSizeX, $GuiSizeY) GUISetState() _GDIPlus_Startup() ;Double Buffer $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY - 65, $hGraphicGUI) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ;End Double Buffer add-on 1 of 3 _GDIPlus_GraphicsClear($hGraphic, 0xFFE8FFEF) $aPoints[0][0] = 5; Number of sides of Polygon $aPoints[1][0] = 100 $aPoints[1][1] = 100 $aPoints[2][0] = 200 $aPoints[2][1] = 150 $aPoints[3][0] = 200 $aPoints[3][1] = 200 $aPoints[4][0] = 150 $aPoints[4][1] = 100 $aPoints[5][0] = 70 $aPoints[5][1] = 200 $aPoints[6][0] = 100;Last point same as 1st point. Polygon is closed $aPoints[6][1] = 100 _GDIPlus_GraphicsDrawPolygon($hGraphic, $aPoints) Local $iRectX = 220, $iRectY = 25, $iRectWidth = 100, $iRectHth = 50 _GDIPlus_GraphicsDrawRect($hGraphic, $iRectX, $iRectY, $iRectWidth, $iRectHth) Local $iElpsX = 220, $iElpsY = 180, $iElpsWidth = 130, $iElpsHth = 70 _GDIPlus_GraphicsDrawEllipse($hGraphic, $iElpsX, $iElpsY, $iElpsWidth, $iElpsHth) $aTriangle[0][0] = 3; Number of sides of Polygon $aTriangle[1][0] = 30 $aTriangle[1][1] = 30 $aTriangle[2][0] = 150 $aTriangle[2][1] = 40 $aTriangle[3][0] = 50 $aTriangle[3][1] = 100 $aTriangle[4][0] = 30;Last point same as 1st point. Polygon is closed $aTriangle[4][1] = 30 _GDIPlus_GraphicsDrawPolygon($hGraphic, $aTriangle) $hButton = GUICtrlCreateButton("In Circle", 22, 240, 75, 20) Local $iCircleX = 20, $iCircleY = 210, $iCircleWidth = 80, $iCircleHth = 80 _GDIPlus_GraphicsDrawEllipse($hGraphic, $iCircleX, $iCircleY, $iCircleWidth, $iCircleHth) ConsoleWrite("Area of Polygon = " & _AreaPoly($aPoints) & @CRLF) Local $aCent = _CentroidPoly($aPoints) ConsoleWrite("Centroid of Polygon: cX = " & $aCent[0] & " cY = " & $aCent[1] & @CRLF) ; Create Double Buffer, doesn't need to be repainted on PAINT-Event GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) GUIRegisterMsg(0x85, "MY_PAINT"); $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ;End Double Buffer add-on 2 of 3 While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hGraphicGUI) _WinAPI_DeleteObject($hBMPBuff) _GDIPlus_Shutdown() Exit Case $hButton MsgBox(0, "", "Button Pressed. ") Case $GUI_EVENT_MOUSEMOVE $aPos = MouseGetPos() ToolTip("Mouse Position X: " & $aPos[0] & " Y: " & $aPos[1] & @CRLF & @CRLF & _ "Cursor in Polygon: " & _PointInPoly($aPos[0], $aPos[1], $aPoints) & @CRLF & _ "Cursor in Triangle: " & _PointInPoly($aPos[0], $aPos[1], $aTriangle) & @CRLF & _ "Cursor in Ellipse: " & _PointInEllipse($aPos[0], $aPos[1], $iElpsX, $iElpsY, _ $iElpsWidth, $iElpsHth) & @CRLF & _ "Cursor in Circle: " & _PointInEllipse($aPos[0], $aPos[1], $iCircleX, $iCircleY, _ $iCircleWidth, $iCircleHth) & @CRLF & _ "Cursor in Rectangle: " & _WinAPI_PtInRectEx($aPos[0], $aPos[1], $iRectX, $iRectY, _ $iRectX + $iRectWidth, $iRectY + $iRectHth) & @CRLF) Case $GUI_EVENT_PRIMARYUP $aPos = MouseGetPos() Select Case _PointInPoly($aPos[0], $aPos[1], $aPoints) ToolTip("") MsgBox(0, "", "Clicked in PolyGon") Case _WinAPI_PtInRectEx($aPos[0], $aPos[1], $iRectX, $iRectY, $iRectX + $iRectWidth, _ $iRectY + $iRectHth) ToolTip("") MsgBox(0, "", "Clicked in Rectangle") Case _PointInEllipse($aPos[0], $aPos[1], $iElpsX, $iElpsY, $iElpsWidth, $iElpsHth) ToolTip("") MsgBox(0, "", "Clicked in Ellipse") Case _PointInPoly($aPos[0], $aPos[1], $aTriangle) ToolTip("") MsgBox(0, "", "Clicked in Triangle") Case _PointInEllipse($aPos[0], $aPos[1], $iCircleX, $iCircleY, $iCircleWidth, $iCircleHth) ToolTip("") MsgBox(0, "", "Clicked in Invisible Circle") EndSelect EndSwitch WEnd EndFunc ;==>_Main ; Returns the area of a polygon Func _AreaPoly($aPoints) Local $Med For $n = 1 To UBound($aPoints) - 2 $Med += $aPoints[$n][0] * $aPoints[$n + 1][1] - $aPoints[$n + 1][0] * $aPoints[$n][1] Next Return $Med / 2 EndFunc ;==>_AreaPoly ; Returns an array containing the x, y position of the centroid of a polygon. Func _CentroidPoly($aPoints) Local $Med, $aRet[2], $MedX, $MedY, $Area For $n = 1 To UBound($aPoints) - 2 $MedX += ($aPoints[$n][0] + $aPoints[$n + 1][0]) * ($aPoints[$n][0] * $aPoints[$n + 1][1] - _ $aPoints[$n + 1][0] * $aPoints[$n][1]) $MedY += ($aPoints[$n][1] + $aPoints[$n + 1][1]) * ($aPoints[$n][0] * $aPoints[$n + 1][1] - _ $aPoints[$n + 1][0] * $aPoints[$n][1]) Next $Area = _AreaPoly($aPoints) $aRet[0] = $MedX / ($Area * 6) $aRet[1] = $MedY / ($Area * 6) Return $aRet EndFunc ;==>_CentroidPoly ; ($xPt, $yPt) - x, y position of the point to check ; $xTL, $yTL, Top left x Pos, top left Y position of the rectangle encompassing the ellipse. ; $w, $h - The width an height of ellipse ; Method: The distance from the 1st focal point to a point on the perimeter plus the distance from ; the second focal point to the same point on the perimeter is a constant and equals the width of ; the ellipse, the major axis. So, if the sum of the two distances form the point to check to the ; two foci is greater than the major axis, then the point is outside the ellipse. Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h) Local $bInside = False, $a = $w / 2, $b = $h / 2 Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b $c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position $c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position $dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 If $dist <= $w Then $bInside = Not $bInside Return $bInside EndFunc ;==>_PointInEllipse ; ($iX, $iY) - x, y position of the point to check ; ($iLeft, $iTop) - x, y position of the top left corner of rectangle ; ($iRight, $iBottom) - x, y position of the bottom right corner of rectangle ; Func _WinAPI_PtInRectExA($iX, $iY, $iLeft, $iTop, $iRight, $iBottom) Local $aResult Local $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, "Left", $iLeft) DllStructSetData($tRect, "Top", $iTop) DllStructSetData($tRect, "Right", $iRight) DllStructSetData($tRect, "Bottom", $iBottom) $aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY) If @error Then Return SetError(@error, 0, False) Return $aResult[0] <> 0 EndFunc ;==>_WinAPI_PtInRectEx ; ($x, $y) - x, y position of the point to check ; $aPoints - An array of x,y values representing the nodes of a polygon. ; Finds the individual x values of the interestion of the individual sides of the polygon with the ; line y = $y (parallel with x-axis). If the number of x values found greater than $x is even, then ; the ($x, $y) point is outside the closed polygon. Plus, if $y is beyond the y values of the end ; points of individual sides of the polygon, the y = $y line will not interest with that side and will ; not be counted. Returns equivalent of, even number of intersections false, and, odd true(inside polygon). ; Requires Iif()function Func _PointInPoly($x, $y, $aPoints) Local $bEvenNum = False, $xOnLine, $yMin, $yMax For $i = 1 To $aPoints[0][0] $yMin = Iif($aPoints[$i + 1][1] < $aPoints[$i][1], $aPoints[$i + 1][1], $aPoints[$i][1]) $yMax = Iif($aPoints[$i + 1][1] > $aPoints[$i][1], $aPoints[$i + 1][1], $aPoints[$i][1]) $xOnLine = -($y * $aPoints[$i + 1][0] - $y * $aPoints[$i][0] - $aPoints[$i][1] * $aPoints[$i + 1][0] + _ $aPoints[$i][0] * $aPoints[$i + 1][1]) / (-$aPoints[$i + 1][1] + $aPoints[$i][1]) If ($x < $xOnLine) And ($y > $yMin) And ($y <= $yMax) Then $bEvenNum = Not $bEvenNum Next Return $bEvenNum EndFunc ;==>_PointInPoly ; Same as _Iif() function from Misc.au3 include file Func Iif($fTest, $vTrueVal, $vFalseVal) If $fTest Then Return $vTrueVal Else Return $vFalseVal EndIf EndFunc ;==>Iif ;Func to redraw on PAINT MSG Func MY_PAINT($hWnd, $msg, $wParam, $lParam) ; Check, if the GUI with the Graphic should be repainted _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) _WinAPI_RedrawWindow($hGUI, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME));,$RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT Edit: Another example of the use of _PointInEllipse() function is at http://www.autoitscript.com/forum/index.ph...st&p=639811 Edit:8thFeb2008 Changed _PointInPoly() to correct wrong return when the conditions point out by martin, post#5, occurred. Edit:8thFeb2008 10hr later Changed _PointInPoly() to correct wrong return when the conditions point out by martin, post#7, occurred. Edit:8thFeb2008 Changed _PointInPoly() to simplify conditional statement as mentioned in posts #9 and #10.1 point -
Firefox and WinClose("CLASS:MozillaWindowClass")
pete_wilde reacted to ahha for a topic
Khumprp, I had similar issues as you, after trying titles and classes, I found the simplest way was to simply kill the process. ProcessClose("firefox.exe") This sometimes generates a restore tab when FF is started up again. If you want to start FF without a restore tab then in FF 1) type about:config in website bar and click ok 2) in Filter type in crash 3) double click browser.sessionstore.resume_from_crash till it says false under value1 point