Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/16/2022 in all areas

  1. A shorter version, not relying on the word 'Edit', but assuming the editcontrol has keyboard focus (only tested on windows 10 with standard notepad): #include <MsgBoxConstants.au3> Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) ; Retrieve the control that has keyboard focus in Notepad. Local $sEditControl = ControlGetFocus($hWnd) ; Display the control that has keyboard focus. MsgBox($MB_SYSTEMMODAL, "", "The control that has keyboard focus in Notepad is: " & $sEditControl) ; Set the edit control in Notepad with some text. The handle returned by WinWait is used for the "title" parameter of ControlSetText. ControlSetText($hWnd, "", $sEditControl, "This is some text") ; Retrieve the text of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetText. Local $sText = ControlGetText($hWnd, "", $sEditControl) ; Display the text of the edit control. MsgBox($MB_SYSTEMMODAL, "", "The text in Edit1 is: " & $sText) ; Close the Notepad window using the handle returned by WinWait. WinClose($hWnd) EndFunc ;==>Example
    3 points
  2. Tested with Insider Preview 21H2 Build 25131 (Dev Channel). This works everywhere: #include <MsgBoxConstants.au3> Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) ; Get the class for the Edit control Local $sText, $sEditControl = _GetNotepadEditClass($hWnd) & "1" If Not @error Then ; Set the edit control in Notepad with some text. The handle returned by WinWait is used for the "title" parameter of ControlSetText. ControlSetText($hWnd, "", $sEditControl, "This is some text") ; Retrieve the text of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetText. $sText = ControlGetText($hWnd, "", $sEditControl) ; Display the text of the edit control. MsgBox($MB_SYSTEMMODAL, "", "The text in " & $sEditControl & " is: " & $sText) EndIf ; Close the Notepad window using the handle returned by WinWait. WinClose($hWnd) EndFunc ;==>Example Func _GetNotepadEditClass($hWnd) Local $aClassList = StringSplit(WinGetClassList($hWnd), @LF) For $n = 1 To $aClassList[0] If StringInStr($aClassList[$n], "Edit") Then Return $aClassList[$n] Next Return SetError(1, 0, "") EndFunc ;==>_GetNotepadEditClass This is the class list from the new Notepad: Windows.UI.Composition.DesktopWindowContentBridge Windows.UI.Input.InputSite.WindowClass Windows.UI.Composition.DesktopWindowContentBridge Windows.UI.Input.InputSite.WindowClass Windows.UI.Core.CoreWindow Windows.UI.Composition.DesktopWindowContentBridge Windows.UI.Input.InputSite.WindowClass RichEditD2DPT msctls_statusbar32 Windows.UI.Composition.DesktopWindowContentBridge Windows.UI.Input.InputSite.WindowClass Windows.UI.Composition.DesktopWindowContentBridge Windows.UI.Input.InputSite.WindowClass Windows.UI.Composition.DesktopWindowContentBridge Windows.UI.Input.InputSite.WindowClass Note: ...maybe add the _GetNotepadEditClass() to "Examples\Helpfile\Extras", as is going to be needed in every Notepad example counting on "Edit1" to be the expected GUI control.
    2 points
  3. water

    Outlook Folder View

    Something like this? #include <OutlookEX.au3> Global $sSourceFolder = "Inbox" Global $oOutlook = _OL_Open() Global $oExplorer = $oOutlook.ActiveExplorer Global $oSourceFolder = $oExplorer.CurrentFolder ; Check the current folder If $oSourceFolder.Name = $sSourceFolder Then ; Run your login Script here EndIf ; Access the target folder Global $aTargetFolder = _OL_FolderAccess($oOutlook, "", $olFolderSentMail) $oExplorer.CurrentFolder = $aTargetFolder[1]
    1 point
  4. .. is in seconds. But this is AutoIt and the time the editor say it was running is quite meaningless for fraction of seconds. Use a timer ( as @Musashi posted above ) if that measurement has importance. But I do agree that a scientific notation can mess with one's visual Feng Shui Edit: This is my take at a timer thing: OnAutoItExitRegister("_MyExitFunc") Global $g___hStarttime = TimerInit() Func _MyExitFunc() ConsoleWrite(@CRLF & "- Time elapsed = " & TimeTimerDiff( TimerDiff($g___hStarttime) ) & @CRLF & @CRLF) EndFunc ;==>_MyExitFunc Func TimeTimerDiff($ms) Local $day, $iHours, $iMins, $iSecs, $iTicks = $ms, $sMsOut = $ms $iTicks = Int($iTicks / 1000) $iHours = Int($iTicks / 3600) $iTicks = Mod($iTicks, 3600) $iMins = Int($iTicks / 60) $iSecs = Mod($iTicks, 60) If $iHours > 23 Then $day = $iHours / 24 $iHours = Mod($iHours, 24) EndIf $ms = "0000" & $ms Return $sMsOut & @TAB & StringReplace(StringFormat("%03i %02i:%02i:%02i", $day, $iHours, $iMins, $iSecs), "000 ", "") & '.' & StringReplace(StringTrimLeft($ms, StringInStr($ms, ".") - 4), ".", ",") EndFunc ;==>TimeTimerDiff ;~ Sleep(1) Exit I find this clear and readable.
    1 point
  5. What does this do? ConsoleWrite(BinaryToString(StringToBinary("η γλώσσα μου έδωσαν ελληνική", 4), 1) & @CRLF)
    1 point
  6. MHz

    Combine variable name

    Eval takes an expression. This means a string is acceptable rather then an actual variable. Example Local $abc1 = 2 Local $abc2 = 3 Local $abc3 = 4 For $1 = 1 To 3 MsgBox(0, $1, Eval('abc' & $1)) Next All 3 variables are shown in the loop by using the expression of 'abc' & $1
    1 point
  7. czardas

    Combine variable name

    Yes: Look at Eval() in the help file.
    1 point
×
×
  • Create New...