Leaderboard
Popular Content
Showing content with the highest reputation on 11/06/2015 in all areas
-
Congratulations, you found out what this thread is about!2 points
-
Is it a Good Idea?: Other Conditions with Case Else
TheSaint and one other reacted to TouchOdeath for a topic
I disagree with JohnOne about the smileys, My brain simply skims past the smileys. I don't think the smileys make you look stupid either, it actually helps the reader understand your emotions better. It wouldn't take any additional time for me to read the smileys. I agree with Melba, I don't see a problem to begin with. While I do agree that yes, It would be nice if you could do case 2, Else, I don't think it solves any problems by doing so.2 points -
#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 Saludos2 points
-
Windows Environment Variables Viewer
coffeeturtle reacted to wakillon for a topic
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.1x641 point -
1 point
-
Is it a Good Idea?: Other Conditions with Case Else
TheSaint reacted to jaberwacky for a topic
Yeah, if you apply the way you are on your job to other aspects of your life. Does sounds like an excuse actually. It is pretty crazy, yeah.1 point -
Is it a Good Idea?: Other Conditions with Case Else
TheSaint reacted to jaberwacky for a topic
I think you might be a psychopath.1 point -
You can do this... Local $sEndData = "" Local $hFile = FileOpen("1.txt", 17) FileSetPos($hFile, 3, 0) FileSetPos($hFile, 3 + 3, 0) $sEndData = FileRead($hFile) FileSetPos($hFile, 3, 0) FileSetEnd($hFile) FileWrite($hFile, $sEndData) FileClose($hFile) Saludos1 point
-
J1, helpful as always1 point
-
From here: 9e9 (9000000000) is wayyyyy more than 16,777,2161 point
-
kcvinu, I would use a dummy control like this: #include <GUIConstantsEx.au3> #include <WinAPI.au3> Local $hGUI = GUICreate("Window", 381, 237, -1, -1) Local $hButton = GUICtrlCreateButton("Button", 97, 145, 192, 77) Local $hInput = GUICtrlCreateInput("", 60, 37, 267, 35) Local $hInput2 = GUICtrlCreateInput("", 60, 97, 267, 35) Local $cInputDummy = GUICtrlCreateDummy() GUISetState() Local $Accle = [["{ENTER}",$cInputDummy]] GUISetAccelerators($Accle) While 1 $hMsg = GUIGetMsg() Switch $hMsg Case $GUI_EVENT_CLOSE Exit Case $cInputDummy If _WinAPI_GetFocus() = GUICtrlGetHandle($hInput) Then BClick() EndIf Case $hButton BClick() EndSwitch WEnd Func BClick() MsgBox(0,"","Button is Clicked") EndFuncM231 point
-
@kcvinu My pleasure1 point
-
Here is a live example which I use in my program: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $g_hMainGUI = GUICreate("Test") Global $g_idMainGUI_YesDummy = GUICtrlCreateDummy() Global $g_idMainGUI_NoDummy = GUICtrlCreateDummy() Global $g_idMainGUI_TryAgainDummy = GUICtrlCreateDummy() Global $g_idMainGUI_AbortDummy = GUICtrlCreateDummy() Local $aAccelKeys[4][2] = [["y", $g_idMainGUI_YesDummy], ["n", $g_idMainGUI_NoDummy], ["t", $g_idMainGUI_TryAgainDummy], ["a", $g_idMainGUI_AbortDummy]] GUISetAccelerators($aAccelKeys, $g_hMainGUI) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $g_idMainGUI_YesDummy MsgBox($MB_OK, "Test", "You pressed 'y' which means Yes!") Case $g_idMainGUI_NoDummy MsgBox($MB_OK, "Test", "You pressed 'n' which means No!") Case $g_idMainGUI_TryAgainDummy MsgBox($MB_OK, "Test", "You pressed 't' which means Try Again!") Case $g_idMainGUI_AbortDummy MsgBox($MB_OK, "Test", "You pressed 'a' which means Abort!") EndSwitch WEndTD1 point
-
kcvinu, I always use _WinAPI_GetFocus to test which control has it: Case $hButton If _WinAPI_GetFocus() = GUICtrlGetHandle($hInput) Then BClick() EndIfand that works for me. M231 point
-
TheDcoder, Delighted to hear that you are checking - I expected no less. And as to "manual" ini file edits, I would want the Case Else code to differ from the "normal" Case and additionally re-edit the ini file to the correct value for future use - which implies a separate Else case as is currently the case. Anyway, enough of this - I am out. M231 point
-
@kcvinu You can use a dummy control for the purpose M23 mentioned1 point
-
kcvinu, Just check which control has focus when the Accelerator key is actioned and only proceed if the correct one is focused. M231 point
-
You guys really ought to get a life, way too serious ... and in my view, one of the biggest problems with the world. Stay in touch with your inner child. There are no rewards for being so super mature you are a boring old fart. P.S. Don't bother to start an argument with me, for I shall not reply. There will be those who agree with me, and those like yourselves, who do not, and will not change anyway. I made my replies, purely in support of TheDcoder and those who wish to be all encompassing as a human being.1 point
-
Don't agree, they indicate tone and humor, and I find TheDcoder to be quite mature for his age.1 point
-
Correct, you need to click on the cell, or cell's child object, such as the image.1 point
-
$age = 14; switch ($age) { case 14: var_dump('So much to learn'); break; case 15: default: // So horrible to read var_dump('So much to learn but getting older'); }If you want to add "hacks" to AutoIt, then just migrate to PHP (a language you know)1 point
-
ThDcoder, I am not "jumping on" you - and I have yet to see the "flaw" that you claim to have found as I have managed to deal with every case (pun intended) you have so far put forward. M231 point
-
Windows Environment Variables Viewer
coffeeturtle reacted to wakillon for a topic
You're right. Script updated. Thanks.1 point -
Sphere Outro build 2015-10-29
coffeeturtle reacted to UEZ for a topic
Here a little Outro for all the animation lovers which I created when I played around with spheres. Download: Sphere Outro.7z --=> 7-Zip archive Credits: Eukalyptus (GDIPlusEx.au3 -> don't search for it because it is not released for the public ) wakillon & TitchySID.dll creator If it is too slow reduce the stars in line 77 (-=> $iStars) If you cannot see the fade in/out text change in line 152 the font name from "Plantagenet Cherokee" to "Times New Roman"!1 point -
Unfinished Video Player
coffeeturtle reacted to Enforcer for a topic
1 point -
Just wanted to update this because I finally figured out what was going on. Originally I think I had a syntax error, possibly a missing space before /c or something. Eventually the script starts working on XP, but not 7x64. Shortcut still getting copied, but missing its icon. Finally I searched to see if the icon is going somewhere else, and I find a copy of it in WindowsSysWOW64, and then it's all clear what was going on. For those who (like me) were not aware, when running a 32-bit executable on 64-bit Windows, the OS will redirect calls for System32 to SysWOW64. To overcome this, you can use %windir%SysNative instead of %windir%system32. Sysnative is just a special alias that tells the OS not to redirect the folder access. Note that it can't be used by 64-bit applications as it is a virtual directory. Hopefully this helps someone else in the future. Also if someone lets me know how, I'll change the title of this thread to include [sOLVED].1 point
-
So, this is my first UDF that I like to share with you all. It can be used to capture debug information written by programs using the OutputDebugString API. A lot of programs write useful information using OutputDebugString. I searched for a way to capture this information and came across this link. This describes a way to read debug information using C++. My first attempt was to try and rewrite this in pure AutoIt using DllCalls. But I guessed it was to much work, especially converting all the structures that are needed. So I decided to take a different approach and use a helper DLL. I used the code by Randy Charles Morin and rewritten it as a DLL. Additionally I made a wrapper UDF. I have put the DLL, UDF and a simple example of a viewer in this ZIP: DebugCapture.zip The DLL is written using Visual Studio 6. For those who are interested, I included the source: DebugCaptureDLLSource.zip The UDF contains 3 functions: _StartDebugCapture() This function loads the helper DLL and starts the capturing process. As soon as this function successfully returns, you have to call _GetDebugOutput() regularly to read the debug information. If you don't read the debug information, you will block the processes trying to write this information for a while (the OutputDebugString() API will block for a maximum time of 10 seconds). _StopDebugCapture() Call this function if you don't want to process debug information anymore. _GetDebugOutput() Call this on a regular basis, to read the debug information. The function is non blocking. If there is nothing to read it will just return an empty string. If you call this function with no parameters it will return all debug information. Optionally you can call it with a PID (for example returned by Run). That way you will only get the debug information written by that specific process. @extended is always set to the PID of the process that outputted the information. That's about it. Hope it's useful. Comments and suggestions are welcome! Steve1 point