Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/27/2017 in all areas

  1. After a bit of discussion in MP, I can answer the issue raised by @mLipok here The problem is that the string retrieved by the UDF is already UTF8. Writing to a file open with UTF8 flag forces AutoIt to reencode in UTF8 the individual characters of the UTF8 string. Encoding to UTF8 twice in a row makes the string gribberish. In this case (UTF8 input) you just need to filewrite things in a file open with the BINARY flag, no UTF8 at all.
    2 points
  2. Here's a UDF to save and restore the entire clipboard contents. I was inspired by AHK's ClipboardAll function, which is missing from AutoIt's clipboard UDF's. If anyone thinks this is worthy of submitting for Standard UDF inclusion, let me know. Otherwise I won't bother. I'm not sure yet whether memory allocated with _MemGlobalAlloc() is automatically freed when the script closes, so I included the function to free it. If this is not necessary, then it will be removed. Notes on Memory Management: Thanks to Valik and ProgAndy for their helpful discussion. The SetClipboardData() function (_Clipboard_SetDataEx()) transfers ownership of the hMem object to the Clipboard. This means that after running this function your script no longer owns that memory, and should not free it. This means - 1. _Clipboard_GetAll() creates a local script owned copy of the Clipboard in memory. If this copy is never used, ie put back onto the Clipboard with _Clipboard_PutAll(), then it MUST be freed with _Clipboard_MemFree() before exiting the script or reusing the variable again with _Clipboard_GetAll(). If not, the memory may be leaked. 2. If the copied memory is at some point placed back on the Clipboard with _Clipboard_PutAll(), then the Clipboard now owns this memory. You should NOT free it with _Clipboard_MemFree() at this point. UPDATE 1: 2008-09-25 Updated the UDF and example based on the memory management notes above. UPDATE 2: 2009-10-23 Updated to use memcpy_s instead of _MemMoveMemory(). Added some more comments. UPDATE 3: 2009-10-24 Small change to return values of _MemCopyMemory(). Added a second example. _Clipboard.au3 - #include-once #include <Clipboard.au3> Func _Clipboard_GetAll(ByRef $avClip) Local $iFormat = 0, $hMem, $hMem_new, $pSource, $pDest, $iSize, $iErr = 0, $iErr2 = 0 Dim $avClip[1][2] If Not _ClipBoard_Open(0) Then Return SetError(-1, 0, 0) Do $iFormat = _ClipBoard_EnumFormats($iFormat) If $iFormat <> 0 Then ReDim $avClip[UBound($avClip) + 1][2] $avClip[0][0] += 1 ; aClip[n][0] = iFormat, aClip[n][1] = hMem $avClip[UBound($avClip) - 1][0] = $iFormat $hMem = _ClipBoard_GetDataEx($iFormat) If $hMem = 0 Then $iErr += 1 ContinueLoop EndIf $pSource = _MemGlobalLock($hMem) $iSize = _MemGlobalSize($hMem) $hMem_new = _MemGlobalAlloc($iSize, $GHND) $pDest = _MemGlobalLock($hMem_new) _MemCopyMemory($pSource, $pDest, $iSize) If @error Then $iErr2 += 1 _MemGlobalUnlock($hMem) _MemGlobalUnlock($hMem_new) $avClip[UBound($avClip) - 1][1] = $hMem_new EndIf Until $iFormat = 0 _ClipBoard_Close() ; Return: ; | 0 - no errors ; |-2 - _MemGlobalAlloc errors ; |-4 - _MemCopyMemory errors ; |-6 - both errors ; @extended: ; - total number of errors Local $ErrRet = 0 If $iErr Then $ErrRet -= 2 If $iErr2 Then $ErrRet -= 4 If $ErrRet Then Return SetError($ErrRet, $iErr + $iErr2, 0) Else Return 1 EndIf EndFunc Func _ClipBoard_PutAll(ByRef $avClip) ; DO NOT free the memory handles after a call to this function ; the system now owns the memory Local $iErr = 0 If Not IsArray($avClip) Or UBound($avClip, 0) <> 2 Or $avClip[0][0] <= 0 Then Return SetError(-1, 0, 0) If Not _ClipBoard_Open(0) Then Return SetError(-2, 0, 0) If Not _ClipBoard_Empty() Then _ClipBoard_Close() Return SetError(-3, 0, 0) EndIf ; seems to work without closing / reopening the clipboard, but MSDN implies we should do this ; since a call to EmptyClipboard after opening with a NULL handle sets the owner to NULL, ; and SetClipboardData is supposed to fail, so we close and reopen it to be safe _ClipBoard_Close() If Not _ClipBoard_Open(0) Then Return SetError(-3, 0, 0) For $i = 1 To $avClip[0][0] If _ClipBoard_SetDataEx($avClip[$i][1], $avClip[$i][0]) = 0 Then $iErr += 1 Next _ClipBoard_Close() If $iErr Then Return SetError(-4, $iErr, 0) Else Return 1 EndIf EndFunc Func _Clipboard_MemFree(ByRef $avClip) Local $iErr = 0 If Not IsArray($avClip) Or UBound($avClip, 0) <> 2 Or $avClip[0][0] <= 0 Then Dim $avClip[1][2] Return SetError(-1, 0, 0) EndIf For $i = 1 To $avClip[0][0] If Not _MemGlobalFree($avClip[$i][1]) Then $iErr += 1 Next Dim $avClip[1][2] If $iErr Then Return SetError(-2, $iErr, 0) Else Return 1 EndIf EndFunc Func _MemCopyMemory($pSource, $pDest, $iLength) Local $aResult = DllCall("msvcrt.dll", "int:cdecl", "memcpy_s", "ptr", $pDest, "ulong_ptr", $iLength, "ptr", $pSource, "ulong_ptr", $iLength) If @error Then Return SetError(@error, 0, -1) Return SetError(Number($aResult[0] <> 0), 0, $aResult[0]) EndFunc Example 1: copy something to the clipboard first - #include <_Clipboard.au3> #include <Array.au3> Global $aClip ConsoleWrite("->Clipboard contents from ClipGet():" & @CRLF & ClipGet() & @CRLF) _Clipboard_GetAll($aClip) ConsoleWrite(">_Clipboard_GetAll Error: " & @error & @CRLF) _ArrayDisplay($aClip) ConsoleWrite("->Clipboard contents after _Clipboard_GetAll (via ClipGet):" & @CRLF & ClipGet() & @CRLF) _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_Close() ConsoleWrite("->Proof the clipboard is empty: |<" & ClipGet() & ">|" & @CRLF) _ClipBoard_PutAll($aClip) ConsoleWrite(">_Clipboard_PutAll Error: " & @error & @CRLF) ConsoleWrite("->New clipboard contents from ClipGet():" & @CRLF & ClipGet() & @CRLF) Example 2: remove formatting from copied text - #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <_Clipboard.au3> HotKeySet("^v", "_ClearAndPaste") HotKeySet("^+v", "_PasteNormal") While 1 Sleep(1000) WEnd Func OnAutoItExit() ; unset hotkeys HotKeySet("^v") HotKeySet("^+v") EndFunc Func _ClearAndPaste() ; CTRL+v HotKeySet("^v") ; unset hotkey Local $aClip _Clipboard_GetAll($aClip) ; save clipboard contents Local $sClip = ClipGet() ; get clipboard as plain text ClipPut($sClip) ; put clear text back on clipboard Send("^v") ; paste it _Clipboard_PutAll($aClip) ; restore previous contents (clears current contents) HotKeySet("^v", "_ClearAndPaste") ; reset hotkey EndFunc Func _PasteNormal() ; CTRL+SHIFT+v HotKeySet("^v") ; unset hotkey Send("^v") ; paste HotKeySet("^v", "_ClearAndPaste") ; reset hotkey EndFunc
    1 point
  3. @mLipok has a few days vacation and will be starting again during the Saturday graveyard shift. Jos
    1 point
  4. Four versions of Inspect.exe: A 32 and a 64 bit version for a standard CPU and an ARM CPU. You need the two versions for a standard CPU in bin\x86 (32 bit) and bin\x64 (64 bit). They are standalone programs and are not depending on anything else. You can rename the files to Inspect_x86.exe and Inspect_x64.exe and copy the files to a folder of your own. If your application is running 64 bit you should use Inspect_x64.exe. If your application is running 32 bit you should use Inspect_x86.exe. You can find CUIAutomation2.au3 in UIA_V0_63.zip in bottem of first post in the UI Automation framework. Regards Lars.
    1 point
  5. Hi, be sure the AutoIt script run with the same Administrative right you will need to use #requireAdmin if the target program run in admin mode
    1 point
  6. Hi, It is illegal to distribute "office 2007 installation files" so you won't find any here. Also, you have bumped a 10 year old thread, please look at the thread's age before posting in it
    1 point
  7. Helpfile error ::/html/libfunctions/_WinAPI_CreateANDBitMap.htm My Helpfile version 3.3.14.0 Thx Skysnake
    1 point
  8. LerN

    Memory Address Help Please

    I don't think your address is correct and BTW u forgot to add the type of the reading memory _memoryread($address,$memoryopem,'dword') dword = 4 bytes
    1 point
  9. The control IDs you have found through SimpleSpy do not have anything to do with ordinary Windows control IDs. The numbers 50000, 50001, ... are global constants defined in CUIAutomation2.au3: ;module UIA_ControlTypeIds Global Const $UIA_ButtonControlTypeId=50000 Global Const $UIA_CalendarControlTypeId=50001 Global Const $UIA_CheckBoxControlTypeId=50002 Global Const $UIA_ComboBoxControlTypeId=50003 Global Const $UIA_EditControlTypeId=50004 Global Const $UIA_HyperlinkControlTypeId=50005 Global Const $UIA_ImageControlTypeId=50006 Global Const $UIA_ListItemControlTypeId=50007 Global Const $UIA_ListControlTypeId=50008 Global Const $UIA_MenuControlTypeId=50009 Global Const $UIA_MenuBarControlTypeId=50010 Global Const $UIA_MenuItemControlTypeId=50011 ... If the AutoIt Window Info tool can't identify your controls, the best option is to try with the UI Automation framework. Note that if you identify the controls with UI Automation code, you also have to automate the controls with UI Automation code. You cannot use classic automation code. Take a look at this post.
    1 point
  10. You can try: #include <File.au3> ;~ Path for New1.txt, New2.txt etc... Local $sFileSave = @ScriptDir ;~ File Name to Read Local $sFileRead = @ScriptDir & "\Notepad.txt" Local $aFileRead, $hFileOpen _FileReadToArray($sFileRead, $aFileRead) For $i = 1 To $aFileRead[0] ;~ This will create the new file + path (if it doesn't exist), using append mode $hFileOpen = FileOpen($sFileSave & "\New" & $i & ".txt", 9) ;~ Write line to new file with new line at the end FileWrite($hFileOpen, $aFileRead[$i] & @CRLF) ;~ Close the File FileClose($hFileOpen) Next
    1 point
  11. Apparently that file doesn't have the correct layout. It probably isn't signed as well. Try retrieving the latest version directly from Mozilla at https://addons.mozilla.org/en-US/firefox/downloads/latest/mozrepl/addon-264678-latest.xpi?src=dp-btn-primary
    1 point
  12. Already answered this in the following post:
    1 point
  13. KickStarter15

    Possible to ??...

    @LerN, Before I've learned Autoit I have C++, java, and PHP but all this coding from that languages are need more details and sometimes frustrating, I need to study in school for those coding just to learn more. But in autoit, I've been coding for almost a year (reading guides, listen to others advise etc...) and it gives me lots of automations easily (with help from the forum of course....cheers!). I'm currently working in a company that navigates website, manipulate documents, create server base automations, mailing system etc.... and these languages are coded with Autoit, VBA, and CMD only which is so powerful and simple. but of course this is just for me using these laguages and I'm not the only person here in our company uses these but lots of us here but some are using C++,PHP, etc.... And I bow down with Moderators, MVPs, Developers, Universalist and other people in this forum in continuing the support and help to people like us. BIG respect GUYS.....! KS15
    1 point
×
×
  • Create New...