Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/17/2019 in all areas

  1. Something like this? #include <Constants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <File.au3> #include <GuiEdit.au3> OnAutoItExitRegister("_Exit") #Region ### START Koda GUI section ### Form= ; [0] - width, [1] - height, [2] - left, [3] - top Local $iGuiRes[4] = [588, 440] $iGuiRes[2] = (@DesktopWidth / 2) - ($iGuiRes[0] / 2) $iGuiRes[3] = (@DesktopHeight / 2) - ($iGuiRes[1] / 2) $hGui = GUICreate("Batch tester", $iGuiRes[0], $iGuiRes[1], $iGuiRes[2], $iGuiRes[3]) $cFilePath = GUICtrlCreateInput("0.bat", 8, 8, 320, 25) GUICtrlSetFont(-1, 12.5) $cStart = GUICtrlCreateButton("Launch bat", 336, 8, 94, 25) GUICtrlSetFont(-1, 12) $cStop = GUICtrlCreateButton("Stop bat", 438, 8, 94, 25) GUICtrlSetFont(-1, 12) Local $iEditWidth = $iGuiRes[0] / 2 - 16 GUICtrlCreateLabel("Batch file output", 16, 48, $iEditWidth - (8 * 3), 17) GUICtrlSetFont(-1, 9, $FW_BOLD) $cBatOutput = GUICtrlCreateEdit("", 8, 72, $iEditWidth, 353, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) _GUICtrlEdit_SetReadOnly(ControlGetHandle($hGui, '', $cBatOutput), True) GUICtrlSetData(-1, "") GUICtrlCreateLabel("Batch file contents", $iEditWidth + (8 * 5), 48, $iEditWidth - (8 * 3) - 58, 17) GUICtrlSetFont(-1, 9, $FW_BOLD) $cSave = GUICtrlCreateButton("Save", ($iEditWidth * 2) - (8 * 6), 45, $iEditWidth - ($iEditWidth - (8 * 3) - 50), 25) GUICtrlSetFont(-1, 10) $cBatEditor = GUICtrlCreateEdit("", $iEditWidth + (8 * 3), 72, $iEditWidth, 353) GUICtrlSetData(-1, "") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $hDOS = False, $sFilePath, $hFile, $sPrevFileText, $sGuiText, $Message While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cStart ; Can't start the batch if the batch is already running If $hDOS And ProcessExists($hDOS) Then ContinueCase $sFilePath = GUICtrlRead($cFilePath) $hDOS = _RunBat($sFilePath) If @error Then GUICtrlSetData($cBatOutput, $hDOS & ' - ' & @error) $hDOS = False Else ConsoleWrite("Batch file contents: " & FileRead($sFilePath) & @CRLF) GUICtrlSetData($cBatEditor, FileRead($sFilePath)) GUICtrlSetData($cBatOutput, '') EndIf Case $cSave $sGuiText = GUICtrlRead($cBatEditor) ; Make sure that we're not just writing a blank file, and that there's actually something to change If $sGuiText <> '' And $sGuiText <> $sPrevFileText Then ConsoleWrite("Current BatEditor text:" & @CRLF & $sGuiText & @CRLF) $hFile = FileOpen($sFilePath, 10) If $hFile <> -1 Then ConsoleWrite("Batch file handle: " & $hFile & @CRLF) FileWrite($hFile, $sGuiText) FileFlush($hFile) FileClose($hFile) $sPrevFileText = $sGuiText EndIf EndIf Case $cStop ; Only need to stop something, if something exists If $hDOS And ProcessExists($hDOS) Then $Message = StdoutRead($hDOS) ProcessClose($hDOS) $Message &= @CRLF & " Output stopped" & @CRLF & $hDOS $hDOS = False _GUICtrlEdit_AppendText($cBatOutput, @CRLF & $Message) $Message = '' ; Write the output to a log file $hFile = FileOpen("output.log", 10) If $hFile <> -1 Then FileWrite($hFile, GUICtrlRead($cBatOutput)) FileFlush($hFile) FileClose($hFile) EndIf EndIf EndSwitch If $hDOS And ProcessExists($hDOS) Then $Message = StdoutRead($hDOS) If @error Then $Message &= @CRLF & " Output stopped" & @CRLF & $hDOS $hDOS = False EndIf If $Message <> '' Then ConsoleWrite($Message & @CRLF) _GUICtrlEdit_AppendText($cBatOutput, @CRLF & $Message) $Message = '' EndIf EndIf WEnd Func _RunBat($sFilePath = '0.bat') $sFilePath = StringReplace($sFilePath, '"', '') $sFilePath = StringReplace($sFilePath, "'", '') If Not FileExists($sFilePath) Then Return SetError(1, 0, "File doesn't exist") Local $sFullPath = _PathFull($sFilePath) If Not FileExists($sFullPath) Then Return SetError(2, 0, "File (PathFull) doesn't exist") ConsoleWrite($sFullPath & @CRLF) Return Run(@ComSpec & ' /k "' & $sFullPath & '"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;~ Return Run(@ComSpec & " /k Ping www.google.com -t", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) EndFunc ;==>_RunBat Func _Exit() $sGuiText = GUICtrlRead($cBatEditor) If $sGuiText <> '' And $sGuiText <> $sPrevFileText Then If Not IsHWnd($hFile) Then $hFile = FileOpen($sFilePath, 10) If $hFile <> -1 Then FileWrite($hFile, $sGuiText) FileClose($hFile) EndIf EndIf If $hDOS Then ProcessClose($hDOS) Exit EndFunc ;==>_Exit This gives you the ability to load up one .bat file, and both display its output and allows you to edit the batch file directly from the same window. It's a pretty basic idea, and probably not the best handling of the file (make a backup). But I'm still not quite sure what your goal is. I want to run a .bat file. (Automated or not it doesn't matter.) Check I need to interact with the bat file for monitoring purpose. Be able to see if I have errors popping in the console. Not sure what you mean by 'interact' with it, but otherwise you can see the output, so check? I can do c:/server/bat.bat OR \\PRET\server\bat.bat it doesn't matter to. I got both access on the server. Check I want to log everything for further use. Check, an 'output.log' file is created when you stop the bat file (it will be overwritten by the next stop)
    2 points
  2. Nine

    Catalog Effect

    Yes it is simply a GIF animation. Look example of _GDIPlus_ImageGetFrameCount in help file. It is a good way to implement GIF animation. Personally, I use AdlibRegister function at every 10ms, to see if it is time to display next frame...
    1 point
  3. seadoggie01

    Make a .jpeg file

    Burgs has something going here. You'll want to apply the fix he talks about, but his code is posted
    1 point
  4. Personally I use indirect recursion with much caution. Also there is too much redundancy in your code. Here what I would advise : Opt("MustDeclareVars", 1) Global $lieferant = 0 ; make it to a value that cannot be found observe() Func observe() While True While Not WinExists("Test2 Rechnungskontrolle (Verbuchung)") Sleep(250) WEnd While WinExists("Test2 Rechnungskontrolle (Verbuchung)") Sleep(250) getLieferant() WEnd WEnd EndFunc ;==>observe Func getLieferant() If Not WinExists("Test2 Rechnungskontrolle (Verbuchung)")) Then Return Local $strString = WinGetText("Test2 Rechnungskontrolle (Verbuchung)") Local $arrResult = StringRegExp($strString, '(?s)&Adresse.*?\d+.*?(\d+)', $STR_REGEXPARRAYGLOBALMATCH) If Not IsArray($arrResult) Then Return If $lieferant == $arrResult[0] Then Return $lieferant = $arrResult[0] ;MsgBox(0,"Changed",$lieferant) ConsoleWrite($lieferant) refreshSidebar($lieferant) EndFunc ;==>getLieferant Func refreshSidebar($vendorID) ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Get connection handle Local $hConnect = _WinHttpConnect($hOpen, "http://MKSRVAPP04:25024") Local $hRequest = _WinHttpSimpleRequest($hConnect, "GET", "api/client/sidebar/sendCommand?user=MULTIKRAFT\" & @UserName & "&call=OBJ:Vendor@@SELECT@@IDX:Vendor%20ID=" & $vendorID) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) EndFunc ;==>refreshSidebar Untested of course...
    1 point
  5. Hello maloysius, After testing this on my two local computers (luckily I actually set them up on the same WORKGROUP), I was able to get this working. Here's the issue, the 'Receiver' needs to keep the name as: "\\.\mailslot\Test", and the 'Sender' is: "\\WORKGROUP\mailslot\Test". That allowed everything to work correctly for me, and I could receive messages from the sender to the receiver computer. This site gave me the information that I needed:
    1 point
  6. Hello Maybe something like this would work. #include <MsgBoxConstants.au3> Global $hDll = DllOpen("RSA_API.dll") If $hDll <> -1 Then Local $aCall = DllCall($hDll, "int:cdecl", "DEVICE_GetAPIVersion", "str*", Null) Local $sAPIVersion = $aCall[1] ConsoleWrite("APIVersion: " & $sAPIVersion & @CRLF) $aCall = DllCall($hDll, "int:cdecl", "DEVICE_SearchInt", "int*", 0, "ptr*", 0, "ptr*", 0, "ptr*", 0) Local $iNumberOfDevices = $aCall[1] ConsoleWrite("NumberOfDevices: " & $iNumberOfDevices & @CRLF) ;here you will need to cast the information from the pointers ;$aCall[2] ;here is maybe DllStructCreate("int[10]",$aCall[2]) ;$aCall[3] ;here is maybe DllStructCreate("ptr[NumberofDevices]",$aCall[3]) ;$aCall[4] ;here is maybe DllStructCreate("ptr[NumberofDevices]",$aCall[4]) ;then get data(string) from each pointer. Else MsgBox(0, "DllOpen", "DllOpen failed") EndIf DllClose($hDll) Saludos
    1 point
×
×
  • Create New...