Jump to content

Gui Close


 Share

Recommended Posts

i have a script that creates a gui ontop of another gui. how do i get the gui ontop (encrypter gui) of the other one to close without closing the main one

#NoTrayIcon
#include <GUIConstants.au3>
#include <String.au3>
#include <misc.au3>
#include <Sound.au3>
#include <File.au3>


$12 = GUICreate ("iPad", 600, 400, -1, -1)
guisetbkcolor("blue")

Hotkeyset("{ESC}", "escape")
HotKeySet("^v", "paste")
HotKeySet("{TAB}", "tab")
Hotkeyset("^c", "copy")
HotKeySet("^s", "save")
Hotkeyset("^o", "open")
hotkeyset("^x", "cut")
hotkeyset("^f", "pref")

Global $progopen
Global $progsaveas

$menu = GUICtrlCreateMenu("File")
$open = GUICtrlCreateMenuItem("Open", $menu)
$save = GUICtrlCreateMenuItem("Save Ctrl + S", $menu)
$saveas = Guictrlcreatemenuitem("Save As", $menu)
$encryption = Guictrlcreatemenuitem("Encryption Tool", $menu)
$exit = GUICtrlCreateMenuItem("Exit", $menu)
$about = GUICtrlCreateMenuItem("About", $menu)
$edit = GUICtrlCreateMenu("Edit")
$pref = GUICtrlCreateMenuItem("Font Ctrl + F", $edit)
$cut = GUICtrlCreateMenuItem("Cut Ctrl + x", $edit)
$copy = GUICtrlCreateMenuItem("Copy Ctrl + C", $edit)
$paste = GUICtrlCreateMenuItem("Paste Ctrl + V", $edit)
$undo = GUICtrlCreateMenuItem("Undo Ctrl + Z", $edit)
$write = GUICtrlCreateEdit("",  5, 5, 590, 370)

GUISetState(@SW_SHOW)

while 1
    
guictrlsetfont("Lucida Sans Unicode", 12)   
    $sav =  GUICtrlRead($write)
    $iResult = GUIGetMsg ()
    Select
    Case ($iResult = $encryption)
        $WinMain = GuiCreate('Encryption tool', 400, 400)

$EditText = GuiCtrlCreateEdit('',5,5,380,350)

$InputPass = GuiCtrlCreateInput('',5,360,100,20, 0x21)

$InputLevel = GuiCtrlCreateInput(1, 110, 360, 50, 20, 0x2001)
$UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($inputlevel),10,1)
; These two make the level input with the Up|Down ability
$putintext = GUICtrlCreateButton('Put Into Text Document', 320, 360, 105, 15)
$EncryptButton = GuiCtrlCreateButton('Encrypt', 170, 360, 105, 35)
$DecryptButton = GuiCtrlCreateButton('Decrypt', 285, 360, 105, 15)
; Encryption/Decryption buttons
;~~
GUICtrlCreateLabel('Password', 5, 385)
GuiCtrlCreateLabel('Level',110,385)
; Simple text labels so you know what is what
;~~
GuiSetState()
; Shows window
;~~

Do
   $Msg = GuiGetMsg()
   If $msg = $EncryptButton Then
     ; When you press Encrypt
     ;~~
      GuiSetState(@SW_DISABLE,$WinMain)
     ; Stops you from changing anything
     ;~~
      $string = GuiCtrlRead($EditText)
     ; Saves the editbox for later
     ;~~
      GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.')
     ; Friendly message
     ;~~
      GuiCtrlSetData($EditText,_StringEncrypt(1,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel)))
     ; Calls the encryption. Sets the data of editbox with the encrypted string
     ;~~
      GuiSetState(@SW_ENABLE,$WinMain)
     ; This turns the window back on
     ;~~
 EndIf
 
 If $msg = $putintext Then
     $data = guictrlread($EditText)
    GUICtrlSetData($write, $data)
    winclose("Encryption Tool")
    EndIf
   If $msg = $DecryptButton Then
     ; When you press Decrypt
     ;~~
      GuiSetState(@SW_DISABLE,$WinMain)
     ; Stops you from changing anything
     ;~~
      $string = GuiCtrlRead($EditText)
     ; Saves the editbox for later
     ;~~
      GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.')
     ; Friendly message
     ;~~
      GuiCtrlSetData($EditText,_StringEncrypt(0,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel)))
     ; Calls the encryption. Sets the data of editbox with the encrypted string
     ;~~
      GuiSetState(@SW_ENABLE,$WinMain)
     ; This turns the window back on
     ;~~
   EndIf
Until $msg = $putintext; Continue loop untill window is closed
case ($iResult = $open)
    $progopen = FileOpenDialog("Open",@desktopcommondir, "text files(*.txt;*.doc)", 1)
    If @error Then
    Sleep(10)
    else
    GUICtrlSetData($write, FileRead($progopen))
    endif
Case ($iResult = -3)
        Exit
case ($iResult = $cut)
        clipput($write)
    send("{backspace}")
Case ($iResult = $exit)
    Exit
Case ($iResult = $saveas)
    $progsaveas = FileSaveDialog("Save", @desktopcommondir, "text files (*.txt;*.doc)")
    FileDelete($progsaveas)
    FileWrite($progsaveas, GUICtrlRead($write))
Case ($iResult = $save)
    if fileexists($progopen) then
    FileDelete($progopen)
    FileWrite($progopen, GUICtrlRead($write))
    EndIf
    if not fileexists($progopen) Then
    $progopen = FileSaveDialog("Save", @desktopcommondir, "text files (*.txt;*.doc)")
    FileDelete($progopen)
    FileWrite($progopen, GUICtrlRead($write))
    EndIf
case ($iResult = $about)
    msgbox(0, "iPad", "iPad, Created by Isaac Flaum is a notepad like tool compiled using Autoit v3" & chr(13) & chr(10) & "Thanks For Trying iPad! Updates Coming Soon. Version 1.1." & chr(13) & chr(10) & "-Isaac")
case ($iResult = $copy)
    ClipPut($sav)
Case ($iResult = $paste)
    GUICtrlSendMsg($write, "^v", 1, 1)
Case $iResult = $pref
    $cfont = _ChooseFont()
    If @error Then
        Sleep(10)
    Else
        GUICtrlSetFont($write, $cfont[3], $cfont[4], $cfont[1], $cfont[2])
        GUICtrlSetColor($write, $cfont[7])
    EndIf
    
EndSelect
WEnd

Func tab()
send("     ", $write)
EndFunc

func save()
if fileexists($progopen) then
FileDelete($progopen)
FileWrite($progopen, GUICtrlRead($write))
EndIf

if not fileexists($progopen) Then
$progopen = FileSaveDialog("Save", @desktopcommondir, "text files (*.txt;*.doc)")
FileDelete($progopen)
FileWrite($progopen, GUICtrlRead($write))
EndIf
EndFunc

Func copy()
Clipput($sav)
EndFunc


func cut()
clipput($write)
send("{backspace}")
EndFunc

func escape()
Exit
EndFunc

func open()
$progopen = FileOpenDialog("Open",@desktopcommondir, "text files(*.txt;*.doc)", 1)
If @error Then
Sleep(10)
else
GUICtrlSetData($write, FileRead($progopen))
endif
EndFunc

Func paste()
send(clipget(), $write)
EndFunc

Func pref()
    $cfont = _ChooseFont()
    If @error Then
        Sleep(10)
    Else
        GUICtrlSetFont($write, $cfont[3], $cfont[4], $cfont[1], $cfont[2])
        GUICtrlSetColor($write, $cfont[7])
    EndIf
EndFunc

Rick rack ree, kick 'em in the knee.Rick rack rass, kick 'em in the other knee!

Link to comment
Share on other sites

Maybe? I suggest using OnEventMode though. Just some personal advice

#NoTrayIcon
#include <GUIConstants.au3>
#include <String.au3>
#include <misc.au3>
#include <Sound.au3>
#include <File.au3>


$12 = GUICreate("iPad", 600, 400, -1, -1)
GUISetBkColor("blue")

HotKeySet("{ESC}", "escape")
HotKeySet("^v", "paste")
HotKeySet("{TAB}", "tab")
HotKeySet("^c", "copy")
HotKeySet("^s", "save")
HotKeySet("^o", "open")
HotKeySet("^x", "cut")
HotKeySet("^f", "pref")

Global $progopen
Global $progsaveas

$menu = GUICtrlCreateMenu("File")
$open = GUICtrlCreateMenuItem("Open", $menu)
$save = GUICtrlCreateMenuItem("Save Ctrl + S", $menu)
$saveas = GUICtrlCreateMenuItem("Save As", $menu)
$encryption = GUICtrlCreateMenuItem("Encryption Tool", $menu)
$exit = GUICtrlCreateMenuItem("Exit", $menu)
$about = GUICtrlCreateMenuItem("About", $menu)
$edit = GUICtrlCreateMenu("Edit")
$pref = GUICtrlCreateMenuItem("Font Ctrl + F", $edit)
$cut = GUICtrlCreateMenuItem("Cut Ctrl + x", $edit)
$copy = GUICtrlCreateMenuItem("Copy Ctrl + C", $edit)
$paste = GUICtrlCreateMenuItem("Paste Ctrl + V", $edit)
$undo = GUICtrlCreateMenuItem("Undo Ctrl + Z", $edit)
$write = GUICtrlCreateEdit("", 5, 5, 590, 370)

GUISetState(@SW_SHOW)

While 1

    GUICtrlSetFont("Lucida Sans Unicode", 12)
    $sav = GUICtrlRead($write)
    $iResult = GUIGetMsg()
    Select
        Case ($iResult = $encryption)
            $WinMain = GUICreate('Encryption tool', 400, 400, -1, -1, -1, -1, $12)

            $EditText = GUICtrlCreateEdit('', 5, 5, 380, 350)

            $InputPass = GUICtrlCreateInput('', 5, 360, 100, 20, 0x21)

            $InputLevel = GUICtrlCreateInput(1, 110, 360, 50, 20, 0x2001)
            $UpDownLevel = GUICtrlSetLimit(GUICtrlCreateUpdown($InputLevel), 10, 1)
            ; These two make the level input with the Up|Down ability
            $putintext = GUICtrlCreateButton('Put Into Text Document', 320, 360, 105, 15)
            $EncryptButton = GUICtrlCreateButton('Encrypt', 170, 360, 105, 35)
            $DecryptButton = GUICtrlCreateButton('Decrypt', 285, 360, 105, 15)
            ; Encryption/Decryption buttons
;~~
            GUICtrlCreateLabel('Password', 5, 385)
            GUICtrlCreateLabel('Level', 110, 385)
            ; Simple text labels so you know what is what
;~~
            GUISetState()
            ; Shows window
;~~

            Do
                $Msg = GUIGetMsg($WinMain)
                $iResult = GUIGetMsg($12)
                If $Msg = $EncryptButton Then
                    ; When you press Encrypt
;~~
                    GUISetState(@SW_DISABLE, $WinMain)
                    ; Stops you from changing anything
;~~
                    $string = GUICtrlRead($EditText)
                    ; Saves the editbox for later
;~~
                    GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.')
                    ; Friendly message
;~~
                    GUICtrlSetData($EditText, _StringEncrypt(1, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel)))
                    ; Calls the encryption. Sets the data of editbox with the encrypted string
;~~
                    GUISetState(@SW_ENABLE, $WinMain)
                    ; This turns the window back on
;~~
                EndIf

                If $Msg = $putintext Then
                    $data = GUICtrlRead($EditText)
                    GUICtrlSetData($write, $data)
                    WinClose("Encryption Tool")
                EndIf
                If $Msg = $DecryptButton Then
                    ; When you press Decrypt
;~~
                    GUISetState(@SW_DISABLE, $WinMain)
                    ; Stops you from changing anything
;~~
                    $string = GUICtrlRead($EditText)
                    ; Saves the editbox for later
;~~
                    GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.')
                    ; Friendly message
;~~
                    GUICtrlSetData($EditText, _StringEncrypt(0, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel)))
                    ; Calls the encryption. Sets the data of editbox with the encrypted string
;~~
                    GUISetState(@SW_ENABLE, $WinMain)
                    ; This turns the window back on
;~~
                EndIf
            Until $Msg = $putintext Or $Msg = $GUI_EVENT_CLOSE Or $iResult = $GUI_EVENT_CLOSE
            If $Msg = $GUI_EVENT_CLOSE Then
                GUIDelete($WinMain)
            ElseIf $iResult = $GUI_EVENT_CLOSE Then
                Exit
            EndIf
            ; Continue loop untill window is closed
        Case ($iResult = $open)
            $progopen = FileOpenDialog("Open", @DesktopCommonDir, "text files(*.txt;*.doc)", 1)
            If @error Then
                Sleep(10)
            Else
                GUICtrlSetData($write, FileRead($progopen))
            EndIf
        Case ($iResult = -3)
            Exit
        Case ($iResult = $cut)
            ClipPut($write)
            Send("{backspace}")
        Case ($iResult = $exit)
            Exit
        Case ($iResult = $saveas)
            $progsaveas = FileSaveDialog("Save", @DesktopCommonDir, "text files (*.txt;*.doc)")
            FileDelete($progsaveas)
            FileWrite($progsaveas, GUICtrlRead($write))
        Case ($iResult = $save)
            If FileExists($progopen) Then
                FileDelete($progopen)
                FileWrite($progopen, GUICtrlRead($write))
            EndIf
            If Not FileExists($progopen) Then
                $progopen = FileSaveDialog("Save", @DesktopCommonDir, "text files (*.txt;*.doc)")
                FileDelete($progopen)
                FileWrite($progopen, GUICtrlRead($write))
            EndIf
        Case ($iResult = $about)
            MsgBox(0, "iPad", "iPad, Created by Isaac Flaum is a notepad like tool compiled using Autoit v3" & Chr(13) & Chr(10) & "Thanks For Trying iPad! Updates Coming Soon. Version 1.1." & Chr(13) & Chr(10) & "-Isaac")
        Case ($iResult = $copy)
            ClipPut($sav)
        Case ($iResult = $paste)
            GUICtrlSendMsg($write, "^v", 1, 1)
        Case $iResult = $pref
            $cfont = _ChooseFont()
            If @error Then
                Sleep(10)
            Else
                GUICtrlSetFont($write, $cfont[3], $cfont[4], $cfont[1], $cfont[2])
                GUICtrlSetColor($write, $cfont[7])
            EndIf

    EndSelect
WEnd

Func tab()
    Send("     ", $write)
EndFunc   ;==>tab

Func save()
    If FileExists($progopen) Then
        FileDelete($progopen)
        FileWrite($progopen, GUICtrlRead($write))
    EndIf

    If Not FileExists($progopen) Then
        $progopen = FileSaveDialog("Save", @DesktopCommonDir, "text files (*.txt;*.doc)")
        FileDelete($progopen)
        FileWrite($progopen, GUICtrlRead($write))
    EndIf
EndFunc   ;==>save

Func copy()
    ClipPut($sav)
EndFunc   ;==>copy


Func cut()
    ClipPut($write)
    Send("{backspace}")
EndFunc   ;==>cut

Func escape()
    Exit
EndFunc   ;==>escape

Func open()
    $progopen = FileOpenDialog("Open", @DesktopCommonDir, "text files(*.txt;*.doc)", 1)
    If @error Then
        Sleep(10)
    Else
        GUICtrlSetData($write, FileRead($progopen))
    EndIf
EndFunc   ;==>open

Func paste()
    Send(ClipGet(), $write)
EndFunc   ;==>paste

Func pref()
    $cfont = _ChooseFont()
    If @error Then
        Sleep(10)
    Else
        GUICtrlSetFont($write, $cfont[3], $cfont[4], $cfont[1], $cfont[2])
        GUICtrlSetColor($write, $cfont[7])
    EndIf
EndFunc   ;=
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...