Jump to content

HELLLLLLLLLLLLLLLLLLLLLLLLLLP


2o2
 Share

Recommended Posts

i need help with two major things. im making a notepad gui first. script below. i would like to be able to know how to make it so that i can open a file when i drag it into the window and how to make it so that crtl a selects all in the notepad box! thanks

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


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

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 Ctrl + o", $menu)
$save = GUICtrlCreateMenuItem("Save Ctrl + s", $menu)
$saveas = Guictrlcreatemenuitem("Save As", $menu)
$Encrypter = GUICtrlCreateMenuitem ("&Encrypt", $menu)
$Decrypter = GUICtrlCreateMenuitem ("&Decrypt", $menu)
$Speaktxt = GUICtrlCreateMenuItem ('&Speak Text', $menu)
$exit = GUICtrlCreateMenuItem("Exit", $menu)
$about = GUICtrlCreateMenuItem("About", $menu)
$edit = GUICtrlCreateMenu("Edit")
$undo = GUICtrlCreateMenuItem("Undo Ctrl + z", $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)

$write = GUICtrlCreateEdit("", 5, 5, 590, 370, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))

GUISetState(@SW_SHOW)

while 1
  Dim $voice = ObjCreate("Sapi.SpVoice") 
guictrlsetfont("Lucida Sans Unicode", 12)   
    $sav =  GUICtrlRead($write)
    $iResult = GUIGetMsg ()
    Select
                Case ($iResult = $Speaktxt)
            $empty = ""
            $txt2speech = GuiCtrlRead($write)
            If $txt2speech == $empty Then
                Speak("There is no text too reed", 0, 100)
                ;sounded out for maximum clarity!!!
                ;Isaac Rocks!!! so does math!
                        Else
            Speak($txt2speech, 0, 100)
        EndIf
        Case ($iResult = $Encrypter)
            $encrt = GUICtrlRead($write)
            $word2encrypt = InputBox("Password", "What do you want the password to encrypt the text to be?")
            GUICtrlSetData($write, _StringEncrypt(1, $encrt, $word2encrypt))
            
        Case ($iResult = $Decrypter)
            $decryt = GuiCtrlRead($write)
            $word2decrypt = InputBox("Password", "Please enter the password to decrypt the text")
            GUICtrlSetData($write, _StringEncrypt(0, $decryt, $word2decrypt))
            
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)
           $saav =  GUICtrlRead($write)
        clipput($saav)
    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.6." & chr(13) & chr(10) & "-Isaac")
case ($iResult = $copy)
    ClipPut($sav)
Case ($iResult = $paste)
    GUICtrlSetData($write, clipget())
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 Speak($Text, $Rate, $Volme)
$voice.Rate = $Rate
$voice.Volume = $Volme
$voice.Speak($Text)
EndFunc

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()
           $saav =  GUICtrlRead($write)
        clipput($saav)
    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

For an edit to accept dropped files you need to do 2 things:-

First you have to set the main gui to have an extended style of $WS_EX_ACCEPTFILES.

Then you need to set the state of the edit like this

Guictrlsetstate($write,$GUI_DROPACCEPTED )

BUT, when you drag a file to the edit and drop it all that you will get is the path and name of the file in the edit. You could instead drag and drop to a special edit box, and then put a button next to it to say 'Paste this file' for example. Maybe someone knows a good way to drop a file into an edit though.

To make all the text selected with Ctrl A is not so straight forward either. Here is a way you could do it but someone with more expertise or a bigger brain than mine will probably know a better way.

Set a Hotkey for ^a, (and maybe also for ^A) so that it runs a new function. In the function check if the edit has focus. If it does have focus then the Ctrl A was to select all the text. Then call the function _GUICtrlEditSetSel to select from the first to the last character. ( you need to include GuiEdit.au3)

If you really are 14 then you've already learnt a hell of a lot about Autoit, and I expect you are learning fast enough that you worked my answer out before I posted it!

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

For an edit to accept dropped files you need to do 2 things:-

First you have to set the main gui to have an extended style of $WS_EX_ACCEPTFILES.

Then you need to set the state of the edit like this

Guictrlsetstate($write,$GUI_DROPACCEPTED )

BUT, when you drag a file to the edit and drop it all that you will get is the path and name of the file in the edit. You could instead drag and drop to a special edit box, and then put a button next to it to say 'Paste this file' for example. Maybe someone knows a good way to drop a file into an edit though.

To make all the text selected with Ctrl A is not so straight forward either. Here is a way you could do it but someone with more expertise or a bigger brain than mine will probably know a better way.

Set a Hotkey for ^a, (and maybe also for ^A) so that it runs a new function. In the function check if the edit has focus. If it does have focus then the Ctrl A was to select all the text. Then call the function _GUICtrlEditSetSel to select from the first to the last character. ( you need to include GuiEdit.au3)

If you really are 14 then you've already learnt a hell of a lot about Autoit, and I expect you are learning fast enough that you worked my answer out before I posted it!

thanks!! ya i am really 14. im a bit of a technical nerd. i also flashed my motorola phone and enabled mms and all that crap, and am learning c++. nvm im alot of a technical nerd. i have friends tho!!! i confess i got the tab thing and the open menu and the font menu from someone else tho!

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

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...