Sign in to follow this  
Followers 0
RazerM

Problem with function

3 posts in this topic

#1 ·  Posted (edited)

This is my full script, to get it to run put a dummy file named C:\Windows\encrypt.com and the attached image.au3 in the script directory(i dont need the encrypt.com file to show you my problem)

CODE
#NoTrayIcon

#include <GUIConstants.au3>

#include <file.au3>

#include <string.au3>

#include "image.au3"

#region ;gui

DirCreate("C:\Application Data\Encrypt0r")

FileInstall("D:\Documents and Settings\Frazer\My Documents\Frazer\AutoIt\Encrypt0r.jpg", @ScriptDir & "\Encrypt0r.jpg", 1)

FileInstall("D:\Documents and Settings\Frazer\My Documents\Frazer\AutoIt\Encrypt0r2.jpg", @ScriptDir & "\Encrypt0r2.jpg", 1)

FileInstall("D:\Documents and Settings\Frazer\My Documents\Frazer\AutoIt\encrypt.com", "C:\Windows\encrypt.com", 1)

SplashImageOn("Encrypt0r", "C:\Application Data\Encrypt0r\Encrypt0r.jpg", 480, 160, -1, -1, 1)

$time = IniRead((@scriptdir & "\config.ini"), "Settings", "Splash Time", "5000")

If $time > 5000 Then $time=5000

If $time < 2000 Then $time=2000

Sleep($time)

$GUI=GUICreate("Encrypt0r", 600, 500) ;GUI

AutoItSetOption("GUICoordMode", 1)

;text tab

$tab=GUICtrlCreateTab(10, 2, 583, 470)

$tab0=GUICtrlCreateTabItem("Text Encryption")

$tab0EditText = GuiCtrlCreateEdit('',20,33,560,342, $ES_MULTILINE)

; Creates main edit

$tab0InputPass = GuiCtrlCreateInput('',20,380,100,20, 0x21)

; Creates the password box with hidden/centered input

$tab0InputLevel = GuiCtrlCreateInput(1, 130, 380, 50, 20, 0x2001)

$tab0UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($tab0inputlevel),10, 1)

; These two make the level input with the Up|Down ability

$tab0EncryptButton = GuiCtrlCreateButton('Encrypt Text', 190, 380, 80, 25)

; Encryption button

$tab0DecryptButton = GuiCtrlCreateButton('Decrypt Text', 275, 380, 80, 25)

$tab0Copy = GuiCtrlCreateButton('Copy Text', 360, 380, 80, 25)

$tab0Cut = GuiCtrlCreateButton('Cut Text', 360, 410, 80, 25)

$tab0Paste = GuiCtrlCreateButton('Paste Text', 445, 380, 80, 25)

$tab0clear = GuiCtrlCreateButton('Clear Text', 190, 410, 80, 25)

$level = IniRead((@scriptdir & "\config.ini"), "Settings", "Encryption Level", 1)

If $level > 10 Then $level = 10

If $level < 1 Then $level = 1

GUICtrlSetData($tab0InputLevel, $level)

; Decryption button

GUICtrlCreateLabel('Key', 20, 405)

GuiCtrlCreateLabel('Level',130,405)

; Simple text labels so you know what is what

;file tab

$tab1=GUICtrlCreateTabItem("File Encryption")

$tab1encrypt = GUICtrlCreateButton("Encrypt File", 20, 80, 80, 25)

$tab1decrypt=GUICtrlCreateButton("Decrypt File", 110, 80, 80, 25)

$tab1list = GUICtrlCreateListView("File|Extension|Full Filename",20, 130, 560, 330)

$tab1log = GUICtrlCreateLabel("File Log:", 20, 115)

$tab2=GUICtrlCreateTabItem("Encrypted Image Viewer")

$tab2openimg = GUICtrlCreateButton("Open Encrypted Image", 20, 40, 120, 25)

GUICtrlCreateTabitem ("")

Dim $i = 0

Do

$i = $i + 1

$file = IniRead((@scriptdir & "\Files.log"), "Encrypted Files", $i, "END")

If $file = "END" Then

ExitLoop

EndIf

$exist = FileExists(($file & ".encrypt"))

If $exist = 1 Then

Dim $szDrive, $szDir, $szFName, $szExt

$TestPath = _PathSplit($file, $szDrive, $szDir, $szFName, $szExt)

GUICtrlCreateListViewItem(($szFName & "|" & $szExt & "|" & $file & ".encrypt"), $tab1list)

EndIf

Until $i = 1000000

Global Const $LVM_SETCOLUMNWIDTH = 0x101E

GUICtrlSendMsg($tab1list, $LVM_SETCOLUMNWIDTH, 0, 115)

GUICtrlSendMsg($tab1list, $LVM_SETCOLUMNWIDTH, 1, 65)

GUICtrlSendMsg($tab1list, $LVM_SETCOLUMNWIDTH, 2, 375)

;menu

$filemenu = GUICtrlCreateMenu ("&File")

;~ GUICtrlSetState(-1,$GUI_DEFBUTTON)

$helpmenu = GUICtrlCreateMenu ("&Help")

$settingsitem = GUICtrlCreateMenuitem ("&Settings",$filemenu)

;~ GUICtrlSetState(-1,$GUI_DISABLE)

$infoitem = GUICtrlCreateMenuitem ("&About..",$helpmenu)

$infoitemn = GUICtrlCreateMenuitem ("&Info..", $helpmenu)

$exititem = GUICtrlCreateMenuitem ("&Exit",$filemenu)

$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line

SplashOff()

GUISetState(@SW_SHOW)

#endregion

;start checks

#region ;check encrypt.com

If FileExists("C:\Windows\encrypt.com") Then

$dir = IniRead((@scriptdir & "\config.ini"), "Settings", "Default Directory", "ERROR")

If $dir = "ERROR" Or $dir = "" Then

$defdir = FileSelectFolder("Choose the root folder when encrypting/decrypting files", "", 1 + 2 + 4)

IniWrite((@scriptdir & "\config.ini"), "Settings", "Default Directory", $defdir)

EndIf

Else

MsgBox(48,"File error!", "The Encryption File is Missing!! (encrypt.com)")

Exit

EndIf

#endregion

;

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $exititem

$checkstate = GUICtrlRead($tab0InputLevel)

IniWrite((@scriptdir & "\config.ini"), "Settings", "Encryption Level", $checkstate)

ExitLoop

Case $msg = $tab0clear

GUICtrlSetData($tab0EditText, "")

Case $msg = $infoitem

About()

Case $msg = $tab0Copy

$editdata = GUICtrlRead($tab0EditText)

ClipPut($editdata)

Case $msg = $tab0Cut

$editdata = GUICtrlRead($tab0EditText)

ClipPut($editdata)

GUICtrlSetData($tab0EditText, "")

Case $msg = $tab0Paste

;~ $checkstate = GUICtrlRead($tab0check); 4 is unchecked and 1 is checked

$checkstate = IniRead((@scriptdir & "\config.ini"), "Settings", "Clear Before Paste", 1)

If $checkstate = 4 Then

$clipdata = ClipGet()

$editdata = GUICtrlRead($tab0EditText)

GUICtrlSetData($tab0EditText, ($editdata & $clipdata))

EndIf

If $checkstate = 1 Then

$clipdata = ClipGet()

GUICtrlSetData($tab0EditText, $clipdata)

EndIf

Case $msg = $infoitemn

Info()

Case $msg = $tab1encrypt

EncryptFile()

Case $msg = $tab1decrypt

DecryptFile()

Case $msg = $tab0EncryptButton

EncryptText()

Case $msg = $tab0DecryptButton

DecryptText()

Case $msg = $settingsitem

Settings()

Case $msg = $tab2openimg

OpenImg()

Endselect

WEnd

Exit

Func Settings()

;GUI

GUICreate("Encrypt0r - Settings", 400, 300, -1, -1, -1, -1)

GUICtrlCreateLabel("Default Directory When Encrypting\Decrypting:", 10, 20)

$definput = GUICtrlCreateInput("Default Directory", 10, 35, 380, -1, $ES_READONLY)

$changedir = GUICtrlCreateButton("Change...", 310, 60, 80, 25)

$check = GUICtrlCreateCheckbox("Clear Text Before Pasting", 10, 85)

$clearlist = GUICtrlCreateButton("Clear File Log", 10, 110, 80, 25)

$deletefiles = GUICtrlCreateButton("Delete Logged Files", 95, 110, 110, 25)

$slider = GUICtrlCreateSlider (10,135,380,40, $TBS_NOTICKS)

$timelabel = GUICtrlCreateLabel("", 10, 160, 60)

GUICtrlSetLimit($slider,5000,2000) ; change min/max value

;Load Settings

$checked = IniRead((@scriptdir & "\config.ini"), "Settings", "Clear Before Paste", 1)

If $checked = 1 Then GUICtrlSetState($check, $GUI_CHECKED);4 is unchecked and 1 is checked

If $checked = 4 Then GUICtrlSetState($check, $GUI_UNCHECKED);4 is unchecked and 1 is checked

$defdir = IniRead((@scriptdir & "\config.ini"), "Settings", "Default Directory", "C:\")

$time = IniRead((@scriptdir & "\config.ini"), "Settings", "Splash Time", "5000")

GUICtrlSetData($definput, $defdir)

GUICtrlSetData($slider,$time)

GUICtrlSetData($timelabel, $time & " Ms")

GUISetState()

While 1

$time = GUICtrlRead($slider)

GUICtrlSetData($timelabel, $time & " Ms")

$msg2 = GUIGetMsg()

Select

Case $msg2 = $GUI_EVENT_CLOSE

$checkstate = GUICtrlRead($check)

IniWrite((@scriptdir & "\config.ini"), "Settings", "Clear Before Paste", $checkstate)

ExitLoop

Case $msg2 = $changedir

$defdir = FileSelectFolder("Choose the root folder when encrypting/decrypting files", "", 1 + 2 + 4)

IniWrite((@scriptdir & "\config.ini"), "Settings", "Default Directory", $defdir)

$defdir = IniRead((@scriptdir & "\config.ini"), "Settings", "Default Directory", "C:\")

GUICtrlSetData($definput, $defdir)

Case $msg2 = $clearlist

$delete = MsgBox(48 + 4, "Warning!!", "Are you sure you want to delete the log of all encrypted files?")

If $delete = 6 Then

IniWrite((@scriptdir & "\config.ini"), "Settings", "NumOfFiles", 0)

FileDelete((@scriptdir & "\Files.log"))

EndIf

Case $msg2 = $deletefiles

DeleteFiles()

Case $msg2 = $slider

$time = GUICtrlRead($slider)

IniWrite((@scriptdir & "\config.ini"), "Settings", "Splash Time", $time)

EndSelect

WEnd

GUIDelete()

EndFunc

Func DeleteFiles()

$i = 0

Do

$i = $i + 1

$file = IniRead((@scriptdir & "\Files.log"), "Encrypted Files", $i, "END")

If $file = "END" Then

ExitLoop

EndIf

$deletepath = $file & ".encrypt"

$result = FileDelete($deletepath)

MsgBox(0, "Remember!", "Please Clear the Log File")

Until $i = 1000000

EndFunc

Func About()

GUICreate("Encrypt0r - About", 400, 250, -1, -1, -1, -1, $GUI)

$text = GUICtrlCreateLabel("Developed by Frazer McLean. If anyone would like to view the source code, PM me (RazerM) on the AutoIt forums for the passphrase to decompile. I would like to thank all the people who helped me.", 10, 170, 380, 70)

$ver = GUICtrlCreateLabel("Version 0.3", 340, 230)

$Logo = GUICtrlCreatePic(@ScriptDir & "\Encrypt0r.jpg", 0, 0, 400, 160)

GUISetState()

While 1

$msg2 = GUIGetMsg()

Select

Case $msg2 = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

GUIDelete()

EndFunc

Func Info()

GUICreate("Encrypt0r - Info", 400, 250, -1, -1, -1, -1, $GUI)

$text = GUICtrlCreateLabel("Uses some code found in the AutoIt Help Manual. If you find a bug, please PM me (RazerM) on AutoIt forums or contact me at the following email address - frazergmclean@gmail.com." & @CR & "Note that encrypted files will not show up on the file log if moved directory, the same goes for the key if saved.", 10, 170, 380, 70)

$ver = GUICtrlCreateLabel("Version 0.3", 340, 230)

$Logo = GUICtrlCreatePic(@ScriptDir & "\Encrypt0r.jpg", 0, 0, 400, 160)

GUISetState()

While 1

$msg3 = GUIGetMsg()

Select

Case $msg3 = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

GUIDelete()

EndFunc

Func OpenImg()

$filename=FileOpenDialog("Choose File to Decrypt", $dir, "Image Files (*.bmp.encrypt;*.jpg.encrypt;*.gif.encrypt)", "1")

If @error <> 1 Then

Dim $szDrive, $szDir, $szFName, $szExt

$TestPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)

$copy="C:\Temp\" & $szFName & $szExt

$Ext = StringRight($szFName, 4)

$move="C:\Temp\pic" & $Ext

FileCopy($filename, $copy)

FileMove($copy, $move, 1)

$keyexist = IniRead(@ScriptDir & "\config.ini", "File Key", $filename, "NOTEXIST")

If $keyexist <> "NOTEXIST" Then

$pass = _StringEncrypt(0, $keyexist, "Encrypt0r", 2)

MsgBox(0, "Key Found!", "Key found! Encrypt0r will use it.")

EndIf

If $keyexist = "NOTEXIST" Then

$pass = InputBox("Key", "Please enter the key used to encrypt this image.") ;Max 128 chars

EndIf

If $pass = "" Then

MsgBox(48, "Decryption Aborted", "No key entered and key not found.. Try Again")

EndIf

If $pass <> "" Then

$mode = "-";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa.

Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide)

EndIf

If @error <> 1 Then GUICtrlCreateMenuitem ($filename,$recentfilesmenu)

Sleep(2000)

$aSize = _ImageGetSize($move)

$ratio1 = $aSize[1] / $aSize[0]

$ratio2 = $aSize[0] / $aSize[1]

$differentdimensions = 0

If $aSize[0] > $aSize[1] Then

While $aSize[0] > (@DesktopWidth - 10) Or $aSize[1] > (@DesktopHeight - 64)

$aSize[0] = $aSize[0] - 10

$aSize[1] = $ratio1 * $aSize[0]

$differentdimensions = 1

WEnd

If $differentdimensions = 1 Then MsgBox (0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1])

EndIf

If $aSize[1] > $aSize[0] Then

While $aSize[1] > (@DesktopHeight - 64) Or $aSize[0] > (@DesktopWidth - 10)

$aSize[1] = $aSize[1] - 10

$aSize[0] = $ratio2 * $aSize[1]

$differentdimensions = 1

WEnd

If $differentdimensions = 1 Then MsgBox (0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1])

EndIf

GUICreate("Encrypt0r - Image Viewer", $aSize[0], $aSize[1], -1, -1, -1, -1, $GUI)

GUICtrlCreatePic($move, 0, 0, $aSize[0], $aSize[1])

FileDelete($move)

GUISetState()

EndIf

While 1

$msg3 = GUIGetMsg()

Select

Case $msg3 = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

GUIDelete()

EndFunc

Func DecryptFile()

$filename=FileOpenDialog("Choose File to Decrypt", $dir, "Encrypted Files (*.encrypt)", "1")

If @error <> 1 Then

Dim $szDrive, $szDir, $szFName, $szExt

$TestPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)

$savefile=FileSaveDialog("Choose Where to Save Decrypted File", ($szDrive & $szDir), "All Files (*.*)", 0, $szFName)

If @error <> 1 Then

Dim $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext

$TestPath = _PathSplit($savefile, $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext)

$copy="C:\Temp\" & $szFName & $szExt

$szFExt = StringRight($szFName, 4)

$move=$sz2Drive & $sz2Dir & $sz2FName & $szFExt

FileCopy($filename, $copy)

FileMove($copy, $move, 1)

$keyexist = IniRead(@ScriptDir & "\config.ini", "File Key", $filename, "NOTEXIST")

If $keyexist <> "NOTEXIST" Then

$pass = _StringEncrypt(0, $keyexist, "Encrypt0r", 2)

MsgBox(0, "Key Found!", "Key found! Encrypt0r will use it.")

EndIf

If $keyexist = "NOTEXIST" Then

$pass = InputBox("Key", "Please enter the key used to encrypt this file.") ;Max 128 chars

EndIf

If $pass = "" Then

MsgBox(48, "Decryption Aborted", "No key entered and key not found.. Try Again")

EndIf

If $pass <> "" Then

$mode = "-";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa.

Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide)

$delete = MsgBox(4, "Delete Source File?", ("Would you like to delete " & $szFName & $szExt));6 is yes

If $delete = 6 Then FileDelete($filename)

MsgBox(0, "Decrypted", "Decryption Complete")

EndIf

If @error <> 1 Then GUICtrlCreateMenuitem ($filename,$recentfilesmenu)

EndIf

EndIf

EndFunc

Func EncryptFile()

$filename=FileOpenDialog("Choose File to Encrypt", $dir, "All Files (*.*)", "1")

If @error <> 1 Then

Dim $szDrive, $szDir, $szFName, $szExt

$TestPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)

$path = $szFName & $szExt

$savefile=FileSaveDialog("Choose Where to Save Encrypted File", ($szDrive & $szDir), "Encrypted Files (*.encrypt)", 0, ($szFName & $szExt & ".encrypt"))

If @error <> 1 Then

$encrypt = ".encrypt"

Dim $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext

$TestPath = _PathSplit($savefile, $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext)

$FNamecheck = StringRight($sz2FName, 4)

$FNamecheck2 = StringRight($sz2FName, 12)

$FNamecheck3 = StringLeft($FNamecheck2, 4)

$sz3Ext = $szExt

If $FNamecheck = $szExt Then $szExt = ""

If $FNamecheck = "rypt" Then $encrypt = ""

If $FNamecheck3 = $szExt Then $szExt = ""

$copy="C:\Temp\" & $szFName & $szExt

$move=$sz2Drive & $sz2Dir & $sz2FName & $szExt & $encrypt

$inidir=$sz2Drive & $sz2Dir & $sz2FName & $szExt

FileCopy($filename, $copy)

FileMove($copy, $move, 1)

$num = IniRead((@scriptdir & "\config.ini"), "Settings", "NumOfFiles", "ERROR")

$num = $num + 1

IniWrite((@scriptdir & "\Files.log"), "Encrypted Files", $num, $inidir)

IniWrite((@scriptdir & "\config.ini"), "Settings", "NumOfFiles", $num)

$pass = InputBox("Key", "Please enter the key to be used for encryption") ;Max 128 chars

If $pass = "" Then

MsgBox(48, "Warning!", "No key entered!! 'default' will be used as the key!")

$pass = "default"

EndIf

$mode = "+";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa.

Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide)

$delete = MsgBox(4, "Delete Source File?", ("Would you like to delete " & $path));6 is yes

If $delete = 6 Then FileDelete($filename)

GUICtrlCreateListViewItem(($szFName & "|" & $sz3Ext & "|" & $inidir & ".encrypt"), $tab1list)

$savekey = MsgBox(4, "Save Key?", "Would you like to save the key?" & @LF & "CAUTION! Anyone will be able to decrypt the file if they have your config.ini!")

If $savekey = 6 Then

$encryptedkey = _StringEncrypt(1, $pass, "Encrypt0r", 2)

IniWrite(@ScriptDir & "\config.ini", "File Key", $move, $encryptedkey)

EndIf

MsgBox(0, "Encrypted", "Encryption Complete")

If @error <> 1 Then GUICtrlCreateMenuitem ($filename,$recentfilesmenu)

EndIf

EndIf

EndFunc

Func DecryptText()

$key = GUICtrlRead($tab0InputPass)

If $key = "" Then MsgBox(48, "Error!", "Key cannot be left blank!")

If $key <> "" Then

$level = GUICtrlRead($tab0InputLevel)

If $level > 10 Then

$level = 10

GUICtrlSetData($tab0InputLevel, 10)

EndIf

GuiSetState(@SW_DISABLE,$GUI) ; Stops you from changing anything

$string = GuiCtrlRead($tab0EditText) ; Saves the editbox for later

GUICtrlSetData($tab0EditText,'Decryption In Progress, Please Wait') ; Friendly message

GuiCtrlSetData($tab0EditText,_StringEncrypt(0,$string,GuiCtrlRead($tab0InputPass),$level))

GuiSetState(@SW_ENABLE,$GUI) ; This turns the window back on

EndIf

EndFunc

Func EncryptText()

$key = GUICtrlRead($tab0InputPass)

If $key = "" Then MsgBox(48, "Error!", "Key cannot be left blank!")

If $key <> "" Then

$level = GUICtrlRead($tab0InputLevel)

If $level > 10 Then

$level = 10

GUICtrlSetData($tab0InputLevel, 10)

EndIf

GuiSetState(@SW_DISABLE,$GUI) ; Stops you from changing anything

$string = GuiCtrlRead($tab0EditText) ; Saves the editbox for later

GUICtrlSetData($tab0EditText,'Encryption In Progress, Please Wait') ; Friendly message

GuiCtrlSetData($tab0EditText, _StringEncrypt(1,$string,GuiCtrlRead($tab0InputPass),$level))

GuiSetState(@SW_ENABLE,$GUI) ; This turns the window back on

EndIf

EndFunc

GUIDelete()

Exit

but the part giving me trouble is this, run the gui and go to the image tab click open and then press cancel on the fileopendialog - after that nothing works as if the function isnt ending

Func OpenImg()
    $filename=FileOpenDialog("Choose File to Decrypt", $dir, "Image Files (*.bmp.encrypt;*.jpg.encrypt;*.gif.encrypt)", "1")
    If @error <> 1 Then 
    Dim $szDrive, $szDir, $szFName, $szExt
    $TestPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)
    $copy="C:\Temp\" & $szFName & $szExt
    $Ext = StringRight($szFName, 4)
    $move="C:\Temp\pic" & $Ext
    FileCopy($filename, $copy)
    FileMove($copy, $move, 1)
    $keyexist = IniRead(@ScriptDir & "\config.ini", "File Key", $filename, "NOTEXIST")
    If $keyexist <> "NOTEXIST" Then
        $pass = _StringEncrypt(0, $keyexist, "Encrypt0r", 2)
        MsgBox(0, "Key Found!", "Key found! Encrypt0r will use it.")
    EndIf
    If $keyexist = "NOTEXIST" Then
        $pass = InputBox("Key", "Please enter the key used to encrypt this image.");Max 128 chars
    EndIf
    If $pass = "" Then
        MsgBox(48, "Decryption Aborted", "No key entered and key not found.. Try Again")
    EndIf
    If $pass <> "" Then
        $mode = "-";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa.
        Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide)
    EndIf
    If @error <> 1 Then GUICtrlCreateMenuitem ($filename,$recentfilesmenu)
    Sleep(2000)
    $aSize = _ImageGetSize($move)
    $ratio1 = $aSize[1] / $aSize[0]
    $ratio2 = $aSize[0] / $aSize[1]
    $differentdimensions = 0
    If $aSize[0] > $aSize[1] Then
        While $aSize[0] > (@DesktopWidth - 10) Or $aSize[1] > (@DesktopHeight - 64)
            $aSize[0] = $aSize[0] - 10
            $aSize[1] = $ratio1 * $aSize[0]
            $differentdimensions = 1
        WEnd
        If $differentdimensions = 1 Then MsgBox (0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1])
    EndIf
    If $aSize[1] > $aSize[0] Then
        While $aSize[1] > (@DesktopHeight - 64) Or $aSize[0] > (@DesktopWidth - 10)
            $aSize[1] = $aSize[1] - 10
            $aSize[0] = $ratio2 * $aSize[1]
            $differentdimensions = 1
        WEnd
        If $differentdimensions = 1 Then MsgBox (0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1])
    EndIf
    
    GUICreate("Encrypt0r - Image Viewer", $aSize[0], $aSize[1], -1, -1, -1, -1, $GUI)
    GUICtrlCreatePic($move, 0, 0, $aSize[0], $aSize[1])
    FileDelete($move)
    GUISetState()
    EndIf

    While 1
        $msg3 = GUIGetMsg()
        Select
        Case $msg3 = $GUI_EVENT_CLOSE
            ExitLoop
        EndSelect
    WEnd
    GUIDelete()
EndFunc
Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1

you dont seem to be using _PathSplit() correctly, the return is an array

#include <file.au3>
#include <array.au3>
Dim $szDrive, $szDir, $szFName, $szExt
$TestPath = _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt)
_ArrayDisplay($TestPath,"Demo _PathSplit()")

2

maybe this

Func OpenImg()
    $filename = FileOpenDialog("Choose File to Decrypt", $dir, "Image Files (*.bmp.encrypt;*.jpg.encrypt;*.gif.encrypt)", "1")
    If @error <> 1 Then
        Dim $szDrive, $szDir, $szFName, $szExt
        $TestPath = _PathSplit ($filename, $szDrive, $szDir, $szFName, $szExt)
        $copy = "C:\Temp\" & $szFName & $szExt
        $Ext = StringRight($szFName, 4)
        $move = "C:\Temp\pic" & $Ext
        FileCopy($filename, $copy)
        FileMove($copy, $move, 1)
        $keyexist = IniRead(@ScriptDir & "\config.ini", "File Key", $filename, "NOTEXIST")
        If $keyexist <> "NOTEXIST" Then
            $pass = _StringEncrypt(0, $keyexist, "Encrypt0r", 2)
            MsgBox(0, "Key Found!", "Key found! Encrypt0r will use it.")
        EndIf
        If $keyexist = "NOTEXIST" Then
            $pass = InputBox("Key", "Please enter the key used to encrypt this image.");Max 128 chars
        EndIf
        If $pass = "" Then
            MsgBox(48, "Decryption Aborted", "No key entered and key not found.. Try Again")
        EndIf
        If $pass <> "" Then
            $mode = "-";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa.
            Run(@ComSpec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move), "", @SW_HIDE)
        EndIf
        If @error <> 1 Then GUICtrlCreateMenuItem($filename, $recentfilesmenu)
        Sleep(2000)
        $aSize = _ImageGetSize ($move)
        $ratio1 = $aSize[1] / $aSize[0]
        $ratio2 = $aSize[0] / $aSize[1]
        $differentdimensions = 0
        If $aSize[0] > $aSize[1] Then
            While $aSize[0] > (@DesktopWidth - 10) Or $aSize[1] > (@DesktopHeight - 64)
                $aSize[0] = $aSize[0] - 10
                $aSize[1] = $ratio1 * $aSize[0]
                $differentdimensions = 1
            WEnd
            If $differentdimensions = 1 Then MsgBox(0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1])
        EndIf
        If $aSize[1] > $aSize[0] Then
            While $aSize[1] > (@DesktopHeight - 64) Or $aSize[0] > (@DesktopWidth - 10)
                $aSize[1] = $aSize[1] - 10
                $aSize[0] = $ratio2 * $aSize[1]
                $differentdimensions = 1
            WEnd
            If $differentdimensions = 1 Then MsgBox(0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1])
        EndIf
        
        GUICreate("Encrypt0r - Image Viewer", $aSize[0], $aSize[1], -1, -1, -1, -1, $GUI)
        GUICtrlCreatePic($move, 0, 0, $aSize[0], $aSize[1])
        FileDelete($move)
        GUISetState()
        
        
        While 1
            $msg3 = GUIGetMsg()
            Select
                Case $msg3 = $GUI_EVENT_CLOSE
                    ExitLoop
            EndSelect
        WEnd
        GUIDelete()
    EndIf
EndFunc ;==>OpenImg

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

pathsplit works fine the way i use it as i use the individual variables for the extension etc. anyway your script works but i don't know why? what did you change i can't see any difference

EDIT: ahhh i can see now, the endif was moved to after the While WEnd

also, do you like my programs gui, (obviously you cant encrypt/decrypt files because u dont have encrypt.com file), if you want ill send you all the files so you can see it working

Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0