Sign in to follow this  
Followers 0
Bert

Need some direction on how to approtch this problem

7 posts in this topic

I have a tool that I use for using common short phrases. It is a easy way to save keystrokes. Think of it a simple replacement clipboard program. works fine:

include<file.au3>
include<GuiConstants.au3>
$main_gui = GUICreate("QuickPaste 2.0", 600, 85)
$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("Paste",$filemenu)
$fileitem1 = GUICtrlCreateMenuitem ("Clean then Paste",$filemenu)
$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)    ; create a separator line
$fileitem2 = GUICtrlCreateMenuitem ("Add Entry",$filemenu)
$fileitem3 = GUICtrlCreateMenuitem ("Remove Entry",$filemenu)
;$separator2 = GUICtrlCreateMenuitem ("",$filemenu,2)    ; create a separator line
$fileitem4 = GUICtrlCreateMenuitem ("Open unplus.ini",$filemenu)
$fileitem5 = GUICtrlCreateMenuitem ("Cancel",$filemenu)
$filemenu1 = GUICtrlCreateMenu ("&Help")
$fileitem6 = GUICtrlCreateMenuitem ("Help",$filemenu1)
$fileitem7 = GUICtrlCreateMenuitem ("About",$filemenu1)
$Combo_2 = GUICtrlCreateCombo("", 20, 5, 500, 80)
$data1 = _LoadData(@ScriptDir & "\bin\unplus.ini", $Combo_2)
$button1 = GUICtrlCreateButton("Paste", 530, 5, 60, 20)
$button2 = GUICtrlCreateButton("Clean then Paste", 500, 32, 90, 20)
$button3 = GUICtrlCreateButton("Add", 20, 32, 60, 20)
$button4 = GUICtrlCreateButton("Remove", 100, 32, 60, 20)
$button5 = GUICtrlCreateButton("Cancel", 180, 32, 60, 20)
;$button10 = GUICtrlCreateButton("About", 260, 32, 60, 20)
; Run the GUI until it is closed


GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        ;When button1 is pressed, label text is copied to the clipboard
        Case $msg = $button1 or $msg = $fileitem
            $data = GUICtrlRead($Combo_2)
            ClipPut($data)
            Sleep(200)
            GUISetState(@SW_HIDE, $main_gui)
            sleep(200)
            Send("^v")
            Exit
        ;When button2 is pressed, it will clean the edit field in the application, then paste the contents from the clipboard.
        Case $msg = $button2 or $msg = $fileitem1
            $data = GUICtrlRead($Combo_2)
            ClipPut($data)
            Sleep(200)
            GUISetState(@SW_HIDE, $main_gui)
            sleep(200)
            Send("^a")
            sleep(200)
            Send("{DELETE}")
            Send("^v")
            Exit
        ;---------------------------------------
        ;this will open a sub GUI window to allow for adding or removing data
        Case $msg = $button3 or $msg = $fileitem2
            GUISetState(@SW_HIDE, $main_gui)
            $add_gui = GUICreate("Add entry to QuickPaste", 520, 165)
            $file = GUICtrlCreateedit("", 10, 5, 500, 130, $SS_LEFT + $WS_VSCROLL) ; , )
            GUICtrlSetState(-1, $GUI_ACCEPTFILES)
            $button6 = GUICtrlCreateButton("Ok", 10, 140, 60, 20)
            $button7 = GUICtrlCreateButton("Cancel", 90, 140, 60, 20)
            GUISetState(@SW_SHOW, $add_gui)

            $msg2 = 0
            While $msg2 <> $GUI_EVENT_CLOSE
                $msg2 = GUIGetMsg()
                Select
                    Case $msg2 = $button6 ; this will add data to the UNPlus.ini file. It will make the file if it is missing
                        $adddata = GUICtrlRead($file)
                        _SaveData(@ScriptDir & "\bin\unplus.ini", $data1 & $adddata & "|")
                        ExitLoop

                    Case $msg2 = $button7

                        ExitLoop
                EndSelect

            WEnd
            GUIDelete($add_gui)
            $data1 = _LoadData(@ScriptDir & "\bin\unplus.ini", $Combo_2)
            GUISetState(@SW_SHOW, $main_gui)

        ;----------------------------------------
        ;this will open a window that will remove a entry selected from the drop down list.
        Case $msg = $button4 or $msg = $fileitem3
            $rem_item = GUICtrlRead($Combo_2)
            If StringLen($rem_item) Then
                GUISetState(@SW_HIDE, $main_gui)
                $del_gui = GUICreate("Remove entry from QuickPaste?", 500, 130)
                $file = GUICtrlCreateLabel ("Are you sure you wish to delete the entry:", 5, 5)
                $file1 = GUICtrlCreateedit ($rem_item, 5, 25, 490, 80, $WS_VSCROLL + $ES_READONLY)
                GUICtrlSetState(-1, $GUI_ACCEPTFILES)
                $button8 = GUICtrlCreateButton("Yes, remove it", 150, 108, 100, 20)
                $button9 = GUICtrlCreateButton("Cancel", 270, 108, 60, 20)
                GUISetState(@SW_SHOW, $del_gui)

                $msg2 = 0
                While $msg2 <> $GUI_EVENT_CLOSE
                    $msg2 = GUIGetMsg()
                    Select
                        Case $msg2 = $button8 ; this will remove an entry from the UNPlus.ini file.
                            $data1 = StringReplace($data1, $rem_item & "|", "")
                            _SaveData(@ScriptDir & "\bin\unplus.ini", $data1)

                            ExitLoop

                        Case $msg2 = $button9
                            ExitLoop
                    EndSelect
                WEnd
                GUIDelete($del_gui)
                $data1 = _LoadData(@ScriptDir & "\bin\unplus.ini", $Combo_2)
                GUISetState(@SW_SHOW, $main_gui)
            EndIf

        Case $msg = $button5 or $msg = $fileitem5
             exit

        Case $msg = $fileitem4
             If fileexists("\bin\unplus.ini") == 0 then
                MsgBox(4096,"", "You have not added any entries to this file. Add a entry, then you can open UNPlus.ini for editing ")
             else
                Run(@ComSpec & " /c " & '\bin\unplus.ini', "", @SW_hide)
             endif

        Case $msg = $fileitem6
            MsgBox(0 + 64, "How to use QuickPaste", "- To select what you want pasted to your current work, use the " & @CRLF _
                     & "  dropdown to select the item you want. Once selected, click PASTE." & @CRLF _
                     & "  If you want to delete the contents from the field you are editing before" & @CRLF _
                     & "  hand, click CLEAN THEN PASTE" & @CRLF _
                     & "" & @CRLF _
                     & "- To enter a new item in the list, click ADD" & @CRLF _
                     & "  Type in what you want to have entered, then click OK." & @CRLF _
                     & "" & @CRLF _
                     & "- To remove a entry, select the item you wanto to remove, then click on REMOVE" & @CRLF _
                     & "  If you are sure this is what you wish to remove, click YES, REMOVE IT." & @CRLF _
                     & "" & @CRLF _
                     & "- You can click CANCEL to back out if needed.")

        Case $msg = $fileitem7
            MsgBox(0 + 64, "About QuickPaste 2.0", "Designed and written by Volly" & @CRLF _
                     & "      xxxxxxxxxxxxx" & @CRLF _
                     & "" & @CRLF _
                     & " To report a bug, call xxxxxxxxx")  ;edited for security purposes

    EndSelect


WEnd
Exit
Func _LoadData($s_file, ByRef $h_Combo)
    ;$note1 = IniRead($s_file, "QuickType", "items", "")
    $note1 = IniRead($s_file, @UserName, "QuickType", "")
    
    GUICtrlSetData($h_Combo, "|" & $note1)
    Return $note1
EndFunc  ;==>_LoadData
Func _SaveData($s_file, $s_data)
    IniWrite($s_file, @UserName, "QuickType", $s_data)
    ;IniWrite($s_file, "QuickType", "items", $s_data)
EndFunc  ;==>_SaveData

I want to make many improvements to it. I know there are cilpboard replacement programs out there, but a AutoIt flaver would be nice...

  • Instead of just one line, I could do a paragraph.
  • Pictures
  • Catagories - possible tabs or something
  • hotkeys along with spacebar -example: say pressing "kj" then the spacebar would change "kj" to "This is what I wanted to say".
I'm not sure on the best way to do this. I thought of using a excel spreadsheet as the storage point, but how to do this.. :)

Is there a better way? Thoughts?

Share this post


Link to post
Share on other sites

Maybe have a look at the lua in SciTe?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I would get lost in that. I had a few ideas on the tree menu, but to right click and add a item to the tree menu...?????? that one is a head scratcher. I posted that question in another thread

Wow Volly, I must admit, you have me T-Totally confused... It's like your in 3 different areas of what you want to accomplish, and I don't know where to start (and not one to go digging through code).

I wish I had a solid grasp on "exactly" what you have/what you want to accomplish/and what it's not currently doing.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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