Leaderboard
Popular Content
Showing content with the highest reputation on 02/23/2012 in all areas
-
SimpleStack
qsek reacted to jaberwacky for a topic
Here's a useless stack data structure using AutoItObject and the latest AutoIt beta. [update: March 05, 2015] -- Maps behind the scenes. Use maps as a stack. Stack to map. Bug fixes. [update: April 04, 2014] -- Uses ternary operators now. New method: ToString. Etc. [update: October 02, 2011] -- Two new functions and a bug fix. SimpleStack.au3 #include-once #include <Array.au3> #include "AutoItObject.au3" #Region ; SimpleStack Func SimpleStack() With _AutoItObject_Class() .AddMethod("Push", "SS_Push") .AddMethod("Pop", "SS_Pop") .AddMethod("Peek", "SS_Peek") .AddMethod("Length", "SS_Length") .AddMethod("Reset", "SS_Reset") .Addmethod("ArrayToStack", "SS_ArrayToStack") .Addmethod("MapToStack", "SS_MapToStack") .Addmethod("ToArray", "SS_ToArray") .Addmethod("ToMap", "SS_ToMap") .Addmethod("ToString", "SS_ToString") Local $mMap[] .AddProperty("Stack", $elscope_private, $mMap) .AddProperty("Size" , $elscope_private, 0) Return .Object EndWith EndFunc ; = Method ================================================================================ ; Name .....: SS_Push ; Syntax ...: $oSimpleStack.Push($data) ; Param(s) .: $data -- The value that you would like to store in the stack. ; Success ..: Stores a value on the top of the stack and returns the value. ; Fail .....: ; Desc. ....: Places an element on top of the stack and returns that element. ; ========================================================================================= Func SS_Push($this, Const $data) With $this Switch IsMap(.Stack) Case 1 Local $mStack[] $mStack = .Stack $mStack[.Size + 1] = $data .Stack = $mStack ;ConsoleWrite('- ' & IsMap($mStack) & @TAB & UBound(MapKeys(.Stack)) & @CRLF) Switch MapExists(.Stack, .Size + 1) Case True .Size += 1 Return .Peek() Case False Return SetError(2, 0, False) EndSwitch Case 0 Return SetError(1, 0, False) EndSwitch EndWith EndFunc ; = Method ================================================================================ ; Name .....: SS_Pop ; Syntax ...: $oSimpleStack.Pop() ; Param(s) .: none ; Success ..: Deletes an element from the top of the stack. Returns the element that was deleted. ; Fail .....: @error: 1 ; Desc. ....: ; ========================================================================================= Func SS_Pop($this) With $this Switch .Size Case True Local Const $peek = .Peek() Local $mStack[] $mStack = .Stack Switch MapRemove($mStack, .Size) Case 1 .Stack = $mStack .Size -= 1 Return $peek Case 0 Return SetError(2, 0, False) EndSwitch Case False Return SetError(1, 0, False) EndSwitch EndWith EndFunc ; = Method ================================================================================ ; Name .....: SS_Peek ; Syntax ...: $oSimpleStack.Peek() ; Param(s) .: none ; Success ..: Returns the data from the top of the stack leaving the stack state unchanged. ; Fail .....: @error: 1 ; Desc. ....: ; ========================================================================================= Func SS_Peek(Const $this) With $this Switch .Size Case True Switch IsMap(.Stack) Case 1 Return .Stack[.Size] Case 0 Return SetError(1, 0, Null) EndSwitch Case False Return SetError(1, 0, Null) EndSwitch EndWith EndFunc ; = Method ================================================================================ ; Name .....: SS_Length ; Syntax ...: $oSimpleStack.Length() ; Param(s) .: none ; Success ..: Returns the count of elements that have been pushed on to the stack. ; Fail .....: ; Desc. ....: ; ========================================================================================= Func SS_Length(Const $this) Return $this.Size EndFunc ; = Method ================================================================================ ; Name .....: SS_Reset ; Syntax ...: $oSimpleStack.Reset() ; Success ..: True & Sets the state of the stack to default. ; Desc. ....: ; ========================================================================================= Func SS_Reset($this) With $this .Stack = Null .Size = 0 EndWith Return True EndFunc ; = Method ================================================================================ ; Name .....: SS_ArrayToStack ; Syntax ...: $oSimpleStack.ArrayToStack($array) ; Param(s) .: $array -- the array to use to populate a stack structure ; Success ..: 1 ; Fail .....: 0 & @error: 1 -- $array is not an array ; Desc. ....: Takes the elements of an existing array and uses them to populate a stack structure. ; ========================================================================================= Func SS_ArrayToStack($this, Const $array) Switch IsArray($array) Case True Local Const $upbound = UBound($array) Local $mStack[] For $i = 1 To $upbound $mStack[$i] = $array[$i - 1] Next With $this .Stack = $mStack .Size = $upbound EndWith Case False Return SetError(1, 0, False) EndSwitch EndFunc ; = Method ================================================================================ ; Name .....: SS_MapToStack ; Syntax ...: $oSimpleStack.MapToStack($map) ; Param(s) .: $map -- the map to use to populate a stack structure ; Success ..: 1 ; Fail .....: 0 & @error: 1 -- $map is not an map ; Desc. ....: Takes the keys of an existing map and uses them to populate a stack structure. ; ========================================================================================= Func SS_MapToStack($this, Const $map) Switch IsMap($map) Case True Local Const $keys = MapKeys($map) Local Const $size = UBound($keys) Local $mStack[] For $i = 1 To $size $mStack[$i] = $map[$keys[$i - 1]] Next With $this .Stack = $mStack .Size = $size EndWith Case False Return SetError(1, 0, False) EndSwitch EndFunc ; = Method ================================================================================ ; Name .....: SS_ToArray ; Syntax ...: $oSimpleStack.ToArray() ; Success ..: Returns the current stack as an array. ; Fail .....: 0 | @error: 1 -- stack is empty ; Desc. ....: ; ========================================================================================= Func SS_ToArray(Const $this) With $this Local Const $size = .Size Switch $size Case True Local $array[$size] For $i = 1 To $size $array[$i - 1] = .Stack[$i] Next Return $array Case False Return SetError(1, 0, False) EndSwitch EndWith EndFunc ; = Method ================================================================================ ; Name .....: SS_ToMap ; Syntax ...: $oSimpleStack.ToMap() ; Success ..: Returns the current stack as an map. ; Fail .....: 0 | @error: 1 -- stack is empty ; Desc. ....: ; ========================================================================================= Func SS_ToMap(Const $this) With $this Switch .Size Case True Return .Stack Case False Return SetError(1, 0, False) EndSwitch EndWith EndFunc ; = Method ================================================================================ ; Name .....: SS_ToString ; Syntax ...: $oSimpleStack.ToString() ; Param(s) .: $seperator -- string to delimit the string ; Success ..: the contents of the stack as a space seperated string ; Fail .....: '' | @error: 1 -- stack is empty ; Desc. ....: ; ========================================================================================= Func SS_ToString(Const $this, Const $seperator = ' ') With $this Local Const $size = .Size If $size Then Local $string = '' For $i = $size To 1 Step -1 $string &= .Stack[$i] & $seperator Next Return $string Else Return SetError(1, 0, '') EndIf EndWith EndFunc #EndRegion1 point -
Ansatsusha (暗殺者) - 3D Sniper game programmed in Autoit
jvanegmond reacted to Rux for a topic
I'd like to present a game I am working on called ANSATSUSHA (means assassin in Japanese). So far, I'm still working on the first level, after having to overcome many problems, and I'm still not finished it. However, I have overcome most of the problems, and now I'm working on it rather than solving problems. I am using the IRRLICHT Autoit engine, autoit to program it, Anim8tor + an animator file to .ms3d converter to make the models. I'm already finished with all/most of the graphics making though. ANSATSUSHA OVERVIEW --------------------------------- The point of the game is to take the roll of an assassin. There will be 10 levels, with 5 different objectives. After beating the first 5, you will do the same objectives, but they will be harder. For now, I'm not going to spoil any of the missions, except the first 1 is just a standard aim and kill mission. Download the first demo here V http://adf.ly/80AKT CONTROLS: WASD - Walk Left Mouse - Shoot Right Mouse - Scope Mouse - Aim R - Reload ALT - F4 (for now) Close out of the game. I haven't programmed a proper exit yet. It's coming soon though. So far, all you can do is walk around and shoot, but its a start. Have fun.1 point -
New version 21 Feb 12 New: You can now choose the manner in which the GUI extends/retracts by adding a parameter to _GUIExtender_Init. This parameter sets the fixed point of the GUI: Left/Top (default and current behaviour), Centre, Right/Bottom. This fixed point can be overridden for a specific section by using a similar parameter in a _GUIExtender_Section_Extend call. See the new examples for more details. Thanks to mechaflash213 for the idea. This is a non-scriptbreaking change - all current scripts will perform as before. New UDF, examples and zip in this post. Previous updates: A recent forum question asked how to have expandable sections in a GUI. Although the coding to do this was not too difficult, it was a bit messy and not too easy to modify for another GUI - as subsequent posts in the thread showed. So I thought I might develop a UDF to do the same thing, but in as transparent manner as possible - and came up with GUIExtender. This UDF allows you to have multiple sections within a GUI which can be static or extendable. The extendable sections can be extended and retracted either by UDF created buttons or programmatically. The controls on the sections are fully functional and there is no overlap problem when retracted (see the details section if you want to know how). And the UDF can be used in both MessageLoop and OnEvent modes. Here are several examples: Some details for the curious among you who might want to know a bit more about how GUIExtender works: New - And finally, the GUIExtender UDF itself - just put it in the same folder as the examples: #include-once ; #INDEX# ============================================================================================================ ; Title .........: GUIExtender ; AutoIt Version : v3.3 or higher ; Language ......: English ; Description ...: Extends and retracts user-defined sections of a GUI either vertically or horizontally ; Remarks .......: ; Note ..........: ; Author(s) .....: Melba23 ; ==================================================================================================================== ;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #GLOBAL VARIABLES# ================================================================================================= ; Declare array to hold section data Global $aGUIExt_Section_Data[1][9] = [[0, 0, 1, 0, "", 9999]] ; [0][0] = Section count [n][0] = Initial section X/Y-coord ; [0][1] = Orientation - 0 = Vertical, 1 = Horizontal [n][1] = Section height/width (inc border) ; [0][2] = All state - 0 = all retracted, 1 = at least 1 extended [n][2] = Section state - 0 = Retracted, 1 = extended, 2 = static ; [0][3] = GUI handle [n][3] = Section anchor ControlID (invisible disabled label) ; [0][4] = Fixed point - 0 = Left/Top, 1 = Centre, 2 = Right/Bottom [n][4] = Section final ControlID ; [0][5] = Action all button ControlID [n][5] = Section action button ControlID ; [0][6] = Action all button extended text [n][6] = Section action button extended text ; [0][7] = Action all button retracted text [n][7] = Section action button retracted text ; [0][8] = Action all button type [n][8] = Section action button type ; Declare array to hold data about embedded objects Global $aGUIExt_Obj_Data[1][2] = [[0]] ; [0][0] = Object count ; [n][0] = Embedded object ControlID ; [n][1] = Original object handle ; Declare flag for section action Global $fGUIExt_SectionAction = False ; #CURRENT# ========================================================================================================== ; _GUIExtender_Init: Initialises the GUI containing the sections and sets orientation and fixed point ; _GUIExtender_Section_Start: Marks the start point of GUI section ; _GUIExtender_Section_End: Marks the end of a GUI section ; _GUIExtender_Section_Action: Creates normal or push buttons to action extension or retraction of GUI sections ; _GUIExtender_Action: Used in GUIGetMsg loops to detect clicks on section action buttons ; _GUIExtender_Restore: Used reset GUI after a MINIMIZE and RESTORE ; _GUIExtender_Section_Extend: Actions section extension or retraction programatically or via section action buttons ; _GUIExtender_Section_State: Returns state of section ; _GUIExtender_UDFCtrlCheck: Hides/Shows and moves UDF-created controls when sections are extended/retracted ; _GUIExtender_ActionCheck: Indicates when sections are extended/retracted so that _GUIExtender_UDFCtrlCheck can be called ; _GUIExtender_Obj_Data: Store additional info on embedded objects ; _GUIExtender_Clear: Called on GUI deletion to clear the data array ready for a new GUI to be initialised ; ==================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; _GUIExtender_Section_All_Extend: Actions all moveable sections ; _GUIExtender_Section_Action_Event: Used to detect clicks on section action buttons in OnEvent mode ; ==================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Init ; Description ...: Initialises the GUI containing the sections and sets orientation and fixed point ; Syntax.........: _GUIExtender_Init($hWnd[, $iOrient = 0[, $iFixed = 0]]) ; Parameters ....: $hWnd - Handle of GUI containing the sections ; $iOrient - 0 = Vert - GUI extends and retracts in vertical sense ; 1 = Horz - GUI extends and retracts in horizontal sense ; $iFixed - 0 = GUI Left/Top fixed (Default) ; 1 = GUI centre fixed ; 2 = GUI Right/Bottom fixed ; Requirement(s).: v3.3 + ; Return values .: Success: Returns 1 ; Failure: Returns 0 and sets @error as follows: ; 1 = Invalid handle ; 2 = Existing initialisation ; 3 = Invalid parameter with @extended set: 1 = $iOrient, 2 $iFixed ; Author ........: Melba23 ; Remarks .......: This function should be called before any controls are created within the GUI ; Only one GUI can be initialised at any one time. _GUIExtender_Clear must be called before a second ; GUI can be initialised. The previous GUI loses all extension/retraction ability ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Init($hWnd, $iOrient = 0, $iFixed = 0) ; Check valid handle If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ; Check for existing initialisation If $aGUIExt_Section_Data[0][3] Then Return SetError(2, 0, 0) ; Check for valid parameters Switch $iOrient Case 0, 1 ; Valid Case Else Return SetError(3, 1, 0) EndSwitch Switch $iFixed Case 0, 1, 2 ; Valid Case Else Return SetError(3, 2, 0) EndSwitch ; Store GUI handle $aGUIExt_Section_Data[0][3] = $hWnd ; Store orientation $aGUIExt_Section_Data[0][1] = $iOrient ; Store fixed point $aGUIExt_Section_Data[0][4] = $iFixed ; Set resizing mode to prevent resizing of controls Opt("GUIResizeMode", 0x0322) ; $GUI_DOCKALL ; Set automatic restore function for OnEvent mode scripts GUISetOnEvent(-5, "_GUIExtender_Restore") ; $GUI_EVENT_RESTORE Return 1 EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Section_Start ; Description ...: Marks the start point of GUI section ; Syntax.........: _GUIExtender_Section_Start($iSection_Coord, $iSection_Size) ; Parameters ....: $iSection_Coord - Coordinates of left/top edge of section depending on orientation ; $iSection_Size - Width/Height of section ; Requirement(s).: v3.3 + ; Return values .: Success: Returns section ID ; Failure: Returns 0 and sets @error as follows: ; 1 = Section overlaps with previous section ; Author ........: Melba23 ; Remarks .......: The function creates a disabled label to act as an anchor for the section position ; The function must be called BEFORE any controls in the section have been cretaed ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Section_Start($iSection_Coord, $iSection_Size) If $aGUIExt_Section_Data[0][0] > 1 Then ; Check section start is after previous section end If $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0] - 1][0] + $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0] - 1][1] > $iSection_Coord Then Return SetError(1, 0, 0) EndIf ; Add new section $aGUIExt_Section_Data[0][0] += 1 ; ReDim array if required If UBound($aGUIExt_Section_Data) < $aGUIExt_Section_Data[0][0] + 1 Then ReDim $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0] + 1][9] EndIf ; Store passed position and size parameters $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][0] = $iSection_Coord $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][1] = $iSection_Size ; Set state to static if not already set If $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][2] = "" Then $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][2] = 2 ; Create a zero size disabled label to act as an anchor for the section If $aGUIExt_Section_Data[0][1] Then ; Depending on orientation $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][3] = GUICtrlCreateLabel("", $iSection_Coord, 0, 1, 1) Else $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][3] = GUICtrlCreateLabel("", 0, $iSection_Coord, 1, 1) EndIf GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT GUICtrlSetState(-1, 128) ; $GUI_DISABLE ; Set dummy action ControlID if needed If $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][5] = "" Then $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][5] = 9999 ; Return section ID Return $aGUIExt_Section_Data[0][0] EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Section_End ; Description ...: Marks the end point of GUI section ; Syntax.........: _GUIExtender_Section_End() ; Parameters ....: None ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Melba23 ; Remarks .......: The function must be called AFTER all the controls in the section have been created ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Section_End() ; Determine End ControlID for the section $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][4] = GUICtrlCreateDummy() - 1 EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Section_Action ; Description ...: Creates controls to action extension or retraction of GUI sections ; Syntax.........: _GUIExtender_Section_Action($iSection[, $sText_Extended = ""[, $sText_Retracted = ""[, $iX = 0[, $iY = 0[, $iW = 0[, $iH = 0[, $iType = 0[, $iEventMode = 0]]]]]]]]]) ; Parameters ....: $iSection - Section to action - 0 = all extendable sections ; $sText_Extended - Text on button when section is extended - default: small up/left arrow ; $sText_Retracted - Text on button when section is retracted - default: small down/right arrow ; $iX - Left side of the button ; $iY - Top of the button ; $iW - Width of the button ; $iH - Height of the button ; $iType - Type of button: ; 0 = pushbutton (default) ; 1 = normal button ; $iEventMode - Set to 1 if using OnEvent mode ; In this case, the control is automatically linked to the _GUIExtender_Section_Action_Event function ; Requirement(s).: v3.3 + ; Return values .: Success: Returns 1 ; Failure: Returns 0 and sets @error as follows: ; 1 = Control not created ; Author ........: Melba23 ; Remarks .......: Sections are static unless an action control has been set ; Omitting all optional parameters creates a section which can be actioned programmatically ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Section_Action($iSection, $sText_Extended = "", $sText_Retracted = "", $iX = 0, $iY = 0, $iW = 1, $iH = 1, $iType = 0, $iEventMode = 0) ; ReDim array if required If $iSection > 1 And UBound($aGUIExt_Section_Data) < $iSection + 1 Then ReDim $aGUIExt_Section_Data[$iSection + 1][9] EndIf ; Set state to extended indicating a extendable section $aGUIExt_Section_Data[$iSection][2] = 1 ; If default arrows required Local $iDef_Arrows = 0 If $sText_Extended = "" And $sText_Retracted = "" Then $iDef_Arrows = 1 If $aGUIExt_Section_Data[0][1] Then ; Dependiing on orientation $sText_Extended = 3 $sText_Retracted = 4 Else $sText_Extended = 5 $sText_Retracted = 6 EndIf EndIf ; What type of button? Switch $iType ; Pushbutton Case 0 ; Create normal button $aGUIExt_Section_Data[$iSection][5] = GUICtrlCreateButton($sText_Extended, $iX, $iY, $iW, $iH) Case Else ; Create pushbutton $aGUIExt_Section_Data[$iSection][5] = GUICtrlCreateCheckBox($sText_Extended, $iX, $iY, $iW, $iH, 0x1000) ; $BS_PUSHLIKE ; Set button state GUICtrlSetState(-1, 1) ; $GUI_CHECKED EndSwitch ; Check for error If $aGUIExt_Section_Data[$iSection][5] = 0 Then Return SetError(2, 0, 0) ; Change font if default arrows required If $iDef_Arrows Then GUICtrlSetFont($aGUIExt_Section_Data[$iSection][5], 10, 400, 0, "Webdings") ; Set event function if required If $iEventMode Then GUICtrlSetOnEvent($aGUIExt_Section_Data[$iSection][5], "_GUIExtender_Section_Action_Event") ; Store required text $aGUIExt_Section_Data[$iSection][6] = $sText_Extended $aGUIExt_Section_Data[$iSection][7] = $sText_Retracted ; Store button type $aGUIExt_Section_Data[$iSection][8] = $iType Return 1 EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Action ; Description ...: Used in GUIGetMsg loops to detect clicks on section action buttons and $GUI_EVENT_RESTORE events ; Syntax.........: _GUIExtender_Action($iMsg) ; Parameters ....: $iMsg - Return from GUIGetMsg ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Melba23 ; Remarks .......: The return from GUIGetMsg is passed to this function to determine if a section action control was clicked ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Action($iMsg) ; If GUI is restored, run the restore function If $iMsg = -5 Then _GUIExtender_Restore() ; $GUI_EVENT_RESTORE ; Check if an action control has been clicked For $i = 0 To $aGUIExt_Section_Data[0][0] ; If action button clicked If $iMsg = $aGUIExt_Section_Data[$i][5] Then ; Check current state Switch $aGUIExt_Section_Data[$i][2] Case 0 _GUIExtender_Section_Extend($i, True) Case Else _GUIExtender_Section_Extend($i, False) EndSwitch ; Set flag for section action occurring $fGUIExt_SectionAction = True EndIf Next EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Restore ; Description ...: Used to reset GUI after a MINIMIZE and RESTORE ; Syntax.........: _GUIExtender_Restore() ; Parameters ....: None ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Melba23 ; Remarks .......: The GUI is not correctly restored after a MINIMIZE if a section is retracted. This function cycles ; the highest extendable section to reset the correct position of the controls ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Restore() ; Hide the GUI to prevent excess flicker GUISetState(@SW_HIDE, $aGUIExt_Section_Data[0][3]) ; Look for the highest extendable function For $i = UBound($aGUIExt_Section_Data) - 1 To 1 Step -1 If $aGUIExt_Section_Data[$i][2] <> 2 Then ; Depending on current state, cycle extendable section Switch $aGUIExt_Section_Data[$i][2] Case 0 _GUIExtender_Section_Extend($i) _GUIExtender_Section_Extend($i, False) Case 1 _GUIExtender_Section_Extend($i, False) _GUIExtender_Section_Extend($i) EndSwitch ExitLoop EndIf Next ; Show GUI again GUISetState(@SW_SHOW, $aGUIExt_Section_Data[0][3]) EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Section_Extend ; Description ...: Actions section extension or retraction programatically or via section action buttons ; Syntax.........: _GUIExtender_Section_Extend($iSection[, $fExtend = True[, $iFixed]]) ; Parameters ....: $iSection - Section to action - 0 = all moveable sections ; $fExtend - True = extend; False = retract ; $iFixed - 0 = Left/Top fixed ; 1 = Expand/contract centred ; 2 = Right/bottom fixed ; Any other value = Default as set by _GUIExtender_Init (default) ; Requirement(s).: v3.3 + ; Return values .: Success: Returns 1 ; Failure: Returns 0 and sets @error as follows: ; 1 = Invalid section ID (@extended: 1 = not in array, 2 = no _Start function used) ; 2 = Section already in required state ; 3 = GUI minimized ; Author ........: Melba23 ; Remarks .......: This function is called by the UDF when the section action buttons are clicked, ; but can also be called programatically ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Section_Extend($iSection, $fExtend = True, $iFixed = 9) Local $aPos, $iCID, $iDelta_GUI ; Check GUI is not minimized If BitAND(WinGetState($aGUIExt_Section_Data[0][3]), 16) Then Return SetError(3, 0, 0) ; Check if all sections to be actioned If $iSection = 0 Then _GUIExtender_Section_All_Extend($fExtend) Return 1 EndIf ; Check for invalid section (either outside array or no _Start function called) If $iSection > UBound($aGUIExt_Section_Data) - 1 Then Return SetError(1, 1, 0) If $aGUIExt_Section_Data[$iSection][1] = "" Then Return SetError(1, 2, 0) ; Check if state already matches demand If ($aGUIExt_Section_Data[$iSection][2] = 1 And $fExtend = True) Or ($aGUIExt_Section_Data[$iSection][2] = 0 And $fExtend = False) Then Return SetError(2, 0, 0) ; Check Move state Switch $iFixed Case 0, 1, 2 ; Do nothing Case Else ; Set default value $iFixed = $aGUIExt_Section_Data[0][4] EndSwitch ; Get current GUI size and set function calculation values Local $aGUIPos = WinGetPos($aGUIExt_Section_Data[0][3]) Local $iGUI_Fixed = $aGUIPos[2] Local $iGUI_Adjust = $aGUIPos[3] If $aGUIExt_Section_Data[0][1] Then ; If Horz orientation $iGUI_Fixed = $aGUIPos[3] $iGUI_Adjust = $aGUIPos[2] EndIf ; Determine action required If $fExtend Then ; Change button text GUICtrlSetData($aGUIExt_Section_Data[$iSection][5], $aGUIExt_Section_Data[$iSection][6]) ; Force action control state if needed If $aGUIExt_Section_Data[$iSection][8] = 1 Then GUICtrlSetState($aGUIExt_Section_Data[$iSection][5], 1) ; $GUI_CHECKED ; Set section state $aGUIExt_Section_Data[$iSection][2] = 1 ; Add size of section being extended $iGUI_Adjust += $aGUIExt_Section_Data[$iSection][1] Else ; Change button text GUICtrlSetData($aGUIExt_Section_Data[$iSection][5], $aGUIExt_Section_Data[$iSection][7]) ; Force action control state if needed If $aGUIExt_Section_Data[$iSection][8] = 1 Then GUICtrlSetState($aGUIExt_Section_Data[$iSection][5], 4) ; $GUI_UNCHECKED ; Set section state $aGUIExt_Section_Data[$iSection][2] = 0 ; Subtract size of section being hidden $iGUI_Adjust -= $aGUIExt_Section_Data[$iSection][1] EndIf ; Hide all sections to prevent ghosting when changing GUI size For $i = $aGUIExt_Section_Data[1][3] To $aGUIExt_Section_Data[$aGUIExt_Section_Data[0][0]][4] GUICtrlSetState($i, 32) ; $GUI_HIDE Next ; Resize and possibly move GUI If $aGUIExt_Section_Data[0][1] Then ; Depending on orientation ; Calculate change in GUI size $iDelta_GUI = $aGUIPos[2] - $iGUI_Adjust ; Check GUI fixed point Switch $iFixed Case 0 WinMove($aGUIExt_Section_Data[0][3], "", Default, Default, $iGUI_Adjust, $iGUI_Fixed) Case 1 WinMove($aGUIExt_Section_Data[0][3], "", $aGUIPos[0] + Int($iDelta_GUI / 2), Default, $iGUI_Adjust, $iGUI_Fixed) Case 2 WinMove($aGUIExt_Section_Data[0][3], "", $aGUIPos[0] + $iDelta_GUI, Default, $iGUI_Adjust, $iGUI_Fixed) EndSwitch Else $iDelta_GUI = $aGUIPos[3] - $iGUI_Adjust Switch $iFixed Case 0 WinMove($aGUIExt_Section_Data[0][3], "", Default, Default, $iGUI_Fixed, $iGUI_Adjust) Case 1 WinMove($aGUIExt_Section_Data[0][3], "", Default, $aGUIPos[1] + Int($iDelta_GUI / 2), $iGUI_Fixed, $iGUI_Adjust) Case 2 WinMove($aGUIExt_Section_Data[0][3], "", Default, $aGUIPos[1] + $iDelta_GUI, $iGUI_Fixed, $iGUI_Adjust) EndSwitch EndIf ; Initial section position = section 1 start Local $iNext_Coord = $aGUIExt_Section_Data[1][0] ; Move sections to required position Local $iAdjust_X = 0, $iAdjust_Y = 0 For $i = 1 To $aGUIExt_Section_Data[0][0] ; Is this section visible? If $aGUIExt_Section_Data[$i][2] > 0 Then ; Get current position of section anchor $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $aGUIExt_Section_Data[$i][3]) If $aGUIExt_Section_Data[0][1] Then ; Depending on orientation ; Determine required change in X position for section controls $iAdjust_X = $aPos[0] - $iNext_Coord ; Determine if controls need to be moved back into the GUI If $aPos[1] > $iGUI_Fixed Then $iAdjust_Y = $iGUI_Fixed Else ; Determine required change in Y position for section controls $iAdjust_Y = $aPos[1] - $iNext_Coord ; Determine if controls need to be moved back into the GUI If $aPos[0] > $iGUI_Fixed Then $iAdjust_X = $iGUI_Fixed EndIf ; For all controls in this section For $j = $aGUIExt_Section_Data[$i][3] To $aGUIExt_Section_Data[$i][4] $iCID = $j ; Adjust the position $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $iCID) If @error Then For $k = 1 To $aGUIExt_Obj_Data[0][0] If $aGUIExt_Obj_Data[$k][0] = $j Then $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $aGUIExt_Obj_Data[$k][1]) $iCID = $aGUIExt_Obj_Data[$k][1] ExitLoop EndIf Next ; If not an object see if the ControlID returns a handle (an internal tab will not) If $iCID = $j And GUICtrlGetHandle($j) = 0 Then $iCID = "Ignore" EndIf If $iCID = "Ignore" Then ContinueLoop ; Move control ControlMove($aGUIExt_Section_Data[0][3], "", $iCID, $aPos[0] - $iAdjust_X, $aPos[1] - $iAdjust_Y) ; And show the control GUICtrlSetState($j, 16) ; $GUI_SHOW Next ; Determine start position for next visible section $iNext_Coord += $aGUIExt_Section_Data[$i][1] Else ; Get current position of hidden section anchor $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $aGUIExt_Section_Data[$i][3]) ; Determine if controls in this section need to be moved outside GUI to prevent possible overlap If $aGUIExt_Section_Data[0][1] Then ; Depending on orientation If $aPos[1] < $iGUI_Fixed Then For $j = $aGUIExt_Section_Data[$i][3] To $aGUIExt_Section_Data[$i][4] $iCID = $j ; Adjust the position $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $j) If @error Then For $k = 1 To $aGUIExt_Obj_Data[0][0] If $aGUIExt_Obj_Data[$k][0] = $j Then $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $aGUIExt_Obj_Data[$k][1]) $iCID = $aGUIExt_Obj_Data[$k][1] ExitLoop EndIf Next ; If not an object see if the ControlID returns a handle (an internal tab will not) If $iCID = $j And GUICtrlGetHandle($j) = 0 Then $iCID = "Ignore" EndIf If $iCID = "Ignore" Then ContinueLoop ; Move control ControlMove($aGUIExt_Section_Data[0][3], "", $iCID, $aPos[0], $aPos[1] + $iGUI_Fixed) Next EndIf Else If $aPos[0] < $iGUI_Fixed Then For $j = $aGUIExt_Section_Data[$i][3] To $aGUIExt_Section_Data[$i][4] $iCID = $j ; Adjust the position $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $j) If @error Then For $k = 1 To $aGUIExt_Obj_Data[0][0] If $aGUIExt_Obj_Data[$k][0] = $j Then $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $aGUIExt_Obj_Data[$k][1]) $iCID = $aGUIExt_Obj_Data[$k][1] ExitLoop EndIf Next ; If not an object see if the ControlID returns a handle (an internal tab will not) If $iCID = $j And GUICtrlGetHandle($j) = 0 Then $iCID = "Ignore" EndIf If $iCID = "Ignore" Then ContinueLoop ; Move control ControlMove($aGUIExt_Section_Data[0][3], "", $iCID, $aPos[0] + $iGUI_Fixed, $aPos[1]) Next EndIf EndIf EndIf Next ; Set correct "all" state if there is a "all" control If $aGUIExt_Section_Data[0][5] <> 9999 Then Local $iAll_State = 0 ; Check if any sections extended For $i = 1 To $aGUIExt_Section_Data[0][0] If $aGUIExt_Section_Data[$i][2] = 1 Then $iAll_State = 1 ExitLoop EndIf Next ; Sync "all" sections control Switch $iAll_State ; None extended Case 0 ; Clear flag $aGUIExt_Section_Data[0][2] = 0 ; Set text GUICtrlSetData($aGUIExt_Section_Data[0][5], $aGUIExt_Section_Data[0][7]) ; Set state if required If $aGUIExt_Section_Data[0][8] = 1 Then GUICtrlSetState($aGUIExt_Section_Data[0][5], 4) ; $GUI_UNCHECKED ; Some extended Case Else ; Set flag $aGUIExt_Section_Data[0][2] = 1 ; Set text GUICtrlSetData($aGUIExt_Section_Data[0][5], $aGUIExt_Section_Data[0][6]) ; Set state if required If $aGUIExt_Section_Data[0][8] = 1 Then GUICtrlSetState($aGUIExt_Section_Data[0][5], 1) ; $GUI_CHECKED EndSwitch EndIf Return 1 EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Section_State ; Description ...: Returns current state of section ; Syntax.........: _GUIExtender_Section_State($iSection) ; Parameters ....: $iSection - Section to check ; Requirement(s).: v3.3 + ; Return values .: Success: State of section: 0 = Retracted, 1 = Extended, 2 = Static ; Failure: Invalid section returns -1 and sets @error to 1 ; Author ........: Melba23 ; Remarks .......: This allows additional GUI controls to reflect the section state ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Section_State($iSection) If $iSection > UBound($aGUIExt_Section_Data) - 1 Then Return SetError(1, 0, -1) Return $aGUIExt_Section_Data[$iSection][2] EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_UDFCtrlCheck ; Description ...: Hides/Shows and moves UDF-created controls when sections are extended/retracted ; Syntax.........: _GUIExtender_UDFCtrlCheck($hControl_Handle, $iSection, $iX, $iY) ; Parameters ....: $hControl_Handle - Handle of UDF-created control ; $iSection - Section within which control is situated ; $iX, $iY - Coords of control - relative to section not to GUI ; Requirement(s).: v3.3 + ; Return values .: Success: Returns 1 ; Failure: Returns 0 and sets @error as follows: ; 1 = Invalid handle ; 2 = Invalid section ; 3 = Invalid coordinate value ; Author ........: Melba23 ; Remarks .......: ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_UDFCtrlCheck($hCtrl_Handle, $iSection, $iX, $iY) Local $iCtrl_Coord ; Check parameters If Not IsHWnd($hCtrl_Handle) Or Not WinExists($hCtrl_Handle) Then Return SetError(1, 0, 0) If $iSection > UBound($aGUIExt_Section_Data) - 1 Then Return SetError(2, 0, 0) If Not IsInt($iX) Or Not IsInt($iY) Then Return SetError(3, 0, 0) ; Is the section visible Switch _GUIExtender_Section_State($iSection) Case 1 ; If section extended then show the control ControlShow($aGUIExt_Section_Data[0][3], "", $hCtrl_Handle) ; Now check required position within the GUI - set intial value depending on orientation If $aGUIExt_Section_Data[0][1] = 0 Then $iCtrl_Coord = $iY + $aGUIExt_Section_Data[1][0] ; Set to offset withint section Else $iCtrl_Coord = $iX + $aGUIExt_Section_Data[1][0] EndIf ; Check which earlier sections are extended For $i = 1 To $iSection - 1 If _GUIExtender_Section_State($i) Then ; Add add their size if extended $iCtrl_Coord += $aGUIExt_Section_Data[$i][1] EndIf Next ; Now move control depending on orientation If $aGUIExt_Section_Data[0][1] = 0 Then WinMove($hCtrl_Handle, "", $iX, $iCtrl_Coord) Else WinMove($hCtrl_Handle, "", $iCtrl_Coord, $iY) EndIf Case 0 ; If section retracted hide the control ControlHide($aGUIExt_Section_Data[0][3], "", $hCtrl_Handle) EndSwitch ; Clear flag for section action $fGUIExt_SectionAction = False Return 1 EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_ActionCheck ; Description ...: Indicates when sections are extended/retracted so that _GUIExtender_UDFCtrlCheck can be called ; Syntax.........: _GUIExtender_ActionCheck() ; Parameters ....: None ; Requirement(s).: v3.3 + ; Return values .: Returns True if sections have been actioned ; Returns False after _GUIExtender_UDFCtrlCheck has been used to adjust UDF-created controls ; Author ........: Melba23 ; Remarks .......: ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_ActionCheck() Return $fGUIExt_SectionAction EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Obj_Data ; Description ...: Store additional info on embedded objects ; Syntax.........: _GUIExtender_Obj_Data($iCID, $oObj) ; Parameters ....: $iCID - Returned ControlID from GUICtrlCreateObj ; $iObj - Object reference number from initial object creation ; Requirement(s).: v3.3 + ; Return values .: Success: Returns 1 ; Failure: Returns 0 and sets @error to 1 ; Author ........: Melba23, DllCall from trancexx ; Remarks .......: This allows embedded objects to be used in the UDF ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Obj_Data($iCID, $iObj) ; Increase array size $aGUIExt_Obj_Data[0][0] += 1 ReDim $aGUIExt_Obj_Data[$aGUIExt_Obj_Data[0][0] + 1][2] ; Store ControlID $aGUIExt_Obj_Data[$aGUIExt_Obj_Data[0][0]][0] = $iCID ; Determine and store object handle Local $aRet = DllCall("oleacc.dll", "int", "WindowFromAccessibleObject", "idispatch", $iObj, "hwnd*", 0) If @error Or $aRet[0] Then Return SetError(1, 0, 0) $aGUIExt_Obj_Data[$aGUIExt_Obj_Data[0][0]][1] = $aRet[2] Return 1 EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIExtender_Clear ; Description ...: Called on GUI deletion to clear the data array ready for a new GUI to be initialised ; Syntax.........: _GUIExtender_Clear() ; Requirement(s).: v3.3 + ; Author ........: Melba23 ; Remarks .......: If the data array is not cleared the array is corrupted during initialisation and the UDF crashes ; Example........: Yes ;===================================================================================================================== Func _GUIExtender_Clear() ; Reset data array Global $aGUIExt_Section_Data[1][9] = [[0, 0, 1, 0, "", 9999]] EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _GUIExtender_Section_All_Extend ; Description ...: Actions all moveable sections ; Author ........: Melba23 ; Modified.......: ; Remarks .......: This function is used internally by _GUIExtender_Section_Extend when all sections are to be moved ; =============================================================================================================================== Func _GUIExtender_Section_All_Extend($fExtend = True) ; Set required state for extendable sections Local $iState = 0 If $fExtend Then $iState = 1 For $i = 1 To $aGUIExt_Section_Data[0][0] ; Check if section requires change of state If $aGUIExt_Section_Data[$i][2] <> 2 And $aGUIExt_Section_Data[$i][2] = Not($iState) Then ; Extend/Shrink as required _GUIExtender_Section_Extend($i, $fExtend) ; Set section state to match $aGUIExt_Section_Data[$i][2] = $iState ; Set section action control state Switch $fExtend Case True GUICtrlSetData($aGUIExt_Section_Data[$i][5], $aGUIExt_Section_Data[$i][6]) If $aGUIExt_Section_Data[$i][8] = 1 Then GUICtrlSetState($aGUIExt_Section_Data[$i][5], 1) ; $GUI_CHECKED Case False GUICtrlSetData($aGUIExt_Section_Data[$i][5], $aGUIExt_Section_Data[$i][7]) If $aGUIExt_Section_Data[$i][8] = 1 Then GUICtrlSetState($aGUIExt_Section_Data[$i][5], 4) ; $GUI_UNCHECKED EndSwitch EndIf Next EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _GUIExtender_Section_Action_Event ; Description ...: Used to detect clicks on section action buttons in OnEvent mode ; Author ........: Melba23 ; Modified.......: ; Remarks .......: This function is called when section action button are clicked in OnEvent mode ; =============================================================================================================================== Func _GUIExtender_Section_Action_Event() _GUIExtender_Action(@GUI_CTRLID) EndFuncNew - For ease of downloading, here are all the above files in zip format:GUIExtender.zip As always, I welcome constructive comments and effusive compliments! M231 point
-
[SOLVED]Some Problems :S .. really need it
iNvokeMePlz reacted to Melba23 for a topic
iNvokeMePlz, Not a lot of improvement on the last effort - and as you can see from the responses so far you will not get a lot of help here if you continue in this vein. We want you to learn just like the people who will use your script and you will not if we do all the work for you. But here are a couple of pointers for you to show that we can help you - if you start to help yourself: - HotKeys: Use lower case letters when you set them - HotKeySet("!p", "TogglePause"). - Global variables: You need to check you use the correct spelling - you have Global $Pause and $Paused = Not $Paused. But as to "need splash image to show an image right-btm with hotkey function Such as "Press Alt + P To Pause" Designed By Photoshop and a Hotkey Ofc" - not a chance. And where is the code for this GUI with an edit control that you want to be "read-only"? Have you even looked at the Help file? I think not as the style you need is actually mentioned on the GUICtrlCreateEdit page. So over to you. Make an effort to code something yourself - or even explain your problem properly rather than just listing your requirements - and you will get help. Continue like you have so far and you will just get a stiff ignoring. Your choice - choose wisely. M231 point -
Minimize Program to Notification Bar
Solarlight27 reacted to guinness for a topic
Search Minime in the examples section.1 point -
Minimize Program to Notification Bar
Solarlight27 reacted to somdcomputerguy for a topic
Sorry, I didn't read your first post right, and I was thinking the @SW_HIDE flag would take care of this. If this is a program you've written in AutoIt, read about the TraySetIcon() function in the Help file.1 point -
Check that function exists
Mikeman27294 reacted to AlmarM for a topic
Then make sure you use the right function names inside the array from the beginning.1 point -
You could do something like this: Global $hWnd = GUICreate("", 300, 40) Global $hProgress = GUICtrlCreateProgress(10, 10, 280, 20) GUISetState() If (Not ShellExecute("setup.exe")) Then Exit MsgBox(48, "My application", "Could not launch setup.") EndIf GUICtrlSetData($hProgress, 20) Sleep (10000) ControlSend("My application", "", "[CLASS:TNewButton; INSTANCE:1]", "{ENTER}") GUICtrlSetData($hProgress, 40) Sleep (10000) ControlSend("My application", "", "[CLASS:TNewButton; INSTANCE:2]", "{ENTER}") GUICtrlSetData($hProgress, 60) Sleep (10000) WinActivate("My application - locales","") GUICtrlSetData($hProgress, 80) Sleep (10000) ControlSend("My application", "", "[CLASS:TNewButton; INSTANCE:2]", "{ENTER}") GUICtrlSetData($hProgress, 100) Sleep (10000) While 1 Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd1 point
-
Is this feasible for a script?
rds_correia reacted to saywell for a topic
Why not run a script on each local PC that copies all the files to your central computer? If you use the original script you could modify it to sort the files by camera before sending them. Or it could just send them all as they come, and work as previously with your script separating them out by camera and date on the central computer. William1 point -
nusaki, The speed might be a little slower, however it should not be enough to show a noticeable difference. My example works fine on my end. If it's not working on your end, then it's more than likely to do with the rest of the code in your script. I can't tell you whats wrong without seeing your code. It would be much easier to help you solve your problem if you would show your script. Don't forget to put your script in code tags [ autoit][ /autoi] (just delelte the spaces) Realm1 point
-
Hi, you know that SciTE includes a lot of abbreviations. I've made an management tool for abbrevs. All existing abbrevs will shown in an Listview, left side the abbrev, right side the abbrev code. What can you do: - Add own abbrevs - Edit abbrevs - Delete abbrevs - Click on an Item shows an GUI with AutoIt-code of this abbrev - Insert an new abbrev in the Input. By hitting button 'Add' you got an GUI to copy in or write AutoIt-code for this abbrev. The abbrev will saved by closing GUI. All your changes will integrated in abbrev-file: "@UserProfileDir & '\abbrev.properties'" and will saved for restore in "@UserProfileDir & '\abbrev.properties.my'". The keywords will integrated in keyword-file: "..\SciTE\properties\au3.keywords.abbreviations.properties" and will saved for restore in "@UserProfileDir & '\au3.keywords.my'". If you update or reinstall SciTE all your own abbrevs and changes are lost. Because that, i save all abbrevs and keywords in own files. So you can reset all with menu entry "Restore". Note: To take effect new or edited abbrevs you need an restart of SciTE. Edit: Thanks Jos for the reload function. Also there was an bug by Edit and Delete, now fixed. #include-once #include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GUIListView.au3> #include <GuiEdit.au3> Opt("GUIOnEventMode", 1) Global $ScitePath = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe", "") Global $KeyWordPath = StringReplace($ScitePath, "SciTE.exe", "properties\au3.keywords.abbreviations.properties") Global $MyKeyWordPath = @UserProfileDir & '\au3.keywords.my' Global $Abbr_Path = @UserProfileDir & '\abbrev.properties' Global $MyAbbrevPath = @UserProfileDir & '\abbrev.properties.my' If Not FileExists($MyAbbrevPath) Then Local $fh = FileOpen($MyAbbrevPath, 1) FileWriteLine($fh, '; >> My own abbrevs <<') FileClose($fh) EndIf Global $Start_STR = '#; -- Gui Variables --', $start = False, $edit = False Global $Last_STR = '#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#' Global $txt, $aTitel[2] = ['Code for new abbrev', 'Code edit'] Global $aLabel[2] = [ _ 'Please insert code for your abbrev. Indentation with <TAB> (inside edit with STRG+TAB).' & @LF & _ 'To set cursor position use pipe: | . Code will saved by closing window.', _ 'Edit here your code. Indentation with <TAB> (inside edit with STRG+TAB).' & @LF & _ 'To set cursor position use pipe: | . Code will saved by closing window.'] Global $aAbbrev _FileReadToArray($Abbr_Path, $aAbbrev) $Form1 = GUICreate("Abbrev Management [" & $Abbr_Path & ']', 800, 620, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $mnu = GUICtrlCreateMenu('Restore') $mnu_restore = GUICtrlCreateMenuItem('Restore own Abbrevs', $mnu) GUICtrlSetOnEvent(-1, '_Restore') $iSearch = GUICtrlCreateInput('', 15, 10, 90, 20) $bSearch = GUICtrlCreateButton('Search', 125, 10, 150, 20, $BS_DEFPUSHBUTTON) GUICtrlSetOnEvent(-1, '_Search') $bCreate = GUICtrlCreateButton('Add', 295, 10, 150, 20) GUICtrlSetOnEvent(-1, '_Create') $bEdit = GUICtrlCreateButton('Edit', 465, 10, 150, 20) GUICtrlSetOnEvent(-1, '_Edit') $bDelete = GUICtrlCreateButton('Delete', 635, 10, 150, 20) GUICtrlSetOnEvent(-1, '_Delete') $ListView1 = GUICtrlCreateListView("Abbrev|Code", 15, 40, 770, 545, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetOnEvent(-1, "ListView1Click") GUICtrlSetBkColor(-1, 0xFF9E00) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_ONECLICKACTIVATE) _GUICtrlListView_SetColumnWidth(-1, 0, 90) _GUICtrlListView_SetColumnWidth(-1, 1, $LVSCW_AUTOSIZE_USEHEADER) _LV_Fill() $Form2 = GUICreate('Abbrev - Code', 700, 400, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close") $Edit1 = GUICtrlCreateEdit('', 10, 10, 680, 380, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) GUICtrlSetBkColor(-1, 0x98FB98) $Form3 = GUICreate('Abbrev - New Code', 700, 400, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "Form3Close") $Label1 = GUICtrlCreateLabel('Please insert code for your abbrev. Indentation with <TAB> (inside edit with STRG+TAB).' & @LF & _ 'To set cursor position use pipe: | . Code will saved by closing window.' _ , 10, 5, 680, 30, $SS_SUNKEN + $SS_CENTER) GUICtrlSetBkColor(-1, 0x98FB98) $Edit2 = GUICtrlCreateEdit('', 10, 40, 680, 350, BitOR($WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_WANTRETURN)) GUICtrlSetBkColor(-1, 0x98FB98) GUISetState(@SW_SHOW, $Form1) GUIRegisterMsg($WM_NOTIFY, "MY_WM_COMMAND") While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc ;==>Form1Close Func Form2Close() GUISetState(@SW_HIDE, $Form2) GUICtrlSetData($Edit1, '') EndFunc ;==>Form2Close Func Form3Close() GUISetState(@SW_HIDE, $Form3) If $edit Then _WriteEditedAbbrev() Else _WriteNewAbbrev() EndIf EndFunc ;==>Form3Close Func _Search() $txt = GUICtrlRead($iSearch) If $txt = '' Then Return Local $indx = _LV_FindInSubItem($ListView1, $txt, 0) If $indx = -1 Then MsgBox(0, 'Search Abbrev', 'Abbrev: "' & $txt & '" not exists.') Else _GUICtrlListView_EnsureVisible($ListView1, $indx) _GUICtrlListView_SetItemSelected($ListView1, $indx) EndIf EndFunc ;==>_Search Func _Create() $txt = GUICtrlRead($iSearch) If $txt = '' Then Return MsgBox(16, 'Error', 'No abbrev inserted.') Local $indx = _LV_FindInSubItem($ListView1, $txt, 0) If $indx > -1 Then Return MsgBox(16, 'Error', 'Abbrev always exists.') $edit = False WinSetTitle($Form3, '', $aTitel[0]) GUICtrlSetData($Label1, $aLabel[0]) GUISetState(@SW_SHOW, $Form3) EndFunc ;==>_Create Func _Edit() $txt = GUICtrlRead($iSearch) If $txt = '' Then Return MsgBox(16, 'Error', 'No abbrev selected.') $edit = True WinSetTitle($Form3, '', $aTitel[1]) GUICtrlSetData($Label1, $aLabel[1]) GUICtrlSetData($Edit2, _Abbrev2Code(_GUICtrlListView_GetItemText($ListView1, _LV_FindInSubItem($ListView1, $txt, 0), 1))) GUISetState(@SW_SHOW, $Form3) EndFunc ;==>_Edit Func _Restore() Local $aMyAbbrev, $split_a, $split_f _FileReadToArray($MyAbbrevPath, $aMyAbbrev) For $i = 2 To UBound($aMyAbbrev) - 1 $start = False For $j = 1 To UBound($aAbbrev) - 1 If $aAbbrev[$j] = $Start_STR Then $start = True If (Not $start) Or (StringLeft($aAbbrev[$j], 1) = '#') Or ($aAbbrev[$j] = '') Then ContinueLoop $split_a = _SplitOnce($aAbbrev[$j]) If @error Then ContinueLoop $split_f = _SplitOnce($aMyAbbrev[$i]) If @error Then ContinueLoop If $split_a[0] = $split_f[0] Then ConsoleWrite($split_f[0] & @CRLF) $aAbbrev[$j] = $split_f[0] & '=' & $split_f[1] WinSetTitle($Form1, '', 'Restore Abbrev: ' & $split_f[0]) $aMyAbbrev[$i] = -1 ExitLoop EndIf Next Next For $i = 2 To UBound($aMyAbbrev) - 1 If $aMyAbbrev[$i] = -1 Then ContinueLoop $split_f = _SplitOnce($aMyAbbrev[$i]) WinSetTitle($Form1, '', 'Restore Abbrev: ' & $split_f[0]) Sleep(20) ReDim $aAbbrev[UBound($aAbbrev) + 1] $aAbbrev[UBound($aAbbrev) - 1] = $aMyAbbrev[$i] For $j = UBound($aAbbrev) - 1 To 1 Step -1 If $aAbbrev[$j] = $Last_STR Then ExitLoop Next _ArraySwap($aAbbrev[UBound($aAbbrev) - 1], $aAbbrev[$j]) Next FileMove($Abbr_Path, $Abbr_Path & '.BAK', 1) _FileWriteFromArray($Abbr_Path, $aAbbrev, 1) If FileExists($MyKeyWordPath) Then Local $aMyKeyWord _FileReadToArray($MyKeyWordPath, $aMyKeyWord) For $i = 1 To UBound($aMyKeyWord) - 1 WinSetTitle($Form1, '', 'Restore Keyword: ' & $aMyKeyWord[$i]) Sleep(20) _KeyWordSet($aMyKeyWord[$i], 1) Next EndIf _FileReadToArray($Abbr_Path, $aAbbrev) WinSetTitle($Form1, '', 'Restore') MsgBox(64, 'Restore', 'Restore finished.', 1.5) WinSetTitle($Form1, '', "Abbrev Management [" & $Abbr_Path & ']') _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) _LV_Fill() EndFunc ;==>_Restore Func _LV_FindInSubItem($hWnd, $2Find, $SubIndex) Local $out = -1 For $i = 0 To _GUICtrlListView_GetItemCount($hWnd) - 1 If _GUICtrlListView_GetItemText($hWnd, $i, $SubIndex) = $2Find Then $out = $i Next Return $out EndFunc ;==>_LV_FindInSubItem Func ListView1Click() Local $indx = _GUICtrlListView_GetHotItem($ListView1) GUICtrlSetData($iSearch, _GUICtrlListView_GetItemText($ListView1, $indx, 0)) GUICtrlSetData($Edit1, _Abbrev2Code(_GUICtrlListView_GetItemText($ListView1, $indx, 1))) GUISetState(@SW_SHOW, $Form2) EndFunc ;==>ListView1Click Func _LV_Fill() GUISetState(@SW_LOCK, $Form1) Local $k = 0 $start = False For $i = 1 To UBound($aAbbrev) - 1 If $aAbbrev[$i] = $Start_STR Then $start = True If (Not $start) Or (StringLeft($aAbbrev[$i], 1) = '#') Or ($aAbbrev[$i] = '') Then ContinueLoop $var = _SplitOnce($aAbbrev[$i]) If @error Then ContinueLoop GUICtrlCreateListViewItem('|', $ListView1) GUICtrlSetBkColor(-1, 0xFFF278) _GUICtrlListView_SetItemText($ListView1, $k, $var[0], 0) _GUICtrlListView_SetItemText($ListView1, $k, $var[1], 1) $k += 1 Next GUISetState(@SW_UNLOCK, $Form1) EndFunc ;==>_LV_Fill Func _SplitOnce($STRING, $DELIM = '=') If Not StringInStr($STRING, $DELIM) Then Return SetError(1, 0, 1) Local $out[2] Local $len = StringLen($STRING) Local $pos = StringInStr($STRING, $DELIM, 1, 1) $out[0] = StringLeft($STRING, $pos - 1) $out[1] = StringRight($STRING, $len - $pos) Return $out EndFunc ;==>_SplitOnce Func _Abbrev2Code($ABBREV) Local $out = '' $var = StringSplit($ABBREV, '\n', 1) For $i = 1 To UBound($var) - 1 If StringInStr($var[$i], '\t', 1) Then $var[$i] = StringReplace($var[$i], '\t', @TAB) If $i = UBound($var) - 1 Then $out &= $var[$i] Else $out &= $var[$i] & @CRLF EndIf Next Return $out EndFunc ;==>_Abbrev2Code Func _Code2Abbrev() Local $out = '', $count = _GUICtrlEdit_GetLineCount($Edit2), $line If @error Then Return SetError(1) For $i = 0 To $count - 1 $line = _GUICtrlEdit_GetLine($Edit2, $i) If StringInStr($line, @TAB, 1) Then $line = StringReplace($line, @TAB, '\t') If $i = $count - 1 Then $out &= $line Else $out &= $line & '\n' EndIf Next Return $out EndFunc ;==>_Code2Abbrev Func _WriteNewAbbrev() If GUICtrlRead($Edit2) = '' Then Return Local $abbr = _Code2Abbrev() Local $fh = FileOpen($MyAbbrevPath, 1) FileWriteLine($fh, $txt & '=' & $abbr) FileClose($fh) ReDim $aAbbrev[UBound($aAbbrev) + 1] $aAbbrev[UBound($aAbbrev) - 1] = $txt & '=' & $abbr For $i = UBound($aAbbrev) - 1 To 1 Step -1 If $aAbbrev[$i] = $Last_STR Then ExitLoop Next _ArraySwap($aAbbrev[UBound($aAbbrev) - 1], $aAbbrev[$i]) FileMove($Abbr_Path, $Abbr_Path & '.BAK', 1) _FileWriteFromArray($Abbr_Path, $aAbbrev, 1) _KeyWordSet($txt) $fh = FileOpen($MyKeyWordPath, 1) FileWrite($fh, $txt & @CRLF) FileClose($fh) _FileReadToArray($Abbr_Path, $aAbbrev) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) GUICtrlSetData($Edit2, '') $start = False $k = 0 _LV_Fill() Local $idx = _LV_FindInSubItem($ListView1, $txt, 0) _GUICtrlListView_EnsureVisible($ListView1, $idx) _GUICtrlListView_SetItemSelected($ListView1, $idx) Reload_Config() EndFunc ;==>_WriteNewAbbrev Func _WriteEditedAbbrev() If GUICtrlRead($Edit2) = '' Then Return Local $abbr = _Code2Abbrev() Local $fh = FileOpen($MyAbbrevPath, 0) Local $content = FileRead($fh) FileClose($fh) If Not StringRegExp($content, '\r\n' & $txt & '=') Then $fh = FileOpen($MyAbbrevPath, 1) FileWriteLine($fh, $txt & '=' & $abbr) FileClose($fh) Else $fh = FileOpen($MyAbbrevPath, 0) Local $line, $row = 2 While 1 $line = FileReadLine($fh, $row) If @error = -1 Then ExitLoop $split_f = _SplitOnce($line) If $txt = $split_f[0] Then ExitLoop $row += 1 WEnd FileClose($fh) _FileWriteToLine($MyAbbrevPath, $row, $txt & '=' & $abbr, 1) EndIf Local $line = _GetLine() - 1 Local $idx = _LV_FindInSubItem($ListView1, $txt, 0) $aAbbrev[$line] = $txt & '=' & $abbr _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) GUICtrlSetData($Edit2, '') $start = False $k = 0 _LV_Fill() _FileWriteToLine($Abbr_Path, $line, $txt & '=' & $abbr, 1) _GUICtrlListView_EnsureVisible($ListView1, $idx) _GUICtrlListView_SetItemSelected($ListView1, $idx) Reload_Config() EndFunc ;==>_WriteEditedAbbrev Func _Delete() $txt = GUICtrlRead($iSearch) If MsgBox(262180, 'Attention', 'You are sure that ' & @LF & '>> ' & $txt & ' <<' & @LF & ' should delete?') = 7 Then Return Local $idx = _GetLine() - 1 $aAbbrev[$idx] = '' _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) GUICtrlSetData($iSearch, '') $start = False $k = 0 _LV_Fill() _FileWriteToLine($Abbr_Path, $idx, '', 1) $fh = FileOpen($MyAbbrevPath, 0) Local $line, $row = 2 While 1 $line = FileReadLine($fh, $row) If @error = -1 Then ExitLoop $split_f = _SplitOnce($line) If @error Then ContinueLoop If $txt = $split_f[0] Then ExitLoop $row += 1 WEnd FileClose($fh) _FileWriteToLine($MyAbbrevPath, $row, '', 1) Local $keys = FileRead($KeyWordPath) $keys = StringReplace($keys, $txt & ' ', '', 1, 1) Local $fh = FileOpen($KeyWordPath, 2) FileWrite($fh, $keys) FileClose($fh) $keys = FileRead($MyKeyWordPath) $keys = StringReplace($keys, $txt & @CRLF, '', 1, 1) $fh = FileOpen($MyKeyWordPath, 2) FileWrite($fh, $keys) FileClose($fh) Reload_Config() EndFunc ;==>_Delete Func _GetLine() Local $var For $i = 1 To UBound($aAbbrev) - 1 $var = _SplitOnce($aAbbrev[$i], '=') If @error Then ContinueLoop If $var[0] = $txt Then Return $i + 1 Next EndFunc ;==>_GetLine Func _KeyWordSet($KEYWORD, $CHECK = 0) Local $txtZeile, $len If $CHECK Then Local $fh = FileOpen($KeyWordPath, 0) Local $read = FileRead($fh) FileClose($fh) If StringInStr($read, $KEYWORD & ' ', 1) Then Return EndIf $zeile = _FileCountLines($KeyWordPath) $txtZeile = FileReadLine($KeyWordPath, $zeile) $len = StringLen($txtZeile) + 4 If $len + StringLen($KEYWORD) > 100 Then _FileWriteToLine($KeyWordPath, $zeile, $txtZeile & "\" & @CRLF, 1) _FileWriteToLine($KeyWordPath, $zeile + 1, @TAB & $KEYWORD & " ", 1) Else _FileWriteToLine($KeyWordPath, $zeile, $txtZeile & $KEYWORD & " ", 1) EndIf EndFunc ;==>_KeyWordSet Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Switch $wParam Case $ListView1 Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $GUI_RUNDEFMSG If DllStructGetData($tagNMHDR, 3) = $NM_CLICK Then ListView1Click() EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND ; Thanks to Jos for following functions: Func Reload_Config() ;Send SciTE Director my GUI handle so it will report info back from SciTE SendSciTE_Command("reloadproperties:") EndFunc ;==>Reload_Config ; Send command to SciTE Func SendSciTE_Command($sCmd, $Wait_For_Return_Info = 0) Local $WM_COPYDATA = 74 Local $WM_GETTEXT = 0x000D Local $WM_GETTEXTLENGTH = 0x000E224 Local Const $SCI_GETLINE = 2153 Local $Scite_hwnd = WinGetHandle("DirectorExtension") ; Get SciTE DIrector Handle Local $My_Hwnd = GUICreate("AutoIt3-SciTE interface") ; Create GUI to receive SciTE info Local $My_Dec_Hwnd = Dec(StringTrimLeft($My_Hwnd, 2)) ; Convert my Gui Handle to decimal $sCmd = ":" & $My_Dec_Hwnd & ":" & $sCmd ; Add dec my gui handle to commandline to tell SciTE where to send the return info ConsoleWrite('SciTE Command --> ' & $sCmd & @LF) Local $CmdStruct = DllStructCreate('Char[' & StringLen($sCmd) + 1 & ']') DllStructSetData($CmdStruct, 1, $sCmd) Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr') DllStructSetData($COPYDATA, 1, 1) DllStructSetData($COPYDATA, 2, StringLen($sCmd) + 1) DllStructSetData($COPYDATA, 3, DllStructGetPtr($CmdStruct)) DllCall('User32.dll', 'None', 'SendMessage', 'HWnd', $Scite_hwnd, _ 'Int', $WM_COPYDATA, 'HWnd', $My_Hwnd, _ 'Ptr', DllStructGetPtr($COPYDATA)) GUIDelete($My_Hwnd) EndFunc ;==>SendSciTE_CommandAbbrevManagement.au31 point