water Posted May 30, 2015 Posted May 30, 2015 (edited) $sString = StringMid($sString, StringInStr($sString, $sDelimiter) + StringLen($sDelimiter)) Edited May 30, 2015 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 30, 2015 Posted May 30, 2015 (edited) Double post. Edited June 1, 2015 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
iamtheky Posted May 30, 2015 Posted May 30, 2015 (edited) $sString = "ThisIsATestStringOfCharacters" $sDelimiter = "String" msgbox(0, 'Before Delim' , _StringBefore($sString , $sDelimiter)) Func _StringBefore($sString , $sDelimiter) Return StringLeft($sString , StringInStr($sString, $sDelimiter) - 1) EndFunc Edited June 8, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
TheDcoder Posted June 1, 2015 Posted June 1, 2015 Thanks @water Updated it, TD EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
nitekram Posted June 1, 2015 Posted June 1, 2015 When you're working in a vmware system that does not have VMTools installed and you want to paste text from your system to the virtual system, you can use this script snippet to ghetto rig paste from your clipboard into the VM system using the send function:#RequireAdmin AutoItSetOption('TrayAutoPause', 0) HotKeySet("^+v", 'Sender') While 1 Sleep(100) WEnd Func Sender() Send(ClipGet()) EndFuncNot at work to test this, but does requie admin rights? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
TheDcoder Posted June 18, 2015 Posted June 18, 2015 (edited) Second Contribution... Small but neat when you use it ; #FUNCTION# ==================================================================================================================== ; Name ..........: CalcPercent ; Description ...: Calculates Percentage ; Syntax ........: CalcPercent($iPartDone, $iTotal[, $iRoundToDecimalPlace = 1]) ; Parameters ....: $iPartDone - Value of the part which is done. ; $iTotal - The total value. ; $iRoundToDecimalPlace- [optional] Round upto which decimal place?. Default is 1. ; Return values .: Percentage (without % symbol) ; Author ........: TheDcoder ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://bit.ly/CalcPercentForAutoIt ; Example .......: Yes, See below ; =============================================================================================================================== Func CalcPercent($iPartDone, $iTotal, $iRoundToDecimalPlace = 1) Return Round(($iPartDone / $iTotal) * 100, $iRoundToDecimalPlace) ; Calculate percentage, round it & return it! EndFunc ;==>CalcPercent ; Example $iCountdown = 60 * 5 ; the value is in seconds ProgressOn("Example for CalcPercent function", "Countdown upto " & $iCountdown & " seconds") $hTimer = TimerInit() For $i = 1 To $iCountdown ProgressSet(CalcPercent($i, $iCountdown)) Sleep(1000) Next $iTime = TimerDiff($hTimer) $iTime /= 1000 ProgressOff() MsgBox(64, "Done!", "The countdown has ended! That took ~" & Round($iTime, 1) & " Seconds.")Hope it may help you, TD P.S Don't reply to this with rude reasons like "Hey! that is so simple! even a newbie can do that." or "It ain't worth posting in snippets section" Edited June 21, 2015 by TheDcoder Updated links with shortend Bitly links :) conmed 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
water Posted June 18, 2015 Posted June 18, 2015 P.S Don't reply to this with rude reasons like "Hey! that is so simple! even a newbie can do that." or "It ain't worth posting in snippets section"If you think this are rude commens then you should have a look at other forums and see how rude comments really look like mLipok 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
TheDcoder Posted June 18, 2015 Posted June 18, 2015 @water EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
Exit Posted June 18, 2015 Posted June 18, 2015 P.S Don't reply to this with rude reasons like "Hey! that is so simple! even a newbie can do that." or "It ain't worth posting in snippets section"No need to reply. You gave the answer yourself. App: Au3toCmd UDF: _SingleScript()
Moderators JLogan3o13 Posted June 18, 2015 Moderators Posted June 18, 2015 P.S Don't reply to this with rude reasons like "Hey! that is so simple! even a newbie can do that." or "It ain't worth posting in snippets section"So, you post something that is basically a rehashing of the example under ProgressSet, you're intelligent *cough* enough to foresee people are probably going to point out the snippet's lack of value, but you posted it anyway? Exit 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
TheDcoder Posted June 18, 2015 Posted June 18, 2015 @JLogan3o13 ...Well...I don't know what to say EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
iamtheky Posted June 18, 2015 Posted June 18, 2015 Maybe explain how you feel your example differs from the progressset helpfile. You should be encouraging discourse and then logically defending your position rather than trying to preempt, as the forum is a good place to hone your debate skills in addition to your coding. water 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
TheDcoder Posted June 18, 2015 Posted June 18, 2015 @JLogan3o13 Debate: How my example differs from ProgressSet's exampleExplanation: The only common thing between the two examples is that both are countdown timers... And its just a example .I posted it here because the threads title reads "AutoIt Snippets" (This isn't part of the debate)...@boththose Thanks P.S Don't take that debate seriously EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
Moderators Melba23 Posted June 18, 2015 Moderators Posted June 18, 2015 Hi all,As I read the post which started all of this, I get the impression that it is the CalcPercent function which was the point of the exercise, not the ProgressSet section. To which end I feel some of the resultant comments are a little OTT - although I also feel that a snippet to calculate a percentage is also not exactly earthshattering in and of itself. So please let us all decide to drop the matter - even though the OP was silly enough to make that ridiculous statement at the end of the post which quite frankly just begged the response it quite rightly got.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
JohnOne Posted June 18, 2015 Posted June 18, 2015 Second Contribution... Small but neat when you use it The name of the function is incorrect in your header. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
TheDcoder Posted June 19, 2015 Posted June 19, 2015 @JohnOne EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
Iczer Posted June 27, 2015 Posted June 27, 2015 as vbscript do no like 64 bit i needed something to replace "unescape()"Func decodeURIComponent($sURIComponent) If StringRegExp($sURIComponent, "%[0-9A-Fa-f]{2}", 0) Then $sURIComponent = Execute('"' & StringRegExpReplace($sURIComponent,"(%)([0-9A-Fa-f]{2})",'" & Chr(Dec(''$2'')) & "') & '"') EndIf Return $sURIComponent EndFunc ;==>decodeURIComponentat first glance result is identical to vbscript's "unescape()"
jchd Posted June 28, 2015 Posted June 28, 2015 [0-9A-Fa-f]you can make that [[:xdigit:]] This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
TheDcoder Posted July 4, 2015 Posted July 4, 2015 (edited) Third Contribution! Maybe useful when you need to convert an 1D Array to an 2D Array expandcollapse popup#include-once #include <Array.au3> ; <----- ONLY NEEDED FOR EXAMPLE, REMOVE BEFORE USING!!! #include <StringConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: ArraySplit ; Description ...: Similar to StringSplit, Converts an 1D Array to an 2D Array based on delimiters ; Syntax ........: ArraySplit(ByRef $aArray, $sDelimiter) ; Parameters ....: $aArray - Array to process. ; $sDelimiter - Delimiter to split array. ; Return values .: Success: An 2D Array ; Failure: 0 & sets @error to: ; @error : 1 = Not an array ; 2 = Delimiter was not found in an element (@extended contains the element's index no.) ; Author ........: TheDcoder ; Modified ......: N/A ; Remarks .......: There should be only 1 delimiter in each element of the Array!!! Only Text before & after the first delimiter will be present in col 1 & col 2 ; Related .......: StringSplit ; Link ..........: bit.ly/ArraySplitForAutoIt ; Example .......: Yes ; =============================================================================================================================== Func ArraySplit(ByRef $aArray, $sDelimiter) If Not IsArray($aArray) Then Return SetError(1, 0, 1) ; The statment itself states what it does $iArrayLen = Ubound($aArray) ; We need Array's length (or no. of elements) Local $aReturn[$iArrayLen][2] ; Delare a 2D Array with 2 coloumns for returning For $i = 0 To $iArrayLen - 1 ; Loop through Array $aTempArray = StringSplit($aArray[$i], $sDelimiter, $STR_ENTIRESPLIT) ; StringSplit the string & store it in an array If $aTempArray[0] = 1 Then Return SetError(2, $i, 0) $aReturn[$i][0] = $aTempArray[1] ; Put the first string in Coloumn 0 $aReturn[$i][1] = $aTempArray[2] ; Put the second string in Coloumn 1 Next Return $aReturn ; Return the Array EndFunc ; Example Local $aArray[3] = ["x=1", "y=2", "z=3"] ; Declare the Array $aArray = ArraySplit($aArray, '=') ; Convert an 1D Array to an 2D Array based on a delimiter _ArrayDisplay($aArray) ; Display the array #cs ---------------------- Visual example ---------------------- This is our $aArray: | Data | ----------------------- 0. | "x=1" | ----------------------- 1. | "y=2" | ----------------------- 2. | "z=3" | ----------------------- This is our $aArray after ArraySplit (with delimiter as "=" (Equal Sign)): | Column 0 | Column 1 | --------------------------------- 0. | "x" | 1 | --------------------------------- 1. | "y" | 2 | --------------------------------- 2. | "z" | 3 | --------------------------------- #ce ---------------------- Visual example ----------------------Hope you may find it useful, TD Edited October 20, 2015 by TheDcoder Added "Error Checking" & Minor Improvements, TD :D EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
guinness Posted July 4, 2015 Posted July 4, 2015 Great. Array UDF has this by the way if people are interested. Exit 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now