Jump to content

copyleft

Active Members
  • Posts

    120
  • Joined

Everything posted by copyleft

  1. @seadoggie01. Wow. Thanks so much for the annotated code; it's been a while since I've run into a post so helpful. Back it 2004 there were a lot more like you around this forum; but now it's a lot of negative energy.
  2. I am marking this as solved, even though it isn't. As my knowledge of AutoIt is evidently not as extensive as yours, we seem to be talking past each other.
  3. Well, with your second script running and the Wndows screen display set to timeout after 1 minute. Nothing happens after several minutes.
  4. Yes, I meant when the screen goes blank after a set period of minutes. However, I tried your second script and nothing happens. Does this script need to be running all the time to detect the console display state? I'm beginning to think that Microsoft just doesn't want any automatic disconnection of network connections, especially on Windows 11. I created a script that initially worked when triggered by Windows Task manager. But it would not run a second time and I basically ended up having the same problem these guys had. And even manually invoking "netsh interface set interface ""Local Area Connection"" admin=disabled" my PC somehow turns networking back on overnight. Not sure what's going on. Definitely not a virus. This is a clean install. I'll mark tthis issue as closed. Thanks again for trying to help me.
  5. I appreciate your effort to help me. But I am trying to write an Autoit script that disables all network connections and logs off a user after the Windows display times out. Executing your code, above, does not do that.
  6. Sorry. I'm lost. Where do I put: Run("netsh interface set interface ""Local Area Connection"" admin=disable", "", @SW_HIDE) Run("shutdown -l -f", "", @SW_HIDE) Should I replace "While True" with that run code?
  7. I'm still learning AutoIt and don't quit understand how to invoke Windows api's correctly. But I am trying to write an Autoit script that disables all network connections and logs off a user after the Windows display times out or (better yet after the screen saver come on). However, my script, below complains there is no defined function for " _WinAPI_GetMonitorPowerStatus" and no declaration for "$PowerDeviceD0". Is there some file missing in my AutoIt "include" directory? #RequireAdmin #include <WinAPI.au3> #include <Constants.au3> Global $hWnd = WinWait("[CLASS:Progman]", "", 10) Global $iLastState = _WinAPI_GetMonitorPowerStatus() While 1 $iCurrentState = _WinAPI_GetMonitorPowerStatus() If $iCurrentState <> $iLastState Then If $iCurrentState = $PowerDeviceD0 Then Run("netsh interface set interface ""Local Area Connection"" admin=disable", "", @SW_HIDE) Run("shutdown -l -f", "", @SW_HIDE) EndIf $iLastState = $iCurrentState EndIf Sleep(1000) WEnd
  8. Thanks. I think there's a conflict with a pre-assigned hotkey within the application because it won't go to the title bar now when the escape key is pressed. I just settled on an old-fashioned time out to get me to the title bar upon timeout expiration.
  9. Trying to write autoit script that opens app search prompt upon app execution then sends cursor to the app title bar if the escape key is pressed. #RequireAdmin #include <MsgBoxConstants.au3> Global $g_bEscPressed = False HotKeySet("{ESC}", "OnEscPressed") ShellExecute("C:\Windows\PowerRun.exe", "Myapp.exe") WinWait("Myapp", "") send ("^f") ;open app search prompt If $g_bEscPressed Then send ("!d"); goto app titlebar EndIf Exit Func OnEscPressed()     $g_bEscPressed = True EndFunc ; end Exit
  10. REMOVED/SOLVED. Plain old batch script seems to work more reliably and faster.  
  11. Added network path check and console write; script completes with no errors but still no files deleted, like I said, must be some other Windows issue. I'll move along unless someone has other ideas. #RequireAdmin #include <File.au3> #include <Date.au3> Global $sNetworkPath = "\\SHARE\home\Logs" If FileExists($sNetworkPath) Then ConsoleWrite("Network path is accessible." & @CRLF) Global $sCurrentDate = _NowCalc() Global $sOldDate = _DateAdd('d', -6, $sCurrentDate) Global $aFileList = _FileListToArray($sNetworkPath, "*.htm", 1) For $i = 1 To $aFileList Global $sFileDate = FileGetTime($sNetworkPath & "\" & $aFileList[$i], 1, 1) If $sFileDate <> -1 And $sFileDate < $sOldDate Then FileDelete($sNetworkPath & "\" & $aFileList[$i]) ConsoleWrite("Deleted file: " & $aFileList[$i] & @CRLF) EndIf Next Else ConsoleWrite("Network path is not accessible." & @CRLF) EndIf If $CmdLine > 0 And $CmdLine = "/console" Then ConsoleWrite("Running script in console mode..." & @CRLF) Else ConsoleWrite("Running script in normal mode..." & @CRLF) EndIf
  12. @Danp2 I have searched the forums. I think something else is broke because trying do delete files older than X doesn't even work with a batch script, which is what brought me here in the first place.
  13. @Danp2 I'm lost here. Do you mean supply a path value for $sFilePath like below? #RequireAdmin #include <File.au3> #include <Date.au3> Global $sFolderPath = "\\SHARE\home\Logs" Global $sfilepath = "\\SHARE\home\Logs\*.htm" Global $iDaysToKeep = 21 Global $sDate = _DateAdd('d', -$iDaysToKeep, _NowCalcDate()) For $sFile In _FileListToArray($sFolderPath) $sFilePath = $sFolderPath & "\" & $sFile $sFileDate = FileGetTime($sFilePath, 1, 1) ; $FT_CREATED, $FT_STRING If $sFileDate <> -1 And $sFileDate < $sDate Then FileDelete($sFilePath) EndIf Next
  14. Tryin to delete files older than 21 days in a network folder. The user has admin access to the folder, but the script, below doesn't delete any files. #RequireAdmin #include <File.au3> #include <Date.au3> Global $sFolderPath = "\\SHARE\home\Logs" Global $iDaysToKeep = 21 Global $sDate = _DateAdd('d', -$iDaysToKeep, _NowCalcDate()) For $sFile In _FileListToArray($sFolderPath) $sFilePath = $sFolderPath & "\" & $sFile $sFileDate = FileGetTime($sFilePath, 1) If $sFileDate <> -1 And $sFileDate < $sDate Then FileDelete($sFilePath) EndIf Next
  15. I cobbled this script from the "WinExists" example in the AutoIt help file. It works fine except if I dismiss the "Window exists" msgbox or leave that "Window exists" command in line 10 out of my script altogether, the browser window closes. I want to perform several file and directory commands and run a program after I manually close the browser normally, without having to dismiss the small Autoit message box. $SetupDir= "D:\Chrome\data" $webfile = "file:///C:/Bin/0HOME.HTM" Chrome() Func Chrome() ; Run Chrome ShellExecute("D:\Chrome\chromium-portable.exe", $webfile) ; Wait 3 seconds for Chrome. WinWait("[CLASS:Chrome_WidgetWin_1]", "", 3) ; Test if Chrome opens and display the results. If WinExists("[CLASS:Chrome_WidgetWin_1]") Then MsgBox($MB_SYSTEMMODAL, "", "Chrome exists") Else Sleep(300); to lower CPU usage less FileDelete($SetupDir & "\Default\Preferences") EndIf EndFunc Exit
  16. @Jfish Thank you.
  17. So, like many users, I've got three text editors on my system: Windows OEM notepad, Scite and either Notepad++ or EmEditor. The latter two I need for global search and replace text in multiple files indside a folder, Vertical Selection Editing, regular expressions support, etc. So I want to downsize. Is there a way to totally jettison Notepad in favor of Scite. Alternatively, does anybody have an AutoIt syntax checking addon for Notepad ++ or Emeditor?
  18. Thanks for the quick response. Great app, now that I understand it a little better.
  19. One other question: When choosing the countdown timer instead of the GUI display icon, is the timer digit(s) always the same size as the message box text or can it be made more or less prominent and can its location in the message box be changed?
  20. Thanks. I appreciate it.
  21. From my understanding, it's not wrong to put UDFs in the include folder and shouldn't make any difference when executing a script. it's just not recommended because that folder could be overwritten during upgrades. Since I backup that folder, I'm not concerned about that possibility. Script works fine, Still not understanding where to put an icon path or how to size it and titlebar text.
  22. Not trying to be coy. I've tried this: #include <ExtMsgBox.au3> _ExtMsgBoxSet ( 3, 0, 0xF0F4F9, 0xFF0000, 16, "Arial" ) $sMsg = "This is a test. Is it OK to proceed?" $iRetValue = _ExtMsgBox ( 128, "OK|Cancel", "Match !", $sMsg, 5 ) Still confused on how to change window icon and font and size of window title.
  23. OK, grad students. Basically, I'm in third grade here. I thought the way to use this UDF was to put "ExtMsgBox.au3" in the AutoIt include folder and then make an "#include" declaration in my AutoIt script to call ExtMsgBox 's functions. But I'm not understanding how to change my message box font, dimensions, dialog icon or time out. I've seen ExtMsgBox called like this: " _ExtMsgBoxSet as well as like this #include= <ExtMsgBox> So can someone post an annotated example of ExtMsgBox with: 1. 16pt Arial font 2. Centered in screen (or shows some X & Y coordinates) 2. with OK/CANCEL buttons 3. uses the "C:\Windows\explorer.exe" icon on the MsgBox 4. that says "Hello World" on the 1st line 5. That says "back at you" on the 2nd line 6. That times out to "OK" button after 5 seconds Basically, I want something that looks like "Test2" example in the "ExtMsgBox_Example_1.au3" scriipt. Thanks in advance.
  24. This is no shade on AutoIt developers who have created an awesome and extremely useful Windows scripting utility but the default AutoIt context menu takes up a lot of space. I get it, as a developer you pretty much have to be in a new user's face in terms of options so they won't bombard you with questions but I quickly figured I didn't need the 4 default AutoIt selections on the file context menu: compile | compile with options | edit script and run. (In addition you have the Windows insanity of the ubiquitous "Open" command, which, when you click on it, doesn't run an AutoIt script but simply opens it it Notepad, but I digress). So I eliminated the clutter by creating a cascading AutoIt context menu and added my own custom icons so these old eyes could quickly tell the difference between edit and compile without reading the menu captions. Registry code appears, below: Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\AutoIt3Script\Shell] [HKEY_CLASSES_ROOT\AutoIt3Script\Shell\AutoIt_Options] "MUIVerb"="AutoIt Options" "SubCommands"="Compile;Edit;Run" "icon"="C:\\PATH TO CUSTOM ICON\\*.ico" "Position"="Top" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell] [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Compile] @="Compile" "icon"="C:\\PATH TO CUSTOM ICON\\*.ico" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Compile\Command] @="\"C:\\Program Files (x86)\\AutoIt3\\SciTE\\..\\AutoIt3.exe\" \"C:\\Program Files (x86)\\AutoIt3\\SciTE\\AutoIt3Wrapper\\AutoIt3Wrapper.au3\" /ShowGui /in \"%l\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Edit] @="Edit" "icon"="C:\\Program Files (x86)\\AutoIt3\\SciTE\\SciTE.exe" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Edit\Command] @="\"C:\\Program Files (x86)\\AutoIt3\\SciTE\\SciTE.exe\" \"%1\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Run] @="Run Script" "icon"="C:\\PATH TO CUSTOM ICON\\*.ico" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Run\Command] @="\"C:\\Program Files (x86)\\AutoIt3\\AutoIt3_x64.exe\" \"%1\" %*"
  25. @Earthshine this thread is beginning to remind me of the scenes where customers tried to order soup on the TV series Seinfeld. You can have the last word on this, I told you my experience and I never used "/DLL". I'm offline.
×
×
  • Create New...