Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/12/2017 in Posts

  1. Neutro

    AS400 tasks automation

    Hey guys! Here are some informations on how to automate AS400 tasks with AutoIT. AS400 are mainframes made by IBM and used mainly in professional workplaces. First you need to launch an IBM Iseries console to the AS400. It looks like this: As it is a regular window, you can use the "AutoIT Window Info" tool and functions like "ControlSetText", "ControlClick" to automate the login process. Notice that the name of the window (in the top left of the above screenshot) is "Session A". This is because it is the first Iseries window that is opened on the client computer. If you do not close it and open another one, the next one will be named "Session B". The third one "Session C"... Once you're logged into the Iseries console interface, the OS400 login window shows up: Use this code to create an autoIT object linked to the iseries console: global $oOIA = ObjCreate("PCOMM.autECLOIA") $oOIA.SetconnectionByName("A") global $oPS = ObjCreate("PCOMM.autECLPS") $oPS.SetConnectionByName("A") The letter "A" is a reference to the name of the session displayed in the iseries console window, as explained before. Change it to another letter if you have multiples iseries console windows opened at the same time. Then there are 3 main functions that you can use to interact with the interface: $oOIA.WaitForInputReady() ;waits for the interface to be ready for input. $oPS.SetCursorPos(6, 53) ;put the cursor of the interface to position X = 6, Y = 53 $oPS.SendKeys("hello world[enter]") ;write the text "hello world" where the cursor of the interface is then press the enter/return key $result = $oPS.SearchText("banana") ;search for the text "banana" on the interface screen. Returns "True" if found, "False" if not. The function "WaitForInputReady" is badfully not very reliable. For better results, use the fuction "SearchText" in a while loop to wait for a specific text to appear on the interface if you want to be sure that the interface is ready for input. With these 3 functions you can pretty much do anything you would do manually on an Iseries console. Special keys for the "SendKeys" function can be found using the virtual keyboard included in the iseries console software. Enjoy Original post (credit to @DangerousDan and @bwochinski) for helping me understand the above stuff ^^):
    1 point
  2. Unfortunately I currently have to work (so think customers - and my wife too) so I miss time For the moment I advise you to be careful with expressions like [^\$] which means "match any non-$ char" To be more secure you can increase selectivity in footnotes tracking by using [\s-] which means "match space or hyphen" $a = StringRegExpReplace($a, '(\$%\$\?\$%[\s-]+(End\s+)?Footnotes[\s-]+)', "") See you later
    1 point
  3. Sorry I might have confused things, the cursor is actually irrelevant, what I was trying to say is that the last line of your log file should always be a new line. I was just using the cursor as an example of new line By default your log file should always save like this, however you may have added or deleted something from the log and then inadvertently saved the log without adding the new line at the end. Anyway just add the new blank line at the end of your log and remove any lines that have doubled up like below and you should be good to go. 2017-05-12 00:03:17 : ATCS Harrisburg was found running properly by the AutoIt3 Script2017-05-13 03:06:36 : *ALERT* *ALERT* SERVER WAS REBOOTED *ALERT* * ALERT*
    1 point
  4. Got the same issue with your script, it turned out that the cursor should be positioned on a new line example below 2017-05-13 02:59:51 : *ALERT* *ALERT* SERVER WAS REBOOTED *ALERT* * ALERT* |<--Cursor When I was testing and I assume when you were testing the cursor was at the end of the last line 2017-05-13 02:59:51 : *ALERT* *ALERT* SERVER WAS REBOOTED *ALERT* * ALERT*|<--Cursor Which meant the _FileWriteLog was appending to the end of the last line and stopping the script from creating the Array, for example: 2017-05-12 00:03:17 : ATCS Harrisburg was found running properly by the AutoIt3 Script2017-05-13 03:06:36 : *ALERT* *ALERT* SERVER WAS REBOOTED *ALERT* * ALERT* Hope that made sense.
    1 point
  5. Hmm strange, I used your log text above and saved it to a file called file.log, I then replaced -05- to -02- and saved it, when I run the code, I'm only left with 11 entries: 2017-02-11 19:58:43 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 19:59:43 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 20:00:44 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 20:02:05 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 20:03:05 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 20:04:05 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 20:06:48 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 20:07:48 : *ALERT* ATCS Pittsburg was restarted by the AutoIt3 Script 2017-02-11 20:17:25 : *ALERT* *ALERT* SERVER WAS REBOOTED *ALERT* * ALERT* 2017-02-11 20:30:00 : *ALERT* *ALERT* SERVER WAS REBOOTED *ALERT* * ALERT* 2017-02-11 23:38:16 : *ALERT* *ALERT* SERVER WAS REBOOTED *ALERT* * ALERT* Please post your code and also the log file you're parsing and see if I get the same results.
    1 point
  6. This thread is 12 years old, do you really think the poster needs this information now?
    1 point
  7. Neutro

    Get Secure Boot state

    Hi meoit Maybe this? $state = Regread("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecureBoot\State", "UEFISecureBootEnabled") if $state then msgbox("","", "Secure boot is enabled") Else msgbox("","", "Secure boot is disabled") EndIf Source: http://stackoverflow.com/questions/18172197/programmatically-determine-if-windows-8-secure-boot-is-enabled
    1 point
  8. Something like this maybe: #include <Date.au3> #include <File.au3> Local $aFileOpen, $sFileOpen = @ScriptDir & "\File.log" _FileReadToArray($sFileOpen, $aFileOpen, 4, " : ") For $i = UBound($aFileOpen) - 1 To 0 Step - 1 If _DateDiff("d", $aFileOpen[$i][0], _NowCalc()) > 30 And $aFileOpen[$i][1] = "ATCS Pittsburg was found running properly by the AutoIt3 Script" Then _FileWriteToLine($sFileOpen, $i + 1, "", True) If _DateDiff("d", $aFileOpen[$i][0], _NowCalc()) > 30 And $aFileOpen[$i][1] = "ATCS Harrisburg was found running properly by the AutoIt3 Script" Then _FileWriteToLine($sFileOpen, $i + 1, "", True) Next
    1 point
  9. InunoTaishou

    Strings from array

    #include <Array.au3> Global $aArray[] = ["Hello","World"] ConsoleWrite(_ArrayToString($aArray, " ") & @LF)
    1 point
  10. mikell

    Arrays? (From Website)

    Why talk about array ? InetGetSource returns a string so you only need to parse this string using a regular expression or String* funcs #include <MsgBoxConstants.au3> #include <Inet.au3> $json = _INetGetSource('http://api.fast.com/netflix/speedtest?https=true&token=YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm&urlCount=1') $site = StringRegExpReplace($json, '.*(https[^"]+).*', "$1") MsgBox($MB_SYSTEMMODAL, "Title", $site)
    1 point
  11. In Koda, try Tools > Generating Options ... (Ctrl+F9), Enable (check) Generate OnEvent code
    1 point
  12. Malkey

    Shorten the code

    Another example. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> _Checkbox_EditCtrl() Func _Checkbox_EditCtrl() Local $hGUI = GUICreate("Example", 400, 410) Local $Number = 20, $iRows = 10, $iSpacing = 5 Local $Error[$Number] ; Array holding Checkbox controls ids Local $Edit[$Number] ; Array holding Edit controls ids ; Create checkbox controls. For $i = 0 To $Number - 1 ; id's are sequentially numbered starting at $Error[0] $Error[$i] = GUICtrlCreateCheckbox("ChkBx" & $i + 1, $iSpacing + (Int($i / $iRows) * 190), ((40 * Mod($i, $iRows)) + $iSpacing), 80, 20) ; Next ; Create Edit controls. For $i = 0 To $Number - 1 ; id's are sequentially numbered starting at $Edit[0] $Edit[$i] = GUICtrlCreateEdit("Edit" & $i + 1, $iSpacing + 80 + (Int($i / $iRows) * 190), ((40 * Mod($i, $iRows)) + $iSpacing), 95, 40, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL), BitOR($WS_EX_CLIENTEDGE, $WS_EX_ACCEPTFILES)) ; GUICtrlSetState($Edit[$i], $GUI_Disable) Next GUISetState(@SW_SHOW, $hGUI) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ;, $idClose ExitLoop Case $Error[0] To $Error[($Number - 1)] $iIndex = $msg - $Error[0] ; Array Index GUICtrlSetState($Edit[$iIndex], (BitAND(GUICtrlRead($Error[$iIndex]), $GUI_CHECKED) = $GUI_CHECKED ? BitOR($GUI_Enable, $GUI_FOCUS) : $GUI_Disable)) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>_Checkbox_EditCtrl
    1 point
  13. Subz

    Shorten the code

    Here is a basic example: a. Create ComboBox.txt with the following text: Text is CSV with the following parameters Varx = CheckBox Variable id Label x = CheckBox Label x Position y Position width height Editx = InputBox Variable associated with CheckBox Var1,Label 1,5,5,100,20,Edit1 Var2,Label 2,5,25,100,20,Edit2 Var3,Label 3,5,45,100,20,Edit3 Var4,Label 4,5,65,100,20,Edit4 Var5,Label 5,5,85,100,20,Edit5 You can then use something like the following for automatically toggling $GUI_Disable/$GU_Enable #Include <Array.au3> #include <File.au3> #include <GUIConstantsEx.au3> Global $aCheckBox[0], $aInputBox[0] _Example() Func _Example() Local $aFileRead, $aStringSplit Local $idCancel GUICreate('', 210, 140) _FileReadToArray('CheckBox.txt', $aFileRead) ReDim $aCheckBox[$aFileRead[0]] ReDim $aInputBox[$aFileRead[0]] For $i = 1 To $aFileRead[0] $aStringSplit = StringSplit($aFileRead[$i], ',', 2) If UBound($aStringSplit) -1 = 6 Then Assign($aStringSplit[0], GUICtrlCreateCheckbox($aStringSplit[1], Number($aStringSplit[2]), Number($aStringSplit[3]), Number($aStringSplit[4]), Number($aStringSplit[5])), 2) Assign($aStringSplit[6], GUICtrlCreateInput('', Number($aStringSplit[2]) + Number($aStringSplit[4]), Number($aStringSplit[3]), Number($aStringSplit[4]), Number($aStringSplit[5])), 2) $aCheckBox[$i - 1] = $aStringSplit[0] $aInputBox[$i - 1] = $aStringSplit[6] EndIf Next $idCancel = GUICtrlCreateButton('Cancel', 5, 110, 95, 25) GUISetState() AdlibRegister("CheckBox") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idCancel ExitLoop EndSwitch WEnd EndFunc Func CheckBox() For $i = 0 To UBound($aCheckBox) - 1 If GUICtrlRead(Eval($aCheckBox[$i])) = $GUI_CHECKED Then GUICtrlSetState(Eval($aInputBox[$i]), 64) Else ConsoleWrite("Checkbox" & $aCheckBox[$i] & @CRLF & "InputBox" & $aInputBox[$i] & @CRLF) GUICtrlSetState(Eval($aInputBox[$i]), 128) EndIf Next EndFunc
    1 point
  14. Hi ur, I prefer not to rely on external programs/tools so let me share an alternative approach to cmdkey.exe. I didn't write this, but I modified it to work for my needs. In my script I actually encrypt the password prior to storing it. Hopefully, this will make it easier for you. #include <Array.au3> $User = "user1" $Password = "password1" $AppName = "My App" $Comment = "Used For ABC" _Cred_Write($User, $Password) ; Write to Crediential Manager $aArray = _Cred_Read() ; Read from Crediential Manager _ArrayDisplay($aArray) _Cred_Delete() ; Delete Credientials Func _Cred_Write($User, $Password, $iPersist = 1, $Target = $AppName, $Comm = $Comment) ; iPersist ; SESSION = 1 ; LOCAL_MACHINE = 2 ; ENTERPRISE = 3 Local $Comment = DllStructCreate("wchar[100]") DllStructSetData($Comment, 1, $Comm) Local $targetName = DllStructCreate("wchar[100]") DllStructSetData($targetName, 1, $Target) Local $userName = DllStructCreate("wchar[100]") DllStructSetData($userName, 1, $User) Local $credentialBlob = DllStructCreate("wchar[100]") DllStructSetData($credentialBlob, 1, $Password) Local $structCREDENTIAL = "" & _ "DWORD Flags;" & _ "DWORD Type;" & _ "Ptr TargetName;" & _ "Ptr Comment;" & _ "UINT64 LastWritten;" & _ "DWORD CredintialBlobSize;" & _ "Ptr CredentialBlob;" & _ "DWORD Persist;" & _ "DWORD AttributeCount;" & _ "ptr Attributes;" & _ "Ptr TargetAlias;" & _ "Ptr Username" Local $NewCred = DllStructCreate($structCREDENTIAL) If @error Then MsgBox(0, "NewCred", "Error in DllStructCreate " & @error) ; Exit EndIf DllStructSetData($NewCred, "Flags", 0) DllStructSetData($NewCred, "Type", 1) DllStructSetData($NewCred, "TargetName", DllStructGetPtr($targetName)) DllStructSetData($NewCred, "Persist", $iPersist) DllStructSetData($NewCred, "AttributeCount", 0) DllStructSetData($NewCred, "UserName", DllStructGetPtr($userName)) DllStructSetData($NewCred, "CredentialBlob", DllStructGetPtr($credentialBlob)) DllStructSetData($NewCred, "CredintialBlobSize", StringLen($Password) * 2) DllStructSetData($NewCred, "Comment", DllStructGetPtr($Comment)) #comments-start MsgBox(0, "DllStruct", "Data:" & @CRLF & _ "Flags: " & DllStructGetData($NewCred, "Flags") & @CRLF & _ "Type: " & DllStructGetData($NewCred,"Type") & @CRLF & _ "TargetName: " & DllStructGetData($NewCred,"TargetName") & @CRLF & _ "Persist: " & DllStructGetData($NewCred,"Persist") & @CRLF & _ "AttributeCount: " & DllStructGetData($NewCred,"AttributeCount") & @CRLF & _ "UserName: " & DllStructGetData($NewCred,"UserName") & @CRLF & _ "CredentialBlob: " & DllStructGetData($NewCred,"CredentialBlob") & @CRLF & _ "CredintialBlobSize: " & DllStructGetData($NewCred,"CredintialBlobSize") & @CRLF & _ "Comment: " & DllStructGetData($NewCred,"Comment")) #comments-end Local $hAdvapi32 = DllOpen("Advapi32.dll") If @error Then MsgBox(0, "Error", "Cannot open Advapi32.dll") Exit EndIf Local $aRet = DllCall($hAdvapi32, 'bool', 'CredWriteW', 'ptr', DllStructGetPtr($NewCred), 'dword', 0) $NewCred = 0 EndFunc Func _Cred_Read($Target = $AppName) Local $aFuncRet[3] Local $iType = 1 ; 1 = Generic | 2 = Domain | 3 = Certificate Local $targetName = DllStructCreate("wchar[100]") DllStructSetData($targetName, 1, $Target) Local $hAdvapi32 = DllOpen("Advapi32.dll") Local $aRet = DllCall($hAdvapi32, 'bool', 'CredReadW', 'ptr', DllStructGetPtr($targetName), 'dword', $iType, 'dword', 0, 'ptr*', 0) If $aRet[0] = 0 Then Return SetError(1, 0) Local $structCREDENTIAL = "" & _ "DWORD Flags;" & _ "DWORD Type;" & _ "Ptr TargetName;" & _ "Ptr Comment;" & _ "UINT64 LastWritten;" & _ "DWORD CredintialBlobSize;" & _ "Ptr CredentialBlob;" & _ "DWORD Persist;" & _ "DWORD AttributeCount;" & _ "Ptr Attributes;" & _ "Ptr TargetAlias;" & _ "Ptr Username" Local $tdata = DllStructCreate($structCREDENTIAL, $aRet[4]) Local $userName = DllStructCreate("wchar[100]", DllStructGetData($tdata, 'Username')) Local $sUser = DllStructGetData($userName, 1) Local $CredentialBlobSize = DllStructGetData($tdata, 'CredintialBlobSize') Local $credentialBlob = DllStructCreate("wchar[100]", DllStructGetData($tdata, 'CredentialBlob')) Local $sPassword = StringLeft(DllStructGetData($credentialBlob, 1), $CredentialBlobSize / 2) Local $Comment = DllStructCreate("wchar[100]", DllStructGetData($tdata, 'Comment')) Local $sComm = DllStructGetData($Comment, 1) Dim $aFuncRet[] = [$sUser, $sPassword, $sComm] Return $aFuncRet EndFunc Func _Cred_Delete($Target = $AppName) Local $aRet Local $targetName = DllStructCreate("wchar[100]") DllStructSetData($targetName, 1, $Target) Local $hAdvapi32 = DllOpen("Advapi32.dll") $aRet = DllCall($hAdvapi32, 'bool', 'CredDeleteW', 'ptr', DllStructGetPtr($targetName), 'dword', 1, 'dword', 0) EndFunc
    1 point
×
×
  • Create New...