Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/27/2020 in all areas

  1. Nine

    detect long key press

    My best effort. I have spent way too much time on this . But it was fun. It is not perfect, but maybe with some tweeks... #include <WinAPIConv.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <Misc.au3> Global Const $iVKStart = 0x41, $iIDBase = 0x0100 OnAutoItExitRegister('OnAutoItExit') Local $hWnd = GUICreate("") GUIRegisterMsg($WM_HOTKEY, 'WM_HOTKEY') HotKeySet("{ESC}", _Exit) For $i = $iVKStart To $iVKStart + 25 _WinAPI_RegisterHotKey($hWnd, $iIDBase + $i, 0, $i) Next While 1 Sleep(100) WEnd Func WM_HOTKEY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $iCount = 0, $iVK = _WinAPI_HiWord($lParam), $sVK = Hex($iVK, 2), $iFirst = Asc("a") Local $char = Chr($iVK - $iVKStart + $iFirst) While _IsPressed($sVK) $iCount += 1 WEnd If $iCount > 15000 Then Send(StringUpper($char)) Else _WinAPI_UnregisterHotKey($hWnd, $iIDBase + $iVK) Send($char) _WinAPI_RegisterHotKey($hWnd, $iIDBase + $iVK, 0, $iVK) EndIf EndFunc ;==>WM_HOTKEY Func OnAutoItExit() For $i = $iVKStart To $iVKStart + 25 _WinAPI_UnregisterHotKey($hWnd, $iIDBase + $i) Next EndFunc ;==>OnAutoItExit Func _Exit() Exit EndFunc ;==>_Exit
    3 points
  2. There's a difference between $a1 and $aL!
    3 points
  3. Switch $al @Musashi: There's a difference between $a1 and $aL!
    2 points
  4. I love the help file and all the information it contains. Its fatal flaw is that it can't be added to. I create a lot of wrapper functions and install a lot of UDFs, so it gets tiring opening the include file each time I need to remember if it returns a 0 or 1 based array, what this particular error means, or what the argument should be. I've been fed up with this for too long, hence this script. Features Reads *.au3 files to parse UDF style headers to get function information (the UDF header style is defined here, thanks water!) Supports multiple search paths Integration with SciTe (more on this later) Stores function documentation so it doesn't need to re-read files each startup (Currently, in a config file) Only updates a file based on it's last modification date Will update another instance instead of launching a new one before exiting. Planned Updates Optionally (user's choice) use a SQLite Database to increase storage/read speeds Redirect unknown functions to AutoItHelper.exe to open the almighty Help File Remove functions from folders not in the search folders (would be a lot easier with SQLite) Fully support and parse UDF headers SciTE Integration This took me a while to figure out (I thought I needed to use lua), but it's totally worth it. By editing your "User Options File" aka SciTEUser.properties files, you can launch this file with a keyboard shortcut. I put this in mine: (After compiling) command.41.$(au3)="$(SciteDefaultHome)\..\FunctionDocs.exe" "$(CurrentWord)" command.name.41.$(au3)=Personal Function Docs command.shortcut.41.$(au3)=Shift+F1 command.subsystem.41.$(au3)=2 command.save.before.41.$(au3)=2 command.quiet.41.$(au3)=1 (Note that 41 is an unused command number. You may need to change this if you've added other tools) It says (respectively): * Launch FunctionDocs.exe from the directory above SciTE.exe with the currently selected word as a command line parameter * Make the MenuItem in SciTE named "Personal Function Docs" * Use Shift F1 as the shortcut to start the program * (I don't know) * Don't save the file before launching the program * (And my favorite) Don't clear SciTE's output panel
    1 point
  5. You need to allow the page to load before continuing. Either change the _IECreate so that it waits for the page to load (change next to last parameter to 1) or add an _IELoadWait.
    1 point
  6. The following shows a couple of ways to process an array of JSON objects. The examples are over-simplified and do not contain any error checking. You can add your own error checking, code optimization, and modification of the logic as needed. #Include <json.au3> ;<== Change to your location Global Const $JSON_DATA = _ '{' & _ ' "result":{' & _ ' "items":[' & _ ' {"name":"Becky", "age":8},' & _ ' {"name":"Dave", "age":6},' & _ ' {"name":"Ashley", "age":7}' & _ ' ]' & _ ' }' & _ '}' for_in_next_example() for_next_example() Func for_in_next_example() ConsoleWrite("For...In...Next Example" & @CRLF) Local $oJson = Json_Decode($JSON_DATA) ;Decode JSON string Local $aoItems = Json_Get($oJson, ".result.items") ;Get array of "Items" objects Local $sName Local $iAge For $oItem in $aoItems $sName = Json_Get($oItem, ".name") $iAge = Json_Get($oItem, ".age") ConsoleWrite($sName & " is " & $iAge & @CRLF) Next ConsoleWrite(@CRLF) EndFunc Func for_next_example() ConsoleWrite("For...Next Example" & @CRLF) Local $oJson = Json_Decode($JSON_DATA) ;Decode JSON string Local $aoItems = Json_Get($oJson, ".result.items") ;Get array of "Items" objects Local $iItemCount = UBound(Json_Get($oJson, ".result.items")) Local $sName Local $iAge For $i = 0 To $iItemCount - 1 $sName = Json_Get($aoItems[$i], ".name") $iAge = Json_Get($aoItems[$i], ".age") ConsoleWrite($sName & " is " & $iAge & @CRLF) Next ConsoleWrite(@CRLF) EndFunc Output: For...In...Next Example Becky is 8 Dave is 6 Ashley is 7 For...Next Example Becky is 8 Dave is 6 Ashley is 7
    1 point
  7. But why don't you directly access the array$a_test or store the data in a new array instead of dynamically creating variables?
    1 point
  8. Oh F**k . My eyes don't get better with age either. Here the whole function without the annoying variable name : Func Start() Local $numberOfLoops = 61 For $iNum = 2 TO $numberOfLoops MoveMouseToStartOrSkipAndClick() sleep(1000) Switch $iNum Case 6, 12, 18, 24, 30, 36, 42, 48, 54 MoveMouseToSkipConfirmationAndClick() Sleep(1000) MoveMouseToStartOrSkipAndClick() Case 11 Sleep(40000) EndSwitch Sleep(40000) MoveMouseOffBannerAndClick() Sleep(1000) Next ; comment out function Quit() to keep script running until ESC key is pressed Quit() EndFunc
    1 point
  9. Check the value of @error, like this -- $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "\\your\xpath\here") If @error = $_WD_ERROR_SUCCESS Then _WD_ElementAction($sSession, $sElement, 'click') EndIf P.S. You should definitely review the function header for each of the UDF functions. I've tried to outline the return values and error codes for each one, but let me know if you find where any of the information is missing / incorrect.
    1 point
  10. I highly suggest using AutoItSetOption("MustDeclareVars", True) at the top of all of your scripts. It enforces good programming practices and helps catch those error before you run the program Alternately, you can edit the AutoIt3Wrapper.ini file and set the AU3Check_Parameter line to something like this: (this will apply to every file running Au3 check) AU3Check_Parameter=-d -w 3 -w 4 -w 5 -w 6 -v3
    1 point
  11. @CYCho I was also interested by that issue, so I tested a few different ways : 1- shell.application object 2- DOS if exists 3- WinAPI_FileExists 4- File* functions All give more or less the same timeout delay. I believe the solution provided by Gibbo is the best there is...
    1 point
  12. Nine

    Show windows side by side

    #include <Constants.au3> SnapExplorer () If @error Then MsgBox ($MB_SYSTEMMODAL,"Error",@error) Func SnapExplorer () Local $aWin = WinList ("[CLASS:CabinetWClass]") If $aWin[0][0] <> 2 Then Return SetError (1) $iW = int(@DesktopWidth / $aWin[0][0]) $iH = @DesktopHeight - 40 For $i = 1 to $aWin[0][0] WinActivate ($aWin[$i][1]) WinMove ($aWin[$i][1],"", ($i-1)*$iW, 0,$iW, $iH, 1) Next EndFunc Try this
    1 point
  13. Windows key + Left arrow or Right arrow: Snap selected window to the left or right half of the screen. Then select another window to fit the opposite half.
    1 point
  14. Haven't seen that one before. Have you ruled out AV interference?
    1 point
  15. Check out this guide from MS -- https://docs.microsoft.com/en-us/exchange/mail-flow/test-smtp-with-telnet?view=exchserver-2019
    1 point
  16. When posting code use this tool. If you can edit your last post, please do so. Otherwise, maybe a mod could do it for your.
    1 point
  17. ReplyRecipient has been added to version 1.5.0.0 of the UDF. You simply need to set the type parameter to $olReplyRecipient. More details can be found on the download page or the history.
    1 point
  18. The User @Ward has left the Forum 2015. Unfortunately, he has also removed almost all his attachments.
    1 point
  19. water

    COM Obj Error Handling

    First step is to read the section about objects in the help file. Then have a look at the Excel or Word UDF that come with AutoIt. Then have a look at the MSDN pages for the Excel or Word object model. Then check some example scripts in the forum like this. Happy reading
    1 point
  20. Hey Guys, Searching multiple forum Topic's i realized that a timeout option isn't coming soon on this function. So i created a simple alternative for the InetRead Function. My function is first looking for the domain prefix by using the _URLSplit() Function from SmOke_N (Thanks! ) Then the function simply tries a InetGet on this domain withhout waiting for it, and starting a loop for Timeout. If InetGetInfo is receiving a Download Complete command the function is relaying the complete URL to the original InetRead() function, then returning the Data. For yours to use if needed, it is working perfectly here #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <array.au3> ; Read Website _InetRead("http://www.geenverbinding.nl/",1,2000) ; Show Msgbox before Ending Script. Msgbox(64,"","Finished") Func _InetRead($IR_URL,$IR_OPTIONS = 1,$IR_TIMEOUT = 2000) ; Define Var's Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) Local $ProcessCounter = 0 Local $ReadedOutput, $GetDomain $GetDomain = _URLSplit($IR_URL) If NOT IsArray($GetDomain) Then Return "" ; Start Connection to Server, Forced Reload. Local $hDownload = InetGet($GetDomain[1]&"://"&$GetDomain[2], $sFilePath, 1, 1) ; Start loop for Timeout Do Sleep(50) $ProcessCounter += 1 Until InetGetInfo($hDownload, 2) OR $ProcessCounter > ($IR_TIMEOUT/50) ; Close the handle returned by InetGet. InetClose($hDownload) ; Delete the file. FileDelete($sFilePath) If $ProcessCounter > ($IR_TIMEOUT/50) Then Return "" $ReadedOutput = InetRead($IR_URL,$IR_OPTIONS) Return $ReadedOutput EndFunc Func _URLSplit($szUrl) Local $sSREPattern = '^(?s)(?i)(http|ftp|https|file)://(.*?/|.*$)(.*/){0,}(.*)$' Local $aUrlSRE = StringRegExp($szUrl, $sSREPattern, 2) If Not IsArray($aUrlSRE) Or UBound($aUrlSRE) - 1 <> 4 Then Return SetError(1, 0, 0) If StringRight($aUrlSRE[2], 1) = '/' Then $aUrlSRE[2] = StringTrimRight($aUrlSRE[2], 1) $aUrlSRE[3] = '/' & $aUrlSRE[3] EndIf $szProtocol = $aUrlSRE[1] $szDomain = $aUrlSRE[2] $szPath = $aUrlSRE[3] $szFile = $aUrlSRE[4] Return $aUrlSRE EndFunc ;==>_URLSplit Just paste these Functions in your script, then simply add the Underscore to all your InetRead functions, enjoy! PS: Standard Timeout Setting is 2000 (Milliseconds), but you can change it to your needs.
    1 point
  21. An example of how to remove blanks using only the original array. Func _ArryRemoveBlanks(ByRef $arr) $idx = 0 For $i = 0 To UBound($arr) - 1 If $arr[$i] <> "" Then $arr[$idx] = $arr[$i] $idx += 1 EndIf Next ReDim $arr[$idx] EndFunc ;==>_ArryRemoveBlanks ;Some code just to show it working #include <array.au3> Dim $arr1[10] $arr1[0] = "" $arr1[1] = "ABC" $arr1[2] = "" $arr1[3] = "xyz" $arr1[4] = "def" $arr1[5] = "" $arr1[6] = "" $arr1[7] = "ffr" $arr1[8] = "" $arr1[9] = "Z33" _ArrayDisplay($arr1, "Before") _ArryRemoveBlanks($arr1) _ArrayDisplay($arr1, "After")
    1 point
  22. Valik

    _MakeLong, _HiWord, _LoWord

    These functions store and retrieve 16 bit values in/from a 32 bit value. ; =================================================================== ; _MakeLong($a, $b) ; ; Concatenates two 16 bit values into one 32 bit value. ; Parameters: ; $l - IN - The low order word (Lowest 16 bits) ; $h - IN - The high order word (Highest 16 bits) ; Returns: ; The two 16 bit values concatenated into a single 32 bit value. ; Notes: ; Retrieve the values with HiWord and LoWord respectively. ; =================================================================== Func _MakeLong($l, $h) Return BitOR(BitAnd($l, 0xFFFF), BitShift(BitAnd($h, 0xFFFF), -16)) EndFunc ; _MakeLong() ; =================================================================== ; _HiWord($x) ; ; Retrieves the high-order word from the 32 bit argument. ; Parameters: ; $x - IN - A 32 bit argument created with _MakeLong() ; Returns: ; The highest 16 bits from the 32 bit integer. ; =================================================================== Func _HiWord(ByRef $x) Return BitShift($x, 16) EndFunc ; _HiWord() ; =================================================================== ; _LoWord($x) ; ; Retrieves the low-oder word from the 32 bit argument ; Parameters: ; $x - IN - A 32 bit argumented created with _MakeLong() ; Returns: ; The lowest 16 bits from the 32 bit integer. ; =================================================================== Func _LoWord(ByRef $x) Return BitAnd($x, 0xFFFF) EndFunc ; _LoWord() Can be tested with: Local $a = _MakeLong(100, 200) MsgBox(4096, "High", _HiWord($a)) MsgBox(4096, "Low", _LoWord($a)) Edit: Added ByRef to _HiWord()/_LoWord() to help make sure the correct parameter is passed (Meaning, a literal string can't be passed by somebody incorrectly using those functions).
    1 point
×
×
  • Create New...