Bert Posted May 28, 2008 Share Posted May 28, 2008 (edited) I have a script that I'm wanting to use to make test for Trandumper. Currently I have to have open several applications depending on what I need. Notepad, Frontpage, and so forth. The test have to be in txt form, and I need to go through and edit a test to make the changes I need. Frontpage doesn't meet my needs for I need to keep the code clean as possible. Frontpage has a nasty habit of adding WAY too much garbage code that just clutters up what I need. In making this project, I can make it do just what I need, and I'm quite happy with what I got so far. I need to add 2 more things, but I'm not sure on the best method of doing it. I need to add methods to select color. I have a function that can let me pick a color, but it is the design of the buttons that control text color and highlighting are things that I'm needing assistance with. What I like to do is have it work like Frontpage has it color controls. It is a button with a dropdown to one side of it that opens a edit box. Has anyone made something like this? For those who want to see what I'm doing: CODE#include<IE.au3> ;this section is for those who are debugging this script and do not have ANYGUI.au3. ;It should be located in C:\Program Files\AutoIt3\Include\ if you run the production of AutoIt. ;It should be located in C:\Program Files\AutoIt3\Beta\Include\ if you run the beta of AutoIt. $filecheck_1 = FileExists("C:\Program Files\AutoIt3\Include\ANYGUI.au3") $filecheck_2 = FileExists("C:\Program Files\AutoIt3\Beta\Include\ANYGUI.au3") if $filecheck_1 = 0 and $filecheck_2 = 0 then MsgBox(0, "ANYGUI.au3 not found!", "You will need to download ANYGUI.au3 to run this script. CLick OK to IE open to the AutoIt site for downloading") _IECreate("http://www.autoitscript.com/forum/index.php?s=&showtopic=9517&view=findpost&p=515205") exit endif ;------------------------------------------------------------- #include<ANYGUI.au3> #include <GuiConstants.au3> #include <Misc.au3> Local $color $font = "Comic Sans MS" dim $button[11], $_CR1,$_button_name1, $_height, $_width, $_w1, $hWnd, $sTEXTgrab dim $_w2, $_w3, $_w4, $_w5, $_w6, $_w7, $_w8, $ans dim $sTEXTDUMP, $sFIND, $sREPL Dim Const $NL = @CRLF Run("notepad.exe") WinWaitActive("") $hWnd = _GuiTarget ("Untitled - Notepad") $child = _TargetaddChild ("", 0, 0, 50000, 20, $hWnd) $blank1 = GuiCtrlCreateGraphic(75, 0, 2,20) $Button3 = GUICtrlCreateButton("B", 0, 0, 25, 20) $Button2 = GUICtrlCreateButton("I", 25, 0, 25, 20) $Button1 = GUICtrlCreateButton("U", 50, 0, 25, 20) $Button4 = GUICtrlCreateButton("<ul>", 78, 0, 30, 20) $Button5 = GUICtrlCreateButton("<ol>", 108, 0, 30, 20) $Button6 = GUICtrlCreateButton("<li>", 138, 0, 30, 20) $Button7 = GUICtrlCreateButton("-->", 168, 0, 30, 20) $Button8 = GUICtrlCreateButton("HL", 203, 0, 30, 20) $Button9 = GUICtrlCreateButton("IP", 233, 0, 30, 20) $Button10 = GUICtrlCreateButton("FI", 263, 0, 30, 20) $Button11 = GUICtrlCreateButton("IB", 293, 0, 30, 20) $Button12 = GUICtrlCreateButton("FF", 293+35, 0, 30, 20) GUICtrlSetFont($Button1, 8.5, 900,4,$font) GUICtrlSetFont($Button2, 9, 900,2,$font) GUICtrlSetFont($Button3, 10, 900,0,$font) GUICtrlSetTip($Button3, "Bold") GUICtrlSetTip($Button2, "Italic") GUICtrlSetTip($Button1, "Underline") GUICtrlSetTip($Button4, "Bullet List") GUICtrlSetTip($Button5, "Number List") GUICtrlSetTip($Button6, "Line item") GUICtrlSetTip($Button7, "Indent one space") GUICtrlSetTip($Button8, "Hyperlink") GUICtrlSetTip($Button9, "Insert Picture") GUICtrlSetTip($Button10, "Insert fill-in answer") GUICtrlSetTip($Button11, "Insert Button") GUICtrlSetTip($Button12, "Fixes formating for CertKiller test") GUICtrlSetBKColor($Button4, 0x00ff00) GUICtrlSetBKColor($Button5, 0x00ff00) GUICtrlSetBKColor($Button6, 0x00ff00) GUISetState(@SW_SHOW) While WinExists($hWnd) $msg = GUIGetMsg() Select Case $msg = $Button1 ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<U>"&ClipGet()&"</U>") Case $msg = $Button2 ;italic ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<I>"&ClipGet()&"</I>") Case $msg = $Button3 ;bold ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<B>"&ClipGet()&"</B>") Case $msg = $Button4 ;bullet list ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<ul>"&@cr&" "&ClipGet()&@cr&"</ul>") Case $msg = $Button5 ;number list ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<ol>"&ClipGet()&"</ol>") Case $msg = $Button6 ;line item ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<li>"&ClipGet()&"</li>") Case $msg = $Button7 ;indent ControlSend($hWnd,"","Edit1"," ") Case $msg = $Button8 ;insert hyperlink ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") sleep(1) $E_string = ClipGet() if $E_string = "" then $input = inputbox("Hyperlink", "Type in hyperlink") if $input = "" then sleep(1) else ControlSend($hWnd,"","Edit1",'<a target="_blank" href='&$input&'">'&$input&'</a>') endif Else ControlSend($hWnd,"","Edit1",'<a target="_blank" href='&ClipGet()&'">'&ClipGet()&'</a>') endif Case $msg = $Button9 ;insert pic $input_P = inputbox("Picture", "Type in path the image."&@CR&'Example: Samples/Resources/Case1Q1.jpg') if $input_P = "" Then sleep(1) Else ControlSend($hWnd,"","Edit1",'<br><img src="'&$input_P&'">') endif Case $msg = $Button11 ;button _exhibit() ControlSend($hWnd,"","Edit1",'<button onclick="window.open('&"'"&$_CR1&"'"&','&"'"&$_button_name1&"','"&'height='&$_height&',width='&$_width _ &',status='&$_w1&',toolbar='&$_w2&',menubar='&$_w3&',location='&$_w4&',titlebar='&$_w5&',scrollbars='&$_w6&',alwaysRaised='&$_w7&',resizable='&$_w8 _ &"'"&')">'&$_button_name1&'</button>') Case $msg = $Button12 ClipPut("") sleep(1) $sTEXTgrab = ControlSend($hWnd,"","Edit1","^C") $sTEXTgrab = ControlSend($hWnd,"","Edit1","^C") _linebreakfix() ClipPut("") EndSelect $size = WinGetClientSize($hWnd) If WinExists($hWnd) Then ControlMove($hWnd, "", 15, 0, 20, $size[0], $size[1] - 20) EndIf Sleep(10) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _colorselect() ;function to select the color I need. Local $color $color = _ChooseColor (2, 0xFF0000, 2) ; default color selected using RGB hex value If (@error) Then MsgBox(262144, "", "Error _ChooseColor: " & @error) Else ;MsgBox(262144,"_ChooseColor","Hex RGB Color: " & $color) clipput($color) EndIf EndFunc Func _exhibit() $_Form1 = GUICreate("Button Controls", 426, 190, 193, 125) $_Button1 = GUICtrlCreateButton("Path", 8, 8, 41, 21, 0) $_inir1 = iniread(@ScriptDir&"/b_set.ini", "1", "2", "") $_input1 = GUICtrlCreateInput("", 56, 8, 353, 21) GUICtrlSetData($_input1, $_inir1) $_Label1 = GUICtrlCreateLabel("Height", 8, 42, 51, 17) $_inir2 = iniread(@ScriptDir&"/b_set.ini", "1", "3", "") $_input2 = GUICtrlCreateInput("", 56, 40, 40, 21, $ES_NUMBER+$ES_RIGHT) GUICtrlSetData($_input2, $_inir2) $_Width = GUICtrlCreateLabel("Width", 8, 75, 32, 17) $_inir3 = iniread(@ScriptDir&"/b_set.ini", "1", "4", "") $_input3 = GUICtrlCreateInput("", 56, 72, 40, 21, $ES_NUMBER+$ES_RIGHT) GUICtrlSetData($_input3, $_inir3) $_button_name = GUICtrlCreateLabel("Button"&@cr&"Name", 8, 102, 42, 25) $_input4 =GUICtrlCreateInput("", 56, 104, 113, 21) $_inir4 = iniread(@ScriptDir&"/b_set.ini", "1", "5", "") GUICtrlSetData($_input4, $_inir4) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $_Checkbox1 = GUICtrlCreateCheckbox("Status", 200, 40, 73, 17) $_inir5 = IniRead(@ScriptDir&"/b_set.ini", "1", "6", "") if $_inir5 = "1" then GUICtrlSetState($_Checkbox1, $GUI_CHECKED) $_Checkbox2 = GUICtrlCreateCheckbox("Toolbar", 200, 64, 73, 17) $_inir6 = IniRead(@ScriptDir&"/b_set.ini", "1", "7", "") if $_inir6 = "1" then GUICtrlSetState($_Checkbox2, $GUI_CHECKED) $_Checkbox3 = GUICtrlCreateCheckbox("Menubar", 200, 88, 73, 17) $_inir7 = IniRead(@ScriptDir&"/b_set.ini", "1", "8", "") if $_inir7 = "1" then GUICtrlSetState($_Checkbox3, $GUI_CHECKED) $_Checkbox4 = GUICtrlCreateCheckbox("Location", 200, 112, 73, 17) $_inir8 = IniRead(@ScriptDir&"/b_set.ini", "1", "9", "") if $_inir8 = "1" then GUICtrlSetState($_Checkbox4, $GUI_CHECKED) $_Checkbox5 = GUICtrlCreateCheckbox("Titlebar", 296, 40, 73, 17) $_inir9 = IniRead(@ScriptDir&"/b_set.ini", "1", "10", "") if $_inir9= "1" then GUICtrlSetState($_Checkbox5, $GUI_CHECKED) $_Checkbox6 = GUICtrlCreateCheckbox("Scroolbars", 296, 64, 73, 17) $_inir10 = IniRead(@ScriptDir&"/b_set.ini", "1", "11", "") if $_inir10= "1" then GUICtrlSetState($_Checkbox6, $GUI_CHECKED) $_Checkbox7 = GUICtrlCreateCheckbox("AlwaysRaised", 296, 88, 89, 17) $_inir11 = IniRead(@ScriptDir&"/b_set.ini", "1", "12", "") if $_inir11= "1" then GUICtrlSetState($_Checkbox7, $GUI_CHECKED) $_Checkbox8 = GUICtrlCreateCheckbox("Resizeable", 296, 112, 89, 17) $_inir12 = IniRead(@ScriptDir&"/b_set.ini", "1", "13", "") if $_inir12= "1" then GUICtrlSetState($_Checkbox8, $GUI_CHECKED) $_Button2 = GUICtrlCreateButton("OK", 56, 144, 75, 25, 0) $_Button3 = GUICtrlCreateButton("Cancel", 168, 144, 73, 25, 0) GUISetState(@SW_SHOW,$_Form1) While 1 $_nMsg = GUIGetMsg() Select Case $_nMsg = $GUI_EVENT_CLOSE Exitloop Case $_nMsg = $_Button1 $_ini_r1 = IniRead(@ScriptDir&"/b_set.ini", "1", "1",@ScriptDir) while 1 $_test_1 = FileOpenDialog("Select *.txt file being edited for Trandumper", $_ini_r1, "All (*.*)", 1+2) IniWrite(@ScriptDir&"/b_set.ini", "1", "1", $_test_1) $_slash = stringinstr($_test_1, "\", 0, -1) $_stringlen_1 = stringlen($_test_1) $_String_trim_R = StringTrimRight($_test_1, $_stringlen_1 - $_slash) $_fod = FileOpenDialog("Select target", $_String_trim_R, "All (*.*)", 1+2) $_pathcheck = StringInStr($_fod, $_String_trim_R) if $_pathcheck = 1 then exitloop MsgBox(0, "Error!", "File selected must be a sub directory where the test is located!") WEnd $_stringlen = StringLen($_String_trim_R) $_String_trim_L = StringTrimLeft($_fod, $_stringlen) $_replace_S = StringReplace($_String_trim_L, "\", "/") GUICtrlSetData($_input1, $_replace_S) ;------------------ ;~ case $Checkbox2 ;~ MsgBox(0, "", GUICtrlRead($Checkbox1)) Case $_nMsg = $_Button2 ;------path-------- $_CR1 = GUICtrlRead ($_input1) IniWrite(@ScriptDir&"/b_set.ini", "1", "2", $_CR1) ;----Width-------- $_width= GUICtrlRead($_input2) IniWrite(@ScriptDir&"/b_set.ini", "1", "3", $_width) ;----Height------- $_height= GUICtrlRead($_input3) IniWrite(@ScriptDir&"/b_set.ini", "1", "4", $_height) ;---button name--- $_button_name1 = GUICtrlRead($_input4) IniWrite(@ScriptDir&"/b_set.ini", "1", "5", $_button_name1) ;---status-------- $_w1=GUICtrlRead($_Checkbox1) IniWrite(@ScriptDir&"/b_set.ini", "1", "6",$_w1) if $_w1= "1" then $_w1= "yes" Else $_w1= "no" endif ;---toolbar------- $_w2=GUICtrlRead($_Checkbox2) IniWrite(@ScriptDir&"/b_set.ini", "1", "7",$_w2) if $_w2= "1" then $_w2= "yes" Else $_w2= "no" endif ;---Menubar------- $_w3=GUICtrlRead($_Checkbox3) IniWrite(@ScriptDir&"/b_set.ini", "1", "8",$_w3) if $_w3= "1" then $_w3= "yes" Else $_w3= "no" endif ;---Location------- $_w4=GUICtrlRead($_Checkbox4) IniWrite(@ScriptDir&"/b_set.ini", "1", "9",$_w4) if $_w4= "1" then $_w4= "yes" Else $_w4= "no" endif ;---Titlebar------- $_w5=GUICtrlRead($_Checkbox5) IniWrite(@ScriptDir&"/b_set.ini", "1", "10",$_w5) if $_w5= "1" then $_w5= "yes" Else $_w5= "no" endif ;---Scroolbars------ $_w6=GUICtrlRead($_Checkbox6) IniWrite(@ScriptDir&"/b_set.ini", "1", "11",$_w6) if $_w6= "1" then $_w6= "yes" Else $_w6= "no" endif ;---AlwaysRaised---- $_w7=GUICtrlRead($_Checkbox7) IniWrite(@ScriptDir&"/b_set.ini", "1", "12",$_w7) if $_w7= "1" then $_w7= "yes" Else $_w7= "no" endif ;---Resizeable------- $_w8=GUICtrlRead($_Checkbox8) IniWrite(@ScriptDir&"/b_set.ini", "1", "13",$_w8) if $_w8= "1" then $_w8= "yes" Else $_w8= "no" endif exitloop Case $_nMsg = $_Button3 ExitLoop EndSelect WEnd GUIDelete($_Form1) EndFunc Func _linebreakfix() $qst = MsgBox(32+3, "How do you want to convert it?", "How do you want to convert the selected text? Select Yes to save to OUTfile.txt. Select NO to convert in" _ &"the current opened file.") if $qst = 6 then $ans = 1 _linebreakfix2() endif if $qst = 7 then $ans = 2 _linebreakfix2() endif EndFunc func _linebreakfix2() $sFileIN = 'FileIN.txt' $sFileOUT = 'FileOUT.txt' If FileExists($sFileIN) Then FileDelete($sFileIN) If FileExists($sFileOUT) Then FileDelete($sFileOUT) FileWrite($sFileIN, ClipGet()) sleep(1) $sTEXTDUMP = FileRead($sFileIN) SR($NL, ' ') ;; first things first, lets get rid of all those pesty line breaks. SR('Actualtests.com - The Power of Knowing', ' ') SR('070-271', ' ') SRR('QUESTION (\d+)\:', $NL & $NL & '\1. ') ;SRR('QUESTION (\d+)\', $NL & $NL & '\1. ') SR('Answer:', $NL & $NL & 'Answer:') SR('Explanation:', $NL & $NL & '<B>Explanation:</B><br>' & $NL) SR('Incorrect Answers:', $NL & $NL & '<B>Incorrect Answers:</B><br>') SRR('([ABCDEFG])\, ([ABCDEFG])\: ', $NL & '<B>\1\2 -</B> ') ;; exception! SRR('([ABCDEFG])\: ', $NL & '<B>\1 -</B> ') SRR(' ([A-G]\. )', $NL & '\1 ') SR('A. ', $NL & $NL & 'A. ') SR('References:', $NL & $NL & '<B>References:</B><br>' & $NL) SR('Reference:', $NL & $NL & '<B>References:</B><br>' & $NL) SR('Certkiller .com', 'AutoIt.com') SR('Certkiller.com', 'AutoIt.com') ;; GENERAL CLEANUP ;; $sFIND = ' ' $sREPL = ' ' While StringInStr($sTEXTDUMP, $sFIND) SR($sFIND, $sREPL) WEnd SR($NL & ' ', $NL) SR(' ' & $NL, $NL) $sFIND = $NL & $NL & $NL $sREPL = $NL & $NL While StringInStr($sTEXTDUMP, $sFIND) SR($sFIND, $sREPL) WEnd if $ans = 1 then FileWrite($sFileOUT, $sTEXTDUMP) if $ans = 2 then FileWrite($sFileOUT, $sTEXTDUMP) $FRnew = FileRead($sFileOUT) ClipPut($FRnew) ControlSend($hWnd,"","Edit1","^v") endif EndFunc Func SR($sFIND, $sREPL) $sTEXTDUMP = StringReplace($sTEXTDUMP, $sFIND, $sREPL, 0, 2) EndFunc Func SRR($sPATERN, $sREPL) $sTEXTDUMP = StringRegExpReplace($sTEXTDUMP, $sPATERN, $sREPL, 0) EndFunc Edited May 28, 2008 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
gianfun Posted May 28, 2008 Share Posted May 28, 2008 Sorry, dont have frontpage installed. Couldn't you use a combo, then put a button next to it "accept"? Or did you want especifically a button with a drop down menu? I don't think that is possible in Autoit, but i'm not that experienced either. My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote] Link to comment Share on other sites More sharing options...
Bert Posted May 28, 2008 Author Share Posted May 28, 2008 I tried the drop down next to the button. looks sloppy. I was hoping for something a bit more clean. I may need to use a pic for the drop down part next to the button. I'm hoping someone has already done the work. You can see another example of what I'm looking for on the back button in Firefox, or the back button in IE. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted May 29, 2008 Author Share Posted May 29, 2008 Ok, I decided to do this, which works ok for the moment. I do have one other question. How do I double the space I put the buttons in? I tried different things, and I couldn't get it to increase in size. My thinking is to have 2 rows of buttons. CODE#include<IE.au3> ;this section is for those who are debugging this script and do not have ANYGUI.au3. ;It should be located in C:\Program Files\AutoIt3\Include\ if you run the production of AutoIt. ;It should be located in C:\Program Files\AutoIt3\Beta\Include\ if you run the beta of AutoIt. $filecheck_1 = FileExists("C:\Program Files\AutoIt3\Include\ANYGUI.au3") $filecheck_2 = FileExists("C:\Program Files\AutoIt3\Beta\Include\ANYGUI.au3") if $filecheck_1 = 0 and $filecheck_2 = 0 then MsgBox(0, "ANYGUI.au3 not found!", "You will need to download ANYGUI.au3 to run this script. CLick OK to IE open to the AutoIt site for downloading") _IECreate("http://www.autoitscript.com/forum/index.php?s=&showtopic=9517&view=findpost&p=515205") exit endif ;------------------------------------------------------------- #include<ANYGUI.au3> #include <GuiConstants.au3> #include <Misc.au3> Local $color $font = "Comic Sans MS" dim $button[11], $_CR1,$_button_name1, $_height, $_width, $_w1, $hWnd, $sTEXTgrab dim $_w2, $_w3, $_w4, $_w5, $_w6, $_w7, $_w8, $ans dim $sTEXTDUMP, $sFIND, $sREPL Dim Const $NL = @CRLF Run("notepad.exe") WinWaitActive("") $hWnd = _GuiTarget ("Untitled - Notepad") $child = _TargetaddChild ("", 0, 0, 50000, 20, $hWnd) $blank1 = GuiCtrlCreateGraphic(75, 0, 4,20) $Button3 = GUICtrlCreateButton("B", 0, 0, 25, 20) $Button2 = GUICtrlCreateButton("I", 25, 0, 25, 20) $Button1 = GUICtrlCreateButton("U", 50, 0, 25, 20) $Button4 = GUICtrlCreateButton("<ul>", 79, 0, 30, 20) $Button5 = GUICtrlCreateButton("<ol>", 109, 0, 30, 20) $Button6 = GUICtrlCreateButton("<li>", 139, 0, 30, 20) $Button7 = GUICtrlCreateButton("-->", 169, 0, 30, 20) $Button8 = GUICtrlCreateButton("HL", 203, 0, 30, 20) $Button9 = GUICtrlCreateButton("IP", 233, 0, 30, 20) $Button10 = GUICtrlCreateButton("FI", 263, 0, 30, 20) $Button11 = GUICtrlCreateButton("IB", 293, 0, 30, 20) $Button12 = GUICtrlCreateButton("FF", 323, 0, 30, 20) ;------------font color----------------------------------- $Button13 = GUICtrlCreateButton("A", 357, 0, 30, 20) $Button14 = GUICtrlCreateButton("", 387, 0, 10, 20) $_inir14 = iniread(@ScriptDir&"/b_set.ini", "1", "14", "0x000000") ;-----------highlight color------------------------------- $Button15 = GUICtrlCreateButton("A", 357+45, 0, 30, 20) $Button16 = GUICtrlCreateButton("", 387+45, 0, 10, 20) $_inir15 = iniread(@ScriptDir&"/b_set.ini", "1", "15", "0xFFFF00") GUICtrlSetFont($Button1, 8.5, 900,4,$font) GUICtrlSetFont($Button2, 9, 900,2,$font) GUICtrlSetFont($Button3, 10, 900,0,$font) GUICtrlSetFont($Button13, 8.5, 900,4,$font) GUICtrlSetTip($Button3, "Bold") GUICtrlSetTip($Button2, "Italic") GUICtrlSetTip($Button1, "Underline") GUICtrlSetTip($Button4, "Bullet List") GUICtrlSetTip($Button5, "Number List") GUICtrlSetTip($Button6, "Line item") GUICtrlSetTip($Button7, "Indent one space") GUICtrlSetTip($Button8, "Hyperlink") GUICtrlSetTip($Button9, "Insert Picture") GUICtrlSetTip($Button10, "Insert fill-in answer") GUICtrlSetTip($Button11, "Insert Button") GUICtrlSetTip($Button12, "Fixes formating for CertKiller test") GUICtrlSetTip($Button13, "Font Color") GUICtrlSetTip($Button14, "Font Color Select") GUICtrlSetTip($Button15, "Highlight Color") GUICtrlSetTip($Button16, "Highlight Color Select") GUICtrlSetBKColor($Button4, 0x00ff00) GUICtrlSetBKColor($Button5, 0x00ff00) GUICtrlSetBKColor($Button6, 0x00ff00) GUICtrlSetColor($Button13, $_inir14) GUICtrlSetBKColor($Button14, $_inir14) GUICtrlSetBKColor($Button16, $_inir15) GUICtrlSetBKColor($Button15, $_inir15) GUISetState(@SW_SHOW) While WinExists($hWnd) $msg = GUIGetMsg() Select Case $msg = $Button1 ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<U>"&ClipGet()&"</U>") Case $msg = $Button2 ;italic ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<I>"&ClipGet()&"</I>") Case $msg = $Button3 ;bold ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<B>"&ClipGet()&"</B>") Case $msg = $Button4 ;bullet list ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<ul>"&@cr&" "&ClipGet()&@cr&"</ul>") Case $msg = $Button5 ;number list ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<ol>"&ClipGet()&"</ol>") Case $msg = $Button6 ;line item ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") ControlSend($hWnd,"","Edit1","<li>"&ClipGet()&"</li>") Case $msg = $Button7 ;indent ControlSend($hWnd,"","Edit1"," ") Case $msg = $Button8 ;insert hyperlink ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") sleep(1) $E_string = ClipGet() if $E_string = "" then $input = inputbox("Hyperlink", "Type in hyperlink") if $input = "" then sleep(1) else ControlSend($hWnd,"","Edit1",'<a target="_blank" href='&$input&'">'&$input&'</a>') endif Else ControlSend($hWnd,"","Edit1",'<a target="_blank" href='&ClipGet()&'">'&ClipGet()&'</a>') endif Case $msg = $Button9 ;insert pic $input_P = inputbox("Picture", "Type in path the image."&@CR&'Example: Samples/Resources/Case1Q1.jpg') if $input_P = "" Then sleep(1) Else ControlSend($hWnd,"","Edit1",'<br><img src="'&$input_P&'">') endif Case $msg = $Button10 ControlSend($hWnd,"","Edit1","[FILL IN] ") Case $msg = $Button11 ;button _exhibit() ControlSend($hWnd,"","Edit1",'<button onclick="window.open('&"'"&$_CR1&"'"&','&"'"&$_button_name1&"','"&'height='&$_height&',width='&$_width _ &',status='&$_w1&',toolbar='&$_w2&',menubar='&$_w3&',location='&$_w4&',titlebar='&$_w5&',scrollbars='&$_w6&',alwaysRaised='&$_w7&',resizable='&$_w8 _ &"'"&')">'&$_button_name1&'</button>') Case $msg = $Button12 ClipPut("") sleep(1) $sTEXTgrab = ControlSend($hWnd,"","Edit1","^C") $sTEXTgrab = ControlSend($hWnd,"","Edit1","^C") _linebreakfix() ClipPut("") Case $msg = $Button13 ;font color ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") $_inir14 = iniread(@ScriptDir&"/b_set.ini", "1", "14", "0x000000") $stl_color = StringTrimLeft($_inir14,2) ControlSend($hWnd,"","Edit1",'<font color='&'#'&$stl_color&'>'&ClipGet()&'</font>',1) Case $msg = $Button14 _colorselect1() Case $msg = $Button15 ClipPut("") sleep(1) $boldtext = ControlSend($hWnd,"","Edit1","^C") $_inir15 = iniread(@ScriptDir&"/b_set.ini", "1", "15", "0xFFFF00") $stl_BKcolor = StringTrimLeft($_inir15,2) ControlSend($hWnd,"","Edit1",'<span style="background-color: #'&$stl_BKcolor&'">'&ClipGet()&'</span>',1) Case $msg = $Button16 _colorselect2() EndSelect $size = WinGetClientSize($hWnd) If WinExists($hWnd) Then ControlMove($hWnd, "", 15, 0, 20, $size[0], $size[1] - 20) EndIf Sleep(10) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _colorselect1() ;function to select the color I need. Local $color1 $color1 = _ChooseColor (2, 0xFF0000, 2) ; default color selected using RGB hex value If (@error) Then MsgBox(262144, "", "Error _ChooseColor: " & @error) Else IniWrite(@ScriptDir&"/b_set.ini", "1", "14", $color1) GUICtrlSetColor($Button13, $color1) GUICtrlSetBKColor($Button14, $color1) EndIf EndFunc Func _colorselect2() ;function to select the color I need. Local $color2 $color2 = _ChooseColor (2, 0xFF0000, 2) ; default color selected using RGB hex value If (@error) Then MsgBox(262144, "", "Error _ChooseColor: " & @error) Else IniWrite(@ScriptDir&"/b_set.ini", "1", "15", $color2) GUICtrlSetBKColor($Button15, $color2) GUICtrlSetBKColor($Button16, $color2) EndIf EndFunc Func _exhibit() $_Form1 = GUICreate("Button Controls", 426, 190, 193, 125) $_Button1 = GUICtrlCreateButton("Path", 8, 8, 41, 21, 0) $_inir1 = iniread(@ScriptDir&"/b_set.ini", "1", "2", "") $_input1 = GUICtrlCreateInput("", 56, 8, 353, 21) GUICtrlSetData($_input1, $_inir1) $_Label1 = GUICtrlCreateLabel("Height", 8, 42, 51, 17) $_inir2 = iniread(@ScriptDir&"/b_set.ini", "1", "3", "") $_input2 = GUICtrlCreateInput("", 56, 40, 40, 21, $ES_NUMBER+$ES_RIGHT) GUICtrlSetData($_input2, $_inir2) $_Width = GUICtrlCreateLabel("Width", 8, 75, 32, 17) $_inir3 = iniread(@ScriptDir&"/b_set.ini", "1", "4", "") $_input3 = GUICtrlCreateInput("", 56, 72, 40, 21, $ES_NUMBER+$ES_RIGHT) GUICtrlSetData($_input3, $_inir3) $_button_name = GUICtrlCreateLabel("Button"&@cr&"Name", 8, 102, 42, 25) $_input4 =GUICtrlCreateInput("", 56, 104, 113, 21) $_inir4 = iniread(@ScriptDir&"/b_set.ini", "1", "5", "") GUICtrlSetData($_input4, $_inir4) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $_Checkbox1 = GUICtrlCreateCheckbox("Status", 200, 40, 73, 17) $_inir5 = IniRead(@ScriptDir&"/b_set.ini", "1", "6", "") if $_inir5 = "1" then GUICtrlSetState($_Checkbox1, $GUI_CHECKED) $_Checkbox2 = GUICtrlCreateCheckbox("Toolbar", 200, 64, 73, 17) $_inir6 = IniRead(@ScriptDir&"/b_set.ini", "1", "7", "") if $_inir6 = "1" then GUICtrlSetState($_Checkbox2, $GUI_CHECKED) $_Checkbox3 = GUICtrlCreateCheckbox("Menubar", 200, 88, 73, 17) $_inir7 = IniRead(@ScriptDir&"/b_set.ini", "1", "8", "") if $_inir7 = "1" then GUICtrlSetState($_Checkbox3, $GUI_CHECKED) $_Checkbox4 = GUICtrlCreateCheckbox("Location", 200, 112, 73, 17) $_inir8 = IniRead(@ScriptDir&"/b_set.ini", "1", "9", "") if $_inir8 = "1" then GUICtrlSetState($_Checkbox4, $GUI_CHECKED) $_Checkbox5 = GUICtrlCreateCheckbox("Titlebar", 296, 40, 73, 17) $_inir9 = IniRead(@ScriptDir&"/b_set.ini", "1", "10", "") if $_inir9= "1" then GUICtrlSetState($_Checkbox5, $GUI_CHECKED) $_Checkbox6 = GUICtrlCreateCheckbox("Scroolbars", 296, 64, 73, 17) $_inir10 = IniRead(@ScriptDir&"/b_set.ini", "1", "11", "") if $_inir10= "1" then GUICtrlSetState($_Checkbox6, $GUI_CHECKED) $_Checkbox7 = GUICtrlCreateCheckbox("AlwaysRaised", 296, 88, 89, 17) $_inir11 = IniRead(@ScriptDir&"/b_set.ini", "1", "12", "") if $_inir11= "1" then GUICtrlSetState($_Checkbox7, $GUI_CHECKED) $_Checkbox8 = GUICtrlCreateCheckbox("Resizeable", 296, 112, 89, 17) $_inir12 = IniRead(@ScriptDir&"/b_set.ini", "1", "13", "") if $_inir12= "1" then GUICtrlSetState($_Checkbox8, $GUI_CHECKED) $_Button2 = GUICtrlCreateButton("OK", 56, 144, 75, 25, 0) $_Button3 = GUICtrlCreateButton("Cancel", 168, 144, 73, 25, 0) GUISetState(@SW_SHOW,$_Form1) While 1 $_nMsg = GUIGetMsg() Select Case $_nMsg = $GUI_EVENT_CLOSE Exitloop Case $_nMsg = $_Button1 $_ini_r1 = IniRead(@ScriptDir&"/b_set.ini", "1", "1",@ScriptDir) while 1 $_test_1 = FileOpenDialog("Select *.txt file being edited for Trandumper", $_ini_r1, "All (*.*)", 1+2) IniWrite(@ScriptDir&"/b_set.ini", "1", "1", $_test_1) $_slash = stringinstr($_test_1, "\", 0, -1) $_stringlen_1 = stringlen($_test_1) $_String_trim_R = StringTrimRight($_test_1, $_stringlen_1 - $_slash) $_fod = FileOpenDialog("Select target", $_String_trim_R, "All (*.*)", 1+2) $_pathcheck = StringInStr($_fod, $_String_trim_R) if $_pathcheck = 1 then exitloop MsgBox(0, "Error!", "File selected must be a sub directory where the test is located!") WEnd $_stringlen = StringLen($_String_trim_R) $_String_trim_L = StringTrimLeft($_fod, $_stringlen) $_replace_S = StringReplace($_String_trim_L, "\", "/") GUICtrlSetData($_input1, $_replace_S) ;------------------ ;~ case $Checkbox2 ;~ MsgBox(0, "", GUICtrlRead($Checkbox1)) Case $_nMsg = $_Button2 ;------path-------- $_CR1 = GUICtrlRead ($_input1) IniWrite(@ScriptDir&"/b_set.ini", "1", "2", $_CR1) ;----Width-------- $_width= GUICtrlRead($_input2) IniWrite(@ScriptDir&"/b_set.ini", "1", "3", $_width) ;----Height------- $_height= GUICtrlRead($_input3) IniWrite(@ScriptDir&"/b_set.ini", "1", "4", $_height) ;---button name--- $_button_name1 = GUICtrlRead($_input4) IniWrite(@ScriptDir&"/b_set.ini", "1", "5", $_button_name1) ;---status-------- $_w1=GUICtrlRead($_Checkbox1) IniWrite(@ScriptDir&"/b_set.ini", "1", "6",$_w1) if $_w1= "1" then $_w1= "yes" Else $_w1= "no" endif ;---toolbar------- $_w2=GUICtrlRead($_Checkbox2) IniWrite(@ScriptDir&"/b_set.ini", "1", "7",$_w2) if $_w2= "1" then $_w2= "yes" Else $_w2= "no" endif ;---Menubar------- $_w3=GUICtrlRead($_Checkbox3) IniWrite(@ScriptDir&"/b_set.ini", "1", "8",$_w3) if $_w3= "1" then $_w3= "yes" Else $_w3= "no" endif ;---Location------- $_w4=GUICtrlRead($_Checkbox4) IniWrite(@ScriptDir&"/b_set.ini", "1", "9",$_w4) if $_w4= "1" then $_w4= "yes" Else $_w4= "no" endif ;---Titlebar------- $_w5=GUICtrlRead($_Checkbox5) IniWrite(@ScriptDir&"/b_set.ini", "1", "10",$_w5) if $_w5= "1" then $_w5= "yes" Else $_w5= "no" endif ;---Scroolbars------ $_w6=GUICtrlRead($_Checkbox6) IniWrite(@ScriptDir&"/b_set.ini", "1", "11",$_w6) if $_w6= "1" then $_w6= "yes" Else $_w6= "no" endif ;---AlwaysRaised---- $_w7=GUICtrlRead($_Checkbox7) IniWrite(@ScriptDir&"/b_set.ini", "1", "12",$_w7) if $_w7= "1" then $_w7= "yes" Else $_w7= "no" endif ;---Resizeable------- $_w8=GUICtrlRead($_Checkbox8) IniWrite(@ScriptDir&"/b_set.ini", "1", "13",$_w8) if $_w8= "1" then $_w8= "yes" Else $_w8= "no" endif exitloop Case $_nMsg = $_Button3 ExitLoop EndSelect WEnd GUIDelete($_Form1) EndFunc Func _linebreakfix() $qst = MsgBox(32+3, "How do you want to convert it?", "How do you want to convert the selected text? Select Yes to save to OUTfile.txt. Select NO to convert in" _ &"the current opened file.") if $qst = 6 then $ans = 1 _linebreakfix2() endif if $qst = 7 then $ans = 2 _linebreakfix2() endif EndFunc func _linebreakfix2() $sFileIN = 'FileIN.txt' $sFileOUT = 'FileOUT.txt' If FileExists($sFileIN) Then FileDelete($sFileIN) If FileExists($sFileOUT) Then FileDelete($sFileOUT) FileWrite($sFileIN, ClipGet()) sleep(1) $sTEXTDUMP = FileRead($sFileIN) SR($NL, ' ') ;; first things first, lets get rid of all those pesty line breaks. SR('Actualtests.com - The Power of Knowing', ' ') SR('070-271', ' ') SRR('QUESTION (\d+)\:', $NL & $NL & '\1. ') ;SRR('QUESTION (\d+)\', $NL & $NL & '\1. ') SR('Answer:', $NL & $NL & 'Answer:') SR('Explanation:', $NL & $NL & '<B>Explanation:</B><br>' & $NL) SR('Incorrect Answers:', $NL & $NL & '<B>Incorrect Answers:</B><br>') SRR('([ABCDEFG])\, ([ABCDEFG])\: ', $NL & '<B>\1\2 -</B> ') ;; exception! SRR('([ABCDEFG])\: ', $NL & '<B>\1 -</B> ') SRR(' ([A-G]\. )', $NL & '\1 ') SR('A. ', $NL & $NL & 'A. ') SR('References:', $NL & $NL & '<B>References:</B><br>' & $NL) SR('Reference:', $NL & $NL & '<B>References:</B><br>' & $NL) SR('Certkiller .com', 'AutoIt.com') SR('Certkiller.com', 'AutoIt.com') ;; GENERAL CLEANUP ;; $sFIND = ' ' $sREPL = ' ' While StringInStr($sTEXTDUMP, $sFIND) SR($sFIND, $sREPL) WEnd SR($NL & ' ', $NL) SR(' ' & $NL, $NL) $sFIND = $NL & $NL & $NL $sREPL = $NL & $NL While StringInStr($sTEXTDUMP, $sFIND) SR($sFIND, $sREPL) WEnd if $ans = 1 then FileWrite($sFileOUT, $sTEXTDUMP) if $ans = 2 then FileWrite($sFileOUT, $sTEXTDUMP) $FRnew = FileRead($sFileOUT) ClipPut($FRnew) ControlSend($hWnd,"","Edit1","^v") endif EndFunc Func SR($sFIND, $sREPL) $sTEXTDUMP = StringReplace($sTEXTDUMP, $sFIND, $sREPL, 0, 2) EndFunc Func SRR($sPATERN, $sREPL) $sTEXTDUMP = StringRegExpReplace($sTEXTDUMP, $sPATERN, $sREPL, 0) EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted May 29, 2008 Author Share Posted May 29, 2008 Well, In looking at AnyGUI, it seems notepad won't let me do what I need, so my last question is unsolveable. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now