Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/16/2019 in all areas

  1. I've figured it out. You have to be very careful to find the top window directly from the Desktop in this way: ; --- Find HomeSeer HS3 window --- ConsoleWrite( "--- Find HomeSeer HS3 window ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreateTrueCondition( $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pElements $oDesktop.FindAll( $TreeScope_Children, $pCondition0, $pElements ) ; Top windows only If Not $pElements Then Return ConsoleWrite( "$pElements ERR" & @CRLF ) ConsoleWrite( "$pElements OK" & @CRLF ) Local $oAutomationElementArray, $iLength $oAutomationElementArray = ObjCreateInterFace( $pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oAutomationElementArray.Length( $iLength ) If Not $iLength Then Return ConsoleWrite( "$iLength ERR" & @CRLF ) ConsoleWrite( "$iLength = " & $iLength & @CRLF ) ConsoleWrite( "$iLength OK" & @CRLF ) Local $pWindow, $oWindow, $sName For $i = 0 To $iLength - 1 $oAutomationElementArray.GetElement( $i, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oWindow.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName ) If $sName <> "HomeSeer HS3" Then ContinueLoop ConsoleWrite( "$sName = " & $sName & @CRLF ) ExitLoop Next If $i = $iLength Then Return ConsoleWrite( "$oWindow ERR" & @CRLF ) ConsoleWrite( "$oWindow OK" & @CRLF ) This technique will be included in the next version of UIASpy in a week. Full code: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Open HomeSeer Run( "C:\Program Files (x86)\HomeSeer HS3\HS3.exe" ) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Sleep( 1000 ) ; 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 Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find HomeSeer HS3 window --- ConsoleWrite( "--- Find HomeSeer HS3 window ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreateTrueCondition( $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pElements $oDesktop.FindAll( $TreeScope_Children, $pCondition0, $pElements ) ; Top windows only If Not $pElements Then Return ConsoleWrite( "$pElements ERR" & @CRLF ) ConsoleWrite( "$pElements OK" & @CRLF ) Local $oAutomationElementArray, $iLength $oAutomationElementArray = ObjCreateInterFace( $pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oAutomationElementArray.Length( $iLength ) If Not $iLength Then Return ConsoleWrite( "$iLength ERR" & @CRLF ) ConsoleWrite( "$iLength = " & $iLength & @CRLF ) ConsoleWrite( "$iLength OK" & @CRLF ) Local $pWindow, $oWindow, $sName For $i = 0 To $iLength - 1 $oAutomationElementArray.GetElement( $i, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oWindow.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName ) If $sName <> "HomeSeer HS3" Then ContinueLoop ConsoleWrite( "$sName = " & $sName & @CRLF ) ExitLoop Next If $i = $iLength Then Return ConsoleWrite( "$oWindow ERR" & @CRLF ) ConsoleWrite( "$oWindow OK" & @CRLF ) ; --- Find Register Now... button --- ConsoleWrite( "--- Find Register Now... button ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Register Now...", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pButton1, $oButton1 $oWindow.FindFirst( $TreeScope_Descendants, $pCondition1, $pButton1 ) $oButton1 = ObjCreateInterface( $pButton1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oButton1 ) Then Return ConsoleWrite( "$oButton1 ERR" & @CRLF ) ConsoleWrite( "$oButton1 OK" & @CRLF ) ; --- Invoke Pattern (action) Object --- ConsoleWrite( "--- Invoke Pattern (action) Object ---" & @CRLF ) Local $pInvokePattern, $oInvokePattern $oButton1.GetCurrentPattern( $UIA_InvokePatternId, $pInvokePattern ) $oInvokePattern = ObjCreateInterface( $pInvokePattern, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvokePattern ) Then Return ConsoleWrite( "$oInvokePattern ERR" & @CRLF ) ConsoleWrite( "$oInvokePattern OK" & @CRLF ) ; --- Invoke Pattern (action) Methods --- ConsoleWrite( "--- Invoke Pattern (action) Methods ---" & @CRLF ) ConsoleWrite( "$oInvokePattern.Invoke()" & @CRLF ) $oInvokePattern.Invoke() EndFunc $oUIAutomation OK $oDesktop OK --- Find HomeSeer HS3 window --- $pCondition0 OK $pElements OK $iLength = 8 $iLength OK $sName = HomeSeer HS3 $oWindow OK --- Find Register Now... button --- $pCondition1 OK $oButton1 OK --- Invoke Pattern (action) Object --- $oInvokePattern OK --- Invoke Pattern (action) Methods --- $oInvokePattern.Invoke()
    2 points
  2. trancexx

    GIF Animation

    No it doesn't speak, I lied. That is impossible. It's about setting animated GIF (and every other type of images) to a GUI control. How is this done for animated GIF? Few simple steps: - created ImageList of GIF Bitmaps retrieved from gif file/resource - created Pic control - every now and then another image is displayed. This is determined by frame delay time - see gif specification somewhere. That's it. All that takes time and could potentially block our gui/script. That's why flying assembly is used. Animation is done in another thread different from one AutoIt's code is executed in. Nothing stops animation but you. Animation works both for x64 and x86. Also it works for all kind of images not only GIFs. That means you can use it to display PNGs, BMPs, JPGs, etc... All of them from resources too. Example: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GIFAnimation.au3" Opt("MustDeclareVars", 1) ; Start by choosing GIF to display Global $sFile = FileOpenDialog("Choose Image", "", "(*.gif;*.png;*.jpg;*.tiff;*.bmp;*.jpeg)", -1, "") If @error Then Exit ; Make GUI Global $hGui = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW) ; Add some buttons Global $hButton = GUICtrlCreateButton("&Pause animation", 50, 450, 100, 25) Global $hButton1 = GUICtrlCreateButton("&Delete Control", 200, 450, 100, 25) Global $hButton2 = GUICtrlCreateButton("&Open Image", 350, 450, 100, 25) ; Make GIF Control Global $hGIF = _GUICtrlCreateGIF($sFile, "", 10, 10) If @extended Then GUICtrlSetState($hButton, $GUI_DISABLE) GUICtrlSetTip($hGIF, "Image") ; Additional processing of some windows messages (for example) GUIRegisterMsg(133, "_Refresh") ; WM_NCPAINT GUIRegisterMsg(15, "_ValidateGIFs") ; WM_PAINT Global $iPlay = 1 ; Show it GUISetState() ; Loop till end While 1 Switch GUIGetMsg() Case -3 Exit Case $hButton If $iPlay Then If _GIF_PauseAnimation($hGIF) Then $iPlay = 0 GUICtrlSetData($hButton, "Resume animation") EndIf Else If _GIF_ResumeAnimation($hGIF) Then $iPlay = 1 GUICtrlSetData($hButton, "Pause animation") EndIf EndIf Case $hButton1 _GIF_DeleteGIF($hGIF) Case $hButton2 $sFile = FileOpenDialog("Choose gif", "", "(*.gif;*.png;*.jpg;*.tiff;*.bmp;*.jpeg)", -1, "", $hGui) If Not @error Then _GIF_DeleteGIF($hGIF); delete previous $hGIF = _GUICtrlCreateGIF($sFile, "", 10, 10) If @extended Then GUICtrlSetState($hButton, $GUI_DISABLE) Else GUICtrlSetState($hButton, $GUI_ENABLE) EndIf GUICtrlSetTip($hGIF, "Image") $iPlay = 1 GUICtrlSetData($hButton, "Pause animation") EndIf EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GIF_RefreshGIF($hGIF) EndFunc ;==>_Refresh Func _ValidateGIFs($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GIF_ValidateGIF($hGIF) EndFunc ;==>_ValidateGIFs It should be 0% cpu. Download from here if you want to impress chicks: http://code.google.com/p/gif-animation/downloads/list There are 8 examples in there. GIF files are downloaded automatically if some example script needs it. Mostly from photobucket.com. Some examples work without classic download. Required data is get with InetRead(). That's mighty cool. So, download, open ZIP, grab folder inside and place it where you want. Run examples and that's it. Word or two about main function, _GUICtrlCreateGIF(). It can handle all sorts of input. Will display Images that are passed as binary, resource identifiers, strings, file names, ... everything. If it's valid image all works. For example, all this is valid: ; Pass GIF File path/name _GUICtrlCreateGIF("Some.gif", "", 10, 10) ; Binary data _GUICtrlCreateGIF($bGIF, "", 10, 10,) ; PE Resource (file GIF.dll, Type: GIF, Name: 4) _GUICtrlCreateGIF("GIF.dll", "GIF;4", 10, 10, 100, 120) ; PE Resource (file @AutoItExe, Type: RES, Name: BLAH, Language: 1033) _GUICtrlCreateGIF(@AutoItExe, "RES;BLAH;1033", 10, 10) ; PE Resource (file "explorer.exe", Type: 2, Name: 6801) _GUICtrlCreateGIF("explorer.exe", "2;6801", 10, 10) ;<- BITMAP ; PE Resource (file @AutoItExe, Type: RC_DATA, Name: PNG) _GUICtrlCreateGIF(@AutoItExe, "10;PNG", 10, 10) ; GIF string _GUICtrlCreateGIF(FileRead("Some.gif"), "", 10, 10) ____________________________________________
    1 point
  3. Tested on a very long song 25.5 mins. So far so good...win7
    1 point
  4. Thanks for testing, I'll update the UDF https://docs.microsoft.com/en-us/windows/desktop/api/Audioclient/nf-audioclient-iaudioclient-initialize On Windows versions prior to Windows 10, a pull-mode capture client will not receive any events when a stream is initialized with event-driven buffering (AUDCLNT_STREAMFLAGS_EVENTCALLBACK) and is loopback-enabled (AUDCLNT_STREAMFLAGS_LOOPBACK). If the stream is opened with this configuration, the Initialize call succeeds, but relevant events are not raised to notify the capture client each time a buffer becomes ready for processing. To work around this, initialize a render stream in event-driven mode. Each time the client receives an event for the render stream, it must signal the capture client to run the capture thread that reads the next set of samples from the capture endpoint buffer. As of Windows 10 the relevant event handles are now set for loopback-enabled streams that are active. Note that all streams must be opened in share mode because exclusive-mode streams cannot operate in loopback mode. For more information about audio loopback, see Loopback Recording. LIES!
    1 point
  5. lol, it did work with the 1st try, so did with the 2nd. Sowy. and thanks =D
    1 point
  6. I have the Schiit Magni amp and Modi Multibit Dac at home. I’ll test with that and my internal sound device too.
    1 point
  7. @Parsix Why didn't you create a new post in which you explain your issue and show us what have you tried so far, instead of bumping a four years old one? Better for you to read carefully this and this before posting again
    1 point
  8. Another no-ReDim version: #include <File.au3> Local $s = FileRead("testdata.csv") $s = StringStripWS($s, $STR_STRIPLEADING + $STR_STRIPTRAILING ) ; remove any superflous \R $s = StringRegExpReplace($s, '("[^"\v]*"|[^",\v]*)(,)', '$1' & ChrW(0xFFFD)) ; comma separators -> 0xFFFD (Unicode "Not a Character") Local $t = _TempFile('.\') Local $h = FileOpen($t, $FO_OVERWRITE) FileWrite($h, $s) FileClose($h) Local $aData _FileReadToArray($t, $aData, $FRTA_NOCOUNT, ChrW(0xFFFD)) FileDelete($t) _ArrayDisplay($aData)
    1 point
  9. @Earthshine I Updated the UDF and Example to add some more info Try that and post the console output It might be that your device doesn't support event mode I still need to flesh out the error handling Error handling should be in a much better state now
    1 point
  10. This is what i wanted to post in the first place. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 0) Opt("GUIEventOptions", 1) Example() Func Example() GUICreate("My GUI Context Menu", 300, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") Global $Controls[3] $Controls[0] = GUICtrlCreateButton('1', 10, 10, 50, 20) GUICtrlSetOnEvent(-1, 'button1') $Controls[1] = GUICtrlCreateButton('2', 10, 40, 50, 20) GUICtrlSetOnEvent(-1, 'button1') $Controls[2] = GUICtrlCreateButton('3', 10, 70, 50, 20) GUICtrlSetOnEvent(-1, 'button1') GUISetState(@SW_SHOW) For $c = 0 To UBound($Controls)-1 Local $idContextmenu = GUICtrlCreateContextMenu($Controls[$c]) Local $idNewsubmenu = GUICtrlCreateMenu("new", $idContextmenu) Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu) GUICtrlSetOnEvent(-1, "text") Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu) GUICtrlSetOnEvent(-1, "info") Next EndFunc While 1 Sleep(100) WEnd Func text() MsgBox(64 + 262144, '', 'text') EndFunc Func info() MsgBox(64 + 262144, '', 'info') EndFunc Func button1() MsgBox(64 + 262144, '', '') EndFunc Func Quit() Exit EndFunc ;==>Quit
    1 point
  11. Local $ProductName, $oIE2 Local $oInputs = _IETagNameGetCollection($oIE1, "a") For $oInput In $oInputs If $oInput.title = "More Information" Then Send("{tab}") $oIE2 = _IECreateTab ($oIE1, $oInput.href) $ProductName = $oInput.innerText DoYourStuff ($ProductName) _IEQuit ($oIE2) Endif Next This is my last attempt. For now you should be able to complete your work by yourself and with your best friend : the autoit help file.
    1 point
  12. cdkid

    _FileWriteToLine

    Well, i've been wanting to write to a specific line for logging stuff w/o racking up a HUGE file so here is how i did it... ;======================================== ;Function name: _FileWriteToLine ;Description: Write text to specified line in a file ;Parameters: ; $sFile - The file to write to ; $iLine - The line number to write to ; $sText - The text to write ; $fOverWrite - if set to 1 will overwrite the old line ; if set to 0 will not overwrite ;Requirement(s): None ;Return Value(s): On success - 1 ; On Failure - 0 And sets @ERROR ; @ERROR = 1 - File has less lines than $iLine ; @ERROR = 2 - File does not exist ; @ERROR = 3 - Error opening file ; @ERROR = 4 - $iLine is invalid ; @ERROR = 5 - $fOverWrite is invalid ; @ERROR = 6 - $sText is invalid ;Author(s): cdkid ;Note(s): ;========================================= Func _FileWriteToLine($sFile, $iLine, $sText, $fOverWrite = 0) If $iLine <= 0 Then SetError(4) Return 0 EndIf If Not IsString($sText) Then SetError(6) Return 0 EndIf If $fOverWrite <> 0 And $fOverWrite <> 1 Then SetError(5) Return 0 EndIf If Not FileExists($sFile) Then SetError(2) Return 0 EndIf $filtxt = FileRead($sFile, FileGetSize($sFile)) $filtxt = StringSplit($filtxt, @CRLF, 1) If UBound($filtxt, 1) < $iLine Then SetError(1) Return 0 EndIf $fil = FileOpen($sFile, 2) If $fil = -1 Then SetError(3) Return 0 EndIf For $i = 1 To UBound($filtxt) - 1 If $i = $iLine Then if $fOverWrite = 1 then if $sText <> '' Then FileWrite($fil, $sText & @CRLF) Else filewrite($fil, $sText) EndIf EndIf If $fOverWrite = 0 Then FileWrite($fil, $filtxt[$i] & @CRLF) EndIf ElseIf $i < UBound($filtxt, 1) - 1 Then FileWrite($fil, $filtxt[$i] & @CRLF) ElseIf $i = UBound($filtxt, 1) - 1 Then FileWrite($fil, $filtxt[$i]) EndIf Next FileClose($fil) Return 1 EndFunc;==>_FileWriteToLine ~cdkid EDIT updated it so i THINK it works with all the things MHz mentioned... tell me if i'm wrong /EDIT EDIT2 updated again, and have sent it in for the UDF library /EDIT2 EDIT3 updated it with the version that has been sent in for the UDF library /EDIT3 EDIT4 updated so if $sText is "" and $fOverWrite is 1 deletes line rather than replacing it with "" /EDIT4
    1 point
×
×
  • Create New...