Sign in to follow this  
Followers 0
FireFox

[SOLVED] How to "Zero-fill right shift" ?

11 posts in this topic

#1 ·  Posted (edited)

Hi,

I'm wondering how to make a zero-fill right shift in autoit as far as the BitShift function has no parameter for this.

Here is an example in javascript : https://developer.mozilla.org/en-US/docs/Javascript/Reference/Operators/Bitwise_Operators#>>>_(Zero-fill_right_shift)

Thanks for anyhelp,

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Perhaps something like this:

For $i = 0 To 32
    ConsoleWrite(LogicalBitShift(0x80000000 ,$i) & @LF)
Next

Func LogicalBitShift($dVal, $iShift)
    If $iShift > 0 And BitAND($dVal, 0x80000000) = 0x80000000 Then
        $dVal = BitShift($dVal, 1)
        $dVal = BitXor($dVal, 0x80000000)
        $iShift -= 1
    EndIf
    Return BitShift($dVal, $iShift)
EndFunc
Edited by czardas
1 person likes this

Share this post


Link to post
Share on other sites

ohhhhhhhhh yeah !

Thanks again :)

1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

No problem. You might want to add some error checks for the input parameters, I also think the function should be renamed to BitLogicalShift(). :)

Share this post


Link to post
Share on other sites

Nice snippet czardas

1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This is a equivalent to the LogicalBitShift() function:

For $i = 0 To 32
   ConsoleWrite(Int(-1 * 0x80000000 / (2^$i)) & @LF)
Next

Br,

UEZ

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This is a equivalent to the LogicalBitShift() function:

For $i = 0 To 32
Ceiling(-1 * 0x80000000 / (2^$i))
Next

Br,

UEZ

I'm getting totally different results:

Local $dVar = 0xFFFFFFFF

For $i = 0 To 32
    ConsoleWrite(BitLogicalShift($dVar ,$i) & @LF)
    ConsoleWrite(Ceiling(-1 * $dVar / (2^$i)) & @LF)
Next

Func BitLogicalShift($dVal, $iShift)
    If $iShift > 0 And BitAND($dVal, 0x80000000) = 0x80000000 Then
        $dVal = BitShift($dVal, 1)
        $dVal = BitXor($dVal, 0x80000000)
        $iShift -= 1
    EndIf
    Return BitShift($dVal, $iShift)
EndFunc

BTW, I changed the function name to a better one, but there is a problem. I'm trying to figure it out.

Edited by czardas

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Well, calculating this way is limited to 0x80000000.

Local $dVar = 0x80000000

For $i = 0 To 32
    ConsoleWrite(BitLogicalShift($dVar, $i) & " / " & Equivalent($dVar, $i) & @LF)
Next

Func Equivalent($dVar, $i)
    If Hex($dVar) > Hex(0x80000000) Then Return SetError(0, 0, -1)
    Local $j = 1
    If Hex($dVar) = Hex(0x80000000) Then $j *= -1
    Return Int($j * $dVar / (2^$i))
EndFunc

Func BitLogicalShift($dVal, $iShift)
    If $iShift > 0 And BitAND($dVal, 0x80000000) = 0x80000000 Then
        $dVal = BitShift($dVal, 1)
        $dVal = BitXor($dVal, 0x80000000)
        $iShift -= 1
    EndIf
    Return BitShift($dVal, $iShift)
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Well, it has to work on any 32 bit integer. I have just realized that my method is faulty, because it isn't a true logical shift. The results of the first example fooled me into thinking it was working. It's actually completely broken.

Edit

I think I know a way to fix it.

Edited by czardas

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I was thinking way too deep about this, The solution is very simple indeed. I have added error checks to force strict input parameters, rather unlike the arithmetic bitwise functions which don't seem to balk at anything. :ph34r:

Local $dVar = 0x00010000

For $i = 21 To -20 Step -1
    ConsoleWrite(BitLogicalShift($dVar ,$i) & @LF)
Next

Func BitLogicalShift($dVal, $iShift)
    If Not IsInt($dVal) Or Not IsInt($iShift) Then Return SetError(1, 0, "")

    If $iShift > 31 Or $iShift < -31 Then
        $dVal = 0 ; Out of range shift values always return zero.
    ElseIf $iShift > 0 And BitAND($dVal, 0x80000000) = 0x80000000 Then
        $dVal = BitXor(BitShift($dVal, 1), 0x80000000)
        $iShift -= 1
    EndIf

    Return BitShift($dVal, $iShift)
EndFunc

Now the bit sequence can be shifted out of range in either direction. With the earlier version, the binary was looping back on itself with shift values greater than 31. That was not the intention.

Edited by czardas
1 person likes this

Share this post


Link to post
Share on other sites

Thank you, it's fine for my needs ;)

1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Reizvoller
      By Reizvoller
      Howdy,
      This is more of a practical question rather than a "I need help with my script" question...
      There are going to be scenarios I will hit where I will need to scroll a web page to the left or the right rather than up or down. Can the MouseWheel function handle this or is there no known method to do this type of scrolling? 
      I know that if I control the mouse manually ( not via Autoit ) I can hit the middle mouse button which gives me a four arrow cursor and when I move the cursor left right up or down it begins scrolling in the relative direction I moved in with a speed relative to the distance I move from the point at which I clicked the middle mouse button. This is why I was wondering if the MouseWheel function had this ability.
      Thanks for your thoughts and advice!
      -Reiz
    • zelles
      By zelles
      WalletSync, Sync/Backup your crypto-currency wallets.
      **Version 0.0.0.2 has been released adding the option to sync by FTP and not just locally.
      This program will sync any wallet.dat files found in their default location, AppData/Roaming/*/wallet.dat... The program will make a copy of all the wallets in a SyncData folder found in the script directory where WalletSync is run.
      The sync runs once every minute and can be minimized to the system tray to constantly stay syncing, a backup, in the background.
      Version 0.0.0.2 Source Code:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icon.ico #AutoIt3Wrapper_Res_Comment=Keep a sync'd backup of your crypto currency wallets locally and optionally with a FTP server. #AutoIt3Wrapper_Res_Description=Keep a sync'd copy of all the crypto-currency wallet.dats found in there default locations on you PC. #AutoIt3Wrapper_Res_Fileversion=0.0.0.2 #AutoIt3Wrapper_Res_LegalCopyright=Copyright 2014 zelles #AutoIt3Wrapper_Res_Language=1033 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#NoTrayIcon #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <FTPEx.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> _Singleton("zellesWalletSync2") OnAutoItExitRegister("CloseSync") Opt("TrayMenuMode", 3) Global $SYNC_OPERATION = False If Not FileExists(@ScriptDir & "\WalletSync_temp") Then DirCreate(@ScriptDir & "\WalletSync_temp") FileInstall("C:\AIP\Logo.jpg", @ScriptDir & "\WalletSync_temp\Logo.jpg") If Not FileExists(@ScriptDir & "\config.ini") Then IniWriteSection(@ScriptDir & "\config.ini", "config", "speed=60") IniWrite(@ScriptDir & "\config.ini", "config", "ftpserver", "none") IniWrite(@ScriptDir & "\config.ini", "config", "ftpport", "21") IniWrite(@ScriptDir & "\config.ini", "config", "ftpusername", "none") IniWrite(@ScriptDir & "\config.ini", "config", "ftppassword", "none") EndIf Global $SYNC_SPEED = IniRead(@ScriptDir & "\config.ini", "config", "speed", "60") Global $SYNC_FTPSERVER = IniRead(@ScriptDir & "\config.ini", "config", "ftpserver", "none") Global $SYNC_FTPPORT = IniRead(@ScriptDir & "\config.ini", "config", "ftpport", "21") Global $SYNC_FTPUSER = IniRead(@ScriptDir & "\config.ini", "config", "ftpusername", "none") Global $SYNC_FTPPASS = IniRead(@ScriptDir & "\config.ini", "config", "ftppassword", "none") Global $GUI_Wallet_Sync = GUICreate("WalletSync, created by zelles", 370, 189, 245, 163) GUISetBkColor(0xFFFFFF) Global $GUI_Tab1 = GUICtrlCreateTab(5, 5, 361, 177) Global $GUI_TabSheet1 = GUICtrlCreateTabItem("Overview") Global $GUI_Logo = GUICtrlCreatePic(@ScriptDir & "\WalletSync_temp\Logo.jpg", 17, 46, 100, 100) Global $GUI_Group1 = GUICtrlCreateGroup("Sync Options", 119, 55, 233, 89) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $GUI_CheckboxLocal = GUICtrlCreateCheckbox("Local", 135, 79, 57, 17) GUICtrlSetState($GUI_CheckboxLocal, $GUI_CHECKED) GUICtrlSetState($GUI_CheckboxLocal, $GUI_DISABLE) Global $GUI_CheckboxFTP = GUICtrlCreateCheckbox("FTP", 135, 111, 57, 17) Global $GUI_CheckboxOther1 = GUICtrlCreateCheckbox("Other", 199, 79, 57, 17) GUICtrlSetState($GUI_CheckboxOther1, $GUI_DISABLE) Global $GUI_CheckboxOther2 = GUICtrlCreateCheckbox("Other", 199, 111, 57, 17) GUICtrlSetState($GUI_CheckboxOther2, $GUI_DISABLE) Global $GUI_ButtonStart = GUICtrlCreateButton("Start", 266, 75, 75, 25) Global $GUI_ButtonStop = GUICtrlCreateButton("Stop", 266, 107, 75, 25) GUICtrlSetState($GUI_ButtonStop, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $GUI_TabSheet2 = GUICtrlCreateTabItem("Status") Global $GUI_Group6 = GUICtrlCreateGroup("Current Sync Status", 21, 65, 329, 73) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $GUI_SyncStatus = GUICtrlCreateLabel("Sync is turned off...", 40, 96, 294, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $GUI_TabSheet3 = GUICtrlCreateTabItem("Local") Global $GUI_Group2 = GUICtrlCreateGroup("Local Output", 22, 64, 329, 73) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $GUI_InputLocalOutput = GUICtrlCreateInput(@ScriptDir & "\SyncData", 35, 92, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $GUI_TabSheet4 = GUICtrlCreateTabItem("FTP") Global $GUI_Group5 = GUICtrlCreateGroup("FTP Settings", 21, 49, 329, 105) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $GUI_Label2 = GUICtrlCreateLabel("Server:", 37, 73, 38, 17) Global $GUI_Label3 = GUICtrlCreateLabel("Port:", 37, 97, 26, 17) Global $GUI_Label1 = GUICtrlCreateLabel("Username:", 189, 73, 55, 17) Global $GUI_Label4 = GUICtrlCreateLabel("Password:", 189, 97, 53, 17) Global $GUI_InputFTPServer = GUICtrlCreateInput($SYNC_FTPSERVER, 79, 70, 105, 21) Global $GUI_InputFTPPort = GUICtrlCreateInput($SYNC_FTPPORT, 79, 94, 105, 21) Global $GUI_InputFTPUsername = GUICtrlCreateInput($SYNC_FTPUSER, 247, 70, 89, 21) Global $GUI_InputFTPPassword = GUICtrlCreateInput($SYNC_FTPPASS, 247, 94, 89, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) Global $GUI_ButtonFTPUpdate = GUICtrlCreateButton("Update", 264, 120, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $GUI_TabSheet6 = GUICtrlCreateTabItem("Scanner") Global $GUI_Group4 = GUICtrlCreateGroup("Sync Scanner", 21, 33, 329, 137) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $GUI_ComboSpeed = GUICtrlCreateCombo("1 minute", 40, 56, 209, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData($GUI_ComboSpeed, "5 minutes|10 minutes|30 minutes|1 hour", "1 minute") Global $GUI_ButtonUpdateSpeed = GUICtrlCreateButton("Update", 256, 56, 75, 21) Global $GUI_Wallets_Found = GUICtrlCreateList("", 120, 88, 209, 69, BitOR($LBS_NOTIFY,$LBS_SORT,$WS_VSCROLL)) Global $GUI_Label5 = GUICtrlCreateLabel("Wallets Found:", 40, 86, 75, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW, $GUI_Wallet_Sync) Global $GUI_Tray_Open = TrayCreateItem("Open WalletSync") TrayCreateItem("") Global $GUI_Tray_Exit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) Global $SyncAdded = "||" Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*") While 1 GUI_Events() If $SYNC_OPERATION = False Then ContinueLoop Local $SyncScanResult = FileFindNextFile($SyncScan) If @error Then SyncReset() If @extended = 1 Then If FileExists(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat") Then GUICtrlSetData($GUI_SyncStatus, $SyncScanResult) If Not StringInStr($SyncAdded, "||" & $SyncScanResult & "||") Then $SyncAdded &= $SyncScanResult & "||" GUICtrlSetData($GUI_Wallets_Found, $SyncScanResult) EndIf If GUICtrlRead($GUI_CheckboxLocal) = $GUI_CHECKED Then If Not FileExists(@ScriptDir & "\SyncData") Then DirCreate(@ScriptDir & "\SyncData") If Not FileExists(@ScriptDir & "\SyncData\" & $SyncScanResult) Then DirCreate(@ScriptDir & "\SyncData\" & $SyncScanResult) FileCopy(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat", @ScriptDir & "\SyncData\" & $SyncScanResult & "\wallet.dat", 1) EndIf EndIf EndIf WEnd Func SyncReset() If $SYNC_OPERATION = True Then If GUICtrlRead($GUI_CheckboxFTP) = $GUI_CHECKED Then GUICtrlSetData($GUI_SyncStatus, "Sending to FTP server...") $SyncFTPOpen = _FTP_Open('FTP') $SyncFTPConn = _FTP_Connect($SyncFTPOpen, $SYNC_FTPSERVER, $SYNC_FTPUSER, $SYNC_FTPPASS, "1", $SYNC_FTPPORT) _FTP_DirPutContents($SyncFTPConn, @ScriptDir & "\SyncData", "", 1) _FTP_Close($SyncFTPOpen) _FTP_Close($SyncFTPConn) EndIf GUICtrlSetData($GUI_SyncStatus, "Sleeping...") EndIf FileClose($SyncScan) Local $SyncTimer = TimerInit() Do GUI_Events() Sleep(10) Until Round(TimerDiff($SyncTimer)/1000, 0) > $SYNC_SPEED Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*") EndFunc Func GUI_Events() Switch TrayGetMsg() Case $GUI_Tray_Open GUISetState(@SW_SHOW, $GUI_Wallet_Sync) WinSetState($GUI_Wallet_Sync, "", @SW_RESTORE) Case $GUI_Tray_Exit CloseSync() EndSwitch Switch GUIGetMsg() Case $GUI_EVENT_CLOSE CloseSync() Case $GUI_EVENT_MINIMIZE GUISetState(@SW_Hide, $GUI_Wallet_Sync) TrayTip("WalletSync", "Minimized to the system tray...", 4) Case $GUI_ButtonStart GUICtrlSetState($GUI_ButtonStart, $GUI_DISABLE) GUICtrlSetState($GUI_ButtonStop, $GUI_ENABLE) $SYNC_OPERATION = True Case $GUI_ButtonStop GUICtrlSetState($GUI_ButtonStop, $GUI_DISABLE) GUICtrlSetState($GUI_ButtonStart, $GUI_ENABLE) GUICtrlSetData($GUI_SyncStatus, "Sync is turned off...") $SYNC_OPERATION = False Case $GUI_ButtonUpdateSpeed Switch GUICtrlRead($GUI_ComboSpeed) Case "5 minutes" $SYNC_SPEED = 300 IniDelete(@ScriptDir & "\config.ini", "config", "speed") IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED) MsgBox(0, "WalletSync Response", "The speed was updated to 5 minute intervals.") Case "10 minutes" $SYNC_SPEED = 600 IniDelete(@ScriptDir & "\config.ini", "config", "speed") IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED) MsgBox(0, "WalletSync Response", "The speed was updated to 10 minute intervals.") Case "30 minutes" $SYNC_SPEED = 1800 IniDelete(@ScriptDir & "\config.ini", "config", "speed") IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED) MsgBox(0, "WalletSync Response", "The speed was updated to 30 minute intervals.") Case "1 hour" $SYNC_SPEED = 3600 IniDelete(@ScriptDir & "\config.ini", "config", "speed") IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED) MsgBox(0, "WalletSync Response", "The speed was updated to 1 hour intervals.") Case Else $SYNC_SPEED = 60 IniDelete(@ScriptDir & "\config.ini", "config", "speed") IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED) MsgBox(0, "WalletSync Response", "The speed was updated to 1 minute intervals.") EndSwitch Case $GUI_ButtonFTPUpdate $SYNC_FTPSERVER = GUICtrlRead($GUI_InputFTPServer) $SYNC_FTPPORT = GUICtrlRead($GUI_InputFTPPort) $SYNC_FTPUSER = GUICtrlRead($GUI_InputFTPUsername) $SYNC_FTPPASS = GUICtrlRead($GUI_InputFTPPassword) IniDelete(@ScriptDir & "\config.ini", "config", "ftpserver") IniDelete(@ScriptDir & "\config.ini", "config", "ftpport") IniDelete(@ScriptDir & "\config.ini", "config", "ftpusername") IniDelete(@ScriptDir & "\config.ini", "config", "ftppassword") IniWrite(@ScriptDir & "\config.ini", "config", "ftpserver", $SYNC_FTPSERVER) IniWrite(@ScriptDir & "\config.ini", "config", "ftpport", $SYNC_FTPPORT) IniWrite(@ScriptDir & "\config.ini", "config", "ftpusername", $SYNC_FTPUSER) IniWrite(@ScriptDir & "\config.ini", "config", "ftppassword", $SYNC_FTPPASS) MsgBox(0, "WalletSync Response", "The ftp credentials were updated.") EndSwitch EndFunc Func CloseSync() FileClose($SyncScan) If FileExists(@ScriptDir & "\WalletSync_temp") Then DirRemove(@ScriptDir & "\WalletSync_temp", 1) Exit EndFunc Version 0.0.0.1 Source Code:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icon.ico #AutoIt3Wrapper_Res_Comment=Backup your crypto currency wallets every minute. #AutoIt3Wrapper_Res_Description=Keep a syncd copy of all the crypto-currency wallet.dats found in there default locations on you PC. #AutoIt3Wrapper_Res_Fileversion=0.0.0.1 #AutoIt3Wrapper_Res_LegalCopyright=Copyright 2014 zelles #AutoIt3Wrapper_Res_Language=1033 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#NoTrayIcon #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> _Singleton("zellesWalletSync") OnAutoItExitRegister("CloseSync") Opt("TrayMenuMode", 3) Global $GUI_Wallet_Sync = GUICreate("Wallet Sync", 162, 196, 258, 150) Global $GUI_File = GUICtrlCreateMenu("&File") Global $GUI_File_Minimize = GUICtrlCreateMenuItem("&Minimize", $GUI_File) Global $GUI_File_Exit = GUICtrlCreateMenuItem("&Exit", $GUI_File) Global $GUI_Help = GUICtrlCreateMenu("&Help") Global $GUI_Help_About = GUICtrlCreateMenuItem("&About", $GUI_Help) Local $GUI_Label1 = GUICtrlCreateLabel("Backing Up:", 8, 8, 95, 19) GUICtrlSetFont(-1, 9, 800, 0, "Arial") Global $GUI_Label2 = GUICtrlCreateLabel("Label2", 24, 32, 132, 17) Local $GUI_Label3 = GUICtrlCreateLabel("Detected Wallets:", 8, 56, 104, 19) GUICtrlSetFont(-1, 9, 800, 0, "Arial") Global $GUI_Wallets_Found = GUICtrlCreateList("", 0, 80, 161, 95, BitOR($LBS_NOTIFY,$LBS_SORT,$WS_VSCROLL)) GUISetState(@SW_SHOW, $GUI_Wallet_Sync) Global $GUI_Tray_Open = TrayCreateItem("Open WalletSync") TrayCreateItem("") Global $GUI_Tray_Exit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) Global $SyncAdded = "||" Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*") While 1 GUI_Events() Local $SyncScanResult = FileFindNextFile($SyncScan) If @error Then SyncReset() If @extended = 1 Then If FileExists(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat") Then GUICtrlSetData($GUI_Label2, $SyncScanResult) If Not StringInStr($SyncAdded, "||" & $SyncScanResult & "||") Then $SyncAdded &= $SyncScanResult & "||" GUICtrlSetData($GUI_Wallets_Found, $SyncScanResult) EndIf If Not FileExists(@ScriptDir & "\SyncData") Then DirCreate(@ScriptDir & "\SyncData") If Not FileExists(@ScriptDir & "\SyncData\" & $SyncScanResult) Then DirCreate(@ScriptDir & "\SyncData\" & $SyncScanResult) FileCopy(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat", @ScriptDir & "\SyncData\" & $SyncScanResult & "\wallet.dat", 1) EndIf EndIf WEnd Func SyncReset() GUICtrlSetData($GUI_Label2, "Sleeping...") FileClose($SyncScan) Local $SyncTimer = TimerInit() Do GUI_Events() Sleep(10) Until Round(TimerDiff($SyncTimer)/1000, 0) > 60 Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*") EndFunc Func GUI_Events() Switch TrayGetMsg() Case $GUI_Tray_Open GUISetState(@SW_SHOW, $GUI_Wallet_Sync) WinSetState($GUI_Wallet_Sync, "", @SW_RESTORE) Case $GUI_Tray_Exit CloseSync() EndSwitch Switch GUIGetMsg() Case $GUI_EVENT_CLOSE CloseSync() Case $GUI_EVENT_MINIMIZE GUISetState(@SW_Hide, $GUI_Wallet_Sync) TrayTip("WalletSync", "Minimized to the system tray...", 4) Case $GUI_File_Exit CloseSync() Case $GUI_File_Minimize GUISetState(@SW_Hide, $GUI_Wallet_Sync) TrayTip("WalletSync", "Minimized to the system tray...", 4) Case $GUI_Help_About MsgBox(0, "WalletSync", "A simple tools to sync all your crypto-currencies wallet.dat" & @CRLF & "files to a folder for backup purposes. Created by zelles") EndSwitch EndFunc Func CloseSync() FileClose($SyncScan) Exit EndFunc Version 0.0.0.1 Source Code:
      WalletSync_v_0.0.0.1_source.zip
      Version 0.0.0.1 Windows Binary:
      WalletSync_v_0.0.0.1_x86.zip
       
      New Version 0.0.0.2 with FTP:
      https://github.com/zelles/WalletSync
    • remin
      By remin
      This is my function to put round brackets "()" around a selected text:
      HotKeySet("^+9", "Encl")   While 1     Sleep(10000) WEnd Func Encl()  ClipPut("")  Send( "^x" )  Sleep(200)  local $ClipEncl = ClipGet()      Switch @HotKeyPressed             Case "^+9"               $ClipEncl = '(' & $ClipEncl & ')'      EndSwitch    ClipPut($ClipEncl )  Send("^v") EndFunc The problem is that many times the ctrl or shift or ctrl-shift key is stuck after I invoke the above hotkey
      and I have to push the ctrl, shift or both keys again to be able to use these as before.
      Does anyone know what I did wrong in this function?
       
    • Rickname
      By Rickname
      The StringToByte function , I expected to return 0s and 1s as strings displayed, but in fact it returns in hex if Im not wrong like 0xH3J4H....
      How can I make to return to me the expression of a string in bits ?