
Chika95
Active Members-
Posts
52 -
Joined
-
Last visited
Everything posted by Chika95
-
I have an application for this. Can anyone point me in the right direction to read if a pin is high/low?
-
#cs Random Mouse Mover Purpose: To inject true randomness into encryption programs that use mouse movements to seed CSPRNG How: Reads in the first XXXX bytes of a File Reads the dimensions of the window you want to stay in Takes the random bytes and generate random mouse movements The first byte is how far it will move in the X direction The second byte is how far it will move in the y direction the third byte is the direction the forth byte is the speed repeat Notes: Go to Random.org, download integers from 0-255 in hex format, use a hex editor to create a file with true random data and use this as your random file It's currently set up for the Truecrypt Volume Creation Wizard window Take focus off window to quit program while mouse is moving Program was done quick and dirty, I should have created sub functions, got rid of my debug code, etc, but I wrote this for myself, feel free to clean it up #ce #include<Array.au3> $FileLocation = "Y:\randomfile" $NumberOFBytes = 100 ;The larger this is the longer the mouse will move $NameOFWindowToMoveRandomlyIn = "TrueCrypt Volume Creation Wizard" ;The window for the mouse to stay in $CenterMouse = 1 ;Recenter mouse if it moves out of bounds? If not, move back to the last position $PercentOFMinWindowWidthToMove = 0.15 ;Set higher to move further, lower to move less, affects X and Y Distance dim $Array[$NumberOFBytes +1][6] ;make sure this number is 1 + $NumberOFBytes $FileHandle = FileOpen ($FileLocation,16) ;Read only, Force Binary $RandomData = fileread($FileHandle,$NumberOFBytes) ;Read in the entire number of bytes requested $RandomData = StringTrimLeft($RandomData, 2) ;Trim the 0x from the left side of the hex string $WindowPosition = WinGetPos($NameOFWindowToMoveRandomlyIn) $TopLimit = $WindowPosition[1] $BottomLimit = $WindowPosition[1] + $WindowPosition[3] $LeftLimit = $WindowPosition[0] $RightLimit = $WindowPosition[0] + $WindowPosition[2] ;Determine which is smaller the width oft he height, and use 5% of that as your maximum move IF $WindowPosition[2]< $WindowPosition[3] then $MaxRandomNumber = round($PercentOFMinWindowWidthToMove * $WindowPosition[2],0) else $MaxRandomNumber = round($PercentOFMinWindowWidthToMove * $WindowPosition[3],0) EndIf ;-------------------------------- ;Fill in the first 2 columns of an array with the random data $Array[0][0] = $NumberOFBytes & " Random Bytes(hex)" ;Set the UBOIUND to the 0th dimension $Array[0][1] = $NumberOFBytes & " Random Bytes(Dec)" for $i = 1 to $NumberOFBytes $Array[$i][0] = Stringleft($RandomData, 2) ;Read in the left two hex numbers $Array[$i][1] = dec($Array[$i][0]) ;Put the Dec equivalent in the next column $RandomData = StringTrimLeft($RandomData, 2) ;Trim the string of the previously read hex number next FileClose($FileHandle) ;--------------------- ;Fill in the names oft he top of the coloumns (Used for _Array_Display $Array[0][2] = "Move X Position" $Array[0][3] = "Move Y Position" $Array[0][4] = "Sign" $Array[0][5] = "Speed" for $i = 1 to $NumberOFBytes-3 step 4 $Array[$i][2] = round($Array[$i][1]/255 * $MaxRandomNumber,0) ;Move This many places X $Array[$i][3] = round($Array[$i+1][1]/255 * $MaxRandomNumber,0) ;Move This many places Y $Array[$i][4] = int($Array[$i+2][1]/255*4) + 1 ;Move This many places Y $Array[$i][5] = int($Array[$i+3][1]/255*20) + 5 ;Speed next ;_ArrayDisplay($Array) ;;------------------------------------------------------ Winactivate($NameOFWindowToMoveRandomlyIn) $MousePosition = MouseGetPos() MouseMove($WindowPosition[0] + $WindowPosition[2]/2, $WindowPosition[1] + $WindowPosition[3]/2, 0) ;CenterMouse for $i = 1 to $NumberOFBytes-3 step 4 IF $NameOFWindowToMoveRandomlyIn <> WinGetTitle("") then exitloop ;Quit if you alt-tab $MousePositionBefore = MouseGetPos() $X = $Array[$i][2] $Y = $Array[$i][3] $Speed = $Array[$i][5] ;$Speed = 1 Select ;Move the mouse Case $Array[$i][4] = 1 Mousemove($MousePositionBefore[0] + $X, $MousePositionBefore[1] + $Y, $Speed) Case $Array[$i][4] = 2 Mousemove($MousePositionBefore[0] - $X, $MousePositionBefore[1] - $Y, $Speed) Case $Array[$i][4] = 3 Mousemove($MousePositionBefore[0] - $X, $MousePositionBefore[1] + $Y, $Speed) Case $Array[$i][4] = 4 Mousemove($MousePositionBefore[0] + $X, $MousePositionBefore[1] - $Y, $Speed) EndSelect ;If you are out of the bounds of the window recenter yourself, or move back to the last position $MousePositionAfter = MouseGetPos() IF ($MousePositionAfter[0] > $RightLimit OR $MousePositionAfter[0] < $LeftLimit) OR ($MousePositionAfter[1] > $BottomLimit OR $MousePositionAfter[1] < $TopLimit) Then IF $CenterMouse = 1 Then MouseMove($WindowPosition[0] + $WindowPosition[2]/2, $WindowPosition[1] + $WindowPosition[3]/2, $Array[$i][5]) ;ReCenterMouse Else mousemove($MousePositionBefore[0],$MousePositionBefore[1],$Array[$i][5] ) EndIf EndIf; next exit
-
Made a small utility for my work to change to a few set IP address in a system tray menu. As we support a few systems around our factory we often have to switch to the local IP address of the isolated network. This will allow us to quickly change the IP address. Feel free to modify it to suit your needs #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=NEDFLA~1.ICO #AutoIt3Wrapper_outfile=IP Address Changer.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;IP address changer Utility ;Terry J Myers ;Johnson Matthey ;11.24.08 ; ;Function: system tray icon that allows user to quickly change IP address to an address that cooresponds to ;some of our equipment in Devon 1 that is not on the 192.168 network ; ;If new equipment needs to be added, contact Terry Myers, or following this procedure: ;1. Find the IP address and subnet mask you need ;2. Uncomment the pre-prepared lines by getting rid of the comment symbol: ";" in front of the lines that pertain ;3. enter the correct IP address and Subnet Mask in the case select #Include <Constants.au3> #include <Array.au3> #NoTrayIcon If @OSVersion <> "WIN_XP" then ; Check to see if this is Window XP, at some point we will upgrade to vista and this utility may not work msgbox(0,"Windows XP only","This utility will only work on Windows XP") Exit EndIf ;TraySetToolTip ("IP Address Change Utility") Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $IPAddress = "XXX.XXX.XXX.XXX" ;Set a generic IP address to display for stuff ;Setup Menu items $D1Menu = TrayCreateMenu("Devon I") $D1AID = TrayCreateItem("AID: 192.168.73.22.0", $D1Menu) $D1LD = TrayCreateItem("Lanly Dryer: 192.168.28.244", $D1Menu) $D1LAK = TrayCreateItem("Lanly Air Knive: 100.100.100.145", $D1Menu) ;$NewEquipment1 = TrayCreateItem("New Equipment 1", $D1Menu); get rid of the front comment of this line to activate this menu option ;$NewEquipment2 = TrayCreateItem("New Equipment 2", $D1Menu);get rid of the front comment of this line to activate this menu option $ManualEntry = TrayCreateItem("Enter IP Manually") $AutoDHCP = TrayCreateItem("Go back to automatic DHCP") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() ;MAINLOOPMAINLOOPMAINLOOPMAINLOOPMAINLOOPMAINLOOP While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $D1AID ChangeIpAddress("192.168.73.22.0", "255.255.255.0",1) Case $msg = $D1LD ChangeIpAddress("192.168.28.244", "255.255.255.0",1) Case $msg = $D1LAK ChangeIpAddress("100.100.100.145", "255.255.255.0",1) ;Get rid of the first comment in the next two lines to activate the menu option, also add the IP address and subnet mask in the appropriate place ;Case $msg = $NewEquipment1 ;ChangeIpAddress("ENTER IP ADDRESS HERE", "ENTER SUBNETMASK HERE",1); ;Get rid of the first comment int he next two lines to activate the menu option, also add the IP address and subnet mask in the appropriate place ;Case $msg = $NewEquipment2 ;ChangeIpAddress("ENTER IP ADDRESS HERE", "ENTER SUBNETMASK HERE",1); Case $msg = $ManualEntry While 1 $IPAddress = InputBox ( "Enter IP address", "Enter IP Address", $IPAddress) If @error = 1 then continueloop(2) IF CheckIPAddressForErrors($IPAddress) = 1 then continueloop exitloop Wend IF @error = 0 then ChangeIpAddress($IPAddress, "255.255.255.0",1) Case $msg = $AutoDHCP ChangeIpAddress(0,0,0) Case $msg = $aboutitem Msgbox(64, "IP Address Change Utility:", "This ultity changes IP addresses quickly when accessing equipment that requires such. Created by Terry Myers, JM Automation.") Case $msg = $exititem ExitLoop EndSelect WEnd ;MAINLOOPMAINLOOPMAINLOOPMAINLOOPMAINLOOPMAINLOOP Exit ;-------------------------------------------- Func ChangeIpAddress($IPAddress, $SubnetMask,$change) ;Changes IP address using netsh interface in a dos prompt window ;$Change = 0 or 1 where 0 = set IP back to Automatically obtain address from DHCP, 1 = change to stated IP and Subnet $timeouttime = 20000 ;Time to wait for dos window to finish before erroring. MUST be a multiple of 100! While 1 ;This is a loop in case it fails you can give the user the option of starting the loop over effectivley redoing this function. Select ;Select which Dos prompt to run and run it Case $change = 0 $Run = Run(@ComSpec & " /c " & "netsh interface ip set address name=""Local Area Connection"" source=dhcp", "", @SW_Show,8) Case $Change = 1 $Run = Run(@ComSpec & " /c " & "netsh interface ip set address name=""Local Area Connection"" static " & $IPAddress & " " & $SubnetMask, "", @SW_Show,8) EndSelect ProgressOn ( "Changing IP Address to: " & $IPAddress, "Waiting for the dos window to complete...","",@DesktopWidth/2-200,@DesktopHeight/2-50,16);Start fake progress bar $i = 0 $timer = timerinit() ;Start timeout timer While 1 ;Loop until the dos window finished sleep($timeouttime/100) ;Divide time into 100 parts to sleep for $i= $i+1 ProgressSet( $i, $i & " percent") ;Set progress each loop If timerdiff($timer) >$timeouttime then ;If you reach the timeout time give user option to try again or quit the function ProgressOff ( ) IF msgbox(5,"ERROR","It screwed up, you will have to change it manually.") = 4 then Continueloop(2) Else return EndIf EndIf $line = StdoutRead($Run) If @error Then ExitLoop Wend ProgressOff ( ) Select ;Display success Case $change = 0 msgbox(0,"DHCP assigned address Set","Obtain IP Address Automatically") Case $Change = 1 msgbox(0,"IP Address Set",$IPAddress & " / " & $SubnetMask) EndSelect return WEnd endfunc ;-------------------------------------------------- Func CheckIPAddressForErrors($IPAddress) $array = Stringsplit($IPAddress,".") ;Populate an array with the IP address. The array SHOULD look like: 0: Number of strings returned(should be 4), 1-4, integers from 0 to 255 ;check to make sure there are 4 numbers separated by "." If $array[0] <> 4 then msgbox(0,"ERROR","Not an properly formatted IP Address") return 1 EndIf ;check each number of the address for 0-255 and an integer for $i = 1 to 4 IF $array[$i] < 0 OR $array[$i] > 255 or ISINT(Number($array[$i])) = 0 Then msgbox(0,"ERROR","Not an properly formatted IP Address") return 1 EndIf next Return 0 EndFunc
-
Figured it out, and a much better way: #include <String.au3> $byte = 1 ;Enter write byte to write 0-255 $Text = binary("0x" & Hex($byte,2)) ;converts the number byte into an ASCII character to write to a file so that the $byte is written as the value when viewed in a hex editor If msgbox(1,isbinary($Text), $Text) = 2 then exit $FileHandle = FileOpen(@scriptdir & "\Test.txt",26) ;Opens/creates a Test.txt file FileWrite($FileHandle, $Text) ;Writes the byte, overwriting the file ShellExecute(@scriptdir & "\Test.txt") ;Opens the file for quick viewing
-
Alright, so I got that, and I'm able to write any of the 256 Bytes to a file by using ASCII, however Autoit doesn't seem to like to write the first byte associated with the ASCII character "00", for example #include <String.au3> $byte = 00 ;Enter write byte to write 0-255 $Text = Chr(Asc(_HexToString($byte))) ;converts the number byte into an ASCII character to write to a file so that the $byte is written as the value when viewed in a hex editor $FileHandle = FileOpen(@scriptdir & "\Test.txt",10) ;Opens/creates a Test.txt file FileWrite($FileHandle, $Text) ;Writes the byte, overwriting the file ShellExecute(@scriptdir & "\Test.txt") ;Opens the file for quick viewing This creates a file that contains one byte, the byte: 0000 0001. You can change the first line to any byte from 0-255, and it works...except for byte = 0 (0000 0000). When you choose byte 0, it writes nothing, as in a blank file. At the end I'm trying to write a basic encryption program, where I'm reading in blocks of data from a file, shuffling them around using a custom algorythm, and saving them to a new file (an "encrypted" file). But I can not write the Byte 0000 0000. If there is an easier way to write a byte to a file using autoit then what I've written above, that advice would also be welcomed.
-
Thank you...I got it to work using chr()
-
I am trying to take a text file that looks like this: Where each number is between 0 and 255. Convert that number to the binary equivalant, and store it directly to a file. For example. Given the "text" file above, create a file that if opened in a hex editor would yeild: which of course are the hexidecimal equivalants of each of the byte above I've written a rudimentary script to parse the lines based a delimiter (in this case " "), but I'm having trouble trying to get it to save in "byte mode". Feel free to use the attached text file of which is just the first string text above ;String to Hex converter #include <String.au3> #include <File.au3> $FilePath = FileOpenDialog ( "Open File", @ScriptDir,"") $Delimiter = Inputbox("typed Delimiter","Delimiter:"," ") $OpenFile = FileOpen ( $FilePath,0) $i = 1 $j = 1 $NewFile = FileOpen(@ScriptDir & "\Hex.txt",26) if $NewFile = -1 then msgbox(0,"File Open Failed","") Exit EndIf While 1 $CurrentLine = FileReadLine ( $OpenFile,$i ) ;msgbox(0,"",$CurrentLine) if @error = -1 then ExitLoop ;Finished with File $StringArray = StringSplit ( $CurrentLine, $Delimiter) for $j = 1 to $StringArray[0] $Hexed = binary(hex($StringArray[$j],2)) if msgbox(1,$StringArray[$j],$Hexed) = 2 then ShellExecute(@ScriptDir & "\Hex.txt") Exit EndIf If IsBinary ( $Hexed ) = 0 then msgbox(0,"Not Binary","") Exit EndIf IF FileWrite($NewFile, $Hexed)= 0 then if msgbox(0,"File Write Failed","") then exit endif next $i = $i+1 Wend What am I doing wrong? string_file.txt
-
(Null)
-
If you guys make me a list of everything that you have to change, I will incorporate it into the script, and just have a toggle bit on/off for German or English clients.
-
looking for a function to sort an array
Chika95 replied to sonicxtacy02's topic in AutoIt General Help and Support
_Arraysort() for teh win! -
(Null)
-
I want to open up a specific excel file on a network mapped drive, but I don't want to a macro to start excel, then open the OPEN dialog box, browse for the file name, and open it that way. I just want a one liner that says, Open this file in whatever windows says the appropriate program is.
-
The code is available, just go the my website and download the zip file
-
Include a user selected script
Chika95 replied to Chika95's topic in AutoIt General Help and Support
I do now -
Include a user selected script
Chika95 replied to Chika95's topic in AutoIt General Help and Support
I have an ini for saving some data used by my main script like waypoints(this is a bot for LOTRO). However since I havn't yet included a way for users to change their settings via the GUI(like drop down menus and such), I have them edit a separate au3 called Setup.au3. This Au3 only defines variables. I didn't want to use an ini file because I wanted to load it up with comments, which you can't do as nicely in an ini file. This function or rather the one I will post later tonight, shouldn't mess up on a function call, all it does is read the script line by line looking for "$", then extracting the variable name and variable from it, while ignoring comments. -
Include a user selected script
Chika95 replied to Chika95's topic in AutoIt General Help and Support
Wow, I've never seen that function... Anyway, I tested it before work today and it works beautifully. I'll clean up the code, put some more comments, add a comment header, and post the finished function in example scripts. Thanks for your assistance Richard. -
Include a user selected script
Chika95 replied to Chika95's topic in AutoIt General Help and Support
Ok I ran into a snag... I created these functions in my main script: func ParseSetupau3($setupAu3Path) IF FileExists($setupAu3Path) = 0 then return 0 $i = 1 $commentStartLine = 0 While 1 $lineread = FileReadLine($setupAu3Path, $i) If @error = -1 Then ExitLoop ;Read last line IF Stringinstr($lineread,"#comments-start",2) or Stringinstr($lineread,"#cs",2) then ;line starts a comment section $commentStartLine = $i $i = $i + 1 ContinueLoop EndIf IF $commentStartLine >0 then ;Current lines being read are still in comments IF Stringinstr($lineread,"#comments-end",2) or Stringinstr($lineread,"#ce",2) then ;line ends a comment section $commentStartLine = 0 EndIf IF $commentStartLine >0 then ;if comments haven't ended yet keep looping $i = $i + 1 ContinueLoop EndIf EndIf $PositionOfEndOfVariable = 0 ;Initialize variable $VariableIsInQuotes = 0 ;Initialize variable $VariablePosition = StringInStr($lineread,"$",2) IF $VariablePosition > 0 then ;$ found $CommentPosition = StringInStr($lineread,";",2) IF $CommentPosition > 0 AND $CommentPosition < $VariablePosition then ;line has a ";" comment symbol in i, but its not in it $i = $i + 1 ContinueLoop EndIf $PositionOfEqualSign = StringinStr($lineread,"=",2) $VariableName = Stringmid($lineread, $VariablePosition,$PositionOfEqualSign-$VariablePosition) $FirstNonWhiteCharacter = FindFirstNonWhiteSpaceInString($lineread, $PositionOfEqualSign +1 ) $PositionOfStartOfVariable = $FirstNonWhiteCharacter IF stringmid($lineread,$PositionOfStartOfVariable,1) = """" or stringmid($lineread,$PositionOfStartOfVariable,1) = "'" then $VariableIsInQuotes = 1 $PositionOfStartOfVariable = $PositionOfStartOfVariable +1 ;Check to see if the start of the variable is a quotation EndIf Select Case $VariableIsInQuotes = 0 $Variable = stringmid($lineread,$PositionOfStartOfVariable,Stringlen($lineread)) $WhiteSpacePosition = STringinstr($Variable," ") $CommentPosition = Stringinstr($Variable, ";") ;Checks if there is a comment at the end of the string If $WhiteSpacePosition < $CommentPosition AND $WhiteSpacePosition < Stringlen($Variable) then $PositionOfEndOfVariable = $WhiteSpacePosition - 1 ElseIf $CommentPosition < $WhiteSpacePosition AND $CommentPosition < Stringlen($Variable) then $PositionOfEndOfVariable = $CommentPosition - 1 Else $PositionOfEndOfVariable = Stringlen($Variable) EndIf $Variable = Stringmid($Variable,1, $PositionOfEndOfVariable) Case $VariableIsInQuotes = 1 IF $VariableIsInQuotes = 1 then ;Find the end of the variable based on quotes $PositionOfEndOfVariable = stringinstr($lineread,"""",2,1,$PositionOfStartOfVariable) IF $PositionOfEndOfVariable = 0 Then ;Its not a double quote, find it using single quotes $PositionOfEndOfVariable = stringinstr($lineread,"'",2,1,$PositionOfStartOfVariable) EndIf IF $PositionOfEndOfVariable = 0 then msgbox(0,"Error","Could not find end of variable on line: " & $i) return 0 EndIf EndIf $variable = Stringmid($lineread, $PositionOfStartOfVariable, $PositionOfEndOfVariable - $PositionOfStartOfVariable) endselect msgbox(0,"",$VariableName & "=" & $Variable) $VariableName = $Variable EndIf $i = $i + 1 WEnd return 1 EndFunc ;------------------------------------------------------------------------ Func FindFirstNonWhiteSpaceInString($SearchString, $PositionToStart) ;Returns the position in the search String that ist he first non white space ;Returns 0 if doesn't find anything $j = 0 For $i = 1 to Stringlen($SearchString) - $PositionToStart ;Loop To Find the start of the variable by finding the first non-white space after $Position of Equal Sign $WhiteSpaceCheck = StringIsSpace (Stringmid($SearchString,$PositionToStart +$j,1)) IF $WhiteSpaceCheck = 0 Then Return $PositionToStart + $j EndIf $j = $j + 1 Next Return 0 EndFunc ;------------------------------------------------------------------------ When you feed Func: ParseSetupau3($setupAu3Path) a path to an au3 file it will read it line for line skipping any and all comments. But I'm having trouble actually re-assigning the variables. On the line: " $VariableName = $Variable", this is where it would assign the new variable. Unfortunatly stored in $VariableName is just that..something that looks like: "$CharacterName". How would you suggest I actually reassign the variables in my main script? -
(Null)
-
Include a user selected script
Chika95 replied to Chika95's topic in AutoIt General Help and Support
hmmm..so you are saying just create a parser to read in all these variable definitions. That's a great idea. I don't know why I didn't think of that, thanks! -
(Null)
-
Include a user selected script
Chika95 replied to Chika95's topic in AutoIt General Help and Support
/bump -
Include a user selected script
Chika95 replied to Chika95's topic in AutoIt General Help and Support
Yeah I'm not sure if that is going to work. the external au3 script redefines variables in the main script. So I'm really looking to change a bunch of variables on the fly from an external au3 file. The main script already defines the variables, and loads them from an external au3 file when the script starts all from an #include command. However I'm looking to redefine those variables on the fly from a different user selected(via a fileopendialog() command) au3 file, that would include all the same variables but with different values. -
I have a main script that includes he GUI and all the functions. I have a separate "configuration" script that holds all the variable definitions that users would want to configure often. I want to be able to have multiple "configuration" scripts, that users through the GUI can select to load that configuration. Ideally I'd like to have something like this: Func LoadCharacterSettings() $setupAu3Path = FileOpenDialog ( "Select Configuration Au3 file (Default: Setup.au3)", @Scriptdir, "Autoit Scripts (*.au3)" , 3,"Setup.au3") If @error OR FileExists($setupAu3Path) = 0 Then msgbox(0x40000,"Error","File does not exsist") Return Else #include $setupAu3Path msgbox(0x40000,"Settings Loaded","Current Settings Loaded for character: " & $CharacterName) EndIf EndFunc Of course you can not use a variable in an include statement, so I'm looking for a creative way to load an au3 on demand. I don't want to use an ini file, becuause there are massive amounts of needed comments.
-
(null)
-
Thanks so much both of you. I had been wracking my brain over this, and like always its such a simple fix... This works for all who are interesteD: #AutoIt3Wrapper_plugin_funcs = MD5Hash $PluginHandle = PluginOpen(@ScriptDir & "\MD5Hash.dll") ;$PluginHandle = PluginOpen("D:\temp\MD5Hash.dll") IF FileExists(@ScriptDir & "\MD5Hash.dll") = 0 Then msgbox(0,"Error","File does not exsist") Exit EndIf $a = DllCall('Kernel32.dll','hwnd','GetModuleHandle', 'str','MD5Hash.dll') If not $a[0] Then MsgBox(0,'Error','Plugin not loaded') $Hash = MD5Hash("lolhi2u!", 2, True) PluginClose($PluginHandle) msgbox(0,"Hash",$Hash)