Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/05/2015 in all areas

  1. If the question is whether you can add your own custom shortcut to do a "Copy as RTF" then the answer is yes: Just add it to the "user.shortcuts" config parameter. Example: user.shortcuts=\ Ctrl+r|IDM_SAVEASRTF|\ Ctrl+Shift+V|IDM_PASTEANDDOWN|\ Ctrl+PageUp|IDM_PREVFILE|\ Ctrl+PageDown|IDM_NEXTFILE|\ Ctrl+Alt+f|IDM_TOGGLE_FOLDALL|\ Ctrl+Alt+x|IDM_TOGGLE_FOLDRECURSIVE|\ Ctrl+F1|IDM_HELP_SCITE|Jos
    2 points
  2. Lately, in this forum, there were many questions and problems referring to the use of ie.au3 UDF using the latest version of AutoIt v3.3.14.x. I would like to present the correct usage of the UDF. I hope that it will help many users to prevent problems. #include <ie.au3> #include <MsgBoxConstants.au3> ; STEP 1 ; YOU MUST SET ANY COM ERROR HANDLER IN ONE OF THE FOLLOWING WAY ; STEP 1: CASE 1 ; you should set COM Error Handler Function for ie.au3 UDF _IEErrorHandlerRegister(_User_ErrFunc) ; STEP 1: CASE 2 ; eventually if you not want to recieve additional information ; you can use just the same function without parameter ; _IEErrorHandlerRegister() ; STEP 1: CASE 3 ; or use your own global COM Error Handler ;~ Global $oCOMErrorHandler = ObjEvent("AutoIt.Error", _User_ErrFunc) ; STEP 2 ; if you do not wish to get in Console Output Pane information like the following: ; --> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType ; You can uncomment this following line: ; _IEErrorNotify(False) _Example() Func _Example() ; First lets create some IE Object Local $oIE = _IECreate('google.com') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IECreate', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(1,0,0) Endif ; here we try to get reference to LuckyStrike button Local $oLuckyStrike = _IEGetObjByName($oIE, 'btnI') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(2,0,0) Endif ; here we try to click LuckyStrike button with previously achieved Object which is a reference to HTML DOM OBJECT in IE Instance _IEAction($oLuckyStrike, 'click') ; you should wait when page is loading _IELoadWait($oIE) ; some user interaction If MsgBox($MB_YESNO, 'Question', 'Do you want to back ?') = $IDYES Then _IEAction($oIE, 'back') EndIf EndFunc ;==>_Example ; User's COM error function. ; After SetUp with ObjEvent("AutoIt.Error", ....) will be called if COM error occurs Func _User_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_User_ErrFunc Regards, mLipok
    1 point
  3. Each one of those variables is assigned a numeric value, the number in the parentheses. You can use either the variables, or the number it equals, or any combination of the two. The variables are there so you don't end up with the problem you have, someone used the numbers and you don't know what they stand for. If they had uses the variables instead of their values, then you could have easily seen that they used Binary mode, CreatePath, and OverWrite mode. That's why "magic numbers" are frowned upon and named variables are used in place of "magic numbers".
    1 point
  4. Man you understand of course that I can't write your whole script - especially because I must go to bed soon Here are clues for doing what you want, you will have to adapt and integrate this to the script Good luck Global $aItems ; declare array to store the IDs of the listview items Func _Fill_Listview() $sGuvercinINI = @ScriptDir & '\guvercin.ini' $sections = IniReadSectionNames($sGuvercinINI) ; get section names If not @error Then GuiCtrlSendMsg($listview, $LVM_DELETEALLITEMS, 0, 0) ; clean the listview Dim $aItems[$sections[0]] ; create and size the items array For $i = 1 to $sections[0] ; loop through sections Local $aAccounts = IniRead($sGuvercinINI, $sections[$i], "Künye", "") Local $bAccounts = IniRead($sGuvercinINI, $sections[$i], "Cinsi", "") Local $cAccounts = IniRead($sGuvercinINI, $sections[$i], "Dog(um", "") ; << typo here !! Local $dAccounts = IniRead($sGuvercinINI, $sections[$i], "Durumu", "") ; create listview items $aItems[$i-1] = GUICtrlCreateListViewItem($aAccounts & "|" & $bAccounts & "|" & $cAccounts & "|" & $dAccounts, $listview) GuiCtrlSetOnEvent($aItems[$i-1], "_display") Next EndIf EndFunc Func _display() For $i = 0 to UBound($aItems)-1 ; loop through the item IDs If @GUI_CtrlId = $aItems[$i] Then ; the item was clicked ; here put the instructions to display the image and infos for this item EndIf Next EndFunc
    1 point
  5. Look Chimp answer Here : But not succeed after combine
    1 point
  6. You're thinking of the word loser not looser, looser means less firmly or tightly fixed in place. Similar spellings, vastly different meanings.
    1 point
  7. GUICtrlSetData($idItem1, $aAccounts & "|" & $bAccounts & "|" & $cAccounts & "|" & $dAccounts) BTW you know what ? the help file is of great help
    1 point
  8. This looks useful - https://www.autoitscript.com/forum/topic/34478-udfs-for-ie-find-x-and-y-of-element/
    1 point
  9. There is probably elsewhere in the script something slowing down the main While loop
    1 point
  10. Teks, Welcome to the AutoIt forums. No, outside of a function, everything is Global by default, even if declared as Local. The Variables - using Global, Local, Static and ByRef tutorial in the Wiki will explain exactly how scoping works in AutoIt. M23
    1 point
  11. I can confirm that the reproducer provided by ferbfletcher does indeed have a memory leak, but only when used with $STDERR_MERGED. We probably should treat this as a bug from here on out so I have created ticket https://www.autoitscript.com/trac/autoit/ticket/3135 You can try to run the following simplified code and observe the memory usage: #include <Constants.au3> While 1 $pid = Run("ping localhost","", @SW_HIDE, $STDERR_MERGED) ProcessWait($pid) StdioClose($pid) ProcessClose($pid) ProcessWaitClose($pid) WEnd@ferbfletcher Many thanks for taking the time to provide a reproduction script to get to the bottom of this. It is very much appreciated and we'll take it from here, assuming your problem is solved adequately.
    1 point
  12. great77, Welcome to the AutoIt forums. The reason you are getting the error is that at some point your RegEx is not returning any matches from a line of the file - so there is no $test array to access. So I suggest you add some errorchecking in your code to cater for this event - then the error will not occur. M23
    1 point
  13. ahmeddzcom, As TheSaint has pointed out, we take a very dim view of people providing help when a Mod is awaiting some clarity on the question posed. Please do not do it again. M23
    1 point
  14. When you see a MOD has replied with a question for the OP, and not given a solution, don't take it upon yourself to then give one.
    1 point
  15. Hello jfish, Congratulations on a job done extremely well. I first came across AutoIt about 3 days after I bought this computer - the only previous experience I had with programming was with a mighty monster called a "VIC-20". I would have loved to have something like this when I started with AutoIt. I agree completely with your position that something more is needed for those who are just starting out. I can also add the simple fact that it doesn't hurt to have a straight forward reference around for people like myself who don't always remember the finer points. I'm just starting a new project with AutoIt and I'm looking forward to having your work handy. Once again jfish - Well Done! JAPP
    1 point
  16. I created this after I developed because I was interested in the entry displaying when a folder was right clicked on. The entry will pass the folder name to your program via a commandline argument, so you'll have to use $CmdLine/$CmdLineRaw to access the folder that was selected. Any problems or suggestions then please post below. Thanks. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _ShellFolder ; AutoIt Version : v3.2.12.1 or higher ; Language ......: English ; Description ...: Create an entry in the shell contextmenu when selecting a folder, includes the program icon as well. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: Special thanks to KaFu for EnumRegKeys2Array() which I used as inspiration for enumerating the Registry Keys. ; =============================================================================================================================== ; #INCLUDES# ==================================================================================================================== ; None ; #GLOBAL VARIABLES# ============================================================================================================ ; None ; #CURRENT# ===================================================================================================================== ; _ShellFolder_Install: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a folder. ; _ShellFolder_Uninstall: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __ShellFolder_RegistryGet ......; Retrieve an array of registry entries for a specific key. ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFolder_Install ; Description ...: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a file and folder. ; Syntax ........: _ShellFolder_Install($sText[, $sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sIconPath = @ScriptFullPath[, ; $iIcon = 0[, $fAllUsers = False[, $fExtended = False]]]]]]) ; Parameters ....: $sText - Text to be shown in the contextmenu. ; $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $sIconPath - [optional] Location of the icon e.g. program executable or dll file. Default is @ScriptFullPath. ; $iIcon - [optional] Index of icon to be used. Default is 0. ; $fAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; $fExtended - [optional] Show in the Extended contextmenu using Shift + Right click. Default is False. ; Return values .: Success - Returns True ; Failure - Returns False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellFolder_Install($sText, $sName = @ScriptName, $sFilePath = @ScriptFullPath, $sIconPath = @ScriptFullPath, $iIcon = 0, $fAllUsers = False, $fExtended = False) Local $i64Bit = '', $sRegistryKey = '' If $iIcon = Default Then $iIcon = 0 EndIf If $sFilePath = Default Then $sFilePath = @ScriptFullPath EndIf If $sIconPath = Default Then $sIconPath = @ScriptFullPath EndIf If $sName = Default Then $sName = @ScriptName EndIf If @OSArch = 'X64' Then $i64Bit = '64' EndIf If $fAllUsers Then $sRegistryKey = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClassesFoldershell' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClassesFoldershell' EndIf $sName = StringLower(StringRegExpReplace($sName, '.[^./]*$', '')) If StringStripWS($sName, 8) = '' Or FileExists($sFilePath) = 0 Then Return SetError(1, 0, False) EndIf _ShellFolder_Uninstall($sName, $fAllUsers) Local $iReturn = 0 $iReturn += RegWrite($sRegistryKey & $sName, '', 'REG_SZ', $sText) $iReturn += RegWrite($sRegistryKey & $sName, 'Icon', 'REG_EXPAND_SZ', $sIconPath & ',' & $iIcon) $iReturn += RegWrite($sRegistryKey & $sName & 'command', '', 'REG_SZ', '"' & $sFilePath & '" "%1"') If $fExtended Then $iReturn += RegWrite($sRegistryKey & $sName, 'Extended', 'REG_SZ', '') EndIf Return $iReturn > 0 EndFunc ;==>_ShellFolder_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFolder_Uninstall ; Description ...: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; Syntax ........: _ShellFolder_Uninstall([$sName = @ScriptName[, $fAllUsers = False]]) ; Parameters ....: $sName - [optional] Name of the Program. Default is @ScriptName. ; $fAllUsers - [optional] Was it added to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - Returns True ; Failure - Returns False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellFolder_Uninstall($sName = @ScriptName, $fAllUsers = False) Local $i64Bit = '', $sRegistryKey = '' If $sName = Default Then $sName = @ScriptName EndIf If @OSArch = 'X64' Then $i64Bit = '64' EndIf If $fAllUsers Then $sRegistryKey = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClassesFoldershell' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClassesFoldershell' EndIf $sName = StringLower(StringRegExpReplace($sName, '.[^./]*$', '')) If StringStripWS($sName, 8) = '' Then Return SetError(1, 0, 0) EndIf Local $aReturn = __ShellFolder_RegistryGet($sRegistryKey), $iReturn = 0, $sNameDeleted = '' If $aReturn[0][0] Then For $i = 1 To $aReturn[0][0] If $aReturn[$i][0] = $sName And $sNameDeleted <> $aReturn[$i][1] Then $sNameDeleted = $aReturn[$i][1] $iReturn += RegDelete($sNameDeleted) EndIf Next EndIf $aReturn = 0 Return $iReturn > 0 EndFunc ;==>_ShellFolder_Uninstall ; #INTERNAL_USE_ONLY#============================================================================================================ Func __ShellFolder_RegistryGet($sRegistryKey) Local $aArray[1][5] = [[0, 5]], $iCount_1 = 0, $iCount_2 = 0, $iDimension = 0, $iError = 0, $sRegistryKey_All = '', $sRegistryKey_Main = '', $sRegistryKey_Name = '', _ $sRegistryKey_Value = '' While 1 If $iError Then ExitLoop EndIf $sRegistryKey_Main = RegEnumKey($sRegistryKey, $iCount_1 + 1) If @error Then $sRegistryKey_All = $sRegistryKey $iError = 1 Else $sRegistryKey_All = $sRegistryKey & $sRegistryKey_Main EndIf $iCount_2 = 0 While 1 $sRegistryKey_Name = RegEnumVal($sRegistryKey_All, $iCount_2 + 1) If @error Then ExitLoop EndIf If ($aArray[0][0] + 1) >= $iDimension Then $iDimension = Ceiling(($aArray[0][0] + 1) * 1.5) ReDim $aArray[$iDimension][$aArray[0][1]] EndIf $sRegistryKey_Value = RegRead($sRegistryKey_All, $sRegistryKey_Name) $aArray[$aArray[0][0] + 1][0] = $sRegistryKey_Main $aArray[$aArray[0][0] + 1][1] = $sRegistryKey_All $aArray[$aArray[0][0] + 1][2] = $sRegistryKey & $sRegistryKey_Main & '' & $sRegistryKey_Name $aArray[$aArray[0][0] + 1][3] = $sRegistryKey_Name $aArray[$aArray[0][0] + 1][4] = $sRegistryKey_Value $aArray[0][0] += 1 $iCount_2 += 1 WEnd $iCount_1 += 1 WEnd ReDim $aArray[$aArray[0][0] + 1][$aArray[0][1]] Return $aArray EndFunc ;==>__ShellFolder_RegistryGetExample 1: #include "_ShellFolder.au3" Example() Func Example() _ShellFolder_Install('Start ShellFolder') ; Add the running EXE to the Shell ContextMenu. This will only display when selecting a drive and folder. Sleep(10000) _ShellFolder_Uninstall() ; Remove the running EXE from the Shell ContextMenu. EndFunc ;==>ExampleAll of the above has been included in a ZIP file. ShellFolder.zip
    1 point
×
×
  • Create New...