Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/23/2018 in all areas

  1. mikell

    StringRegExpReplace Call

    Regex is nice, but sometimes simpler is better $s = "1 , 29,46, 46 , 25" Msgbox(0,"", StringReplace(StringStripWS($s, 8), ",", ", ") )
    2 points
  2. Hi all, Thanks Subz for indicating OnAutoItExitRegister, didn't know that one. Like Caramen, I guess OP would like to supervise a user exiting the script abnormally. So IAMK, here is a script I just wrote that could help you, tweak it as you wish. The following 1st pic will display if you click on exit in systray, during the 5s the script will run. I tested the other situations too (logoff, windows shutdown) and the log file did a fine job (2nd pic) Good luck #include <Date.au3> #include <MsgBoxConstants.au3> OnAutoItExitRegister("How_Did_Script_End") MsgBox($MB_TOPMOST, "Don't touch please", "This script will end in 5 seconds", 5) ; timeout 5s Func How_Did_Script_End() Local $Date_Time = _Now() Local $sMsg = "" Switch @exitMethod Case 0 $sMsg = "Natural ending" Case 1 $sMsg = "Exit function encountered" Case 2 $sMsg = "Click on Exit in Systray" Case 3 $sMsg = "User logoff" Case 4 $sMsg = "Windows Shutdown" Case Else $sMsg = "Unknown reason" EndSwitch MsgBox($MB_TOPMOST, "How did script end ?", $sMsg) If @exitMethod > 1 Then Local $sLogFile = @ScriptDir & "\Log_to_be_deleted.txt" FileWrite($sLogFile, $Date_Time & @CRLF & _ "Script " & @ScriptName & " did not end normally : " & @CRLF & _ "@exitMethod = " & @exitMethod & " (" & $sMsg & ")" & @CRLF & @CRLF) ; Display the log file ShellExecute($sLogFile) EndIf EndFunc ; ==> How_Did_Script_End
    2 points
  3. If you're just trying to capture closing the program naturally you can use OnAutoItExitRegister If you're referring to killing a task from task manager, the only way would be to have two processes running at the same time, both monitoring each other So: Startup script starts Main script and monitors when process is closed and writes the log when Main.exe process is closed. Main script checks Startup script is always running, using AdLibRegister to check and re-start Startup script if it's closed.
    2 points
  4. I learn day by day.... ... because I make mistakes day by day so I do not need additional mistakes, because I have a lot of my own.
    2 points
  5. Return 1 ; DO NOT Pass on to default winproc Return $GUI_RUNDEFMSG ;Pass on to default winproc
    1 point
  6. @Deye So you need to extract digits separated by a comma?
    1 point
  7. careca, Have you looked at my code for a suggested new function in the same post as the line you quoted? Obviously not, as that is exactly what it does..... M23
    1 point
  8. I think this AutoIt3Wrapper version which you are using, have not any feature for reporting incorrect parameters. I thinks you should use y/n instead 1/0 My INI config is here:
    1 point
  9. Danyfirex

    dll call failed

    @caramen You should do a forum search here is a Tutorial You can check AutoIt include UDFs compare with MSDN API calls etc. Tips: Learn Dllcall correct declaration, Make sure to do correct data conversion from API to AutoIt Dllcall, Learn About Pointers. Saludos
    1 point
  10. caramen, No real impact - other than being a nuisance. - With the old functionality you would only need the 2 calls when you wanted to delete the content of a line: one call to delete the existing line and another to insert a new blank line. - With the new functionality you would have to use a wrapper function using FileReadToArray, _ArrayDelete, FileWriteToArray (or some form of FileOpen, SFileRead, StringRegExpReplace, FileWrite, FileClose magic) to completely delete a line. So IMO getting both functionalities into the _FileWriteToLine function is a "good thing". M23
    1 point
  11. water

    PixelSearch

    You have started 3 threads since 2015, two of them have already been locked because all were game related. Looks like you still haven't read the forum rules I guess this thread will be locked as well.
    1 point
  12. darkshark, Perhaps this will help? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> Global $iX1, $iY1, $iX2, $iY2, $aPos, $sMsg, $sBMP_Path ; Create GUI $hMain_GUI = GUICreate("Select Rectangle", 240, 50) $hRect_Button = GUICtrlCreateButton("Mark Area", 10, 10, 80, 30) $hCancel_Button = GUICtrlCreateButton("Cancel", 150, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $hCancel_Button FileDelete(@ScriptDir & "Rect.bmp") Exit Case $hRect_Button GUISetState(@SW_HIDE, $hMain_GUI) Mark_Rect() ; Capture selected area $sBMP_Path = @ScriptDir & "Rect.bmp" _ScreenCapture_Capture($sBMP_Path, $iX1, $iY1, $iX2, $iY2, False) GUISetState(@SW_SHOW, $hMain_GUI) ; Display image $hBitmap_GUI = GUICreate("Selected Rectangle", $iX2 - $iX1 + 1, $iY2 - $iY1 + 1, 100, 100) $hPic = GUICtrlCreatePic(@ScriptDir & "Rect.bmp", 0, 0, $iX2 - $iX1 + 1, $iY2 - $iY1 + 1) GUISetState() EndSwitch WEnd ; ------------- Func Mark_Rect() Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp Local $UserDLL = DllOpen("user32.dll") ; Create transparent GUI with Cross cursor $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight - 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) WinSetTrans($hCross_GUI, "", 8) GUISetState(@SW_SHOW, $hCross_GUI) GUISetCursor(3, 1, $hCross_GUI) Global $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x000000) ; Wait until mouse button pressed While Not _IsPressed("01", $UserDLL) Sleep(10) WEnd ; Get first mouse position $aMouse_Pos = MouseGetPos() $iX1 = $aMouse_Pos[0] $iY1 = $aMouse_Pos[1] ; Draw rectangle while mouse button pressed While _IsPressed("01", $UserDLL) $aMouse_Pos = MouseGetPos() $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0) $hMask = _WinAPI_CreateRectRgn($iX1, $aMouse_Pos[1], $aMouse_Pos[0], $aMouse_Pos[1] + 1) ; Bottom of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($iX1, $iY1, $iX1 + 1, $aMouse_Pos[1]) ; Left of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($iX1 + 1, $iY1 + 1, $aMouse_Pos[0], $iY1) ; Top of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($aMouse_Pos[0], $iY1, $aMouse_Pos[0] + 1, $aMouse_Pos[1]) ; Right of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) ; Set overall region _WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask) If WinGetState($hRectangle_GUI) < 15 Then GUISetState() Sleep(10) WEnd ; Get second mouse position $iX2 = $aMouse_Pos[0] $iY2 = $aMouse_Pos[1] ; Set in correct order if required If $iX2 < $iX1 Then $iTemp = $iX1 $iX1 = $iX2 $iX2 = $iTemp EndIf If $iY2 < $iY1 Then $iTemp = $iY1 $iY1 = $iY2 $iY2 = $iTemp EndIf GUIDelete($hRectangle_GUI) GUIDelete($hCross_GUI) DllClose($UserDLL) EndFunc ;==>Mark_Rect Any use? M23
    1 point
  13. #include <GuiConstantsEx.au3> ; ... GuiCtrlSetState($idCtrl, $GUI_ONTOP)
    1 point
×
×
  • Create New...