Leaderboard
Popular Content
Showing content with the highest reputation on 06/27/2013 in all areas
-
Hi! I wrote a small editor for another project that uses Scintilla with a custom lexer as editor component. Everything, including the lexer (styling and folding) is written in AutoIt in a way that it can be easily integrated into other projects. The archive contains everything neccessary: the compiled editor, complete source code, form definitions, external libraries, etc.. Certainly, everything written by someone else is documented, either in authors.txt in the "Libs" folder or as comments in the source itself. The lexer is mainly designed to be used with script languages (SGML-like languages won't work really well) and can be customized via its own menu item. You can add your own additional script language definitions as well. There are already some lexer definitions, test scripts and a small example, how to integrate the editor component into a different project (mainly only 4 lines of code) in the archive. See _LexingUDF_example.au3. When you start the editor it runs in german without any default lexer selected, so if you would like to start in english and with AutoIt lexing enabled, call it this way: 'scripteditor.exe -l=en -x=autoit' Apart from that you can go to 'Lexer' menu and choose one from the list. You can take a look at every command line parameter with '-h' Screenshot (ok, in german, yet I think you will understand): Download: ScriptEditor v1.9 A short description how to integrate the component into another project (for a closer look, see _LexingUDF_example.au3): ; 0.) we need the whole content of the archive, so extract everything, delete editor.au3 and start coding ;-) #include "_LexingUDF.au3" ; at first the parent GUI needs to be created, we need the control id (in this example $hGUI) ; 1.) now set the parent GUI for the new editor component $__default_editor_parent = $hGUI ; 2.) load a lexer definition - name of the file without .def extension from 'LexDef' folder _GUICtrlLex_ReadLEXFile($lexer) -> ie: _GUICtrlLex_ReadLEXFile("autoit") ; 3.) create editor component within $__default_editor_parent _GUICtrlLex_CreateScriptEditor($x, $y, $width, $height) -> ie: _GUICtrlLex_CreateScriptEditor(0, 0, 800, 600) ; 4.) initialize necessary variables, arrays, etc. and apply the styles, layout defaults, marker definitions, etc. which have been loaded before to the editor _GUICtrlLex_SetupStylingAndFolding() ; this is it.... for everyone who wants to have a nice menu with every existing lexer definition and a ; menu point to customize things, as shown in the screenshot, adds the following: ; (advice: use OnEvent mode to ease things) ; 5.) create a separate 'Lexer' main menu entry with everthing needed _GUICtrlLex_CreateLexerDefMenu('main') ; 6.) connect the menu item created in 5.) with the configuration dialog GUICtrlSetOnEvent($__arM[2], "_GUICtrlLex_OpenLexerDef") ; IMPORTANT: if you need to register your own WM_COMMAND or WM_NOTIFY routines, use ; _GUIRegisterMsg from _GUIRegisterMsg.au3 !!! Really nice is that you can change the lexer definition, colors, fonts, etc. and if you click on 'Save' everything will be applied immediately so that you can see what happens. Try it with the test scripts ;-) To be fair, I have to admit, that the editor is too slow for big scripts - it's running in AutoIt speed . But as speed wasn't important for me, because I wanted to handle small scripts with my own special lexing, it was ok for me. So please don't blame me for the fact, that your 8000 lines of code script won't get styled and folded really fast ;-) Also, there might be still some bugs in it and I don't really know how smart my way of coding is (especially the folding algorithm , perhaps a rewrite it from scratch), because I'm still quite new to AutoIt, but it was fun to do ;-) and it works for me. Perhaps someone likes it , it is meant as a contribution to a very informative forum ! Regards, Holger1 point
-
Yes, in general, using the code Melba provides is the preferred method for AutoIt-ing. and running through the GuiCtrlSet* portion of the help file will assist with manipulating the data, to include font.1 point
-
One function in my script is not working...
UndefinedVar reacted to guinness for a topic
My motto is "If at first you don't succeed, try and rebuild!"1 point -
Why not return an unused error code code? like -1. Br, FireFox.1 point
-
Return value
olo reacted to UndefinedVar for a topic
Maybe try this : if yolo() = "<0" Then MsgBox(0, ""," Hey fella there is an error !") Func yolo() return "<0" EndFunc1 point -
Zeerti, That was a bit of fun. Create an ini file like this and save it as "Riddles.ini" in the same folder as the script: [1] Riddle=Riddle 1 Answer=Answer 1 Hint_1=Hint 11 Hint_2=Hint 12 Hint_3=Hint 13 [2] Riddle=Riddle 2 Answer=Answer 2 Hint_1=Hint 21 Hint_2=Hint 22 Hint_3=Hint 23 [3] Riddle=Riddle 3 Answer=Answer 3 Hint_1=Hint 31 Hint_2=Hint 32 Hint_3=Hint 33 Then run this script and you should get something close to what you want: #include <GUIConstantsEx.au3> Global $aButton[3], $aHint_Label[3] Global $iRiddle = 1, $sRiddle, $sAnswer, $aHint[3] Global $sRiddles = @ScriptDir & "\Riddles.ini" Global $iSkip = 0 $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xFFCCCC) $cRiddle_Label = GUICtrlCreateLabel("The riddle will appear here", 10, 10, 480, 100) GUICtrlSetFont(-1, 24) GUICtrlSetBkColor(-1, 0xCCFFCC) For $i = 0 To 2 $aButton[$i] = GUICtrlCreateButton("Hint " & $i + 1, 15 + (165 * $i), 120, 145, 30) GUICtrlSetState(-1, $GUI_DISABLE) $aHint_Label[$i] = GUICtrlCreateLabel("Hints appear here", 15 + (165 * $i), 180, 145, 100) GUICtrlSetBkColor(-1, 0xCCCCFF) Next $cAnswer = GUICtrlCreateInput("Enter your answer here", 10, 300, 480, 100) GUICtrlSetFont(-1, 18) GUICtrlSetBkColor(-1, 0xCCFFFF) $cButton_Check = GUICtrlCreateButton("Start", 10, 420, 230, 60) GUICtrlSetState(-1, $GUI_FOCUS) $cButton_Skip = GUICtrlCreateButton("Skip Current Riddle", 260, 420, 230, 60) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $cButton_Check If GUICtrlRead($cButton_Check) = "Start" Then GUICtrlSetData($cButton_Check, "Check Answer") $iRiddle = _Load_Riddle($iRiddle) _Show_Riddle() Else If GUICtrlRead($cAnswer) = $sAnswer Then MsgBox(0, "Congrats", "Correct answer") $iRiddle = _Load_Riddle($iRiddle) If $iRiddle Then _Show_Riddle() Else MsgBox(0, "Hi", "Now we show the directions GUI") EndIf Else MsgBox(0, "Sorry", "Not correct - try again") EndIf EndIf Case $cButton_Skip If MsgBox(1, "Really?", "You only get 2 chances to skip a riddle!") = 1 Then $iSkip += 1 If $iSkip = 2 Then GUICtrlSetState($cButton_Skip, $GUI_DISABLE) EndIf MsgBox(0, "Correct Answer", $sAnswer) $iRiddle = _Load_Riddle($iRiddle) If $iRiddle Then _Show_Riddle() Else MsgBox(0, "Hi", "Now we show the directions GUI") EndIf EndIf Case Else For $i = 0 To 2 If $iMsg = $aButton[$i] Then GUICtrlSetState($aHint_Label[$i], $GUI_SHOW) GUICtrlSetState($aButton[$i], $GUI_DISABLE) If $i < 2 Then GUICtrlSetState($aButton[$i + 1], $GUI_ENABLE) EndIf ExitLoop EndIf Next EndSwitch WEnd Func _Show_Riddle() GUICtrlSetData($cRiddle_Label, $sRiddle) GUICtrlSetData($cAnswer, "") For $i = 0 To 2 GUICtrlSetData($aHint_Label[$i], $aHint[$i]) GUICtrlSetState($aHint_Label[$i], $GUI_HIDE) GUICtrlSetState($aButton[$i], $GUI_DISABLE) Next GUICtrlSetState($aButton[0], $GUI_ENABLE) EndFunc Func _Load_Riddle($iIndex) $sRiddle = IniRead($sRiddles, $iIndex, "Riddle", "Error") $sAnswer = IniRead($sRiddles, $iIndex, "Answer", "Error") $aHint[0] = IniRead($sRiddles, $iIndex, "Hint_1", "Error") $aHint[1] = IniRead($sRiddles, $iIndex, "Hint_2", "Error") $aHint[2] = IniRead($sRiddles, $iIndex, "Hint_3", "Error") If $sRiddle <> "Error" Then Return $iIndex + 1 Else Return 0 EndIf EndFunc As you are getting a complete freebie solution, I have deliberately left out all comments so you have to work a bit to refine the script. But if you do get stuck, please do ask. I hope your friend enjoys his present. M231 point
-
Use psexec to excute the script you copy over to the station. Else, you need to find the parent handle through wingethandle (looped until you find it)...which wouldn't make sense, because then you would need to execute the installer and THEN the autoit script on the target station1 point
-
very neat. Here's a tool I made for the same purpose. edit: removed garbage from bad autoit tag production. edit: Added IP address in Listview and Host List support. Windows 7 icons are not correct. Will need to make an exception for Win7 vs Win XP. #include <GuiListView.au3> #include <Inet.au3> #include <File.au3> Global $delay $gui = GUICreate("PingTool", 480, 340, -1, -1, -1) $listview = GUICtrlCreateListView("|Hostname|IP|Sent|Recv|Lost|Last Seen ", 10, 10, 450, 280, 0x0008) ;Listview to Store Ping Info _GUICtrlListView_SetColumnWidth($listview,0,22) For $x = 3 to 5 _GUICtrlListView_SetColumnWidth($listview,$x,38) ;Set Sent, Recv, and Lost Columns Next _GUICtrlListView_SetColumnWidth($listview,6,119) $cmbDelay = GUICtrlCreateCombo("60",44,304,40,20,0x0003) ;Delay in Seconds GUICtrlSetData(-1,"45|30|15|5|1","5") GUICtrlCreateLabel("Every",10,308,30,30) GUICtrlCreateLabel("seconds",88,308,40,30) GUICtrlCreateLabel("Add:",160,308,26,30) $inputHost = GUICtrlCreateInput(@ComputerName,188,304,100,20) $btnAdd = GUICtrlCreateButton("",294,300,24,24, 0x0041) GUICtrlSetImage(-1, "C:\WINDOWS\system32\netshell.dll", -150, 0) GUICtrlCreateLabel("Open Host List:",354,308,80,30) $btnHostList = GUICtrlCreateButton("",434,300,24,24, 0x0040) GUICtrlSetImage(-1, "C:\WINDOWS\system32\shell32.dll", -43, 0) $contextmnu = GUICtrlCreateContextMenu($listview) $cntxtRem = GUICtrlCreateMenuItem("Remove Selected",$contextmnu) TCPStartup() ;Required for IP Resolution $delay = GUICtrlRead($cmbDelay) $timer = TimerInit() GUISetState(@SW_SHOW) While 1 ;Main Loop $nMsg = GUIGetMsg() Switch $nMsg Case -3 ;Exit TCPShutdown() Exit Case $cmbDelay ;Delay Time Change $delay = GUICtrlRead($cmbDelay) Case $btnAdd ;Add Host to Ping Listview _AddHost(StringUpper(GUICtrlRead($inputHost))) Case $cntxtRem ;Remove Host from Ping Listview _RemHost() Case $btnHostList _OpenList() ;Import Host List EndSwitch If TimerDiff($timer) > $delay * 1000 Then ;Perform Ping Routine if Delay Threshold is reached _PingRoutine() $timer = TimerInit() EndIf WEnd Func _PingRoutine() ;Loop through Listview $listcount = _GUICtrlListView_GetItemCount($listview) For $x = 0 To $listcount-1 _Ping($x) Next EndFunc Func _Ping($item) ;Individual Ping Routine $data = _GUICtrlListView_GetItemTextArray($listview,$item) $host = $data[2] $data[4] += 1 $id = _GUICtrlListView_GetItemParam($listview, $item) _Results($id,$data) GUICtrlSetImage($id, "C:\WINDOWS\system32\netshell.dll", -61) sleep(250) $ping = Ping($host,250) If $ping and Not @error Then $data[5] += 1 $data[7] = @HOUR & ":" & @MIN & ":" & @SEC & " " & @MON & "/" & @MDAY & "/" & @YEAR _Results($id,$data) GUICtrlSetImage($id, "C:\WINDOWS\system32\netshell.dll", -62) sleep(250) _HostOnline($id) Else $data[6] += 1 _Results($id,$data) _HostOffline($id,@error) EndIf EndFunc Func _HostOnline($item) ;Animate Host Online GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -63) sleep(125) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -60) sleep(125) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -63) sleep(125) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -60) sleep(125) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -63) EndFunc Func _HostOffline($item,$err) ;Animate Host Offline If $err = 3 Then GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -65) sleep(250) GUICtrlSetImage($item, "shell32.dll", -50) sleep(250) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -65) sleep(250) GUICtrlSetImage($item, "shell32.dll", -50) sleep(250) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -65) Else GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -66) sleep(250) GUICtrlSetImage($item, "shell32.dll", -50) sleep(250) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -66) sleep(250) GUICtrlSetImage($item, "shell32.dll", -50) sleep(250) GUICtrlSetImage($item, "C:\WINDOWS\system32\netshell.dll", -66) EndIf EndFunc Func _Results($item, $data) ;Set Listview Item Data Dim $str = "" For $x = 1 to UBound($data)-1 $str &= $data[$x] If $x < UBound($data) -1 Then $str &= "|" Next GUICtrlSetData($item,$str) EndFunc Func _AddHost($host) ;Add Host to Listview $ip = TCPNameToIP($host) If $ip <> $host Then GUICtrlCreateListViewItem("|" & $host & "|" & $ip & "|0|0|0",$listview) Else $host = _TCPIpToName($ip) GUICtrlCreateListViewItem("|" & $host & "|" & $ip & "|0|0|0",$listview) EndIf EndFunc Func _RemHost() ;Remove Host from Listview $item = _GUICtrlListView_GetSelectedIndices($listview,True) For $x = $item[0] To 1 Step -1 GUICtrlDelete(_GUICtrlListView_GetItemParam($listview, $item[$x])) Next EndFunc Func _OpenList() ;Import Host List $src = FileOpenDialog("Host List",@ScriptDir,"Text files (*.txt)|All (*.*)",1) If Not FileExists($src) Then Return 0 Local $arrHosts _FileReadToArray($src, $arrHosts) For $x = 1 to $arrHosts[0] _AddHost($arrHosts[$x]) Next EndFunc1 point