Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Misc.au3>
- #include <Array.au3>
- #include <Constants.au3>
- #include <MsgBoxConstants.au3>
- #include <GUIConstants.au3>
- #include <FileConstants.au3>
- #include <File.au3>
- #include <WinAPIFiles.au3>
- Local $GuiWidth = 100
- Local $GuiHeigh = 370
- Local $sFilePath = "C:\Program Files (x86)\AutoIt3\ScriptsForLaser/CustomCoordList.txt"
- Func NumButton($numButton)
- return 10+50*$numButton
- EndFunc
- Local $SetGUI = GUICreate("Settings ",$GuiWidth,$GuiHeigh)
- Local $startPointSet = GUICtrlCreateButton("Point Set",10,NumButton(0),80,40)
- Local $startAreaSet = GUICtrlCreateButton("Area Set",10,NumButton(1),80,40)
- Local $ShowList = GUICtrlCreateButton("Show Coord List",10,NumButton(2),80,40,$BS_MULTILINE)
- Local $Update = GUICtrlCreateButton("Update Coord",10,NumButton(3),80,40,$BS_MULTILINE)
- Local $UpdateName = GUICtrlCreateButton("Update Line Name",10,NumButton(4),80,40,$BS_MULTILINE)
- Local $DelCord = GUICtrlCreateButton("Delete Line",10,NumButton(5),80,40,$BS_MULTILINE)
- Local $DeleteFile = GUICtrlCreateButton("Delete File",10,NumButton(6),80,40,$BS_MULTILINE)
- Local $sOutString = "Unknown"
- Local $sBoofer = "Unknown"
- Local $sNameOfLine = "Unknown"
- Local $sNewNameOfLine = "Unknown"
- Local $aMousePos = MouseGetPos()
- Local $mouseX = $aMousePos[0]
- Local $mouseY = $aMousePos[1]
- ;---------------------------------------------------------------------------------------------
- Func WriteToFile($sString)
- $hFileOpen = FileOpen($sFilePath,1)
- If $hFileOpen = -1 Then
- MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
- Return False
- EndIf
- FileWrite($hFileOpen,$sString&@CRLF)
- FileClose($hFileOpen)
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func StringSerch($sStringToFinde)
- Local $TypeCheck = "UNKNOWN"
- Local $iTypeCheck = -1
- Local $iIndexOfSubString = 0
- Local $i = 3
- Local $iResult = 0
- Local $aResult[$i] = [0,"UNKNOWN","UNKNOWN"]
- ;MsgBox("","",$aResult[0]&" "&$aResult[1]&" "&$aResult[2])
- Local $sResult = "UNKNOWN"
- Local $aLineArray[_FileCountLines ( $sFilePath )]
- Local $sSearchPoint = $sStringToFinde
- Local $iStringChekIndex = StringLen($sSearchPoint)
- _FileReadToArray ($sFilePath,$aLineArray)
- for $line =1 to UBound($aLineArray)-1
- $iIndexOfSubString = StringInStr($aLineArray[$line],$sSearchPoint)
- If $iIndexOfSubString>0 AND StringInStr($aLineArray[$line]," ",0,1,$iStringChekIndex,$iStringChekIndex+1)>0 Then
- $iResult = $line
- ExitLoop
- EndIf
- Next
- If $iResult=0 Then
- ;MsgBox("Result","","Not Found")
- $sResult = "Not Found"
- Else
- $sResult = $aLineArray[$iResult]
- ;MsgBox("result","",$sResult)
- EndIf
- $iTypeCheck = StringInStr($sResult,"p ")
- If $iTypeCheck =1 Then
- $TypeCheck = "Point"
- Else
- $TypeCheck = "Area"
- EndIf
- $aResult[0] = $iResult
- $aResult[1] = $TypeCheck
- $aResult[2] = $sResult
- ;MsgBox("","",$aResult[0]&" "&$aResult[1]&" "&$aResult[2])
- Return $aResult
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func SetButton($sName)
- Local $namePoint = $sName
- Local $aCheckExist[3] = [0,"UNKNOWN","UNKNOWN"]
- $aCheckExist = StringSerch($sName)
- If $aCheckExist[0]>0 Then
- MsgBox("Result","","Line "&$sName&" is allready exist!"&@CRLF&$aCheckExist[2])
- Else
- while 1
- Sleep (100)
- If _IsPressed("01") Then
- $aMousePos = MouseGetPos()
- $mouseX = $aMousePos[0]
- $mouseY = $aMousePos[1]
- $sOutString = "p "&$namePoint&" x="&$mouseX&" y="&$mouseY
- MsgBox("","",$sOutString)
- ExitLoop
- EndIf
- WEnd
- return $sOutString
- EndIf
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func SetNamePoint($sName,$sNewName)
- Local $sResult = "Unknown"
- Local $aSplitLine[5]
- $aSplitLine = StringSplit($sName, " ")
- $sResult = $aSplitLine[1]&" "&$sNewName&" "&$aSplitLine[3]&" "&$aSplitLine[4]
- return $sResult
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func SetNameArea($sName,$sNewName)
- Local $sResult = "Unknown"
- Local $aSplitLine[7]
- $aSplitLine = StringSplit($sName, " ")
- $sResult = $aSplitLine[1]&" "&$sNewName&" "&$aSplitLine[3]&" "&$aSplitLine[4]&" "&$aSplitLine[5]&" "&$aSplitLine[6]
- return $sResult
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func SetArea($sName)
- Local $nameArea = $sName
- Local $aCheckExist[3] = [0,"UNKNOWN","UNKNOWN"]
- $aCheckExist = StringSerch($sName)
- If $aCheckExist[0]>0 Then
- MsgBox("Result","","Line "&$sName&" is allready exist!"&@CRLF&$aCheckExist[2])
- Else
- while 1
- while 1
- If _IsPressed("01") Then
- $aMousePos = MouseGetPos()
- $mouseX = $aMousePos[0]
- $mouseY = $aMousePos[1]
- $sOutString = "a "&$nameArea&" Left="&$mouseX&" Top="&$mouseY
- ExitLoop
- EndIf
- WEnd
- MsgBox("","",$sOutString)
- while 1
- If _IsPressed("01") Then
- $aMousePos = MouseGetPos()
- $mouseX = $aMousePos[0]
- $mouseY = $aMousePos[1]
- $sOutString = $sOutString&" Right="&$mouseX&" Bottom="&$mouseY
- ExitLoop
- EndIf
- WEnd
- MsgBox("","",$sOutString)
- ExitLoop
- WEnd
- return $sOutString
- EndIf
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func Delete()
- FileDelete($sFilePath)
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func ShowList()
- ;$FileCheck
- If FileExists($sFilePath)>0 Then
- $sFileRead = FileRead($sFilePath)
- MsgBox("File content","",$sFileRead)
- Else
- MsgBox("Error","","File not exist")
- EndIf
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func StringDelete($sStringToFinde)
- Local $aStatusArray[3] = [0,"UNKNOWN","UNKNOWN"]
- Local $aLinesArray[_FileCountLines ( $sFilePath )]
- $aStatusArray = StringSerch($sStringToFinde)
- If $aStatusArray[0]>0 Then
- _FileReadToArray ($sFilePath,$aLinesArray)
- Delete()
- MsgBox("","","Index of Line: "&$aStatusArray[0]&" | Type of Line: "&$aStatusArray[1]&" | Line content: "&$aStatusArray[2])
- _ArrayDelete($aLinesArray,$aStatusArray[0])
- _FileWriteFromArray($sFilePath,$aLinesArray,1)
- MsgBox("Result","",$aStatusArray[2]&" was deleted")
- Else
- MsgBox("Result","","Line not found")
- EndIf
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func UpdateCoord($sName)
- Local $aStatusArray[3] = [0,"UNKNOWN","UNKNOWN"]
- Local $iTypeCheck = "Point"
- Local $aLinesArray[_FileCountLines ( $sFilePath )]
- Local $sNewData = "UNKNOWN"
- Local $aStatusArray = StringSerch($sName)
- If $aStatusArray[0]>0 Then
- StringDelete($sName)
- _FileReadToArray ($sFilePath,$aLinesArray)
- Delete()
- If StringInStr($aStatusArray[1],"Area")>0 Then
- $sNewData = SetArea($sName)
- Else
- $sNewData = SetButton($sName)
- EndIf
- _ArrayAdd($aLinesArray,$sNewData)
- _FileWriteFromArray($sFilePath,$aLinesArray,1)
- MsgBox("Result","",$aStatusArray[2]&" was updated to:"&@CRLF&$sNewData)
- Else
- MsgBox("Result","","Can`t update Line")
- EndIf
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func UpdateName($sName,$sNewName)
- Local $aStatusArray[3] = [0,"UNKNOWN","UNKNOWN"]
- Local $iTypeCheck = "Point"
- Local $aLinesArray[_FileCountLines ( $sFilePath )]
- Local $sNewData = "UNKNOWN"
- Local $aStatusArray = StringSerch($sName)
- If $aStatusArray[0]>0 Then
- StringDelete($sName)
- _FileReadToArray ($sFilePath,$aLinesArray)
- Delete()
- If StringInStr($aStatusArray[1],"Area")>0 Then
- $sNewData = SetNameArea($aStatusArray[2],$sNewName)
- Else
- $sNewData = SetNamePoint($aStatusArray[2],$sNewName)
- EndIf
- _ArrayAdd($aLinesArray,$sNewData)
- _FileWriteFromArray($sFilePath,$aLinesArray,1)
- MsgBox("Result","",$aStatusArray[2]&" was updated to:"&@CRLF&$sNewData)
- Else
- MsgBox("Result","","Can`t update Line")
- EndIf
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Func DeleteCoord()
- Local $sSearchPoint = InputBox("","Enter name of Line")
- StringDelete($sSearchPoint)
- EndFunc
- ;---------------------------------------------------------------------------------------------
- Local $iLeftDesktopWidth = 50
- Local $iLeftDesktopHeight = @DesktopHeight - $GuiHeigh - 50
- GUISetState(@SW_SHOW,$SetGUI)
- WinSetOnTop ("Settings","",1)
- WinMove("Settings","",$iLeftDesktopWidth,$iLeftDesktopHeight)
- While 1
- Sleep (50)
- Switch GUIGetMsg()
- Case $GUI_EVENT_CLOSE
- ExitLoop
- Case $startPointSet
- $sNameOfLine = InputBox(""," ","Enter name of Point")
- $sBoofer = SetButton($sNameOfLine)
- If StringLen($sBoofer)>2 Then
- WriteToFile($sBoofer)
- EndIf
- Case $startAreaSet
- $sNameOfLine = InputBox(""," ","Enter name of Area")
- $sBoofer = SetArea($sNameOfLine)
- If StringLen($sBoofer)>2 Then
- WriteToFile($sBoofer)
- EndIf
- Case $DeleteFile
- Delete()
- Case $ShowList
- ShowList()
- Case $Update
- $sNameOfLine = InputBox(""," ","Enter name of Line")
- UpdateCoord($sNameOfLine)
- Case $UpdateName
- $sNameOfLine = InputBox(""," ","Enter name of Line")
- $sNewNameOfLine = InputBox(""," ","Enter new name of Line")
- UpdateName($sNameOfLine,$sNewNameOfLine)
- Case $DelCord
- DeleteCoord()
- EndSwitch
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement