Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/31/2015 in all areas

  1. There is several ways to get programmatically Windows Environment Variables : - using "set" cmd line tool. - using objWMIService with Win32_Environment. - reading HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. but also using the WinAPi GetEnvironmentStrings function. Here is the Ansi version : #NoTrayIcon #Region ;************ Includes ************ #Include <WindowsConstants.au3> #Include <GUIConstantsEx.au3> #Include <GuiListView.au3> #Include <WinAPIMisc.au3> #Include <GuiMenu.au3> #EndRegion ;************ Includes ************ Opt ( 'GUIResizeMode', $GUI_DOCKAUTO ) Opt ( 'MustDeclareVars', 1 ) Global $hGui, $hListview, $iGuiWidth, $iGuiHeight, $aEnvVariables, $iIndex, $hLVMenu, $bRightClick = False Global $iExport, $sExportFilePath, $sTxt, $hFile Global Enum $iId_Copy = 3000, $Id_Save $aEnvVariables = _WinApi_GetEnvironmentStringsA() _Gui() For $i = 0 To UBound ( $aEnvVariables ) -1 $iIndex = _GUICtrlListView_AddItem ( $hListview, $aEnvVariables[$i][0], -1, 0 ) _GUICtrlListView_AddSubItem ( $hListView, $iIndex, $aEnvVariables[$i][1], 1 ) Next #Region ------ Main Loop ------------------------------ While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete ( $hGui ) Exit Case Else If $bRightClick = True Then $bRightClick = False $hLVMenu = _GUICtrlMenu_CreatePopup() If _GUICtrlMenu_IsMenu ( $hLVMenu ) Then _GUICtrlMenu_InsertMenuItem ( $hLVMenu, 0, 'Copy Selected Variable Name', $iId_Copy ) _GUICtrlMenu_InsertMenuItem ( $hLVMenu, 1, 'Export Variables List', $Id_Save ) _GUICtrlMenu_SetMenuStyle ( $hLVMenu, BitOR ( $MNS_CHECKORBMP, $MNS_AUTODISMISS, $MNS_NOCHECK ) ) _GUICtrlMenu_TrackPopupMenu ( $hLVMenu, $hGui ) _GUICtrlMenu_DestroyMenu ( $hLVMenu ) $hLVMenu = 0 EndIf EndIf If $iExport Then $iExport = 0 $sExportFilePath = FileSaveDialog ( 'Export Variables List', '', 'Text Files (*.txt;*.csv)|All Files (*.*)', 2+16, 'Windows Environment Variables List', $hgui ) If Not @error Then $sTxt = '' For $i = 0 To UBound ( $aEnvVariables ) -1 $sTxt &= StringStripWS ( $aEnvVariables[$i][0], 7 ) & ' : ' & StringStripWS ( $aEnvVariables[$i][1], 7 ) & @CRLF Next $hFile = FileOpen ( $sExportFilePath, 2+8+512 ) FileWrite ( $hFile, $sTxt ) FileClose ( $hFile ) EndIf EndIf EndSwitch Sleep ( 10 ) WEnd #EndRegion --- Main Loop ------------------------------ Func _Gui() $hGui = GUICreate ( 'Windows Environment Variables Viewer', 700, 600, -1, -1, BitOR ( $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SYSMENU, $WS_SIZEBOX ) ) GUICtrlCreateListView ( 'Environment Variable Names|Values', 10, 10, 680, 555 ) $hListview = GUICtrlGetHandle ( -1 ) _GUICtrlListView_SetColumnWidth ( $hListview, 0, 220 ) _GUICtrlListView_SetColumnWidth ( $hListview, 1, @DesktopWidth - 270 ) Local $aPos = WinGetPos( $hGui ) $iGuiWidth = $aPos[2] $iGuiHeight = $aPos[3] GUIRegisterMsg ( $WM_GETMINMAXINFO, '_WM_GETMINMAXINFO' ) GUIRegisterMsg ( $WM_NOTIFY, '_WM_NOTIFY' ) GUIRegisterMsg ( $WM_COMMAND, '_WM_COMMAND' ) GUISetState() EndFunc ;==> _Gui() Func _WinApi_FreeEnvironmentStringsA ( $pEnv ) ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683151(v=vs.85).aspx Local $aRet = DllCall ( 'kernel32.dll', 'int', 'FreeEnvironmentStringsA', 'ptr', $pEnv ) If Not @error And $aRet[1] <> 0 Then Return SetError ( 0, @extended, $aRet[1] ) Return SetError ( @error, 0, 0 ) EndFunc ;==> _WinApi_FreeEnvironmentStringsA() Func _WinApi_GetEnvironmentStringsA() ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683187(v=vs.85).aspx Local $pEnvBlock, $iPtrStringLen, $tEnvString, $aSplit, $aRet, $sEnvString, $aEnvString[0][2] $aRet = DllCall ( 'kernel32.dll', 'ptr', 'GetEnvironmentStringsA' ) ; GetEnvironmentStringsA returns OEM characters. If @error Then Return SetError ( @error, @extended, '' ) $pEnvBlock = $aRet[0] ; pointer to a block of memory that contains the environment variables. If Not IsPtr ( $pEnvBlock ) Then Return SetError ( -1, 0, '' ) While 1 $iPtrStringLen = _WinAPI_StringLenA ( $pEnvBlock ) If $iPtrStringLen > 0 Then $tEnvString = DllStructCreate ( 'char[' & $iPtrStringLen + 1 & ']', $pEnvBlock ) $sEnvString = _WinAPI_OemToChar ( DllStructGetData ( $tEnvString, 1 ) ) ; Convert Oem to Ansi. If StringLeft ( $sEnvString, 1 ) <> '=' Then $aSplit = StringSplit ( $sEnvString, '=', 1+2 ) If Not @error Then ReDim $aEnvString[UBound ( $aEnvString )+1][2] $aEnvString[UBound ( $aEnvString )-1][0] = $aSplit[0] ; name $aEnvString[UBound ( $aEnvString )-1][1] = $aSplit[1] ; value EndIf EndIf $pEnvBlock += $iPtrStringLen + 1 Else _WinApi_FreeEnvironmentStringsA ( $pEnvBlock ) ; Free memory block. $tEnvString = 0 Return SetError ( 0, 0, $aEnvString ) EndIf WEnd EndFunc ;==> _WinApi_GetEnvironmentStringsA() Func _WM_COMMAND ( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $wParam Case $iId_Copy ClipPut ( _GUICtrlListView_GetItemText ( $hListview, _GUICtrlListView_GetSelectedIndices ( $hListview ), 0 ) ) Case $Id_Save $iExport = 1 EndSwitch EndFunc ;==> _WM_COMMAND() Func _WM_GETMINMAXINFO ( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $hWnd Case $hGui Local $tMinMaxInfo = DllStructCreate ( 'int;int;int;int;int;int;int;int', $lParam ) DllStructSetData ( $tMinMaxInfo, 7, $iGuiWidth ) ; min w DllStructSetData ( $tMinMaxInfo, 8, $iGuiHeight ) ; min h $tMinMaxInfo = 0 ; Release resource. EndSwitch EndFunc ;==> _WM_GETMINMAXINFO() Func _WM_NOTIFY ( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam, $lParam Local $hWndFrom, $iCode, $tNMHDR, $tInfo $tNMHDR = DllStructCreate ( $tagNMLISTVIEW, $lParam ) $hWndFrom = HWnd ( DllStructGetData ( $tNMHDR, 'hWndFrom' ) ) $iCode = DllStructGetData ( $tNMHDR, 'Code' ) $tInfo = DllStructCreate ( $tagNMLISTVIEW, $lParam ) Switch $hWndFrom Case $hListView Switch $iCode Case $NM_RCLICK If DllStructGetData ( $tInfo, 'Item' ) >= 0 Then If $hLVMenu <> 0 Then _GUICtrlMenu_DestroyMenu ( $hLVMenu ) $hLVMenu = 0 $bRightClick = True EndIf EndSwitch EndSwitch $tInfo = 0 $tNMHDR = 0 Return $GUI_RUNDEFMSG EndFunc ;==> _WM_NOTIFY()Tested under Win XP SP3x86 and Win 8.1x64
    1 point
  2. wakillon

    StringFinder v1.2.3

    I hate the Microsoft Windows search. After trying the powerfull "Agent Ransack", i said to myself ; why not create a free alternative in AutoIt ? StringFinder replace my old TinyAu3FilesSearch utility and will be added to the next version of SciTE Hopper Unlike to TinyAu3FileSearch, you can search strings in any "Text" files. Source and compiled Version are available in the Download Section. Enjoy !
    1 point
  3. Danyfirex

    Measure Speaker Volume

    #include <GuiConstants.au3> #include <ProgressConstants.au3> Global Const $S_OK = 0 ;=============================================================================== #interface "IMMDeviceEnumerator" Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" ; Definition Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr);" ;=============================================================================== ;=============================================================================== #interface "IMMDevice" Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" ; Definition Global Const $tagIMMDevice = "Activate hresult(clsid;dword;variant*;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(ptr*);" & _ "GetState hresult(dword*);" ;=============================================================================== ;=============================================================================== #interface "IAudioMeterInformation" Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" ; Definition Global Const $tagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _ "GetMeteringChannelCount hresult(dword*);" & _ "GetChannelsPeakValues hresult(dword;float*);" & _ "QueryHardwareSupport hresult(dword*);" ;=============================================================================== Global $oAudioMeterInformation = _AudioVolObject() If Not IsObj($oAudioMeterInformation) Then Exit -1 ; Will happen on non-supported systems Global $hGUI Global $hControl = _MakePeakMeterInWindow($hGUI) ; Register function to periodically update the progress control AdlibRegister("_LevelMeter", 45) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd AdlibUnRegister() ; Bye, bye... Func _MakePeakMeterInWindow($hWindow) $hWindow = GUICreate("ABC", 80, 300) Return GUICtrlCreateProgress(20, 20, 40, 260, $PBS_VERTICAL) EndFunc ;==>_MakePeakMeterInWindow Func _LevelMeter() Local $iPeak If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then $iCurrentRead = 100 * $iPeak GUICtrlSetData($hControl, $iCurrentRead + 1) GUICtrlSetData($hControl, $iCurrentRead) EndIf EndFunc ;==>_LevelMeter Func _AudioVolObject() ; Sequences of code below are taken from the source of plugin written for AutoIt for setting master volume on Vista and above systems. ; Code was written by wraithdu in C++. ; MMDeviceEnumerator Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator) If @error Then Return SetError(1, 0, 0) Local Const $eRender = 0 Local Const $eConsole = 0 ; DefaultAudioEndpoint Local $pDefaultDevice $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eRender, $eConsole, $pDefaultDevice) If Not $pDefaultDevice Then Return SetError(2, 0, 0) ; Turn that pointer into object Local $oDefaultDevice = ObjCreateInterface($pDefaultDevice, $sIID_IMMDevice, $tagIMMDevice) Local Const $CLSCTX_INPROC_SERVER = 0x1 ; AudioMeterInformation Local $pAudioMeterInformation $oDefaultDevice.Activate($sIID_IAudioMeterInformation, $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation) If Not $pAudioMeterInformation Then Return SetError(3, 0, 0) Return ObjCreateInterface($pAudioMeterInformation, $sIID_IAudioMeterInformation, $tagIAudioMeterInformation) EndFunc ;==>_AudioVolObject Saludos
    1 point
  4. You might want to use the methods of the Word application object or the following functions to translate from/to points: Func CentimetersToPoints($iValue) Return ($iValue * 28.35) EndFunc ;==>CentimetersToPoints Func InchesToPoints($iValue) Return ($iValue * 72) EndFunc ;==>InchesToPoints Func LinesToPoints($iValue) Return ($iValue * 12) EndFunc ;==>LinesToPoints Func PicasToPoints($iValue) Return ($iValue * 12) EndFunc ;==>PicasToPoints Func PointsToCentimeters($iValue) Return ($iValue / 28.35) EndFunc ;==>CentimetersToPoints Func PointsToInches($iValue) Return ($iValue / 72) EndFunc ;==>InchesToPoints Func PointsToLines($iValue) Return ($iValue / 12) EndFunc ;==>LinesToPoints Func PointsToPicas($iValue) Return ($iValue / 12) EndFunc ;==>PicasToPoints
    1 point
  5. Since JohnOne was so kind to give an example, I modified it for my thought as well #include <WinAPI.au3> $iPid = Run("Notepad.exe") Sleep(2000) HotKeySet("{Esc}", "_Exit") AdlibRegister("_PauseIfProcessWinNotActive",500) Func _PauseIfProcessWinNotActive() Local $iTempPid _WinAPI_GetWindowThreadProcessId(WinGetHandle("[ACTIVE]"),$iTempPid) While $iTempPid <> $iPid ConsoleWrite("I'm sleeping!!" & @CRLF) Sleep(1000) _WinAPI_GetWindowThreadProcessId(WinGetHandle("[ACTIVE]"),$iTempPid) WEnd ConsoleWrite("I'm not sleeping!!" & @CRLF) EndFunc ;==>_CheckUserMovedMouse Func _Exit() Exit EndFunc ; this will actually be your script: While True WEndAs long as the notepad started...or some window spawned from that process (such as a save as window) is active, the console will output "I'm not sleeping!!"...make anything else active, then you will see console output "I'm sleeping!!" If you are working with multiple PIDs then you can create an array, and keep adding to it as you create them...then in the adlib func, loop through that array and see if the temppid matches anything in the array (loop through the array)...
    1 point
  6. Here is a simple but effective way of doing that. It's based on knowing where the mouse clicks, which you obviously do, seeing as how you wrote the code. In the example the array of expected mouse positions is hard coded, you can change them as you wish if your script has dynamic positions. Please try to figure out how, for yourself. (hint: you should only need two entries in array, where the mouse is, and where it is going to be next) Global $aMousePositions[3][2] $aMousePositions[0][0] = 200 $aMousePositions[0][1] = 200 $aMousePositions[1][0] = 300 $aMousePositions[1][1] = 300 $aMousePositions[2][0] = 400 $aMousePositions[2][1] = 400 HotKeySet("{Esc}", "_Exit") AdlibRegister("_CheckUserMovedMouse") While 3 For $i = 0 To UBound($aMousePositions) - 1 MouseMove($aMousePositions[$i][0], $aMousePositions[$i][1], 0) Sleep(1000) Next WEnd Func _CheckUserMovedMouse() Local $aMousePos = MouseGetPos() For $i = 0 To UBound($aMousePositions) - 1 If ($aMousePos[0] = $aMousePositions[$i][0] And $aMousePos[1] = $aMousePositions[$i][1]) Then Return ; Mouse is one of your predefined positions; EndIf Next MsgBox(0, "User Active", "Exiting") ; Someone moved mouse. Exit EndFunc ;==>_CheckUserMovedMouseEDIT: Obviously I used Move instead of Click, for demonstration purpose.
    1 point
  7. Another thought. If you are interacting with a specific window, then you can create an AdLibRegister to call a function to sleep if that window is not active. So if a user clicks into a new window, your script will sleep until your window is active again.
    1 point
  8. nitekram

    Adult sites blocker

    You might be able to use NAT or the route command - have not tested, but it may be something to look at. There is also a website that you can use...https://www.opendns.com/
    1 point
  9. We learn from mistakes It is a pity that often on their own
    1 point
  10. @dangbeau it would also help to know what you're trying to accomplish. In all likelihood you could get away from using the mouse if you employ the Control commands. Then it wouldn't matter as much if someone moved the mouse.
    1 point
  11. There are several ways to do this, but the simplest might be to use BlockInput and stop anyone else using your PC altogether until a Hotkey is clicked. Be sure you read up on BlockInput though, as you don't want to block that Hotkey. As for the Hotkey, look at the _IsPressed command .... making sure you use the DLL version for repeated calls/checks on a regular basis. Another method is to regularly check your mouse position. Personally, I would combine all the above ... both enabling and disabling BlockInput at key moments, providing window of opportunity pauses perhaps. You really do not want an auto-click to go astray. BE CAREFUL with BlockInput.
    1 point
  12. JohnOne

    Adult sites blocker

    You can have If ProcessExists Then ProcessClose in a loop, or I'm sure there is group policy setting to deny softwares. PS hosts file redirects domains not ip addresses.
    1 point
  13. You don't need to run your scripts on the desktop. You can run it on the service level (session 0), and then not worry about any user messing it up. There is a function=_Timer_GetIdleTime, but your script will trigger it (if it sends keys or moves the mouse), so the user action wouldn't matter. But you could do adlibregister with that function, and if the timer resets, then sleep until the timer goes over some set amount of time.
    1 point
  14. Rhazz, As explained in the Help file, you should only use the "For...In...Next" type of loop when dealing with a collection (an Object or an Array). In this case you are using an integer - and so you get an error, again explained in the Help file. Do it like this: For $i = 1 To (_FileCountLines($sFile1) / 3 )as the "For...To...Next" loop expects number bounds. M23
    1 point
  15. if you want combine your script use (FileInstall) something like FileInstall("ffmpeg.exe" , @ScriptDir&"/ffmpeg.exe") $CMD = "ffmpeg -i xxxx.MP4 -codec copy yyyy.avi" RunWait(@ComSpec & " /c " & $CMD)
    1 point
  16. something like? run ('cmd /k ffmpeg -loop 1 -framerate ' & 1 /$duracionCadaImagen & ' -i ' & $imagenes & ' -i ' & $audioVideo & ' -c:v libx264 -s ' & $videoResolucion & ' -t ' & $duracionVideoFinal & ' -aspect ' & $relacionDeAspecto & ' -c:a libvo_aacenc -ac 2 -ab 128k -r ' & $fpsVideoFinal & ' -preset ' & $velocidadAlCodificar & $videoFinal')
    1 point
  17. ptrex seriously, this is very simple and it is OCR that you can rely on. I used to use Tesseract but after trying modi... Thanks for sharing this. Edit: BTW Modi is not included in MS Office Professional Plus 2010. You will have to install Ms office sharepoint designer 2007 and then enable to run all from your computer to be able to run the codes in this thread.
    1 point
×
×
  • Create New...