Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/18/2017 in all areas

  1. iamtheky

    WTF JOS???

    Actually any script that can do what you want, would be able to do the other with little to no modification. Caps Lock doesn't fix that. also you aren't very good at searching the forum, because it's something we don't discuss now, not something we haven't discussed ever.
    1 point
  2. Here is a cleaned up version of my post above. Easy enough to cycle through a list of users you would like to remove (this is where the "teach a man to fish" part comes in ). And no need to mix objects and command line. #RequireAdmin ;Assume we want to delete Bob... Local $oGroup = ObjGet("WinNT://./Administrators") For $sUser In $oGroup.Members If StringInStr($sUser.ADsPath, "/Bob") Then $oGroup.Remove($sUser.AdsPath) Next
    1 point
  3. TwistedXion

    Help with game

    Ok so I'm making a game in auto it and I need some help with optimizing the code(making it shorter/faster or better ways of doing things) and if you could when you make suggestions please explain why you suggest those changes as I'm very new to autoit and am doing this project just to learn more about the language (first computer language I have ever tried to learn) thanks for any help in advance, also you may need to uncomment the #requireAdmin as it does need to make a dir to save a .ini file where all the info about your character. ps I know it's not much of a game but I have only been working on the code for a few hours and I will be adding a lot more stuff, so this is by no mean finished. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> ;~ #RequireAdmin Global $nClickButtonCount = 0 Global $pDamage = 0 Global $bDamage = 0 Global $fPath = @AppDataCommonDir & "\Fantom\Path" Global $pGold = IniRead($fPath & "\" & "InFo", "Item", "Gold", "1000") Global $cTName = IniRead($fPath & "\" & "InFo", "Name", "ToonName", "") Global $cUName = IniRead($fPath & "\" & "InFo", "Name", "UserName", "") #Region ### START mm GUI section ### $mm = GUICreate("MainMenu", 238, 199, 337, 189) $tName = GUICtrlCreateInput($cTName, 64, 64, 113, 21) $uName = GUICtrlCreateInput($cUName, 64, 120, 113, 21) GUICtrlCreateLabel("ToonName", 90, 40, 57, 17) GUICtrlCreateLabel("UserName", 91, 96, 54, 17) $Enter = GUICtrlCreateButton("Enter", 90, 151, 57, 41) GUISetState(@SW_SHOW, $mm) #EndRegion ### START mm GUI section ### #Region ### START Town GUI section ### $Town = GUICreate("Town", 387, 316, 396, 122) $TGroup1 = GUICtrlCreateGroup("", 0, 0, 385, 313) $TButton1 = GUICtrlCreateButton("Inn", 8, 8, 57, 33) $TButton2 = GUICtrlCreateButton("Wild", 320, 8, 57, 33) $TButton3 = GUICtrlCreateButton("Gen store", 8, 48, 57, 33) GUISetState(@SW_HIDE, $Town) #EndRegion ### START Town GUI section ### #Region ### START Wild GUI section ### $Wild = GUICreate("Wild", 387, 316, 396, 122) $WGroup1 = GUICtrlCreateGroup("", 0, 0, 385, 313) $WButton1 = GUICtrlCreateButton("Town", 8, 8, 57, 33) $WButton2 = GUICtrlCreateButton("Fight", 320, 8, 57, 33) GUISetState(@SW_HIDE, $Wild) #EndRegion ### START Wild GUI section ### #Region ### START Fight GUI section ### $Fight = GUICreate("Fight", 390, 319, 396, 122) $listview = GUICtrlCreateListView("Your Damage | Eneime Damage | Your HP | Eneime HP", 2, 146, 386, 150) $Progress1 = GUICtrlCreateProgress(8, 32, 185, 25) $Progress2 = GUICtrlCreateProgress(200, 32, 185, 25) $YourHP = GUICtrlCreateLabel("YourHP", 8, 8, 41, 17) $EneimeHP = GUICtrlCreateLabel("EneimeHP", 200, 8, 56, 17) $Start = GUICtrlCreateButton("Start", 158, 80, 73, 41) $Attack = GUICtrlCreateButton("Attack", 158, 80, 73, 41) GUISetState(@SW_HIDE, $Fight) #EndRegion ### START Fight GUI section ### #Region ### START Inn GUI section ### $Inn = GUICreate("Inn", 390, 319, 396, 122) $hpdisplay = GUICtrlCreateLabel("You have " & $pGold & " gold", 16, 8, 100, 100) $fullH = GUICtrlCreateButton("Heal", 8, 111, 73, 57) $drink = GUICtrlCreateButton("Drink", 120, 111, 73, 57) $eat = GUICtrlCreateButton("eat", 232, 111, 73, 57) $bttown = GUICtrlCreateButton("town", 8, 250, 73, 57) $fRHP = GUICtrlCreateLabel("Fully Restore HP", 0, 96, 83, 17) $aHPlDam = GUICtrlCreateLabel("Adds more HP" & @LF & "lowers Dammage", 232, 80, 83, 30) $Label1 = GUICtrlCreateLabel("Add more Dammage" & @LF & "Lower HP", 120, 80, 100, 30) GUISetState(@SW_HIDE, $Inn) #EndRegion ### START Inn GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Enter $iniTName = GUICtrlRead($tName) $iniUName = GUICtrlRead($uName) DirCreate($fPath) IniWrite($fPath & "\" & "InFo", "Name", "ToonName", $iniTName) IniWrite($fPath & "\" & "InFo", "Name", "UserName", $iniUName) GUIDelete($mm) GUISetState(@SW_SHOW, $Town) Case $TButton2 GUISetState(@SW_HIDE, $Town) GUISetState(@SW_SHOW, $Wild) Case $WButton1 GUISetState(@SW_HIDE, $Wild) GUISetState(@SW_SHOW, $Town) Case $WButton2 GUISetState(@SW_HIDE, $Wild) GUISetState(@SW_SHOW, $Fight) Case $Start GUICtrlDelete($Start) GUISetState(@SW_SHOW) Start() Case $Attack Dice() Case $TButton1 GUISetState(@SW_HIDE, $Town) GUISetState(@SW_SHOW, $Inn) Case $bttown GUISetState(@SW_HIDE, $Inn) GUISetState(@SW_SHOW, $Town) Case $fullH GUICtrlSetData($Progress1, 100) If $pGold >= 100 Then IniWrite($fPath & "\" & "InFo", "Item", "Gold", $pGold - 100) $pGold = IniRead($fPath & "\" & "InFo", "Item", "Gold", "1000") GUICtrlSetData($hpdisplay, "You have " & $pGold & " gold") Else MsgBox(1, "Sorry", "You do not have enough gold for that action", 1) EndIf EndSwitch WEnd Func Start() GUICtrlSetData($Progress1, 100) GUICtrlRead($Progress1) GUICtrlSetData($Progress2, 100) GUICtrlRead($Progress2) EndFunc ;==>Start Func Dice() Global $pDamage = Random(1, 20, 1) Global $bDamage = Random(1, 20, 1) Global $gGold = Random(0, 50, 1) Damage() EndFunc ;==>Dice Func Damage() $cpHP = GUICtrlRead($Progress1) $cbHP = GUICtrlRead($Progress2) $pHP = $cpHP - $bDamage $bHP = $cbHP - $pDamage GUICtrlSetData($Progress1, $pHP) GUICtrlSetData($Progress2, $bHP) GUICtrlRead($Progress1) GUICtrlRead($Progress2) $listview = GUICtrlCreateListView("Your Damage | Eneime Damage | Your HP | Eneime HP", 2, 146, 386, 150) GUICtrlCreateListViewItem($pDamage & "|" & $bDamage & "|" & $pHP & "|" & $bHP, $listview) If $pHP <= 0 And $bHP <= 0 Then IniWrite($fPath & "\" & "InFo", "Item", "Gold", $pGold + $gGold) GUICtrlDelete($listview) GUISetState(@SW_HIDE, $Fight) GUISetState(@SW_SHOW, $Town) Global $pGold = IniRead($fPath & "\" & "InFo", "Item", "Gold", "1000") MsgBox(1, "Draw", "You Draw..." & @LF & "You get " & $gGold & " gold" & @LF & " you now have " & $pGold) GUICtrlSetData($Progress2, 100) ElseIf $bHP <= 0 Then IniWrite($fPath & "\" & "InFo", "Item", "Gold", $pGold + $gGold) GUICtrlDelete($listview) GUISetState(@SW_HIDE, $Fight) GUISetState(@SW_SHOW, $Town) Global $pGold = IniRead($fPath & "\" & "InFo", "Item", "Gold", "1000") MsgBox(1, "Win", "You win..." & @LF & "You get " & $gGold & " gold" & @LF & " you now have " & $pGold) GUICtrlSetData($Progress2, 100) ElseIf $pHP <= 0 Then GUICtrlDelete($listview) GUISetState(@SW_HIDE, $Fight) GUISetState(@SW_SHOW, $Town) GUICtrlSetData($Progress2, 100) Global $pGold = IniRead($fPath & "\" & "InFo", "Item", "Gold", "1000") MsgBox(1, "Death", "You died...") $t = MsgBox(4, "Dead", "Would you like to revive") If $t = 6 Then $pGold = IniRead($fPath & "\" & "InFo", "Item", "Gold", "1000") If $pGold < 25 Then GUICtrlSetData($Progress1, 75) Else $pGold = $pGold - 25 GUICtrlSetData($Progress1, 100) Global $pGold = IniRead($fPath & "\" & "InFo", "Item", "Gold", "1000") IniWrite($fPath & "\" & "InFo", "Item", "Gold", $pGold + $gGold) MsgBox(1, "Revived", "Your new gold amount is " & $pGold) EndIf ElseIf $t = 7 Then Exit EndIf EndIf EndFunc ;==>Damage
    1 point
  4. @donpot if you do a search of the forum you will find a number of system cleanup type scripts. This is one that I used to use to prepare a machine for cloning, although I have not updated in quite some time. It may give you some ideas: #RequireAdmin #include <Array.au3> #include <EventLog.au3> #include <File.au3> ;====================== ;Enable Defrag Service ;Perform Cleanup Operations ;Disable Defrag Service (company policy) ;===================== _defragSVC(2) _diskCleanup() _diskDrafrag() _clearEvents() _defragSVC(1) Sleep(1000) _deleteTempFiles() _shutDown() Func _diskCleanup() $sMainKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\" Local $aSubKeys[21] $aSubKeys[0] = "Active Setup Temp Folders" $aSubKeys[1] = "Debug Dump Files" $aSubKeys[2] = "Downloaded Program Files" $aSubKeys[3] = "Internet Cache Files" $aSubKeys[4] = "Memory Dump Files" $aSubKeys[5] = "Offline Pages Files" $aSubKeys[6] = "Old ChkDsk Files" $aSubKeys[7] = "Previous Installations" $aSubKeys[8] = "Recycle Bin" $aSubKeys[9] = "Setup Log Files" $aSubKeys[10] = "System error memory dump files" $aSubKeys[11] = "System $error minidump files" $aSubKeys[12] = "Temporary Files" $aSubKeys[13] = "Temporary Setup Files" $aSubKeys[14] = "Thumbnail Cache" $aSubKeys[15] = "Update Cleanup" $aSubKeys[16] = "Upgrade Discarded Files" $aSubKeys[17] = "Windows Error Reporting Archive Files" $aSubKeys[18] = "Windows Error Reporting Queue Files" $aSubKeys[19] = "Windows Error Reporting System Archive Files" $aSubKeys[20] = "Windows Error Reporting System Queue Files" For $sKey In $aSubKeys RegWrite($sMainKey & $sKey, "StateFlags0666", "REG_DWORD", 2) Next $sDiskSize = Round((DriveSpaceTotal("C:") / 1024), 2) $sDiskFree = DriveSpaceFree("C:") ShellExecuteWait("cleanmgr.exe", "/sagerun:666") Sleep(500) $sNewDiskFree = DriveSpaceFree("C:") For $sKey In $aSubKeys RegDelete($sMainKey & $sKey, "StateFlags0666") Next EndFunc Func _diskDrafrag() If @OSArch = "X64" Then _Wow64FsRedirection(False) Sleep(1000) EndIf Local $aArray = DriveGetDrive("ALL") For $i = 1 To $aArray[0] If DriveGetType($aArray[$i]) = "Fixed" Then Run(@ComSpec & " /k defrag " & $aArray[$i] & " /H /U /V", @SystemDir, @SW_MAXIMIZE) Sleep(2000) While ProcessExists("Defrag.exe") Sleep(100) WEnd WinClose("[CLASS:ConsoleWindowClass]", "") Sleep(500) Run(@ComSpec & " /k defrag " & $aArray[$i] & " /H /U /V /X", @SystemDir, @SW_MAXIMIZE) Sleep(2000) While ProcessExists("Defrag.exe") Sleep(100) WEnd WinClose("[CLASS:ConsoleWindowClass]", "") Sleep(500) EndIf Next If @OSArch = "X64" Then _Wow64FsRedirection(True) EndFunc Func _clearEvents() $sTime = TimerInit() RunWait(@ComSpec & " /c wevtutil el > C:\Temp\logs.txt", @SystemDir, @SW_HIDE) Local $aLogs, $hEventLog, $file = "C:\Temp\Logs.txt" _FileReadToArray($file, $aLogs) _ArraySort($aLogs) For $i = 0 To UBound($aLogs) - 1 $hEventLog = _EventLog__Open("", $aLogs[$i]) _EventLog__Clear($hEventLog, "") _EventLog__Close($hEventLog) Next $hEventLog = _EventLog__Open("", "System") _EventLog__Clear($hEventLog, "") _EventLog__Close($hEventLog) Sleep(1000) FileDelete($file) EndFunc Func _deleteTempFiles() $aFolders = _FileListToArray(@TempDir, "*", $FLTA_FOLDERS, True) $aFiles = _FileListToArray(@TempDir, "*", $FLTA_FILES, True) If IsArray($aFolders) Then For $i = 1 To $aFolders[0] DirRemove($aFolders[$i], 1) Next EndIf If IsArray($aFiles) Then For $x = 1 To $aFiles[0] If Not StringInStr($aFiles[$x], "FXSAPI") Then FileDelete($aFiles[$x]) Next EndIf EndFunc Func _shutDown() $complete = MsgBox(1, "Disk Maintenance", "Maintenance complete, system will shut down in 10 seconds.") If $complete = 2 Then Exit Else $oWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") $oDHCPNic = $oWMI.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For $oNIC In $oDHCPNic $oNIC.ReleaseDHCPLease() Next Shutdown(12) EndIf EndFunc Func _Wow64FsRedirection($state) If @OSArch = "X64" Then If $state Then DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int", 0) Else DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0) EndIf If @error Then Return SetError(1) EndIf EndFunc Func _defragSVC($iState) $oServices = ObjGet("winmgmts:\\.\Root\CIMv2").ExecQuery("SELECT * FROM Win32_Service WHERE Name = 'defragsvc'") If IsObj($oServices) Then If $iState = 1 Then For $sService In $oServices $sService.StopService() $sService.ChangeStartMode("Disabled") Next ElseIf $iState = 2 Then For $sService In $oServices $sService.ChangeStartMode("Manual") Sleep(500) $sService.StartService() Next EndIf EndIf EndFunc
    1 point
  5. Use the fully qualified name for the INI as the FileOpenDialog() will change the workdir. When the INI is located in the scriptdir you could simply do: IniWrite(@ScriptDir & "\VLC_convert.ini","VLC","VLCpath",$VLC_path) Jos
    1 point
  6. LarsJ

    Automating Windows Explorer

    Make item visible. The following is an answer to this question. #include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) MakeItemVisible( "ItemName" ) Func MakeItemVisible( $sItemName ) ; Windows Explorer on XP, Vista, 7, 8, 10 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then Return ConsoleWrite( "$hExplorer ERR" & @CRLF ) ConsoleWrite( "$hExplorer OK" & @CRLF ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Explorer object Local $pExplorer, $oExplorer $oUIAutomation.ElementFromHandle( $hExplorer, $pExplorer ) $oExplorer = ObjCreateInterface( $pExplorer, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oExplorer ) Then Return ConsoleWrite( "$oExplorer ERR" & @CRLF ) ConsoleWrite( "$oExplorer OK" & @CRLF ) ; Get ListView (right pane window) object Local $pCondition, $pListView, $oListView $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition ) $oExplorer.FindFirst( $TreeScope_Descendants, $pCondition, $pListView ) $oListView = ObjCreateInterface( $pListView, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oListView ) Then Return ConsoleWrite( "$oListView ERR" & @CRLF ) ConsoleWrite( "$oListView OK" & @CRLF ) ; Find visible item by name Local $pVisibleItem, $oVisibleItem $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, $sItemName, $pCondition ) $oListView.FindFirst( $TreeScope_Descendants, $pCondition, $pVisibleItem ) $oVisibleItem = ObjCreateInterface( $pVisibleItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If IsObj( $oVisibleItem ) Then Return ConsoleWrite( "$oVisibleItem OK" & @CRLF ) ; Continue only if item is non-visible ConsoleWrite( "$oVisibleItem ERR" & @CRLF ) ; Create ItemContainer object Local $pItemContainer, $oItemContainer $oListView.GetCurrentPattern( $UIA_ItemContainerPatternId, $pItemContainer ) $oItemContainer = ObjCreateInterface( $pItemContainer, $sIID_IUIAutomationItemContainerPattern, $dtagIUIAutomationItemContainerPattern ) If Not IsObj( $oItemContainer ) Then Return ConsoleWrite( "$oItemContainer ERR" & @CRLF ) ConsoleWrite( "$oItemContainer OK" & @CRLF ) ; Find non-visible item by name Local $pNonVisibleItem, $oNonVisibleItem $oItemContainer.FindItemByProperty( 0, $UIA_NamePropertyId, $sItemName, $pNonVisibleItem ) $oNonVisibleItem = ObjCreateInterface( $pNonVisibleItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oNonVisibleItem ) Then Return ConsoleWrite( "$oNonVisibleItem ERR" & @CRLF ) ConsoleWrite( "$oNonVisibleItem OK" & @CRLF ) ; Make non-visible item visible Local $pVirtualItem, $oVirtualItem $oNonVisibleItem.GetCurrentPattern( $UIA_VirtualizedItemPatternId, $pVirtualItem ) $oVirtualItem = ObjCreateInterface( $pVirtualItem, $sIID_IUIAutomationVirtualizedItemPattern, $dtagIUIAutomationVirtualizedItemPattern ) If Not IsObj( $oVirtualItem ) Then Return ConsoleWrite( "$oVirtualItem ERR" & @CRLF ) ConsoleWrite( "$oVirtualItem OK" & @CRLF ) $oVirtualItem.Realize() ; Make item visible EndFunc All code: MakeItemVisible.7z
    1 point
  7. I'm trying to get the HTML code after executing javascript in IE. Here is my code. $url = "http://example.com" $oIE = _IECreate($url) Sleep(3000) ;waiting for executing javascript. But useless. $oFrame = _IEFrameGetCollection($oIE, 0) $sCode &= _IEPropertyGet($oFrame, "innerhtml") & @CRLF Then, I get this error. "C:\Program Files (x86)\AutoIt3\Include\IE.au3" (2308) : ==> The requested action with this object has failed.: $oTemp = $oObject.document.body $oTemp = $oObject^ ERROR After executing javascript, when I view source in IE, there are HTML code like below. <html> <head> ... </head> <body> ... </body> </html> What should I do?
    1 point
  8. dazza, You cannot! There is a longstanding bug that cancels all styles when the button is coloured - either text or background. I seem to remember that it sets the button to OWNER_DRAWN and so no standard Windows styles are available. Yashied came up with a way to get coloured text here and in subsequent posts, but I have never seen a way to keep the background coloured. Sorry not to be of more help. M23
    1 point
  9. Clay

    Killing a Process Tree

    Background... I want to be able to kill an install if a certain error occurs. Now I know that other then sending commands to the buttons to exit the install correctly I can also kill the process with ProcessClose(). However, when I use ProcessClose(), the process is killed but the dailogs from the install remain open. This does not work for me.... Question.... Is there anyway to kill a process TREE with Autoit? Has anyone attempted this before?
    1 point
  10. The built in windows command to kill a task is called taskkill, the /t flag indicates you want to kill the entire program tree, and the /im is for the program matching whatever name comes after it. Run(@ComSpec & "/c taskkill /t /im program.exe", "")
    1 point
×
×
  • Create New...