Jump to content

Echbiahn

Members
  • Posts

    9
  • Joined

  • Last visited

  • Days Won

    1

Echbiahn last won the day on July 24 2016

Echbiahn had the most liked content!

About Echbiahn

  • Birthday 05/04/1987

Profile Information

  • Location
    Texas
  • Interests
    Gaming mostly

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Echbiahn's Achievements

Seeker

Seeker (1/7)

3

Reputation

  1. I'm writing a custom script to help compile data together for monitoring customer databases. On the listview control, I'm trying to use the checkbox feature to allow for ignoring alerts from specific databases. For some reason, the code recognizes the checkboxes in a certain state and execute the code as expected, except they never update the state of the checkbox to the other state (unchecked) or vice versa. I'm using a modified WM_NOTIFY function, could that be the reason it's not recognizing when I call _GUICtrlListView_SetItemChecked, or am I just doing something completely wrong in my code? Code and picture example below... Picture Func LVControl($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $CurrentIgnoreList $hWndListView = $ListView If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $SelectedIndex = DllStructGetData($tInfo, "Index") ConsoleWrite("-->Index:" & @TAB & $SelectedIndex & @LF) If $SelectedIndex = -1 Then ContinueCase ; <add key="NCPDPIgnoreList" value="3684366,5725342,1485122,1484663,2519152,1406138,1044243,0139469,4613039,0357168,5126760,2784177,2784165,5132181"/> ;Get checked state of selected index If _GUICtrlListView_GetItemChecked($ListView, $SelectedIndex) = True Then ;It is checked, uncheck the box _GUICtrlListView_SetItemChecked($ListView, $SelectedIndex, False) ;remove from ignore list $CurrentIgnoreList = _GetIgnoreList() For $q = 1 To $CurrentIgnoreList[0] If $CurrentIgnoreList[$q] = $dbArray[$SelectedIndex][3] Then _ArrayDelete($CurrentIgnoreList, $q) $NewString = ' <add key="NCPDPIgnoreList" value="' For $z = 1 To UBound($CurrentIgnoreList) - 1 $NewString = $NewString & $CurrentIgnoreList[$z] & ',' Next $NewString = StringTrimRight($NewString, 1) & '"/>' _FileWriteToLine(IniRead($Ini, "SET", "SSDBMonitor", "\\10.1.1.96\c$\Program Files (x86)\RNA\SSDBMonitor") & "\SSDBMonitor.exe.config", 13, $NewString, True) ExitLoop EndIf Next Else ;False ;It is unchecked, check the box _GUICtrlListView_SetItemChecked($ListView, $SelectedIndex, True) ;add it to the ignore list $CurrentIgnoreList = _GetIgnoreList() $NewString = ' <add key="NCPDPIgnoreList" value="' For $q = 1 To $CurrentIgnoreList[0] $NewString = $NewString & $CurrentIgnoreList[$q] & ',' Next $NewString = $NewString & $dbArray[$SelectedIndex][3] & '"/>' _FileWriteToLine(IniRead($Ini, "SET", "SSDBMonitor", "\\10.1.1.96\c$\Program Files (x86)\RNA\SSDBMonitor") & "\SSDBMonitor.exe.config", 13, $NewString, True) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
  2. For those who are curious, I found my solution from this article: http://woshub.com/how-to-access-mapped-network-drives-from-the-elevated-apps/ I discovered from testing that the script would not map the network drive with #RequireAdmin line in the code. Using the article above I added the missing registry key and rebooted. All testing after that worked 100% with and without #RequireAdmin.
  3. Well, I tried using the other method of just calling command prompt and executing the NET USE commands. This is really weird to me because they do the EXACT same thing as the Autoit functions. I setup Stdoutread for both commands: NET USE N: /Delete - Actually comes back saying "N: was deleted successfully." when the share doesnt event exist in the first place. Manually testing in Command Prompt gives me the expected results saying "The network connection could not be found." NET USE N: \\10.0.0.16\RNAPGM /P:Yes - Always says "The command completed successfully.", but checking Command Prompt manually will show "New connections will be remembered." because it's not actually mapped. Manually doing this works perfectly fine though and I'm able to access the mapped drive just fine. Here's the code, the function I'm trying to fix is _StepSeven(), I have a while loop to pause it right after it runs the step for testing. #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Control.ico #AutoIt3Wrapper_Outfile=AutoHelix.Exe #AutoIt3Wrapper_Outfile_x64=AutoHelix_x64.Exe #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <StringConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <Date.au3> Global $stepArray[] = ["PC Name", "PC Serial", "Enable RDP", "Disable ACL", "Disable Firewall", "Environment Variables", "Regional Format", "Map N Drive", "Create Shortcuts", "Install Crystal Reports", "Install MS Components", "Install Oracle", "Net Manager", "Get Colors ID"] Global $installStep[UBound($stepArray)] Global $x, $sID, $stepStatus = Null Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error","ErrorHandle") #Region ### START Koda GUI section ### Form=C:\Users\Admin\Desktop\AutoHelix\Helix Auto-Installer.kxf $Form = GUICreate("AutoHelix", 459, 500, -1, -1) GUICtrlCreateGroup("Setup Information", 8, 0, 441, 113) GUICtrlCreateLabel("Pharmacy", 24, 26, 51, 17) $pharmacyName = GUICtrlCreateInput("", 80, 24, 137, 21) GUICtrlCreateLabel("PC Name/IP", 24, 58, 64, 17) $pcNameIP = GUICtrlCreateInput("", 96, 56, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) GUICtrlCreateLabel("Server Name", 248, 26, 66, 17) $serverName = GUICtrlCreateInput("", 317, 24, 121, 21) GUICtrlCreateLabel("Serial Number", 248, 58, 70, 17) $serialNumber = GUICtrlCreateInput("", 320, 56, 118, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) GUICtrlCreateLabel("OnTime Ticket #", 16, 86, 84, 17) $ticketNumber = GUICtrlCreateInput("", 104, 84, 113, 21) $newInstall = GUICtrlCreateRadio("New Install", 248, 86, 81, 17) $newReplacement = GUICtrlCreateRadio("Replacement", 352, 86, 89, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Installation Steps", 8, 120, 233, 377) Local $fromTop = 135 For $x = 0 To UBound($stepArray) - 1 $installStep[$x] = GUICtrlCreateLabel("O", 24, $fromTop, 16, 20) GUICtrlSetFont(-1, 12, 800, 0, "Symbol") GUICtrlSetColor(-1, 0xFF8C00);Red FF0000 | Green 008000 | Orange FF8C00 GUICtrlCreateLabel($stepArray[$x], 48, $fromTop, 175, 20) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $fromTop += 26 Next GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Control", 248, 120, 201, 137) $startButton = GUICtrlCreateButton("Start", 264, 144, 75, 25) $pauseButton = GUICtrlCreateButton("Pause", 264, 176, 75, 25) $stopButton = GUICtrlCreateButton("Stop", 264, 208, 75, 25) $helpButton = GUICtrlCreateButton("Help", 352, 160, 75, 25) $exitButton = GUICtrlCreateButton("Exit", 352, 192, 75, 25) GUICtrlSetState($pauseButton, $GUI_DISABLE) GUICtrlSetState($stopButton, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Console", 248, 264, 201, 233) $Console = GUICtrlCreateEdit("", 256, 280, 185, 210, BitOR($ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $exitButton Exit Case $startButton ;Check for filled input boxes before running $getPharmacy = GUICtrlRead($pharmacyName) $getServer = GUICtrlRead($serverName) $getTicket = GUICtrlRead($ticketNumber) $getNewInstall = GUICtrlRead($newInstall) ;$GUI_CHECKED or $GUI_UNCHECKED $getReplacement = GUICtrlRead($newReplacement) ;$GUI_CHECKED or $GUI_UNCHECKED If $getPharmacy = "" Then MsgBox(16, "Error!", "Pharmacy name is empty!") ContinueCase EndIf If $getServer = "" Then MsgBox(16, "Error!", "Server name or IP is empty!") ContinueCase EndIf If $getTicket = "" Then MsgBox(16, "Error!", "A ticket number is required to run!") ContinueCase EndIf If $getNewInstall = $GUI_UNCHECKED And $getReplacement = $GUI_UNCHECKED Then MsgBox(16, "Error!", "Must choose if this workstation is a Replacement or New Install!") ContinueCase EndIf If $getNewInstall = $GUI_CHECKED Then $installType = "New Install" ElseIf $getReplacement = $GUI_CHECKED Then $installType = "Replacement" EndIf ;Disable/Enable GUI buttons GUICtrlSetState($startButton, $GUI_DISABLE) GUICtrlSetState($pauseButton, $GUI_ENABLE) GUICtrlSetState($stopButton, $GUI_ENABLE) GUICtrlSetState($pharmacyName, $GUI_DISABLE) GUICtrlSetState($serverName, $GUI_DISABLE) GUICtrlSetState($ticketNumber, $GUI_DISABLE) GUICtrlSetState($newInstall, $GUI_DISABLE) GUICtrlSetState($newReplacement, $GUI_DISABLE) ;Get information from Requested By and Completed By $getRequestedBy = InputBox("AutoHelix", "Requested By?", GUICtrlRead($pharmacyName)) If @error Or $getRequestedBy = "" Then MsgBox(16, "Error!", "This cannot be blank! Please fill in who requested the workstation install.") ContinueCase EndIf $getCompletedBy = InputBox("AutoHelix", "Completed By?", "") If @error Or $getCompletedBy = "" Then MsgBox(16, "Error!", "This cannot be blank! Please fill in who is completing the install.") ContinueCase EndIf ;Start log file $logFile = FileOpen("Log.txt", 2) ;Start timer $iTimer = TimerInit() $stepCounter = 0;Start first step GUICtrlSetData($Console, GUICtrlRead($Console) & "Running AutoHelix..." & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Running AutoHelix..." & @CRLF) For $x = 0 To 13 ;Run installer $nMsg = GUIGetMsg() If $nMsg = $pauseButton Then _PauseScript() ElseIf $nMsg = $stopButton Then GUICtrlSetData($Console, GUICtrlRead($Console) & "AutoHelix Stopped by User!" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] AutoHelix Stopped by User!" & @CRLF) FileClose($logFile) ExitLoop EndIf Switch $x Case 0 $stepStatus = _StepZero() ;Get PC Name Case 1 $stepStatus = _StepOne() ;Get PC Serial Case 2 $stepStatus = _StepTwo() ;Enable RDP Case 3 $stepStatus = _StepThree() ;Disable UAC/ACL Case 4 $stepStatus = _StepFour() ;Disable Firewall Case 5 $stepStatus = _StepFive() ;Set Environment Variables Case 6 $stepStatus = _StepSix() ;Set Regional Format Case 7 $stepStatus = _StepSeven() ;Map N Drive Case 8 $stepStatus = _StepEight() ;Create Shortcuts Case 9 $stepStatus = _StepNine() ;Install Crystal Reports Case 10 $stepStatus = _StepTen() ;Install MS Components Case 11 $stepStatus = _StepEleven() ;Install Oracle Case 12 $stepStatus = _StepTwelve() ;Configure Net Manager Case 13 $stepStatus = _StepThirteen() ;Create Colors File EndSwitch If $stepStatus = True Then GUICtrlSetData($installStep[$x], Chr(214));Check Symbol GUICtrlSetColor($installStep[$x], 0x008000);Green ElseIf $stepStatus = False Then GUICtrlSetData($installStep[$x], Chr(67));X Symbol GUICtrlSetColor($installStep[$x], 0xFF0000);Red EndIf Sleep(150) Next ;Finish installation and calculate timer difference GUICtrlSetData($Console, GUICtrlRead($Console) & "AutoHelix Install Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] AutoHelix Install Complete" & @CRLF) $iDiff = TimerDiff($iTimer) $timeSpent = _Diff2Time($iDiff) If $timeSpent[0] = 0 And $timeSpent[1] < 30 Then $finalTime = "30 Minutes" ElseIf $timeSpent[0] = 0 And $timeSpent[1] > 30 Then $finalTime = $timeSpent[1] & " Minutes" ElseIf $timeSpent[0] > 0 Then $finalTime = $timeSpent[0] & " Hours and " & $timeSpent[1] & " Minutes" EndIf ;Reset GUI controls GUICtrlSetState($startButton, $GUI_ENABLE) GUICtrlSetState($pauseButton, $GUI_DISABLE) GUICtrlSetState($stopButton, $GUI_DISABLE) GUICtrlSetState($pharmacyName, $GUI_ENABLE) GUICtrlSetState($serverName, $GUI_ENABLE) GUICtrlSetState($ticketNumber, $GUI_ENABLE) GUICtrlSetState($newInstall, $GUI_ENABLE) GUICtrlSetState($newReplacement, $GUI_ENABLE) ;Write completed form $Workstation = FileOpen("Workstation.txt", 2) FileWrite($Workstation, "Pharmacy: " & $getPharmacy & @CRLF) FileWrite($Workstation, "----------------------" & @CRLF) FileWrite($Workstation, "Server: " & $getServer & @CRLF) FileWrite($Workstation, "Workstation: " & GUICtrlRead($pcNameIP) & @CRLF) FileWrite($Workstation, "Serial: " & GUICtrlRead($serialNumber) & @CRLF) FileWrite($Workstation, "Ticket: " & $getTicket & @CRLF) FileWrite($Workstation, "Type: " & $installType & @CRLF) FileWrite($Workstation, "" & @CRLF) FileWrite($Workstation, "Requested By: " & $getRequestedBy & @CRLF) FileWrite($Workstation, "Completed By: " & $getCompletedBy & @CRLF) FileWrite($Workstation, "Time Spent: " & $finalTime & @CRLF) FileWrite($Workstation, "Station ID: " & $sID & @CRLF) FileWrite($Workstation, "----------------------" & @CRLF) FileClose($Workstation) ;Email completed form to helixinstaller@rnahealth.com ;_INetSmtpMailCom("smtp.gmail.com", "helixinstaller@gmail.com", "helixinstaller@gmail.com", "helixinstaller@rnahealth.com", "Workstation Install", "File attached.", "Workstation.txt", "", "", "High", "helixinstaller@gmail.com", "RN@@dmin", 465, 1) ;Close out log file FileClose($logFile) Case $pauseButton ContinueLoop Case $stopButton ContinueLoop Case $helpButton MsgBox(64, "About", "AutoHelix v1.0" & @CRLF & _ "By Dale Stewart" & @CRLF & _ "Mobile Medsoft LLC" & @CRLF & _ "" & @CRLF & _ "How to Use:" & @CRLF & _ "1. Input Pharmacy Name, Server IP or Name, and Ticket Number" & @CRLF & _ "2. Input if New Install or Replacement" & @CRLF & _ "3. Click Start button to run") EndSwitch WEnd Func _StepZero() GUICtrlSetData($pcNameIP, @ComputerName) Return True EndFunc Func _StepOne() $getSerial = Run(@ComSpec & " /c " & 'wmic bios get serialnumber', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($getSerial) $readSerial = StdoutRead($getSerial) $writeSerial = StringSplit(StringStripWS(StringStripCR($readSerial), 8), "SerialNumber") GUICtrlSetData($serialNumber, $writeSerial[13]) Return True EndFunc Func _StepTwo() RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server", "fDenyTSConnections", "REG_DWORD", 0) If @error Then Switch @error Case 1 $message = "unable to open requested key" Case 2 $message = "unable to open requested main key" Case 3 $message = "unable to remote connect to the registry" Case -1 $message = "unable to open requested value" Case -2 $message = "value type not supported" EndSwitch GUICtrlSetData($Console, GUICtrlRead($Console) & "Enable RDP Error: " & $message & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Enable RDP Error: " & $message & @CRLF) Return False Else GUICtrlSetData($Console, GUICtrlRead($Console) & "Enable RDP Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Enable RDP Complete" & @CRLF) Return True EndIf EndFunc Func _StepThree() _Toggle_UAC(0) Switch @error Case 0 GUICtrlSetData($Console, GUICtrlRead($Console) & "Disable UAC Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Disable UAC Complete" & @CRLF) Return True Case 1 $message = "Current user is not Admin" Case 2 $message = "OS is not Vista or Win 7" Case 3 $message = "Reading the the registry key failed" Case 4 $message = "Writing the registry keyname value failed" Case 5 $message = "$iValue parameter not valid" EndSwitch GUICtrlSetData($Console, GUICtrlRead($Console) & "Enable UAC Error: " & $message & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Enable UAC Error: " & $message & @CRLF) Return False EndFunc Func _StepFour() Local $aReg[] = ["DomainProfile", "StandardProfile", "PublicProfile"] For $z = 0 to 2 $Key = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\" & $aReg[$z] RegWrite($Key, "EnableFirewall", "REG_DWORD", 0) If @error Then Switch @error Case 1 $message = "unable to open requested key" Case 2 $message = "unable to open requested main key" Case 3 $message = "unable to remote connect to the registry" Case -1 $message = "unable to open requested value" Case -2 $message = "value type not supported" EndSwitch GUICtrlSetData($Console, GUICtrlRead($Console) & "Firewall Error: " & $message & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Firewall Error: " & $message & @CRLF) Return False EndIf Next GUICtrlSetData($Console, GUICtrlRead($Console) & "Disable Firewall Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Disable Firewall Complete" & @CRLF) Return True EndFunc Func _StepFive() RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "RNAPGM", "REG_SZ", "N:\") If @error Then Switch @error Case 1 $message = "unable to open requested key" Case 2 $message = "unable to open requested main key" Case 3 $message = "unable to remote connect to the registry" Case -1 $message = "unable to open requested value" Case -2 $message = "value type not supported" EndSwitch GUICtrlSetData($Console, GUICtrlRead($Console) & "Set EnvVar Error: " & $message & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Set EnvVar Error: " & $message & @CRLF) Return False Else GUICtrlSetData($Console, GUICtrlRead($Console) & "Set EnvVar Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Set EnvVar Complete" & @CRLF) Return True EndIf EndFunc Func _StepSix() Local $aReg[] = ["HKEY_CURRENT_USER\Control Panel\International", "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\CommonGlobUserSettings\Control Panel\International"] For $z = 0 to 1 RegWrite($aReg[$z], "sShortDate", "REG_SZ", "MM\dd\yyyy") If @error Then Switch @error Case 1 $message = "unable to open requested key" Case 2 $message = "unable to open requested main key" Case 3 $message = "unable to remote connect to the registry" Case -1 $message = "unable to open requested value" Case -2 $message = "value type not supported" EndSwitch GUICtrlSetData($Console, GUICtrlRead($Console) & "Set Regional Error: " & $message & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Set Regional Error: " & $message & @CRLF) Return False EndIf Next GUICtrlSetData($Console, GUICtrlRead($Console) & "Set Regional Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Set Regional Complete" & @CRLF) Return True EndFunc Func _StepSeven() $remoteShare = "\\" & GUICtrlRead($serverName) & "\RNAPGM" $remoteShare = String($remoteShare) $Map = Run(@ComSpec & " /c " & "NET USE N: /Delete", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($Map) $read = StdoutRead($Map) ConsoleWrite($read & @CRLF) ;ConsoleWrite(String("NET USE N: " & $remoteShare & " /P:Yes") & @CRLF) ;$Map = Run(@ComSpec & " /c " & String("NET USE N: " & $remoteShare & " /P:Yes"), "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $Map = Run(@ComSpec & " /c " & String("NET USE N: \\10.0.0.16\RNAPGM /P:Yes"), "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($Map) $read = StdoutRead($Map) ConsoleWrite($read & @CRLF) While 1 ; WEnd Exit If @error Then GUICtrlSetData($Console, GUICtrlRead($Console) & "Drive Map Error: Unable to map drive" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Drive Map Error: Unable to map drive" & @CRLF) Return False EndIf ;DriveMapDel("N:") ;DriveMapAdd("N:", $remoteShare, 8) ;If @error Then ; Switch @error ; Case 1 ; $message = "Undefined / Other error" ; Case 2 ; $message = "Access to the remote share was denied" ; Case 3 ; $message = "The device is already assigned" ; Case 4 ; $message = "Invalid device name" ; Case 5 ; $message = "Invalid remote share" ; Case 6 ; $message = "Invalid password" ; EndSwitch ; GUICtrlSetData($Console, GUICtrlRead($Console) & "Drive Map Error: " & $message & @CRLF) ; FileWrite($logFile, "[" & _TimeStamp() & "] Drive Map Error: " & $message & @CRLF) ; Return False ;EndIf GUICtrlSetData($Console, GUICtrlRead($Console) & "Drive Map Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Drive Map Complete" & @CRLF) Return True EndFunc Func _StepEight() $shortcut1Status = FileCreateShortcut("N:\RNA\Helix.exe", @DesktopDir & "\Helix.lnk");Success 1 | Failure 0 $shortcut2Status = FileCreateShortcut("N:\RNA\HelixImaging.exe", @DesktopDir & "\Helix Imaging.lnk") If $shortcut1Status = 0 Then GUICtrlSetData($Console, GUICtrlRead($Console) & "Shortcut Error: Helix Denied" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Shortcut Error: Helix Denied" & @CRLF) Return False EndIf If $shortcut2Status = 0 Then GUICtrlSetData($Console, GUICtrlRead($Console) & "Shortcut Error: Imaging Denied" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Shortcut Error: Imaging Denied" & @CRLF) Return False EndIf GUICtrlSetData($Console, GUICtrlRead($Console) & "Shortcuts Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Shortcuts Complete" & @CRLF) Return True EndFunc Func _StepNine() Local $pID = RunWait(@ScriptDir & "\CRXIRuntimesetup.msi") ProcessWaitClose($pID) GUICtrlSetData($Console, GUICtrlRead($Console) & "Crystal Reports Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Crystal Reports Complete" & @CRLF) Return True EndFunc Func _StepTen() Local $pID = RunWait(@ScriptDir & "\vcredist_x86.exe") ProcessWaitClose($pID) GUICtrlSetData($Console, GUICtrlRead($Console) & "MS VisualCom Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] MS VisualCom Complete" & @CRLF) Return True EndFunc Func _StepEleven() Run(@ScriptDir & "\Disk1\setup.exe") While 1 $Handle = WinWaitActive("Oracle Universal Installer: End of Installation", "", 600) If $Handle > 0 Then $pID = WinGetProcess($Handle) ProcessClose($pID) GUICtrlSetData($Console, GUICtrlRead($Console) & "Oracle 10g Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Oracle 10g Complete" & @CRLF) Return True Else GUICtrlSetData($Console, GUICtrlRead($Console) & "Oracle 10g Error: Timeout" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Oracle 10g Error: Timeout" & @CRLF) Return False EndIf WEnd EndFunc Func _StepTwelve() $oFile = _FileCreate("C:\oracle\product\10.2.0\client_1\network\ADMIN\tnsnames.ora") If @error Then Switch @error Case 1 $message = "Error opening specified file" Case 2 $message = "File could not be written to" EndSwitch GUICtrlSetData($Console, GUICtrlRead($Console) & "Net Manager Error: " & $message & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Net Manager Error: " & $message & @CRLF) Return False Else $tnsNames = FileOpen("C:\oracle\product\10.2.0\client_1\network\ADMIN\tnsnames.ora", 2) FileWrite($tnsNames, "RNA1 =" & @CRLF) FileWrite($tnsNames, " (DESCRIPTION =" & @CRLF) FileWrite($tnsNames, " (ADDRESS_LIST =" & @CRLF) FileWrite($tnsNames, " (ADDRESS = (PROTOCOL = TCP)(HOST = " & GUICtrlRead($serverName) & ")(PORT = 1521))" & @CRLF) FileWrite($tnsNames, " )" & @CRLF) FileWrite($tnsNames, " (CONNECT_DATA =" & @CRLF) FileWrite($tnsNames, " (SERVICE_NAME = RNA1)" & @CRLF) FileWrite($tnsNames, " )" & @CRLF) FileWrite($tnsNames, " )" & @CRLF) FileWrite($tnsNames, "" & @CRLF) FileClose($tnsNames) GUICtrlSetData($Console, GUICtrlRead($Console) & "Net Manager Complete" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] Net Manager Complete" & @CRLF) Return True EndIf EndFunc Func _StepThirteen() Local $pID= Run(@ComSpec & " /c " & 'echo exit | sqlplus -s RNAPGM/RNA_RNA_202@RNA1 "@' & @ScriptDir & '\IDS.sql"', "", @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($pID) $Output = StdoutRead($pID) $aString = StringSplit($Output, @CRLF, $STR_ENTIRESPLIT) ;Create array with sql output for station ids/dateused/lastuser For $x = UBound($aString) - 1 To 0 Step -1 ;Find array string with 'selected' and calculate next available ID $Check = StringInStr($aString[$x], "selected") If $Check > 0 Then $LastID = $aString[$x - 2] ExitLoop EndIf Next $Result = Int($LastID + 1) MsgBox(0, "Station ID", $Result) $sID = $Result Return True EndFunc Func _PauseScript() GUICtrlSetData($Console, GUICtrlRead($Console) & "*Paused*" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] *Paused*" & @CRLF) GUICtrlSetState($startButton, $GUI_ENABLE) GUICtrlSetState($pauseButton, $GUI_DISABLE) While 1 $pMsg = GUIGetMsg() If $pMsg = $startButton Then GUICtrlSetState($startButton, $GUI_DISABLE) GUICtrlSetState($pauseButton, $GUI_ENABLE) GUICtrlSetData($Console, GUICtrlRead($Console) & "*Resumed*" & @CRLF) FileWrite($logFile, "[" & _TimeStamp() & "] *Resumed*" & @CRLF) ExitLoop EndIf WEnd EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Toggle_UAC ; Description ...: Toggle or Force UAC Off or On or Query UAC current setting without changing. ; Syntax.........: _Toggle_UAC([$iValue = -2]) ; Parameters ....: $iValue - [Optional] Default is -2, see below for explanations and other values. ; -1 = Toggle the current UAC to the oposite of what it is currently. ; If UAC is curently disabled then It will be enabled using 1, ; Prompt the Consent Admin to enter his or her user name and password ; (or another valid admin) when an operation requires elevation of privilege. ; -2 = Toggle the current UAC to the oposite of what it is currently. ; If UAC is curently disabled then It will be enabled using 2, ; Admin Approval Mode to select either "Permit" or "Deny" an operation that requires elevation of privilege. ; -3 = Return the current UAC value found in the registry, don't change anything. ; 0 = Set UAC to 0 Allow the Consent Admin to perform an operation that requires elevation without consent or credentials. ; 1 = Set UAC to 1 Prompt the Consent Admin to enter his or her user name and password ; (or another valid admin) when an operation requires elevation of privilege. ; 2 = Set UAC to 2 Admin Approval Mode to select either "Permit" or "Deny" an operation that requires elevation of privilege. ; Return values .: Success - Value that was found in the registry before changinging and @error 0, Return could be as follows: ; 0 = UAC was disabled ; 1 = UAC was Prompt the Consent Admin to enter his or her user name and password ; 2 = UAC was Admin Approval Mode to select either "Permit" or "Deny" ; Failure - -1 and @error ; @error 1 = Current user is not Admin ; @error 2 = OS is not Vista or Win 7 ; @error 3 = Reading the the registry key failed, check @extended for the returned error from RegRead() as to why it failed. ; @error 4 = Writing the registry keyname value failed, check @extended for the returned error from RegWrite() as to why it failed. ; @error 5 = $iValue parameter not valid ; Author ........: AlienStar ; Modified.......: smashly ; Remarks .......: ; Related .......: ; Link ..........: http://msdn.microsoft.com/en-us/library/cc232761%28v=prot.10%29.aspx ; Example .......: ; =============================================================================================================================== #cs Returns one of the following: "WIN_10", "WIN_81", "WIN_8", "WIN_7", "WIN_VISTA", "WIN_XP", "WIN_XPe", for Windows servers: "WIN_2016", "WIN_2012R2", "WIN_2012", "WIN_2008R2", "WIN_2008", "WIN_2003"". #ce Func _Toggle_UAC($iValue = -2) If Not IsAdmin() Then Return SetError(1, 0, -1) If Not StringInStr("WIN_VISTA|WIN_7|WIN_8|WIN_81|WIN_10", @OSVersion) Then Return SetError(2, 0, -1) Local $sHKLM, $sName, $iReadValue, $iNewValue $sHKLM = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" $sName = "ConsentPromptBehaviorAdmin" $iReadValue = RegRead($sHKLM, $sName) If @error Then Return SetError(3, @error, -1) Switch $iValue Case -1, -2 Switch $iReadValue Case 0 $iNewValue = Abs($iValue) Case Else $iNewValue = 0 EndSwitch Case -3 Return SetError(0, 0, $iReadValue) Case 0, 1, 2 $iNewValue = $iValue Case Else Return SetError(5, 0, -1) EndSwitch RegWrite($sHKLM, $sName, "REG_DWORD", $iNewValue) If @error Then Return SetError(4, @error, -1) Return SetError(0, 0, $iReadValue) EndFunc ;==>_Toggle_UAC Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF);### Debug Console If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf $objEmail.Configuration.Fields.Update Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom Func ErrorHandle() Local $HexNumber Local $strMsg $HexNumber = Hex($oMyError.Number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) $strMsg = "Error Number: " & $HexNumber & @CRLF $strMsg &= "WinDescription: " & $oMyError.WinDescription & @CRLF $strMsg &= "Script Line: " & $oMyError.ScriptLine & @CRLF MsgBox(48, "### COM Error !", "Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1]) SetError(1) Exit Endfunc ;==>ErrorHandle Func _Diff2Time($TimerDiff) Dim $HMS[3] $HMS[2] = Int($TimerDiff / 1000) $HMS[1] = $HMS[2] - Mod($HMS[2], 60) $HMS[2] -= $HMS[1] $HMS[1] /= 60 $HMS[0] = $HMS[1] - Mod($HMS[1], 60) $HMS[1] -= $HMS[0] $HMS[0] /= 60 Return $HMS EndFunc; _Diff2Time Func _TimeStamp() $tCur = _Date_Time_GetLocalTime() $tSplit = StringSplit(_Date_Time_SystemTimeToDateTimeStr($tCur), " ", 2) Return $tSplit[1] EndFunc
  4. Good idea, just tested that. I am unable to run anything by trying to access the N:\ drive via windows explorer and also tried through the Run prompt and Command Prompt. This time the script reported this drive map error, 'The device is already assigned', and still executed both msi and exe files from N:\. The files aren't located elsewhere unless it's somehow calling from a temp folder I'm not aware of. I feel that I'm reaching some limit and thinking of trying the other route of just calling cmd to run a batch command instead. I forgot to mention, I don't know if it's related with running on Windows 10 or not.
  5. Yes, I do get it to display what I'm expecting. If I reboot my computer, it works the first time, after I disconnect the drive to test for 2nd time is when it starts to act funny and not display... but later in the installation it calls executables from the mapped drive and they execute successfully even though I can't see the drive visibly mapped.
  6. I am running it logged in under a domain admin.
  7. Hello, I've been writing a script to help automate a big installation that usually requires a bunch of manual work. On one of the steps is to map the N:\ drive. I created a function to run this step, but for some reason it never visibly shows it mapped the drive and the function always returns as successful (True). Sometimes if I run it again it will return the error: "The device is already assigned", which is why I added the DriveMapDel beforehand. Func _StepSeven() $remoteShare = "\\" & GUICtrlRead($serverName) & "\RNAPGM" $remoteShare = String($remoteShare) DriveMapDel("N:") DriveMapAdd("N:", $remoteShare) If @error Then Switch @error Case 1 $message = "Undefined / Other error" Case 2 $message = "Access to the remote share was denied" Case 3 $message = "The device is already assigned" Case 4 $message = "Invalid device name" Case 5 $message = "Invalid remote share" Case 6 $message = "Invalid password" EndSwitch GUICtrlSetData($Console, GUICtrlRead($Console) & "Drive Map Error: " & $message & @CRLF) Return False EndIf GUICtrlSetData($Console, GUICtrlRead($Console) & "Drive Map Complete" & @CRLF) Exit;Abruptly stop script to test drive mapping Return True EndFunc Now, if I run a simple script, such as below, it always successfully maps and shows the mapped drive everytime. DriveMapDel("N:") DriveMapAdd("N:", "\\10.0.0.16\RNAPGM") If @error Then MsgBox(0, "ERROR", @error) Is there something I'm doing wrong or missing to make this work in my function? If needed, I can post the rest of the source code. Thanks for the help!
  8. Is there a way to set GuiCtrlCreatePic to create the control on a specific GUI window if I have multiple with my script?
  9. Hi everyone! It's been a long time since I wrote anything in AutoIt, but I wanted to get back into it. Here's a simple UDF that generates random sword names to use in a game. Enjoy ; #FUNCTION# ==================================================================================================================== ; Name...........: _GenSword ; Description ...: Generates random RPG sword names ; Parameters ....: $Type - The type of name to generate ; $Amount - [optional] value to be used for generating more names (default: 1) ; Return values .: Success - Return Value of the name generated or an array of names generated with index[0] = number of names ; Failure - Return Value 0, @error set to 1 ; Author ........: Echibahn ; Modified.......: ; Details .......: You can select one or multiple generator types by separating the types with a semi-colon. ; When selecting the amount of names to gen, the number reflects how many of a selected type will gen. This means ; selecting multiple types will generate the amount of names per type. ; Type 1 = Single Generator #1 ; Type 2 = Single Generator #2 ; Type 3 = Double Generator #1 ; Type 4 = Double Generator #2 ; Type 5 = Double Generator #3 ; Type 6 = Triple Generator #1 ; Type 7 = Triple Generator #2 ; ; Example .......; _GenSword(1) ; _GenSword("2;4") ; _GenSword("1;5;6", 2) ; _GenSword("1;2;3;4;5;6", 10) ; =============================================================================================================================== #include-once #include <Array.au3> Global $nm1[] = ["Shadowfang","Azurewrath","Assurance","ForgetMeNot","Red Obsidian","Abyssal Shard","Aetherius","Agatha","Alpha","Amnesia","Anduril","Anger’s Tear","Apocalypse","Armageddon","Arondite","Ashrune","Betrayal","Betrayer","Blackest Heart","Blackout","Blade of a Thousand Cuts","Blade of the Grave","Blazefury","Blazeguard","Blight's Plight","Blind Justice","Blinkstrike","Bloodquench","Bloodweep","Broken Promise","Brutality","Cataclysm","Catastrophe","Celeste","Chaos","Cometfell","Convergence","Corruption","Darkheart","Darkness","Dawn","Dawn of Ruins","Dawnbreaker","Deathbringer","Deathraze","Decimation","Desolation","Despair","Destiny's Song","Devine","Devourer","Dirge","Divine Light","Doomblade","Doombringer","Draughtbane","Due Diligence","Early Retirement","Echo","Piece Maker","Eclipse","Endbringer","Epilogue","Espada","Eternal Harmony","Eternal Rest","Extinction","Faithkeeper","Fallen Champion","Fate","Final Achievement","Fleshrender","Florance","Frenzy","Fury","Ghost Reaver","Ghostwalker","Gladius","Glimmer","Godslayer","Grasscutter","Grieving Blade","Gutrender","Hatred's Bite","Heartseeker","Heartstriker","Hell's Scream","Hellfire","Hellreaver","Hollow Silence","Honor's Call","Hope's End","Infamy","Interrogator","Justice","Justifier","King's Defender","King's Legacy","Kinslayer","Klinge","Knight's Fall","Knightfall","Lament","Last Rites","Last Words","Lazarus","Life's Limit","Lifedrinker","Light's Bane","Lightbane","Lightbringer","Lightning","Limbo","Loyalty","Malice","Mangler","Massacre","Mercy","Misery's End","Morbid Doom","Morbid Will","Mournblade","Narcoleptic","Needle","Nethersbane","Night's Edge","Night's Fall","Nightbane","Nightcrackle","Nightfall","Nirvana","Oathbreaker","Oathkeeper","Oblivion","Omega","Orenmir","Peacekeeper","Perfect Storm","Persuasion","Prick","Purifier","Rage","Ragespike","Ragnarok","Reaper","Reaper's Toll","Reckoning","Reign of Misery","Remorse","Requiem","Requiem of the Lost","Retirement","Righteous Might","Rigormortis","Savagery","Scalpel","Scar","Seethe","Severance","Shadow Strike","Shadowsteel","Silence","Silencer","Silver Saber","Silverlight","Skullcrusher","Slice of Life","Soul Reaper","Soulblade","Soulrapier","Spada","Spike","Spineripper","Spiteblade","Stalker","Starshatterer","Sting","Stinger","Storm","Storm Breaker","Stormbringer","Stormcaller","Storm-Weaver","Striker","Sun Strike","Suspension","Swan Song","The Ambassador","The Black Blade","The End","The Facelifter","The Light","The Oculus","The Stake","The Untamed","The Unyielding","The Void","Thorn","Thunder","Toothpick","Tranquility","Treachery","Trinity","Tyrhung","Unending Tyranny","Unholy Might","Valkyrie","Vanquisher","Vengeance","Venom","Venomshank","Warmonger","Widow Maker","Willbreaker","Winterthorn","Wit's End","Witherbrand","Wolf","Worldbreaker","Worldslayer"]; Global $nm2[] = ["Massive","Military","Amber Infused","Ancient","Anguish","Annihilation","Antique","Arcane","Arched","Assassination","Atuned","Oathkeeper's","Bandit's","Baneful","Banished","Barbarian","Barbaric","Battleworn","Blazefury","Blood Infused","Blood-Forged","Bloodcursed","Bloodied","Bloodlord's","Bloodsurge","Bloodvenom","Bone Crushing","Bonecarvin","Brutal","Brutality","Burnished","Captain's","Cataclysm","Cataclysmic","Cold-Forged","Corroded","Corrupted","Crazed","Crying","Cursed","Curved","Dancing","Decapitating","Defiled","Demonic","Deserted","Desire's","Desolation","Destiny's","Dire","Doom","Doom's","Dragon's","Dragonbreath","Ebon","Eerie","Enchanted","Engraved","Eternal","Executing","Exiled","Extinction","Faith's","Faithful","Fancy","Fearful","Feral","Fierce","Fiery","Fire Infused","Fireguard","Firesoul","Firestorm","Flaming","Flimsy","Forsaken","Fortune's","Fragile","Frail","Frenzied","Frost","Frozen","Furious","Fusion","Ghastly","Ghost-Forged","Ghostly","Gladiator","Gladiator's","Gleaming","Glinting","Greedy","Grieving","Guard's","Guardian's","Hailstorm","Hateful","Haunted","Heartless","Hollow","Holy","Honed","Honor's","Hope's","Hopeless","Howling","Hungering","Improved","Incarnated","Infused","Inherited","Isolated","Jade Infused","Judgement","Knightly","Legionnaire's","Liar's","Lich","Lightning","Lonely","Loyal","Lustful","Lusting","Mage's","Malevolent","Malicious","Malignant","Mended","Mercenary","Misfortune's","Misty","Moonlit","Mourning","Nightmare","Ominous","Peacekeeper","Phantom","Polished","Possessed","Pride's","Prideful","Primitive","Promised","Protector's","Deluded","Proud","Recruit's","Reforged","Reincarnated","Relentless","Remorseful","Renewed","Renovated","Replica","Restored","Retribution","Ritual","Roaring","Ruby Infused","Rune-Forged","Rusty","Sailor's","Sapphire Infused","Savage","Shadow","Sharpened","Silent","Singed","Singing","Sinister","Skullforge","Skyfall","Smooth","Solitude's","Sorrow's","Soul","Soul Infused","Soul-Forged","Soulcursed","Soulless","Spectral","Spectral-Forged","Spiteful","Storm","Storm-Forged","Stormfury","Stormguard","Terror","Thirsting","Thirsty","Thunder","Thunder-Forged","Thunderfury","Thunderguard","Thundersoul","Thunderstorm","Timeworn","Tormented","Trainee's","Treachery's","Twilight","Twilight's","Twisted","Tyrannical","Undead","Unholy","Vengeance","Vengeful","Venom","Vicious","Vindication","Vindictive","Void","Volcanic","Vowed","War-Forged","Warlord's","Warp","Warped","Whistling","Wicked","Wind's","Wind-Forged","Windsong","Woeful","Wrathful","Wretched","Yearning","Zealous"]; Global $nm3[] = ["Adamantite","Bronze","Copper","Diamond","Glass","Gold","Iron","Mithril","Obsidian","Silver","Skeletal","Steel"]; Global $nm4[] = ["Blade","Broadsword","Claymore","Defender","Deflector","Doomblade","Greatsword","Guardian","Katana","Longsword","Mageblade","Protector","Quickblade","Rapier","Reaver","Sabre","Scimitar","Shortsword","Slicer","Spellblade","Swiftblade","Sword","Warblade","Skewer","Carver","Etcher","Sculptor","Razor","Crusader"]; Global $nm5[] = ["Annihilation","Betrayer","Blade","Blessed Blade","Blood Blade","Bond","Boon","Breaker","Bringer","Broadsword","Butcher","Call","Carver","Champion","Claymore","Conqueror","Crusader","Cry","Cunning","Dark Blade","Dawn","Defender","Defiler","Deflector","Destroyer","Doomblade","Edge","Ender","Etcher","Executioner","Favor","Ferocity","Foe","Gift","Glory","Greatsword","Guardian","Heirloom","Hope","Incarnation","Jaws","Katana","Last Hope","Last Stand","Legacy","Longblade","Longsword","Mageblade","Memory","Might","Oath","Pact","Pledge","Promise","Protector","Quickblade","Rapier","Ravager","Razor","Reach","Reaper","Reaver","Runed Blade","Saber","Sabre","Savagery","Scimitar","Sculptor","Secret","Shortsword","Skewer","Slayer","Slicer","Soul","Spellblade","Spine","Swiftblade","Sword","Terror","Token","Tribute","Vengeance","Voice","Warblade","Warglaive","Whisper","Wit"]; Global $nm6[] = ["of Agony","of Ancient Power","of Anguish","of Ashes","of Assassins","of Black Magic","of Blessed Fortune","of Blessings","of Blight","of Blood","of Bloodlust","of Broken Bones","of Broken Dreams","of Broken Families","of Burdens","of Chaos","of Closing Eyes","of Conquered Worlds","of Corruption","of Cruelty","of Cunning","of Dark Magic","of Dark Souls","of Darkness","of Decay","of Deception","of Degradation","of Delusions","of Denial","of Desecration","of Diligence","of Dismay","of Dragonsouls","of Due Diligence","of Echoes","of Ended Dreams","of Ending Hope","of Ending Misery","of Eternal Bloodlust","of Eternal Damnation","of Eternal Glory","of Eternal Justice","of Eternal Rest","of Eternal Sorrow","of Eternal Struggles","of Eternity","of Executions","of Faded Memories","of Fallen Souls","of Fools","of Frost","of Frozen Hells","of Fury","of Giants","of Giantslaying","of Grace","of Grieving Widows","of Hate","of Hatred","of Hell's Games","of Hellish Torment","of Heroes","of Holy Might","of Honor","of Hope","of Horrid Dreams","of Horrors","of Illuminated Dreams","of Illumination","of Immortality","of Inception","of Infinite Trials","of Insanity","of Invocation","of Justice","of Light's Hope","of Lost Comrades","of Lost Hope","of Lost Voices","of Lost Worlds","of Magic","of Mercy","of Misery","of Mountains","of Mourning","of Mystery","of Necromancy","of Nightmares","of Oblivion","of Perdition","of Phantoms","of Power","of Pride","of Pride's Fall","of Putrefaction","of Reckoning","of Redemption","of Regret","of Riddles","of Secrecy","of Secrets","of Shadow Strikes","of Shadows","of Shifting Sands","of Shifting Worlds","of Silence","of Slaughter","of Souls","of Stealth","of Storms","of Subtlety","of Suffering","of Suffering's End","of Summoning","of Terror","of Thunder","of Time-Lost Memories","of Timeless Battles","of Titans","of Torment","of Traitors","of Trembling Hands","of Trials","of Truth","of Twilight's End","of Twisted Visions","of Unholy Blight","of Unholy Might","of Vengeance","of Visions","of Wasted Time","of Widows","of Wizardry","of Woe","of Wraiths","of Zeal","of the Ancients","of the Banished","of the Basilisk","of the Beast","of the Blessed","of the Breaking Storm","of the Brotherhood","of the Burning Sun","of the Caged Mind","of the Cataclysm","of the Champion","of the Claw","of the Corrupted","of the Covenant","of the Crown","of the Damned","of the Daywalker","of the Dead","of the Depth","of the Dreadlord","of the Earth","of the East","of the Emperor","of the Empty Void","of the End","of the Enigma","of the Fallen","of the Falling Sky","of the Flame","of the Forest","of the Forgotten","of the Forsaken","of the Gladiator","of the Harvest","of the Immortal","of the Incoming Storm","of the Insane","of the King","of the Lasting Night","of the Leviathan","of the Light","of the Lion","of the Lionheart","of the Lone Victor","of the Lone Wolf","of the Lost","of the Moon","of the Moonwalker","of the Night Sky","of the Night","of the Nightstalker","of the North","of the Occult","of the Oracle","of the Phoenix","of the Plague","of the Prince","of the Protector","of the Queen","of the Serpent","of the Setting Sun","of the Shadows","of the Sky","of the South","of the Stars","of the Storm","of the Summoner","of the Sun","of the Sunwalker","of the Talon","of the Undying","of the Victor","of the Void","of the West","of the Whispers","of the Wicked","of the Wind","of the Wolf","of the World","of the Wretched"]; Global $nm7[] = ["Aetherius","Agatha","Alpha","Amnesia","Anduril","Apocalypse","Armageddon","Arondite","Ashrune","Betrayal","Betrayer","Blackout","Blazefury","Blazeguard","Blinkstrike","Bloodquench","Bloodweep","Brutality","Celeste","Chaos","Cometfell","Convergence","Darkheart","Dawn","Dawnbreaker","Deathbringer","Deathraze","Decimation","Desolation","Destiny's Song","Dirge","Doomblade","Doombringer","Draughtbane","Due Diligence","Echo","Eclipse","Endbringer","Epilogue","Espada","Extinction","Faithkeeper","Fate","Fleshrender","Florance","Frenzy","Fury","Ghost Reaver","Ghostwalker","Gladius","Glimmer","Godslayer","Grasscutter","Gutrender","Hatred's Bite","Heartseeker","Heartstriker","Hell's Scream","Hellfire","Piece Maker","Hellreaver","Honor's Call","Hope's End","Infamy","Interrogator","Justifier","Kinslayer","Klinge","Knightfall","Lament","Lazarus","Lifedrinker","Light's Bane","Lightbane","Lightbringer","Lightning","Limbo","Loyalty","Malice","Mangler","Massacre","Mercy","Misery","Mournblade","Narcoleptic","Needle","Nethersbane","Night's Edge","Night's Fall","Nightbane","Nightcrackle","Nightfall","Nirvana","Oathbreaker","Oathkeeper","Oblivion","Omega","Orenmir","Peacekeeper","Persuasion","Prick","Purifier","Rage","Ragespike","Ragnarok","Reckoning","Reign","Remorse","Requiem","Retirement","Rigormortis","Savagery","Scalpel","Scar","Seethe","Severance","Shadow Strike","Shadowsteel","Silence","Silencer","Silver Saber","Silverlight","Skullcrusher","Slice of Life","Soul Reaper","Soulblade","Soulrapier","Spada","Spike","Spineripper","Spiteblade","Stalker","Starshatterer","Sting","Stinger","Storm","Storm Breaker","Stormbringer","Stormcaller","Story-Weaver","Striker","Sun Strike","Suspension","Swan Song","The Ambassador","The Black Blade","The End","The Facelifter","The Light","The Oculus","The Stake","The Untamed","The Unyielding","The Void","Thorn","Thunder","Toothpick","Tranquility","Treachery","Trinity","Tyrhung","Unending Tyranny","Unholy Might","Valkyrie","Vanquisher","Vengeance","Venom","Venomshank","Warmonger","Widow Maker","Willbreaker","Winterthorn","Wit's End","Witherbrand","Wolf","Worldbreaker","Worldslayer"]; MsgBox(0, "Name Gen", _GenSword(4)) $Gen = _GenSword("1;2;3;4;5;6;7", 3) _ArrayDisplay($Gen) Func _GenSword($Type, $Amount = 1) If StringInStr($Type, ";") Then;Run multiple $String = StringSplit($Type, ";") Local $Size = $String[0] * $Amount Dim $Name[$Size+1] $x = 1 $z = 1 $Name[0] = $Size While $x <= $String[0] $String[$x] = Int($String[$x]) Switch $String[$x] Case 1 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $Name[$z] = $nm1[$r1] If ($z + 1) <= $Size Then $z += 1 Next Case 2 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm7))) $Name[$z] = $nm7[$r7] If ($z + 1) <= $Size Then $z += 1 Next Case 3 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r4 = Floor(Random(0, UBound($nm4))) $Name[$z] = $nm2[$r2] & " " & $nm4[$r4] If ($z + 1) <= $Size Then $z += 1 Next Case 4 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $r6 = Floor(Random(0, UBound($nm6))) $Name[$z] = $nm1[$r1] & " " & $nm6[$r6] If ($z + 1) <= $Size Then $z += 1 Next Case 5 For $i = 1 To $Amount $r3 = Floor(Random(0, UBound($nm3))) $r5 = Floor(Random(0, UBound($nm5))) $Name[$z] = $nm3[$r3] & " " & $nm5[$r5] If ($z + 1) <= $Size Then $z += 1 Next Case 6 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r3 = Floor(Random(0, UBound($nm3))) $r4 = Floor(Random(0, UBound($nm4))) $Name[$z] = $nm2[$r2] & " " & $nm3[$r3] & " " & $nm4[$r4] If ($z + 1) <= $Size Then $z += 1 Next Case 7 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm7))) $r5 = Floor(Random(0, UBound($nm5))) $r6 = Floor(Random(0, UBound($nm6))) $Name[$z] = $nm7[$r7] & " " & $nm5[$r5] & " " & $nm6[$r6] If ($z + 1) <= $Size Then $z += 1 Next EndSwitch $x += 1 WEnd Return $Name ElseIf IsInt($Type) And $Type >= 1 And $Type <= 6 Then;Run Single Local $Name = "" Switch $Type Case 1 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $Name = $Name & $nm1[$r1] & @CRLF Next Case 2 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm1))) $Name = $Name & $nm7[$r7] & @CRLF Next Case 3 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r4 = Floor(Random(0, UBound($nm4))) $Name = $Name & $nm2[$r2] & " " & $nm4[$r4] & @CRLF Next Case 4 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $r6 = Floor(Random(0, UBound($nm6))) $Name = $Name & $nm1[$r1] & " " & $nm6[$r6] & @CRLF Next Case 5 For $i = 1 To $Amount $r3 = Floor(Random(0, UBound($nm3))) $r5 = Floor(Random(0, UBound($nm5))) $Name = $Name & $nm3[$r3] & " " & $nm5[$r5] & @CRLF Next Case 6 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r3 = Floor(Random(0, UBound($nm3))) $r4 = Floor(Random(0, UBound($nm4))) $Name = $Name & $nm2[$r2] & " " & $nm3[$r3] & " " & $nm4[$r4] & @CRLF Next Case 7 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm7))) $r5 = Floor(Random(0, UBound($nm5))) $r6 = Floor(Random(0, UBound($nm6))) $Name = $Name & $nm7[$r7] & " " & $nm5[$r5] & " " & $nm6[$r6] & @CRLF Next EndSwitch Return $Name Else SetError(1) Return 0 EndIf EndFunc
×
×
  • Create New...