Jump to content
Sign in to follow this  
careca

Error check - operators question

Recommended Posts

careca

Hi ppl, got a problem with this, It's for a small project i have, it was sugested that i should include an error check, but now im stuck here,

if i only use one string to compare, it works, so im wondering am im missing some operator for this?

I could do multiple checks with each of them, but this way it would be simpler, what am i missing here?

$LastKey1 = ClipGet()
$string = StringRegExp($LastKey1, "HKEY_CLASSES_ROOT" Or "HKEY_CURRENT_USER" Or "HKEY_LOCAL_MACHINE" Or "HKEY_USERS" Or "HKEY_CURRENT_CONFIG", 0)
If $string = 0 Then
MsgBox(4096, "Error", "Clipboard content is not a registry key!")
Exit
ElseIf $string = 1 Then
MsgBox(4096, "ClipGet", "Clipboard content is a registry key!")
;function
EndIf

error check.au3

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
water

Please have a look at function StringRegExp. The regular expression you have added look wrong to me. Simply use something like this:

If $string = "HKEY_CLASSES_ROOT" Or $string = "HKEY_CURRENT_USER" Or $string = "HKEY_LOCAL_MACHINE" Or $string = "HKEY_USERS" Or $string = "HKEY_CURRENT_CONFIG" Then ..
or shorter
If StringLeft($string, 5) = "HKEY_" Then ..

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
guinness

It is wrong as you can't use OR, SRE requires a pattern. Give me 10 mins and I will try to come up with something.


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 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: 22/04/2018

Share this post


Link to post
Share on other sites
careca

Please have a look at function StringRegExp. The regular expression you have added look wrong to me. Simply use something like this:

If $string = "HKEY_CLASSES_ROOT" Or $string = "HKEY_CURRENT_USER" Or $string = "HKEY_LOCAL_MACHINE" Or $string = "HKEY_USERS" Or $string = "HKEY_CURRENT_CONFIG" Then ..
or shorter
If StringLeft($string, 5) = "HKEY_" Then ..

Hello, thanks for the quick answers, although there is a problem with the first option you pointed out, Water, that is, that way the string has to be exactly like one of those strings...using "SRE" i check if there is any of the strings IN the clipboard string...

The second one works fine, as long as i don't copy any " ", in the left, that is. :)

EDIT: I managed to do it in a complicated way, here it goes: (i don't really open any of the "HKEY_USERS" or "HKEY_CURRENT_CONFIG" so left those out)

$LastKey1 = ClipGet()
$string = StringRegExp($LastKey1, "HKEY_CLASSES_ROOT", 0)
If $string = 0 Then
Error1()
ElseIf $string = 1 Then
OK()
EndIf
Func Error1()
$string = StringRegExp($LastKey1, "HKEY_CURRENT_USER", 0)
If $string = 0 Then
Error3()
ElseIf $string = 1 Then
OK()
EndIf
EndFunc ;==>Error1
Func Error3()
$string = StringRegExp($LastKey1, "HKEY_LOCAL_MACHINE", 0)
If $string = 0 Then
Error4()
ElseIf $string = 1 Then
OK()
EndIf
EndFunc ;==>Error3

Func Error4()
MsgBox(4096, "Error", "Clipboard content is not a registry key!")
Exit
EndFunc ;==>Error4

Func OK()
MsgBox(4096, "ClipGet", "Clipboard content is a registry key!")
;function
EndFunc ;==>OK
Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
water

To handle leading spaces you could use:

If StringLeft(StringStripWS($string, 1), 5) = "HKEY_" Then ..

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
careca

Thank you, Indeed, that removes the spaces, for the "" i'll have to use something else, like:

$LastKey1 = StringRegExpReplace($LastKey1, '"', '')

Although i have a rudimentar error check, feel free to improve it with smaller, simpler code,

maybe using StringRegExp, meaning im still stuck, because i can't make it work in one sentence with SRE. lol

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
water

$LastKey1 = StringRegExpReplace($LastKey1, '"', '')

isn't a regular expression.

As you don't seem to be familiar with SRE I would stick with the "basic" functions. So use

$LastKey1 = StringReplace($LastKey1, '"', '')

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
careca

My fail, thanks.


Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
guinness

This >>

Edited by guinness

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 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: 22/04/2018

Share this post


Link to post
Share on other sites
careca

Wow, thanks, it was returning HKEY_LOCAL_MACHINE as false, added |MACHINE to the last part of the SRE. gonna work on this to implement the errors and such, thanks guinness, do you have this somewhere here in the forum? would be a nice snippet adition, don't you think? :)

Return StringRegExp($LastKey1, '^(HK(LM|U|CU|CR|CC|EY)_?(CLASSES|CURRENT|LOCAL)?_?(USER(S)?|ROOT|CONFIG|MACHINE)?)', 0) = 1

Does the question mark act like a concatenate operator? i think im starting to understand this patterns.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
guinness

No, I created it for your use only.

I also fixed the error with MACHINE, realised after I posted it.


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 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: 22/04/2018

Share this post


Link to post
Share on other sites
careca

Thanks, here it is the result of what im going to include in the project, thanks to Mr. Guinness.

$LastKey1 = ClipGet()
$LastKey1 = StringReplace($LastKey1, '"', '')
$LastKey2 = StringRegExp($LastKey1, '^(HK(LM|U|CU|CR|CC|EY)_?(CLASSES|CURRENT|LOCAL)?_?(USER(S)?|ROOT|CONFIG|MACHINE)?)', 0) = 1
If $LastKey2 = True Then
MsgBox(4096, "ClipGet", "Clipboard content is a registry key!")
Else
MsgBox(4096, "Error", "Clipboard content is NOT a registry key!")
;Exit
EndIf

Edit: typo

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
guinness

You're welcome. I may optimise the SRE and post to the examples section in the next couple of days.


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 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: 22/04/2018

Share this post


Link to post
Share on other sites
guinness

A different approach without using SRE >>

Edited by guinness

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 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: 22/04/2018

Share this post


Link to post
Share on other sites
careca

Thank you, Good job, only a question, "HKEY_LOCAL_MACHINE64" this doesn't exist on my registry, i believe, so why does it appear as valid?


Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
guinness

When running on 64-bit Windows if you want to read a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.


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 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: 22/04/2018

Share this post


Link to post
Share on other sites
careca

Alright, thanks.


Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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  

  • Similar Content

    • Rhazz
      By Rhazz
      Hello! I have a "syntax error" but I can't understand where is it. Can you help me with this?
      There is two text files. I want to write three lines of the first file in each line of the second file. Then, if the first file has 600 lines, the second file should have 200 lines.
      I hope I have explained well what I want.
      #include <File.au3> Local $sFile1 $sFile1 = "File1.txt" Local $sFile2 $sFile2 = "File2.txt" Local $sThreeLinesIntoOne FileOpen($sFile1,0) FileOpen($sFile2,2) For $i In ( _FileCountLines($sFile1) / 3 ) For $a = ( ( $i - 1 ) * 3 ) + 1 ) To ( $i * 3 ) $sThreeLinesIntoOne = $sThreeLinesIntoOne & FileReadLine($sFile1, $a) Next FileWriteLine($sFile2, $sThreeLinesIntoOne) Next FileClose($sFile2) FileClose($sFile1) AutoIt returns:
       
    • czardas
      By czardas
      I needed this library to continue working on one or two of my projects. Hopefully it will be of use to someone else too. These functions attempt to perform accurate calculations for the largest Int-64 values, testing for integer overflow and resorting to floats when results go out of range. This library is primarily intended to be used with Int-32 or Int-64 values and it offers no advantage whatsoever to pass floats as parameters. It only makes sense if you intend to perform accurate calculations on large Int-64 values. I know this can be done using strings too, but I prefer not to speculate as to the difference in time penalties.
      ; #INDEX# ====================================================================================================================== ; Title .........: operator64 ; AutoIt Version : 3.3.14.0 ; Language ......: English ; Description ...: Helper functions for basic maths operations to be used with Int-32 and Int-64 numeric data types. ; Notes .........: Tests for integer overflow and attempts to correct for small inaccuracies affecting certain calculations. ; Return values are cast as Int-32 or Int-64 when possible, otherwise the result will be returned as a double. ; If it is not possible to return an Int-64 data type, the @extended flag is always set to non zero. ; Extended return values indicate that 100% accuracy cannot be guaranteed or that the result is ambiguous. ; The following values are valid for all functions in this library ; |@error = 1 The input or first operand is not an integer. ; |@error = 2 The second operand is not an integer. ; |@error = 3 Internal function error (ignore). ; |@extended = 1 The result is limited to double precision. ; |@extended = 2 The result is not an integer. ; |@extended = 3 The result is out of range for Int-64. ; |@extended = 4 The result is infinity. ; |@extended = 5 The result is an imaginary number. ; When an error occurs, the @extended flag is always set to non zero and a value returned regardless. ; Author(s) .....: czardas ; ============================================================================================================================== ; #CURRENT# ==================================================================================================================== ; _Abs64 ; _Add64 ; _Divide64 ; _Multiply64 ; _Power64 ; _Root64 ; _Subtract64 ; ============================================================================================================================== ; #INTERNAL_USE_ONLY#=========================================================================================================== ; __DoubleTo64 ; __Integer64 ; __OverflowDetect ; __Product64 ; __WholeNumberDivision ; ============================================================================================================================== ; #FUNCTION# =================================================================================================================== ; Name...........: _Abs64 ; Description ...: Returns the absolute value of an integer. ; Syntax.........: _Abs64($iInteger) ; Parameters.....; $iInteger - The integer to operate on. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@error = 1 The input parameter is not an integer. ; |@extended = 2 The result is not an integer. ; |@extended = 3 The absolute value (2^63) is out of range for Int-64. ; Author.........: czardas ; ============================================================================================================================== Func _Abs64($iInteger) $iInteger = __Integer64($iInteger) If @error Then Return SetError(1, 2, Abs($iInteger)) If $iInteger = 0x8000000000000000 Then Return SetExtended(3, Abs($iInteger)) Return $iInteger < 0 ? $iInteger *-1 : $iInteger EndFunc ;==> _Abs64 ; #FUNCTION# =================================================================================================================== ; Name...........: _Add64 ; Description ...: Adds two integers together. ; Syntax.........: _Add64($iOperand_1, $iOperand_2) ; Parameters.....; $iOperand_1 - The first operand. ; $iOperand_2 - The second operand. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@error = 1 The first parameter is not an integer. ; |@error = 2 The second parameter is not an integer. ; |@extended = 1 The result is limited to double precision. ; |@extended = 3 The result is out of range for Int-64. ; Author.........: czardas ; ============================================================================================================================== Func _Add64($iOperand_1, $iOperand_2) $iOperand_1 = __Integer64($iOperand_1) If @error Then Return SetError(1, 1, __DoubleTo64($iOperand_1 + $iOperand_2)) ; may still return an integer $iOperand_2 = __Integer64($iOperand_2) If @error Then Return SetError(2, 1, __DoubleTo64($iOperand_1 + $iOperand_2)) ; ditto Local $bOverflow, $nResult $bOverflow = __OverflowDetect('+', $iOperand_1, $iOperand_2, $nResult) Return SetExtended($bOverflow *3, $nResult) EndFunc ;==> _Add64 ; #FUNCTION# =================================================================================================================== ; Name...........: _Divide64 ; Description ...: Divides two integers. ; Syntax.........: _Divide64($iOperand_1, $iOperand_2) ; Parameters.....; $iOperand_1 - The first operand. ; $iOperand_2 - The second operand. ; Failure returns the executed expression and sets the following flags: ; |@error = 1 The first parameter is not an integer. ; |@error = 2 The second parameter is not an integer. ; |@extended = 1 The result is limited to double precision. ; |@extended = 2 The result is not an integer. ; |@extended = 4 The result is infinity. ; Author.........: czardas ; Comments ......; Due to internal rounding, errors may return an integer with the extended flag set to 2. This is not a bug! ; ============================================================================================================================== Func _Divide64($iOperand_1, $iOperand_2) $iOperand_1 = __Integer64($iOperand_1) If @error Then Return SetError(1, 1, __DoubleTo64($iOperand_1 / $iOperand_2)) ; may still return an integer $iOperand_2 = __Integer64($iOperand_2) If @error Then Return SetError(2, 1, __DoubleTo64($iOperand_1 / $iOperand_2)) ; as above If $iOperand_1 = 0x8000000000000000 Then ; this is not dealt with by the internal function If $iOperand_2 = 0x8000000000000000 Then Return 1 ; $iOperand_1 is divided by itself ; divide both values by 2 to remain within the specified range of the function __WholeNumberDivision() $iOperand_1 = 0xC000000000000000 ; -4611686018427387904 $iOperand_2 = __WholeNumberDivision($iOperand_2, 2) If @extended Then Return SetExtended(@extended, $iOperand_1 / $iOperand_2) EndIf Local $nResult = __WholeNumberDivision($iOperand_1, $iOperand_2) Return SetExtended(@extended, $nResult) EndFunc ;==> _Divide64 ; #FUNCTION# =================================================================================================================== ; Name...........: _Multiply64 ; Description ...: Multiplies two integers together. ; Syntax.........: _Multiply64($iOperand_1, $iOperand_2) ; Parameters.....; $iOperand_1 - The first operand. ; $iOperand_2 - The second operand. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@error = 1 The first parameter is not an integer. ; |@error = 2 The second parameter is not an integer. ; |@extended = 2 The result is not an integer. ; |@extended = 3 The result is out of range for Int-64. ; Author.........: czardas ; Comments ......; Due to internal rounding, errors may return an integer with the extended flag set to 2. This is not a bug! ; ============================================================================================================================== Func _Multiply64($iOperand_1, $iOperand_2) $iOperand_1 = __Integer64($iOperand_1) If @error Then Return SetError(1, 2, $iOperand_1 * $iOperand_2) $iOperand_2 = __Integer64($iOperand_2) If @error Then Return SetError(2, 2, $iOperand_1 * $iOperand_2) Local $iProduct = __Product64($iOperand_1, $iOperand_2) Return SetExtended(@extended, $iProduct) EndFunc ;==> _Multiply64 ; #FUNCTION# =================================================================================================================== ; Name...........: _Power64 ; Description ...: Raises an integer to the power of a second integer. ; Syntax.........: _Power64($iInteger, $iPower) ; Parameters.....; $iInteger - The integer to operate on. ; $iPower - The power to raise the integer to. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@error = 1 The first parameter is not an integer. ; |@error = 2 The second parameter is not an integer. ; |@extended = 1 The result is limited to double precision. ; |@extended = 3 The result is out of range for Int-64. ; Author.........: czardas ; ============================================================================================================================== Func _Power64($iInteger, $iPower) $iInteger = __Integer64($iInteger) If @error Then Return SetError(1, 1, $iInteger ^ $iPower) $iPower = __Integer64($iPower) If @error Then Return SetError(2, 1, $iInteger ^ $iPower) If $iInteger = 1 Or $iPower = 0 Then Return 1 If $iPower < 0 Or $iPower > 63 Then Return SetExtended(1, $iInteger ^ $iPower) Local $iTriggers = 0, $iCount = 0, $iPow = $iPower While $iPow > 1 If Mod($iPow, 2) Then $iPow -= 1 Else ; to reduce calls to __Product64() ; triggers indicate the product should be squared (see next loop) $iTriggers += 2 ^ $iCount ; set trigger $iPow /= 2 EndIf $iCount += 1 WEnd Local $iOperand, $iResult = $iInteger For $i = $iCount -1 To 0 Step -1 ; multiply the product either by itself or the original value $iOperand = BitAND($iTriggers, 2^$i) ? $iResult : $iInteger $iResult = __Product64($iResult, $iOperand) If @extended Then Return SetExtended(3, $iInteger ^ $iPower) Next Return $iResult EndFunc ;==> _Power64 ; #FUNCTION# =================================================================================================================== ; Name...........: _Root64 ; Description ...: Calculates the nth root of an integer. ; Syntax.........: _Root64($iInteger, $iRoot) ; Parameters.....; $iInteger - The integer to operate on. ; $iRoot - The root of the integer to calculate. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@error = 1 The first parameter is not an integer. ; |@error = 2 The second parameter is not an integer. ; |@extended = 1 The result is limited to double precision. ; |@extended = 2 The result is not an integer. ; |@extended = 5 The result is an imaginary number. ; Author.........: czardas ; Comments ......; _Root64() has limited application beyond forcing an integer return value whenever possible. ; Roots of negative integers return a defined value if one exists, otherwise the result is always undefined. ; ============================================================================================================================== Func _Root64($iInteger, $iRoot) $iInteger = __Integer64($iInteger) If @error Then Return SetError(1, 1, $iInteger ^ (1 / $iRoot)) $iRoot = __Integer64($iRoot) If @error Then Return SetError(2, 1, $iInteger ^ (1 / $iRoot)) If $iRoot > 63 Or $iRoot < 1 Then Return SetExtended(1, $iInteger ^ (1 / $iRoot)) ; out of range If $iRoot = 1 Then Return $iInteger Local $iSign = $iInteger < 0 ? -1 : 1 If $iSign = -1 And Not Mod($iRoot, 2) Then Return SetExtended(5, $iInteger ^ (1 / $iRoot)) ; undefined If $iInteger = 0x8000000000000000 Then ; here the absolute value cannot be represented by Int-64 ; a small set of defined return values are simply hard coded Local $aMaxRoot = [[3,-2097152],[7,-512],[9,-128],[21,-8],[63,-2]] ; there are only five cases For $i = 0 To 4 If $iRoot = $aMaxRoot[$i][0] Then Return $aMaxRoot[$i][1] Next Return SetExtended(2, $iInteger ^ (1 / $iRoot)) ; the return value is not an integer EndIf ; positive values are used to calculate the odd roots of negative integers Local $iOperand = $iSign = 1 ? $iInteger : $iInteger *-1 ; here the margin of error with Int() is probably too small to necessitate further processing Local $iReturn = Int($iOperand ^ (1 / $iRoot)) ; check the result Local $iCompare = $iReturn For $i = 2 To $iRoot $iCompare *= $iReturn Next ; the chances that this comparison will fail seem negligible - see comments above If $iCompare <> $iOperand Then Return SetExtended(2, $iInteger ^ (1 / $iRoot)) ; the return value is not an integer Return $iReturn * $iSign EndFunc ;==> _Root64 ; #FUNCTION# =================================================================================================================== ; Name...........: _Subtract64 ; Description ...: Subtracts one integer from another. ; Syntax.........: _Subtract64($iOperand_1, $iOperand_2) ; Parameters.....; $iOperand_1 - The first operand. ; $iOperand_2 - The second operand. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@error = 1 The first parameter is not an integer. ; |@error = 2 The second parameter is not an integer. ; |@extended = 1 The result is limited to double precision. ; |@extended = 3 The result is out of range for Int-64. ; Author.........: czardas ; ============================================================================================================================== Func _Subtract64($iOperand_1, $iOperand_2) $iOperand_1 = __Integer64($iOperand_1) If @error Then Return SetError(1, 1, __DoubleTo64($iOperand_1 - $iOperand_2)) ; may still return an integer $iOperand_2 = __Integer64($iOperand_2) If @error Then Return SetError(2, 1, __DoubleTo64($iOperand_1 - $iOperand_2)) ; ditto Local $bOverflow, $nResult $bOverflow = __OverflowDetect('-', $iOperand_1, $iOperand_2, $nResult) Return SetExtended($bOverflow *3, $nResult) EndFunc ;==> _Subtract64 #Region - Internal Functions ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __DoubleTo64 ; Description ...: Helper function - converts an integer value double to Int-32 or Int-64. ; Syntax.........: __DoubleTo64($nValue) ; Parameters.....; $nValue - The double to convert ; Return values .: Success returns Int-32 or Int-64 when the interpreter evaluates the converted double equal to the input. ; Failure returns the input parameter without any modification and sets the following flags: ; |@error = 3 Internal error (x2) ==> see comments in the code. ; |@extended = 2 Conversion failed ==> the return value is not an integer. ; Author ........: czardas ; Comments ......; Doubles representing integer values greater than 15 digits cannot be relied on for accuracy. ; ============================================================================================================================== Func __DoubleTo64($nValue) If Not IsNumber($nValue) Then Return SetError(3, 2, $nValue) ; the input is not a number. If $nValue > -1.0e+015 And $nValue < 1.0e+015 Then Local $iVal64 = Number($nValue, 2) ; convert to Int-64 If $iVal64 = $nValue Then ; check to see if conversion was a success [expected range +/- 5.62949953421311e+014] Return ($iVal64 > 2147483647 Or $iVal64 < -2147483648) ? $iVal64 : Number($iVal64, 1) ; Int-64 or Int-32 ElseIf $iVal64 -1 = $nValue Then ; attempt to adjust for inaccuracies [subject to possible change] Return $iVal64 -1 ElseIf $iVal64 +1 = $nValue Then ; as above Return $iVal64 +1 EndIf EndIf Return SetError(3, 2, $nValue) ; conversion failed EndFunc ;==> __DoubleTo64 ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __Integer64 ; Description ...: Checks if a number is an integer and converts doubles to Int-32 or Int-64 if the result appears unambiguous. ; Syntax.........: __Integer64($nParam) ; Parameters.....; $nParam - The number to test ; Return values .: Success returns Int-32 or Int-64 when the interpreter evaluates the returned integer equal to the input. ; Failure returns the input parameter without any modification and sets the following flags: ; |@error = 1 The input is not an integer. ; |@extended = 2 The return value is not an integer. ; Author ........: czardas ; Comments ......; Doubles representing integer values greater than 15 digits cannot be relied on for accuracy. ; ============================================================================================================================== Func __Integer64($nParam) If Not StringInStr(VarGetType($nParam), 'Int') Then Local $iInt64 = __DoubleTo64($nParam) ; attempt conversion If @error Then Return SetError(1, 2, $nParam) ; $fParam <> $iInt64 $nParam = $iInt64 ; float was compared as being equal to an integer EndIf Return $nParam EndFunc ;==> __Integer64 ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __OverflowDetect ; Description ...: Checks for integer overflow on execution of the expression. ; Syntax.........: __OverflowDetect($sOperator, $iOperand_1, $iOperand_2, $nResult) ; Parameters.....; $sOperator - May be +, - or *. ; $iOperand_1 - The first operand. ; $iOperand_2 - The second operand. ; $nResult - [ByRef] Result of executed expression. ; Return values .: Returns True if integer overflow occurs - otherwise returns False. Returns $nResult ByRef. ; Author ........: czardas ; Comments ......; Int-32 or Int-64 only. No error checks! ; ============================================================================================================================== Func __OverflowDetect($sOperator, $iOperand_1, $iOperand_2, ByRef $nResult) Local $iExecute, $fCompare Switch $sOperator Case '+' ; execute the expression $iExecute = $iOperand_1 + $iOperand_2 ; execute the expression with the operands converted to doubles $fCompare = Number($iOperand_1, 3) + Number($iOperand_2, 3) Case '-' ; as above $iExecute = $iOperand_1 - $iOperand_2 $fCompare = Number($iOperand_1, 3) - Number($iOperand_2, 3) Case '*' ; as above $iExecute = $iOperand_1 * $iOperand_2 $fCompare = Number($iOperand_1, 3) * Number($iOperand_2, 3) EndSwitch ; the results should be approximately equal Local $bReturn = StringFormat('%.14e', $iExecute) <> StringFormat('%.14e', $fCompare) ; %.15e is too sensitive $nResult = $bReturn ? $fCompare : $iExecute Return $bReturn EndFunc ;==> __OverflowDetect ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __Product64($iOperand_1, $iOperand_2) ; Description ...: Helper function - multiplies two Int-32 or Int-64 values together. ; Syntax.........: __Product64($iOperand_1, $iOperand_2) ; Parameters.....; $iOperand_1 - The first integer. ; $iOperand_2 - The second integer. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@extended = 3 The result is out of range for Int-64. ; Author.........: czardas ; Comments ......; Int-32 or Int-64 only. No error checks! ; ============================================================================================================================== Func __Product64($iOperand_1, $iOperand_2) Local $bOverflow, $nResult $bOverflow = __OverflowDetect('*', $iOperand_1, $iOperand_2, $nResult) Return SetExtended($bOverflow *3, $nResult) EndFunc ;==> __Product64 ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __WholeNumberDivision ; Description ...: Divides two integers. ; Syntax.........: __WholeNumberDivision($iDividend, $iDivisor) ; Parameters.....; $iDividend - The first operand. ; $iDivisor - The second operand. ; Return values .: Returns an Int-32, or Int-64, value. ; Failure returns the executed expression and sets the following flags: ; |@extended = 1 The result is limited to double precision. ; |@extended = 2 The result is not an integer. ; |@extended = 4 The result is infinity. ; Author ........: czardas ; Comments ......; Input is limited to +/- 9223372036854775807 for both consitency and compatibility with future libraries. ; May return an integer with the extended flag set to 2 due to internal rounding. This is not a bug! ; ============================================================================================================================== Func __WholeNumberDivision($iDividend, $iDivisor) ; Input ranges -9223372036854775807 To 9223372036854775807 If $iDivisor = 0 Then Return SetExtended(4, $iDividend / $iDivisor) ; division by zero Local $aDiv = [$iDividend, $iDivisor], _ $iSign = 1 For $i = 0 To 1 If $aDiv[$i] > 0x7FFFFFFFFFFFFFFF Or $aDiv[$i] < 0x8000000000000001 Then Return SetExtended(1, $iDividend / $iDivisor) ; input range exceeded If $aDiv[$i] < 0 Then ; force positive integers $aDiv[$i] *= -1 $iSign *= -1 ; to add back later EndIf Next If Mod($aDiv[0], $aDiv[1]) Then Return SetExtended(2, $iDividend / $iDivisor) ; not divisible If $aDiv[0] = 0 Then Return 0 If $aDiv[1] = 1 Then Return $aDiv[0] * $iSign Local $iDivision = Floor($aDiv[0] / $aDiv[1]), $iDifference, $iIntegral While $iDivision * $aDiv[1] > $aDiv[0] ; division is overstated $iDifference = ($aDiv[1] * $iDivision) - $aDiv[0] $iIntegral = Floor($iDifference / $aDiv[1]) ; avoid shooting beyond the target If $iIntegral = 0 Then $iIntegral = 1 ; prevents hanging in an infinite loop $iDivision -= $iIntegral WEnd While $iDivision * $aDiv[1] < $aDiv[0] ; division is understated $iDifference = $aDiv[0] - ($aDiv[1] * $iDivision) $iIntegral = Floor($iDifference / $aDiv[1]) ; as above If $iIntegral = 0 Then $iIntegral = 1 ; prevents hanging $iDivision += $iIntegral WEnd Return $iDivision * $iSign EndFunc ;==> __WholeNumberDivision #EndRegion
      The following tests need updating because values for @error and @extended have changed.
      #include 'operator64.au3' ConsoleWrite("Testing _Abs64()" & @LF) ; ==> Err Ext Result $test = _Abs64(0xC000000000000000) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 4611686018427387904 $test = _Abs64(0x8000000000000000) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 2 1 9.22337203685478e+018 $test = _Abs64(0x8000000000000001) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 9223372036854775807 $test = _Abs64(-0.123) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 1 1 0.123 ;=========================================================== ConsoleWrite(@LF & "Testing _Add64()" & @LF) $test = _Add64(0x7FFFFFFFFFFFFFFF, 1) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 1 9.22337203685478e+018 $test = _Add64(0x7FFFFFFFFFFFFFFF, 0) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 9223372036854775807 $test = _Add64(0x7FFFFFFFFFFFFFFF, -1) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 9223372036854775806 $test = _Add64(33, 15) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 48 ;=========================================================== ConsoleWrite(@LF & "Testing _Divide64()" & @LF) $test = _Divide64(0x7FFFFFFFFFFFFFFF, -1) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 -9223372036854775807 $test = _Divide64(0x8000000000000000, -2) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 4611686018427387904 $test = _Divide64(10.0, 2) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 5 $test = _Divide64(9223372036854775552, -2) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 -4611686018427387776 $test = _Divide64(9223372036854775552, 0) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 2 1 1.#INF $test = _Divide64(675432.0097, -987) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 1 1 -684.328277304965 $test = _Divide64(6922337, 15) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 4 1 461489.133333333 ;=========================================================== ConsoleWrite(@LF & "Testing _Multiply64()" & @LF) $test = _Multiply64(9223372036854775552, -2) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 1 -1.84467440737096e+019 $test = _Multiply64(223372036854775552, 9) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 2010348331692979968 $test = _Multiply64(1.01, -1) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 1 1 -1.01 ;=========================================================== ConsoleWrite(@LF & "Testing _Power64()" & @LF) $test = _Power64(-2.0, 63) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 -9223372036854775808 $test = _Power64(37, 12.0) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 6582952005840035281 $test = _Power64(17, 19) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 1 2.39072435685151e+023 ;=========================================================== ConsoleWrite(@LF & "Testing _Subtract64()" & @LF) $test = _Subtract64(1.0, 1) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 0 $test = _Subtract64(0x8000000000000000, -1) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 -9223372036854775807 $test = _Subtract64(0x8000000000000000, 0) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 0 -9223372036854775808 $test = _Subtract64(0x8000000000000000, 1) ConsoleWrite(@Error & @TAB & @Extended & @TAB & $test & @LF) ; ==> 0 1 -9.22337203685478e+018 It's nice to try and figure out something like this for yourself, but it would be quite impossible without the hints and advice I receive from others when I take a wrong turn sometimes. So thanks to those people.
    • guestscripter
      By guestscripter
      I´m getting mixed up!
      What´s the difference between:
      While NOT Func1() AND Func2()   and
      While NOT Func1() AND NOT Func2() ??
       
      I´m using lots of these and it works find,
      but now that I´m rewriting my script I´m mixing things up and getting unsure.
    • Schoening
      By Schoening
      Hey,
      so after searching the Forums, Google, YouTube and Other Forums, I found ImageSearch!

      AnyBody Not Shure what ImageSearch is, it is a pixelsearch that looks for a image file in the ImageSearch.au3 directory and then Looks for it on the Screen

      Great Stuff !

      Here is a Little Example where i Search for a .png

      #include <ImageSearch.au3> $x = 0 $y = 0 $res = _imagesearcharea("GreenYellow.png",1,340,150,940,512,$x,$y,100) If $res = 1 Then MouseMove($x,$y,100) Else MsgBox(0,"404","Not Found") EndIf Just a quick explain on what happens in the function _imagesearcharea:

      _imagesearcharea("GreenYellow.png",1,340,150,940,512,$x,$y,100)
      _imagesearcharea("image_name" , a*,b*,b*,b*,b*,c*,c*,d*)

      a* = Chooses the Return Value for C*. 0 = top x,y Pixel 1 = Center of the Found image.
      b* = Coordinates for the Search Window(Top,Left,Right,Bottom)
      c* = The Return Variables (See a*)
      d* = Variaton between Image and Search.

      I'm not sure if the explanation was needed, i just like pretty Topics


      My actual problem :
      I want to make a do_until loop that keeps doing _Imagesearcharea until i drag the desktop icon in the circa Area.
      I could do this by just specifying the Search window. But that would be way to Easy
      Instead i want the Loop to Run until the icon is dragged "near" a predefined spot on one axis using one of the Variables from _Imagesearcharea.

      So lets say i want to ImageSearch until i drag it near the middle of the Screen Seen from the X axis.

      Until $x = 640 But that is not "Near" ! That is exact ! I want it to Do_Until it is "close" to 640, so it should also stop searching when it is +20 or -20 from 640.

      I think i will do this with some advanced Operators ? Math has never been my Strength...
      Please Help
×