Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/25/2014 in all areas

  1. Hi mates, well this is my first contribution. a simple UDF to use Virustotal API v2.0 The response return is not parsed|splitted. requires >WinHttp UDF Functions List: Update: Now a Only Function using a flags for respective mode. VT() Use respective flag($Type) VT(ByRef $aAPI, $Type, $sResource, $sAPIkey,$Comments="") flags($Type) $fReport = retrieve a scan report on a given file $fScan = submit a file for Scanning $fRescan = Rescan files in VirusTotal's file store $uReport = retrieve a scan report on a given URL $uScan = submit a URL for Scanning $Comment = Make a commnet on files and URLs Example: #include <Crypt.au3> #include "VT.au3" Example() Func Example() _Crypt_Startup() Local $sFilePath = @WindowsDir & "\Explorer.exe" Local $bHash = _Crypt_HashFile($sFilePath, $CALG_MD5) _Crypt_Shutdown() Local $hVirusTotal = VT_Open() Local $APIkey='Your API key' ConsoleWrite(VT($hVirusTotal, $fReport, '20c83c1c5d1289f177bc222d248dab261a62529b19352d7c0f965039168c0654',$APIkey) & @CRLF) ConsoleWrite(VT($hVirusTotal, $fScan, $sFilePath,$APIkey) & @CRLF) ConsoleWrite(VT($hVirusTotal, $fRescan, hex($bHash),$APIkey) & @CRLF) ConsoleWrite(VT($hVirusTotal, $uReport, "http://www.virustotal.com",$APIkey) & @CRLF) ConsoleWrite(VT($hVirusTotal, $uScan, "http://www.google.com",$APIkey) & @CRLF) ConsoleWrite(VT($hVirusTotal, $Comment, hex($bHash) ,$APIkey,"Hello Word | Hola Mundo") & @CRLF) VT_Close($hVirusTotal) ; EndFunc ;==>Example Saludos VT.au3
    1 point
  2. engine

    Registry UDFs

    SecurityEx.au3 Reg.au3 (Requires SecurityEx.au3 from above) Current functions: _RegLoadHive _RegRestoreHive _RegSaveHive _RegUnloadHive Features: These functions support remote computers. Notes: All functions are supposed to work on Windows 2000 and later HKCUReg.au3 (Requires Reg.au3 from above) Current functions: _HKCU_Delete _HKCU_EnumKey _HKCU_EnumVal _HKCU_Import _HKCU_Read _HKCU_Write Features: With the exception of _HKCU_Import, all functions support remote computers. It's possible to specify one user account or use all accounts on a computer at once. Both local accounts and domain like accounts are supported. Notes: _HKCU_Import is supposed to work on Windows XP and later. The rest are supposed to work on Windows 2000 and later. Reg.au3 requires SecurityEx.au3 on the same folder to work properly. HKCUReg.au3 requires Reg.au3 and SecurityEx.au3 on the same folder to work properly.
    1 point
  3. [NEW VERSION] - 19 May 14 Added: - 1. A new function _GUIFrame_ResizeState to indicate when frames have been resized and the resizing is complete. The idea is to help users who fill frames with elements which require heavy processing (e.g. GDI images) and where continually rewriting the content would cause severe slowdowns. The function is called in the script idle loop and returns an array of flags indicating that a resizing action is complete. - 2. A new parameter ($fShowWindow) in the _GUIFrame_Create function. A few people have found that the frames do not always appear on creation - particularly if the GUI does not have focus during this process. KaFu came up with a workaround, not approved by the AutoIt devs, using the API to confirm the frame display. Setting this new parameter to True uses the API call - use it at your own risk and peril! Fixed: A couple of minor bugs which no-one had noticed - and now never will. New code below and in the attached zip. Previous changes: Changelog.txt Before we start, my sincere thanks to Kip who wrote the first version of this UDF and who very kindly allowed me to build on it to produce this new version. Many GUIs are divided into frames, where you can drag a separator bar to alter the relative sizes of the elements displayed within the GUI. Think of an Explorer window where the folder list is on one side and the files in the selected folder on the other - or SciTE with its editing and Director areas. The GUIFrame UDF allows you to divide your own GUIs into 2 frames with a separator bar. - The frames can be full-frame or set to a user-defined position and size within the GUI. - The minimum size of each frame can be specified. - The separator bar can be horizontal or vertical and its size and initial position set. - The frames can resize as the main GUI resizes or can remain at their original position and size. - You can even divide existing frames into further frames until you run out of space. - x86 and x64 compatible. [New] The frames themselves are normal AutoIt GUIs. You can colour them and create controls within them just as you would in any other script - functions are provided for easy navigation between them (think of GUISwitch). Here is an example script to show the UDF working: #include <guiconstantsex.au3> #include <windowsconstants.au3> #include "GUIFrame.au3" Global $iSep_Pos $hGUI = GUICreate("GUI_Frame Example 1", 500, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() ; Create a 1st level frame $iFrame_A = _GUIFrame_Create($hGUI) _GUIFrame_SetMin($iFrame_A, 50, 100) _GUIFrame_Switch($iFrame_A, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_A, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetState(-1, $GUI_DISABLE) $hButton_1 = GUICtrlCreateButton("Pos Sep", 10, 10, 50, 30) ; Create a 2nd level frame $iFrame_B = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_A, 1), 1) GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_B, 1)) _GUIFrame_SetMin($iFrame_B, 100, 100) _GUIFrame_Switch($iFrame_B, 1) $hButton_2 = GUICtrlCreateButton("Pos Sep", 10, 10, 50, 30) ; Create a 3rd level frame $iFrame_C = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_B, 2)) _GUIFrame_Switch($iFrame_C, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_C, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xD0D000) ; Create a 4th level frame $iFrame_D = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_C, 1), 1) _GUIFrame_Switch($iFrame_D, 1) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_D, 1)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0x00FFFF) _GUIFrame_Switch($iFrame_D, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_D, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xFF00FF) ; Set resizing flag for all created frames _GUIFrame_ResizeSet(0) ; Create a non-resizable 2nd level frame $iFrame_E = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_B, 1), 0, 0, 5, 5, 55, 200, 100) _GUIFrame_Switch($iFrame_E, 1) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_E, 1)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xFF8000) _GUIFrame_Switch($iFrame_E, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_E, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xD0C0D0) ; Register the $WM_SIZE handler to permit resizing _GUIFrame_ResizeReg() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; The UDF does all the tidying up as you exit Exit Case $hButton_1 _GUIFrame_SetSepPos($iFrame_A, 300) $iSep_Pos = _GUIFrame_GetSepPos($iFrame_A) GUICtrlSetData($hButton_1, $iSep_Pos) Sleep(1000) GUICtrlSetData($hButton_1, "Sep Pos") Case $hButton_2 $iRet = _GUIFrame_SetSepPos($iFrame_B, 310) $iSep_Pos = _GUIFrame_GetSepPos($iFrame_ GUICtrlSetData($hButton_2, $iSep_Pos) Sleep(1000) GUICtrlSetData($hButton_2, "Sep Pos") EndSwitch WEnd The UDF uses the WM_SIZE message sent by the original GUIs to determine when to resize frames. If you want to register the same message within your script, you can still use this UDF. All you have to do is call a specific UDF function within your own message handler, as you can see here: #include <guiconstantsex.au3> #include <windowsconstants.au3> #include "GUIFrame.au3" Global $iSep_Pos $hGUI = GUICreate("GUI_Frame Example 2", 500, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() ; Register WM_SIZE to simulate the script requiring it GUIRegisterMsg($WM_SIZE, "_WM_SIZE") ; Create a 1st level frame $iFrame_A = _GUIFrame_Create($hGUI) _GUIFrame_SetMin($iFrame_A, 50, 100) _GUIFrame_Switch($iFrame_A, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_A, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetState(-1, $GUI_DISABLE) $hButton_1 = GUICtrlCreateButton("Sep Pos", 10, 10, 50, 30) ; Create a 2nd level frame $iFrame_B = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_A, 1), 1) GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_B, 1)) _GUIFrame_SetMin($iFrame_B, 100, 100) _GUIFrame_Switch($iFrame_B, 1) $hButton_2 = GUICtrlCreateButton("Pos Sep", 10, 10, 50, 30) ; Create a 3rd level frame $iFrame_C = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_B, 2)) _GUIFrame_Switch($iFrame_C, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_C, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xD0D000) ; Create a 4th level frame $iFrame_D = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_C, 1), 1) _GUIFrame_Switch($iFrame_D, 1) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_D, 1)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0x00FFFF) _GUIFrame_Switch($iFrame_D, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_D, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xFF00FF) ; Set resizing flag for all created frames _GUIFrame_ResizeSet(0) ; Create a non-resizable 2nd level frame $iFrame_E = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_B, 1), 0, 0, 5, 5, 55, 200, 100) _GUIFrame_Switch($iFrame_E, 1) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_E, 1)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xFF8000) _GUIFrame_Switch($iFrame_E, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_E, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xD0C0D0) ; DO NOT Register the $WM_SIZE handler to permit resizing as the message is already registered ;_GUIFrame_ResizeReg() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; The UDF does all the tidying up as you exit Exit Case $hButton_1 _GUIFrame_SetSepPos($iFrame_A, 300) $iSep_Pos = _GUIFrame_GetSepPos($iFrame_A) GUICtrlSetData($hButton_1, $iSep_Pos) Sleep(1000) GUICtrlSetData($hButton_1, "Sep Pos") Case $hButton_2 $iRet = _GUIFrame_SetSepPos($iFrame_B, 310) $iSep_Pos = _GUIFrame_GetSepPos($iFrame_ GUICtrlSetData($hButton_2, $iSep_Pos) Sleep(1000) GUICtrlSetData($hButton_2, "Sep Pos") EndSwitch WEnd ; This is the already registered WM_SIZE handler Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ; Just call the GUIFrame resizing function here - do NOT use the _GUIFrame_ResizeReg function in the script _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam) Return "GUI_RUNDEFMSG" EndFunc ;==>_WM_SIZE An example to show how to set absolute/relative minimum frame sizes and the different behaviours available on GUI resizing: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIFrame.au3" Global $iSep_Pos $hGUI = GUICreate("GUI_Frame Example 3", 500, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() ; Create a 1st level frame $iFrame_A = _GUIFrame_Create($hGUI, 1) _GUIFrame_SetMin($iFrame_A, 50, 125, True) ; This line sets the minima as absolute values <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;_GUIFrame_SetMin($iFrame_A, 50, 125) ; This line adjusts the minima to equivalent percentages on resizing <<<<<<<<<<<<<<<<<<<<< _GUIFrame_Switch($iFrame_A, 1) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_A, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateLabel("", 0, 0, 50, 50) GUICtrlSetBkColor(-1, 0x0000FF) GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetState(-1, $GUI_DISABLE) _GUIFrame_Switch($iFrame_A, 2) $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_A, 2)) GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetState(-1, $GUI_DISABLE) ; Set resizing flag for all created frames _GUIFrame_ResizeSet(0, 2) ; Adjust the second parameter to change the resizing behaviour <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Register the $WM_SIZE handler to permit resizing _GUIFrame_ResizeReg() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; The UDF does all the tidying up as you exit Exit EndSwitch WEnd [New] An example to show the resizing callback in action: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIFrame.au3" $hGUI = GUICreate("GUI_Frame Example #", 500, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() ; Create a 1st level frame $iFrame_A = _GUIFrame_Create($hGUI) _GUIFrame_SetMin($iFrame_A, 50, 100) ; Create a 2nd level frame $iFrame_B = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_A, 1), 1) GUISetBkColor(0xCCFFCC, _GUIFrame_GetHandle($iFrame_B, 1)) _GUIFrame_Switch($iFrame_B, 2) $cSetSize = GUICtrlCreateButton("Set Sep", 10, 10, 80, 30) ; Create another 2nd level frame $iFrame_C = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_A, 2), 1) GUISetBkColor(0xCCCCFF, _GUIFrame_GetHandle($iFrame_C, 2)) ; Set resizing flag for all created frames _GUIFrame_ResizeSet(0) ; Register the WM_SIZE handler _GUIFrame_ResizeReg() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; The UDF does all the tidying up as you exit Exit Case $cSetSize ; Set separator position _GUIFrame_SetSepPos($iFrame_B, 100) EndSwitch ; Get resize flags $aResize = _GUIFrame_ResizeState() ; If a frame has been resized then the [0] element = 1 If $aResize[0] Then _Check_Frames($aResize) WEnd Func _Check_Frames($aFlags) ; Check specific frame flags If $aFlags[$iFrame_B] And $aFlags[$iFrame_C] Then MsgBox(0, "Resize", "Green and blue areas have been resized") Elseif $aFlags[$iFrame_B] Then MsgBox(0, "Resize", "Green area has been resized") ElseIf $aFlags[$iFrame_C] Then MsgBox(0, "Resize", "Blue area has been resized") EndIf EndFunc [New] Here is the GUIFrame UDF itself: #include-once ; #INDEX# ============================================================================================================ ; Title .........: GUIFrame ; AutoIt Version : 3.3 + ; Language ......: English ; Description ...: Splits a GUI into slideable and resizable 2 part frames which can be further split if required ; Remarks .......: - The UDF uses OnAutoItExitRegister to call _GUIFrame_Exit to delete subclassed separator bars ; using the UDF created WndProc and to release the Callback on exit ; - The UDF can indicate when a specific fram has been resized ; - If the script already has a WM_SIZE message handler then do NOT use _GUIFrame_ResizeReg, ; but call the _GUIFrame_SIZE_Handler function from within the existing handler ; Author ........: Original UDF by Kip ; Modified ......; This version by Melba23 - using x64 compatible code drawn from Yashied's WinAPIEx library ; ==================================================================================================================== ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INCLUDES# ========================================================================================================= #include <WinAPI.au3> ; #GLOBAL VARIABLES# ================================================================================================= ; Array to hold handles for each frame set Global $aGF_HandleIndex[1][8] = [[0, 0, 0]] ; [0][0] = 0 ; Count of frames [0][1] = Move registered flag ; ; [n][0] = Parent GUI handle [n][4] = Original GUI handle ; [n][1] = First frame handle [n][5] = Indices of first frame internal frames ; [n][2] = Second frame handle [n][6] = Indices of second frame internal frames ; [n][3] = Separator bar handle [n][7] = Frame resize flag ; Array to hold sizing percentages for each frame set Global $aGF_SizingIndex[1][8] ; [n][0] = First frame min [n][2] = X coord [n][4] = Width [n][6] = Seperator percentage position ; [n][1] = Second frame min [n][3] = Y coord [n][5] = Height [n][7] = Resize type (0/1/2) ; Array to hold other settings for each frame set Global $aGF_SettingsIndex[1][3] ; [n][0] = Separator orientation (vert/horz = 0/1) ; [n][1] = Resizable frame flag (0/1) ; [n][2] = Separator size (default = 5) ; Array to hold WinProc handles for each separator Global $aGF_SepProcIndex[1][2] = [[0, 0]] ; Store registered Callback handle Global $hGF_RegCallBack = DllCallbackRegister("_GUIFrame_SepWndProc", "lresult", "hwnd;uint;wparam;lparam") $aGF_SepProcIndex[0][1] = DllCallbackGetPtr($hGF_RegCallBack) ; #ONAUTOITEXIT FUNCTIONS# =========================================================================================== OnAutoItExitRegister("_GUIFrame_Exit") ; #CURRENT# ========================================================================================================== ; _GUIFrame_Create: Splits a GUI into 2 frames ; _GUIFrame_SetMin: Sets minimum sizes for each frame ; _GUIFrame_ResizeSet: Sets resizing flag for all or specified frame sets ; _GUIFrame_GetHandle: Returns the handle of a frame element (required for further splitting) ; _GUIFrame_Switch: Sets a frame element as current GUI ; _GUIFrame_GetSepPos: Returns the current position of the separator ; _GUIFrame_SetSepPos: Moves the separator bar to adjust frame sizes ; _GUIFrame_ResizeState: Returns the resize state of the frames ; _GUIFrame_ResizeReg: Registers WM_SIZE message for resizing ; _GUIFrame_SIZE_Handler: WM_SIZE message handler to resize frames using _GUIFrame_Move ; ==================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; _GUIFrame_SepSubClass: Sets new WndProc for frame separator bar ; _GUIFrame_SepWndProc: New WndProc for frame separator bar ; _GUIFrame_SepPassMsg: Passes Msg to original frame WndProc for action ; _GUIFrame_Move: Moves and resizes frame elements and separator bars ; _GUIFrame_Exit: Deletes all subclassed separator bars to free UDF WndProc and frees registered callback handle ; ==================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_Create ; Description ...: Splits a GUI into 2 frames ; Syntax.........: _GUIFrame_Create($hWnd, $iSepOrient = 0, $iSepPos = 0, $iSepSize = 5, $iX = 0, $iY = 0, $iWidth = 0, $iHeight = 0, $iStyle = 0, $iExStyle = 0, $fShowWindow) ; Parameters ....: $hWnd - Handle of GUI to split ; $iSepOrient - Orientation of separator bar: 0 = Vertical (default), 1 = Horizontal ; $iSepPos - Required initial position of separator (default = centre of frame GUI) ; $iSepSize - Size of separator bar (default = 5, min = 3, max = 9) ; $iX - Left of frame area (default = 0) ; $iY - Top of frame area (default = 0) ; $iWidth - Width of frame area (default = full width) ; $iHeight - Height of frame area (default = full height) ; SiStyle - Required style value for frame elements ; SiExStyle - Required extended style value for frame elements ; $fShowWindow - True = Use API call to display frame if not displayed on start ; - False (default) - Do not use API call ; Requirement(s).: v3.3 + ; Return values .: Success: Returns index number of frame/separator set ; Failure: Returns 0 and sets @error as follows: ; 1 = Deprecated ; 2 = GUI creation failed ; 2 = Separator subclassing failed ; Author ........: Kip ; Modified ......: Melba23 ; Remarks .......: ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_Create($hWnd, $iSepOrient = 0, $iSepPos = 0, $iSepSize = 5, $iX = 0, $iY = 0, $iOrg_Width = 0, $iOrg_Height = 0, $iStyle = 0, $iExStyle = 0, $fShowWindow = False) Local $iSeperator_Pos, $hSeparator, $hFirstFrame, $hSecondFrame, $nSepPercent ; Set separator size Local $iSeparatorSize = 5 Switch $iSepSize Case 3 To 9 $iSeparatorSize = $iSepSize EndSwitch ; Set default sizing if no parameters set Local $iWidth = $iOrg_Width Local $iHeight = $iOrg_Height Local $aFullSize = WinGetClientSize($hWnd) If Not $iOrg_Width Then $iWidth = $aFullSize[0] If Not $iOrg_Height Then $iHeight = $aFullSize[1] ; Create parent GUI within client area Local $hParent = GUICreate("FrameParent", $iWidth, $iHeight, $iX, $iY, BitOR(0x40000000, $iStyle), $iExStyle, $hWnd) ; $WS_CHILD If $fShowWindow Then _WinAPI_ShowWindow($hParent, @SW_SHOW) ; Possible fix if frames do not display on start GUISetState(@SW_SHOW, $hParent) ; Confirm size of frame parent client area Local $aSize = WinGetClientSize($hParent) $iWidth = $aSize[0] $iHeight = $aSize[1] If $iSepOrient = 0 Then ; Set initial separator position $iSeperator_Pos = $iSepPos ; Adjust position if not within GUI or default set (=0) If $iSepPos > $iWidth Or $iSepPos < 1 Then $iSeperator_Pos = Round(($iWidth / 2) - ($iSeparatorSize / 2)) EndIf ; Create separator bar and force cursor change over separator $hSeparator = GUICreate("", $iSeparatorSize, $iHeight, $iSeperator_Pos, 0, 0x40000000, -1, $hParent) ;$WS_CHILD GUICtrlCreateLabel("", 0, 0, $iSeparatorSize, $iHeight, -1, 0x00000001) ; $WS_EX_DLGMODALFRAME GUICtrlSetCursor(-1, 13) GUISetState(@SW_SHOW, $hSeparator) ; Create the sizable frames $hFirstFrame = GUICreate("", $iSeperator_Pos, $iHeight, 0, 0, 0x40000000, -1, $hParent) ;$WS_CHILD GUISetState(@SW_SHOW, $hFirstFrame) $hSecondFrame = GUICreate("", $iWidth - ($iSeperator_Pos + $iSeparatorSize), $iHeight, $iSeperator_Pos + $iSeparatorSize, 0, 0x40000000, -1, $hParent) ;$WS_CHILD GUISetState(@SW_SHOW, $hSecondFrame) ; Set seperator position percentage $nSepPercent = $iSeperator_Pos / $iWidth Else $iSeperator_Pos = $iSepPos If $iSepPos > $iHeight Or $iSepPos < 1 Then $iSeperator_Pos = Round(($iHeight / 2) - ($iSeparatorSize / 2)) EndIf $hSeparator = GUICreate("", $iWidth, $iSeparatorSize, 0, $iSeperator_Pos, 0x40000000, -1, $hParent) ;$WS_CHILD GUICtrlCreateLabel("", 0, 0, $iWidth, $iSeparatorSize, -1, 0x01) ; $WS_EX_DLGMODALFRAME GUICtrlSetCursor(-1, 11) GUISetState(@SW_SHOW, $hSeparator) $hFirstFrame = GUICreate("", $iWidth, $iSeperator_Pos, 0, 0, 0x40000000, -1, $hParent) ;$WS_CHILD GUISetState(@SW_SHOW, $hFirstFrame) $hSecondFrame = GUICreate("", $iWidth, $iHeight - ($iSeperator_Pos + $iSeparatorSize), 0, $iSeperator_Pos + $iSeparatorSize, 0x40000000, -1, $hParent) ;$WS_CHILD GUISetState(@SW_SHOW, $hSecondFrame) $nSepPercent = $iSeperator_Pos / $iHeight EndIf ; Check for error creating GUIs If $hParent = 0 Or $hSeparator = 0 Or $hFirstFrame = 0 Or $hSecondFrame = 0 Then ; Delete all GUIs and return error GUIDelete($hParent) GUIDelete($hSeparator) GUIDelete($hFirstFrame) GUIDelete($hSecondFrame) Return SetError(2, 0, 0) EndIf ; Subclass the separator If _GUIFrame_SepSubClass($hSeparator) = 0 Then ; If Subclassing failed then delete all GUIs and return error GUIDelete($hParent) GUIDelete($hSeparator) GUIDelete($hFirstFrame) GUIDelete($hSecondFrame) Return SetError(3, 0, 0) EndIf ; Create new lines in the storage arrays for this frame set Local $iIndex = $aGF_HandleIndex[0][0] + 1 ReDim $aGF_HandleIndex[$iIndex + 1][8] ReDim $aGF_SizingIndex[$iIndex + 1][8] ReDim $aGF_SettingsIndex[$iIndex + 1][3] ; Store this frame set handles/variables/defaults in the new lines $aGF_HandleIndex[0][0] = $iIndex $aGF_HandleIndex[$iIndex][0] = $hParent $aGF_HandleIndex[$iIndex][1] = $hFirstFrame $aGF_HandleIndex[$iIndex][2] = $hSecondFrame $aGF_HandleIndex[$iIndex][3] = $hSeparator $aGF_HandleIndex[$iIndex][4] = $hWnd $aGF_HandleIndex[$iIndex][5] = 0 $aGF_HandleIndex[$iIndex][6] = 0 $aGF_SizingIndex[$iIndex][0] = 0 $aGF_SizingIndex[$iIndex][1] = 0 $aGF_SizingIndex[$iIndex][6] = $nSepPercent $aGF_SettingsIndex[$iIndex][0] = $iSepOrient $aGF_SettingsIndex[$iIndex][1] = 0 $aGF_SettingsIndex[$iIndex][2] = $iSeparatorSize ; Store this frame index in parent line if parent is an existing frame For $i = 1 To $aGF_HandleIndex[0][0] - 1 If $aGF_HandleIndex[$i][1] = $hWnd Then If $aGF_HandleIndex[$i][5] = 0 Then $aGF_HandleIndex[$i][5] = $iIndex Else $aGF_HandleIndex[$i][5] &= "|" & $iIndex EndIf ExitLoop EndIf If $aGF_HandleIndex[$i][2] = $hWnd Then If $aGF_HandleIndex[$i][6] = 0 Then $aGF_HandleIndex[$i][6] = $iIndex Else $aGF_HandleIndex[$i][6] &= "|" & $iIndex EndIf ExitLoop EndIf Next ; Store coordinate and size fractions If $iX Then $aGF_SizingIndex[$iIndex][2] = $iX / $aFullSize[0] Else $aGF_SizingIndex[$iIndex][2] = 0 EndIf If $iY Then $aGF_SizingIndex[$iIndex][3] = $iY / $aFullSize[1] Else $aGF_SizingIndex[$iIndex][3] = 0 EndIf If $iOrg_Width Then $aGF_SizingIndex[$iIndex][4] = $iOrg_Width / $aFullSize[0] Else $aGF_SizingIndex[$iIndex][4] = 1 EndIf If $iOrg_Height Then $aGF_SizingIndex[$iIndex][5] = $iOrg_Height / $aFullSize[1] Else $aGF_SizingIndex[$iIndex][5] = 1 EndIf ; Switch back to main GUI GUISwitch($hWnd) ; Return the index for this frame Return $iIndex EndFunc ;==>_GUIFrame_Create ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_SetMin ; Description ...: Sets minimum sizes for frames ; Syntax.........: _GUIFrame_SetMin($iFrame, $iFirstMin = 0, $iSecondMin = 0, $fAbsolute = False) ; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create ; $iFirstMin - Min size of first (left/top) frame - max half size ; $iSecondMin - Min Size of second (right/bottom) frame - max half size ; $fAbsolute - True = Minima fixed when GUI resized ; - False = Minima adjusted on resize to equivalent percentage of new GUI size (default) ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Melba23 based on some original code by Kip ; Modified ......: ; Remarks .......: If the frame is resized, these minima are adjusted accordingly unless $fAbsolute is set ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_SetMin($iFrame, $iFirstMin = 0, $iSecondMin = 0, $fAbsolute = False) ; Check for valid frame index If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return 0 ; Get size of parent Local $aSize = WinGetClientSize($aGF_HandleIndex[$iFrame][0]) ; Now check orientation and determine Local $iMax, $iFullSize If $aGF_SettingsIndex[$iFrame][0] = 0 Then $iMax = Floor(($aSize[0] / 2) - $aGF_SettingsIndex[$iFrame][2]) $iFullSize = $aSize[0] Else $iMax = Floor(($aSize[1] / 2) - $aGF_SettingsIndex[$iFrame][2]) $iFullSize = $aSize[1] EndIf ; Set minimums If $fAbsolute Then $aGF_SizingIndex[$iFrame][0] = Int($iFirstMin) $aGF_SizingIndex[$iFrame][1] = Int($iSecondMin) Else If $iFirstMin > $iMax Then $aGF_SizingIndex[$iFrame][0] = $iMax / $iFullSize Else $aGF_SizingIndex[$iFrame][0] = $iFirstMin / $iFullSize EndIf If $iSecondMin > $iMax Then $aGF_SizingIndex[$iFrame][1] = $iMax / $iFullSize Else $aGF_SizingIndex[$iFrame][1] = $iSecondMin / $iFullSize EndIf EndIf EndFunc ;==>_GUIFrame_SetMin ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_ResizeSet ; Description ...: Sets resizing flag for frames ; Syntax.........: _GUIFrame_ResizeSet($iFrame = 0[, $iType = 0]) ; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create (Default - 0 = all existing frames) ; $iType - Separator behaviour on GUI resize ; 0 = Frames retain percentage size (default) ; 1 = Top/left frame fixed size ; 2 = Bottom/right frame fixed size ; Requirement(s).: v3.3 + ; Return values .: Success: 2 - All existing frame flags set ; 1 - Specified flag set ; Failure: 0 with @error set to: ; 1 - Invalid frame specified ; 2 - Invalid type parameter ; Author ........: Melba23 ; Modified ......: ; Remarks .......: ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_ResizeSet($iFrame = 0, $iType = 0) Switch $iType Case 0, 1, 2 ; Valid Case Else Return SetError(2, 0, 0) EndSwitch Switch $iFrame Case 0 ; Set all frames For $i = 1 To $aGF_HandleIndex[0][0] $aGF_SettingsIndex[$i][1] = 1 $aGF_SizingIndex[$i][7] = $iType Next Return 2 Case 1 To $aGF_HandleIndex[0][0] ; Only valid frames accepted $aGF_SettingsIndex[$iFrame][1] = 1 $aGF_SizingIndex[$iFrame][7] = $iType Return 1 Case Else ; Error Return SetError(1, 0, 0) EndSwitch EndFunc ;==>_GUIFrame_ResizeSet ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_GetHandle ; Description ...: Returns the handle of a frame element (required for further splitting) ; Syntax.........: _GUIFrame_GetHandle($iFrame, $iElement) ; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create ; $iElement - 1 = first (left/top) frame, 2 = second (right/bottom) frame ; Requirement(s).: v3.3 + ; Return values .: Success: Handle of frame ; Failure: 0 with @error set as follows ; 1 - Invalid frame specified ; 2 - Invalid element specified ; Author ........: Kip ; Modified ......: Melba23 ; Remarks .......: _GUIFrame_Create requires a GUI handle as a parameter ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_GetHandle($iFrame, $iElement) ; Check valid frame index and element Switch $iFrame Case 1 To $aGF_HandleIndex[0][0] Switch $iElement Case 1, 2 ; Return handle Return $aGF_HandleIndex[$iFrame][$iElement] EndSwitch Return SetError(2, 0, 0) EndSwitch Return SetError(1, 0, 0) EndFunc ;==>_GUIFrame_GetHandle ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_Switch ; Description ...: Sets a frame element as current GUI ; Syntax.........: _GUIFrame_Switch($iFrame, $iElement) ; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create ; $iElement - 1 = first (left/top) frame, 2 = second (right/bottom) frame ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Kip ; Modified ......: Melba23 ; Remarks .......: Subsequent controls are created in the specified frame element ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_Switch($iFrame, $iElement) ; Check valid frame index and element Switch $iFrame Case 1 To $aGF_HandleIndex[0][0] Switch $iElement Case 1, 2 ; Switch to specified element Return GUISwitch($aGF_HandleIndex[$iFrame][$iElement]) EndSwitch Return SetError(2, 0, 0) EndSwitch Return SetError(1, 0, 0) EndFunc ;==>_GUIFrame_Switch ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_GetSepPos() ; Description ...: Returns the current position of the separator ; Syntax.........: _GUIFrame_GetSepPos($iFrame) ; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create ; Requirement(s).: v3.3 + ; Return values .: Success: Position of separator ; Failure: -1 = Invalid frame specified ; Author ........: Melba23 ; Remarks .......: This value can be stored and used as the initial separator position parameter in _GUIFrame_Create ; to restore exit position on restart ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_GetSepPos($iFrame) Local $iSepPos ; Check for valid frame index If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return -1 ; Get position of first frame Local $aFrame_Pos = WinGetPos($aGF_HandleIndex[$iFrame][1]) ; Get position of separator Local $aSep_Pos = WinGetPos($aGF_HandleIndex[$iFrame][3]) ; Check on separator orientation If $aGF_SettingsIndex[$iFrame][0] Then $iSepPos = $aSep_Pos[1] - $aFrame_Pos[1] Else $iSepPos = $aSep_Pos[0] - $aFrame_Pos[0] EndIf Return $iSepPos EndFunc ;==>_GUIFrame_GetSepPos ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_SetSepPos() ; Description ...: Moves the separator bar to adjust frame sizes ; Syntax.........: _GUIFrame_SetSepPos($iFrame, $iSepPos) ; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create ; $iSepos - Position of separator bar within frame ; Requirement(s).: v3.3 + ; Return values .: Success: 1 ; Failure: 0 with @error set as follows ; 1 - Invalid frame specified ; 2 - Invalid separator position (outside frame) ; 3 - Invalid separator position (below frame minimum size) ; Author ........: Melba23 ; Remarks .......: This value can be stored and used as the initial separator position parameter in _GUIFrame_Create ; to restore exit position on restart ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_SetSepPos($iFrame, $iSepPos) Local $iFirstMin, $iSecondMin ; Check for valid frame index If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return SetError(1, 0, 0) ; Check separator actually needs to move If $iSepPos = _GUIFrame_GetSepPos($iFrame) Then Return 1 ; Get frame GUI size Local $aWinPos = WinGetPos($aGF_HandleIndex[$iFrame][0]) ; Depending on separator orientation If $aGF_SettingsIndex[$iFrame][0] Then ; Check sep position is valid If $iSepPos < 0 Or $iSepPos > $aWinPos[3] Then Return SetError(2, 0, 0) ; Determine minima for frames $iFirstMin = $aWinPos[3] * $aGF_SizingIndex[$iFrame][0] $iSecondMin = ($aWinPos[3] * (1 - $aGF_SizingIndex[$iFrame][1])) - $aGF_SettingsIndex[$iFrame][2] ; Check required value is valid If $iSepPos < $iFirstMin Or $iSepPos > $iSecondMin Then Return SetError(3, 0, 0) ; Move frames and seperator WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $aWinPos[2], $iSepPos) WinMove($aGF_HandleIndex[$iFrame][2], "", 0, $iSepPos + $aGF_SettingsIndex[$iFrame][2], $aWinPos[2], $aWinPos[3] - ($iSepPos + $aGF_SettingsIndex[$iFrame][2])) WinMove($aGF_HandleIndex[$iFrame][3], "", 0, $iSepPos, $aWinPos[2], $aGF_SettingsIndex[$iFrame][2]) ; Store new separator position $aGF_SizingIndex[$iFrame][6] = $iSepPos / $aWinPos[3] Else If $iSepPos < 0 Or $iSepPos > $aWinPos[2] Then Return SetError(2, 0, 0) $iFirstMin = $aWinPos[2] * $aGF_SizingIndex[$iFrame][0] $iSecondMin = ($aWinPos[2] * (1 - $aGF_SizingIndex[$iFrame][1])) - $aGF_SettingsIndex[$iFrame][2] If $iSepPos < $iFirstMin Or $iSepPos > $iSecondMin Then Return SetError(3, 0, 0) WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iSepPos, $aWinPos[3]) WinMove($aGF_HandleIndex[$iFrame][2], "", $iSepPos + $aGF_SettingsIndex[$iFrame][2], 0, $aWinPos[2] - ($iSepPos + $aGF_SettingsIndex[$iFrame][2]), $aWinPos[3]) WinMove($aGF_HandleIndex[$iFrame][3], "", $iSepPos, 0, $aGF_SettingsIndex[$iFrame][2], $aWinPos[3]) $aGF_SizingIndex[$iFrame][6] = $iSepPos / $aWinPos[2] EndIf ; Set callback $aGF_HandleIndex[$iFrame][7] = 1 Return 1 EndFunc ;==>_GUIFrame_SetSepPos ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_ResizeState ; Description ...: Returns the resize state of the frames ; Syntax.........: _GUIFrame_ResizeState() ; Parameters ....: None ; Requirement(s).: v3.3 + ; Return values .: Success: Array of frame resize flags ; Author ........: Melba23 ; Remarks .......: An array is always returned - the user must query the flag for the relevant frame to detect resizing ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_ResizeState() ; Create array to hold resize flags Local $aRet[$aGF_HandleIndex[0][0] + 1] = [0] For $i = 1 To $aGF_HandleIndex[0][0] ; Read state $aRet[$i] = $aGF_HandleIndex[$i][7] ; Set flag is resized If $aGF_HandleIndex[$i][7] Then $aRet[0] = 1 ; Clear resized flag $aGF_HandleIndex[$i][7] = 0 Next ; Return array of flags Return $aRet EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_ResizeReg ; Description ...: Registers WM_SIZE message for resizing ; Syntax.........: _GUIFrame_ResizeReg() ; Parameters ....: None ; Requirement(s).: v3.3 + ; Return values .: Success: 1 - Message handler registered ; Failure: 0 with @error set to 1 - Message handler already registered ; Author ........: Melba23 ; Modified ......: ; Remarks .......: ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_ResizeReg() ; Register the WM_SIZE message If $aGF_HandleIndex[0][1] = 0 Then Local $iRet = GUIRegisterMsg(0x05, "_GUIFrame_SIZE_Handler") ; $WM_SIZE If $iRet Then $aGF_HandleIndex[0][1] = 1 Return 1 EndIf EndIf Return SetError(1, 0, 0) EndFunc ;==>_GUIFrame_ResizeReg ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIFrame_SIZE_Handler ; Description ...: Used to resize frames when resizing of holding GUI occurs ; Syntax.........: _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam) ; Parameters ....: None ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Melba23 ; Modified ......: ; Remarks .......: If the script already has a WM_SIZE handler, then just call this function from within it ; and do NOT use the _GUIFrame_ResizeReg function ; Example........: Yes ;===================================================================================================================== Func _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iIndex ; Get index of base frame GUI For $iIndex = 1 To $aGF_HandleIndex[0][0] If $aGF_HandleIndex[$iIndex][4] = $hWnd Then ExitLoop Next ; If handle not found If $iIndex > $aGF_HandleIndex[0][0] Then Return "GUI_RUNDEFMSG" ; Check if we should resize this set If $aGF_SettingsIndex[$iIndex][1] = 1 Then ; Get new base GUI size Local $aSize = WinGetClientSize($hWnd) ; Resize frames _GUIFrame_Move($iIndex, $aSize[0] * $aGF_SizingIndex[$iIndex][2], $aSize[1] * $aGF_SizingIndex[$iIndex][3], $aSize[0] * $aGF_SizingIndex[$iIndex][4], $aSize[1] * $aGF_SizingIndex[$iIndex][5]) ; Adjust any resizeable internal frames - array elements are adjacent for ease of coding For $i = 0 To 1 ; Adjust internal frames of first/second frame if any exist If $aGF_HandleIndex[$iIndex][5 + $i] <> 0 Then ; StringSplit the element content on "|" Local $aInternal = StringSplit($aGF_HandleIndex[$iIndex][5 + $i], "|") ; Then loop though the Number(values) found For $j = 1 To $aInternal[0] Local $iIntIndex = Number($aInternal[$j]) ; Check if internal frame is resizable If $aGF_SettingsIndex[$iIntIndex][1] = 1 Then ; And change if so _GUIFrame_SIZE_Handler($aGF_HandleIndex[$iIntIndex][4], $iMsg, $wParam, $lParam) EndIf Next EndIf Next ; Set callback $aGF_HandleIndex[$iIndex][7] = 1 EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>_GUIFrame_SIZE_Handler ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _GUIFrame_SepSubClass ; Description ...: Sets new WndProc for frame separator bar ; Author ........: Kip ; Modified.......: Melba23, using SetWindowLongPtr x64 compatible code drawn from Yashied's WinAPIEx library ; Remarks .......: This function is used internally by _GUIFrame_Create ; =============================================================================================================================== Func _GUIFrame_SepSubClass($hWnd) Local $aRet ; Check separator has not already been used For $i = 1 To $aGF_SepProcIndex[0][0] If $aGF_SepProcIndex[$i][0] = $hWnd Then Return 0 Next ; Store current WinProc handle in new array line Local $iIndex = $aGF_SepProcIndex[0][0] + 1 ReDim $aGF_SepProcIndex[$iIndex + 1][2] $aGF_SepProcIndex[0][0] = $iIndex $aGF_SepProcIndex[$iIndex][0] = $hWnd ; Subclass separator bar If @AutoItX64 Then $aRet = DllCall('user32.dll', 'long_ptr', 'SetWindowLongPtrW', 'hwnd', $hWnd, 'int', -4, 'long_ptr', $aGF_SepProcIndex[0][1]) ; $GWL_WNDPROC Else $aRet = DllCall('user32.dll', 'long', 'SetWindowLongW', 'hwnd', $hWnd, 'int', -4, 'long', $aGF_SepProcIndex[0][1]) ; $GWL_WNDPROC EndIf ; Check for subclassing error If @error Or $aRet[0] = 0 Then Return 0 ; Return success $aGF_SepProcIndex[$iIndex][1] = $aRet[0] Return 1 EndFunc ;==>_GUIFrame_SepSubClass ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _GUIFrame_SepWndProc ; Description ...: New WndProc for frame separator bar ; Author ........: Kip ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _GUIFrame_SepSubClass ; =============================================================================================================================== Func _GUIFrame_SepWndProc($hWnd, $iMsg, $wParam, $lParam) Local $iSubtract, $fAbsolute = False If $iMsg = 0x0111 Then ; WM_COMMAND ; Check if hWnd is a Separator bar For $iIndex = 1 To $aGF_HandleIndex[0][0] If $aGF_HandleIndex[$iIndex][3] = $hWnd Then ExitLoop Next ; If not then pass message on to org WndProc If $iIndex > $aGF_HandleIndex[0][0] Then Return _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam) ; Extract values from array Local $hParent = $aGF_HandleIndex[$iIndex][0] Local $hFirstFrame = $aGF_HandleIndex[$iIndex][1] Local $hSecondFrame = $aGF_HandleIndex[$iIndex][2] Local $hSeparator = $aGF_HandleIndex[$iIndex][3] Local $iFirstMin = $aGF_SizingIndex[$iIndex][0] Local $iSecondMin = $aGF_SizingIndex[$iIndex][1] If $iFirstMin > 1 Or $iSecondMin > 1 Then $fAbsolute = True EndIf Local $iSeparatorSize = $aGF_SettingsIndex[$iIndex][2] ; Get client size of the parent Local $aClientSize = WinGetClientSize($hParent) Local $iWidth = $aClientSize[0] Local $iHeight = $aClientSize[1] ; Get cursor info for the Separator Local $aCInfo = GUIGetCursorInfo($hSeparator) ; Depending on separator orientation If $aGF_SettingsIndex[$iIndex][0] = 0 Then ; Get Separator X-coord $iSubtract = $aCInfo[0] Do ; Get parent X-coord $aCInfo = GUIGetCursorInfo($hParent) Local $iCursorX = $aCInfo[0] ; Determine width of first frame Local $iFirstWidth = $iCursorX - $iSubtract ; And ensure it is at least minimum If $fAbsolute Then If $iFirstWidth < $iFirstMin Then $iFirstWidth = $iFirstMin If $iWidth - $iFirstWidth - $iSeparatorSize < $iSecondMin Then $iFirstWidth = $iWidth - $iSeparatorSize - $iSecondMin Else If $iFirstWidth < $iWidth * $iFirstMin Then $iFirstWidth = $iWidth * $iFirstMin If $iWidth - ($iFirstWidth + $iSeparatorSize) < $iWidth * $iSecondMin Then $iFirstWidth = $iWidth - ($iWidth * $iSecondMin) - $iSeparatorSize EndIf ; Move the GUIs to the correct places WinMove($hFirstFrame, "", 0, 0, $iFirstWidth, $iHeight) WinMove($hSecondFrame, "", $iFirstWidth + $iSeparatorSize, 0, $iWidth - ($iFirstWidth + $iSeparatorSize), $iHeight) WinMove($hSeparator, "", $iFirstWidth, 0, $iSeparatorSize, $iHeight) ; Do until the mouse button is released Until Not _WinAPI_GetAsyncKeyState(0x01) ; Store current separator percentage position $aGF_SizingIndex[$iIndex][6] = $iFirstWidth / $iWidth ElseIf $aGF_SettingsIndex[$iIndex][0] = 1 Then $iSubtract = $aCInfo[1] Do $aCInfo = GUIGetCursorInfo($hParent) Local $iCursorY = $aCInfo[1] Local $iFirstHeight = $iCursorY - $iSubtract If $fAbsolute Then If $iFirstHeight < $iFirstMin Then $iFirstHeight = $iFirstMin If $iHeight - $iFirstHeight - $iSeparatorSize < $iSecondMin Then $iFirstHeight = $iHeight - $iSeparatorSize - $iSecondMin Else If $iFirstHeight < $iHeight * $iFirstMin Then $iFirstHeight = $iHeight * $iFirstMin If $iHeight - ($iFirstHeight + $iSeparatorSize) < $iHeight * $iSecondMin Then $iFirstHeight = $iHeight - ($iHeight * $iSecondMin) - $iSeparatorSize EndIf WinMove($hFirstFrame, "", 0, 0, $iWidth, $iFirstHeight) WinMove($hSecondFrame, "", 0, $iFirstHeight + $iSeparatorSize, $iWidth, $iHeight - ($iFirstHeight + $iSeparatorSize)) WinMove($hSeparator, "", 0, $iFirstHeight, $iWidth, $iSeparatorSize) Until Not _WinAPI_GetAsyncKeyState(0x01) $aGF_SizingIndex[$iIndex][6] = $iFirstHeight / $iHeight EndIf ; Set callback $aGF_HandleIndex[$iIndex][7] = 1 EndIf ; Pass the message on to org WndProc Return _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_GUIFrame_SepWndProc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _GUIFrame_SepPassMsg ; Description ...: Passes Msg to frame parent WndProc for action ; Author ........: Kip ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _GUIFrame_SepWndProc ; =============================================================================================================================== Func _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam) For $i = 1 To $aGF_SepProcIndex[0][0] If $aGF_SepProcIndex[$i][0] = $hWnd Then Return _WinAPI_CallWindowProc($aGF_SepProcIndex[$i][1], $hWnd, $iMsg, $wParam, $lParam) Next EndFunc ;==>_GUIFrame_SepPassMsg ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _GUIFrame_Move ; Description ...: Moves and resizes frame elements and separator bars ; Author ........: Kip ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _GUIFrame_SIZE_Handler ; =============================================================================================================================== Func _GUIFrame_Move($iFrame, $iX, $iY, $iWidth = 0, $iHeight = 0) If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return 0 Local $fAbsolute = False, $iDimension, $iActual_Size_1, $iActual_Size_2, $iSize Local $iOrientation = $aGF_SettingsIndex[$iFrame][0] Local $iSeparatorSize = $aGF_SettingsIndex[$iFrame][2] ; Set size if not specified If Not $iWidth Then $iWidth = _WinAPI_GetWindowWidth($aGF_HandleIndex[$iFrame][0]) If Not $iHeight Then $iHeight = _WinAPI_GetWindowHeight($aGF_HandleIndex[$iFrame][0]) ; Move parent WinMove($aGF_HandleIndex[$iFrame][0], "", $iX, $iY, $iWidth, $iHeight) ; Depending on separator orientation get required width/height values If $iOrientation = 1 Then $iDimension = $iHeight $iActual_Size_1 = _WinAPI_GetWindowHeight($aGF_HandleIndex[$iFrame][1]) $iActual_Size_2 = _WinAPI_GetWindowHeight($aGF_HandleIndex[$iFrame][2]) Else $iDimension = $iWidth $iActual_Size_1 = _WinAPI_GetWindowWidth($aGF_HandleIndex[$iFrame][1]) $iActual_Size_2 = _WinAPI_GetWindowWidth($aGF_HandleIndex[$iFrame][2]) EndIf ; Check resize type required Switch $aGF_SizingIndex[$iFrame][7] Case 0 ; Determine new size for first frame using separator position percentage $iSize = Int($iDimension * $aGF_SizingIndex[$iFrame][6]) Case 1 ; Get current fixed first frame size $iSize = $iActual_Size_1 Case 2 ; Determine new first frame size with fixed second frame size $iSize = $iDimension - $iSeparatorSize - $iActual_Size_2 EndSwitch ; Set frame min percentages Local $iFirstMin = $aGF_SizingIndex[$iFrame][0] Local $iSecondMin = $aGF_SizingIndex[$iFrame][1] If $iFirstMin > 1 Or $iSecondMin > 1 Then $fAbsolute = True EndIf ; Check for minimum size of first frame Local $iAdjust_Other = True Local $fSep_Adjusted = False ; Adjust first frame size If $fAbsolute Then If $iSize < $iFirstMin Then $iSize = $iFirstMin $iAdjust_Other = False $fSep_Adjusted = True EndIf Else If $iSize < $iDimension * $iFirstMin Then $iSize = $iDimension * $iFirstMin $iAdjust_Other = False $fSep_Adjusted = True EndIf EndIf ; Now adjust second frame if first not adjusted If $iAdjust_Other Then ; Find max available size for this frame Local $iSecondMax = $iDimension - $iFirstMin - $iSeparatorSize If $iSecondMax < $iSecondMin Then $iSecondMin = $iSecondMax EndIf ; Adjust second frame size If $fAbsolute Then If $iActual_Size_2 < $iSecondMin Then $iSize = $iDimension - $iSecondMin - $iSeparatorSize $fSep_Adjusted = True EndIf Else If $iActual_Size_2 < $iDimension * $iSecondMin Then $iSize = $iDimension - ($iDimension * $iSecondMin) - $iSeparatorSize $fSep_Adjusted = True EndIf EndIf EndIf ; If the separator has been moved programatically then reset percentage size of first frame If $fSep_Adjusted Then $aGF_SizingIndex[$iFrame][6] = $iSize / $iDimension EndIf ; Move and resize GUIs according to orientation If $iOrientation = 1 Then WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iWidth, $iSize) WinMove($aGF_HandleIndex[$iFrame][2], "", 0, $iSize + $iSeparatorSize, $iWidth, $iHeight - $iSize - $iSeparatorSize) WinMove($aGF_HandleIndex[$iFrame][3], "", 0, $iSize, $iWidth, $iSeparatorSize) Else WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iSize, $iHeight) WinMove($aGF_HandleIndex[$iFrame][2], "", $iSize + $iSeparatorSize, 0, $iWidth - $iSize - $iSeparatorSize, $iHeight) WinMove($aGF_HandleIndex[$iFrame][3], "", $iSize, 0, $iSeparatorSize, $iHeight) EndIf EndFunc ;==>_GUIFrame_Move ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _GUIFrame_Exit() ; Description ...: Deletes all subclassed separator bars to free UDF WndProc and frees registered callback handle ; Author ........: Melba23 ; Remarks .......: Called by OnAutoItExitRegister to delete all subclassed separator bars and to free the UDF created WndProc. ; Example........: Yes ;================================================================================================================================ Func _GUIFrame_Exit() ; Delete all subclassed separator bars For $i = $aGF_HandleIndex[0][0] To 1 Step -1 GUIDelete($aGF_HandleIndex[$i][3]) Next ; Free registered Callback handle DllCallbackFree($hGF_RegCallBack) EndFunc ;==>_GUIFrame_Exit [New] And finally all 5 files in zip format: GUIFrame.zip I hope you find this UDF useful. As always brickbats and bouquets welcomed. M23
    1 point
  4. Ascend4nt

    GUI Fun!

    GUI Fun! Not enough posts here are about just plain fun stuff to do with AutoIt, at least not lately. So I figure, why not dig up one of my old UDFs, clean it up a bit, and throw it very emphatically at you lot of misfits! One way of mucking about with AutoIt and Windows that can be entertaining is creating shaped GUIs. Sure, GUIs with regions are nothing new here or in general on the Windows platform. But have you ever just wanted to stare at colorful shapes flying across your screen, for no apparent reason? Well, my friend, you've come to the right place. The first UDF I've put up pretty simple. Boxes, circles, triangles, diamonds, and stars are what I bring you, in technicolor wonder. I will probably add a few more examples when I find the time.. However, its my hope that more people add to this thread - and maybe provide links to other topics or posts where some nifty GUI fun is to be had! GUI related Threads & UDFs of Interest >GUI design concepts (started by Guinness) >Perforator - Perforated GUIs (and really anything GUI or GDI+-related by UEZ) >PNG as GUI >Multiple PNG images as GUI elements >FreeText - Text shape GUIs >Visible Controls on a Transparent Window >Layered Window without Image >AnyGUI - Extend the GUI of any Window >_UskinLibrary - Skinning w/DLL >XSkin - More GUI Skinning >GUIExtender, >GUIFrame, >Toast and other nice UDFs by Melba23 >GIF Animation >GDI+ Animated Waiting / Loading Screens My Examples I should point out other GUI manipulation UDF's I've uploaded in the past, as they too can provide some amusement. >GUIBox - Rubber-band GUIs >Full-screen Crosshairs >BarSweep (very simple example) >BoxSelection (another simple example) Okay, on to the new stuff! _GUIShapes is a UDF with functions to create GUI's shapes like Circles, Boxes, Triangles, Stars, and Diamonds. These GUI's have no interactive elements or controls and are click-through-able, meaning that a click on the GUI will pass through to whatever window is underneath. _LineTraverser is a UDF with functions to create a well, line traverser. Given a start and end point, it will allow you to step through a given line without needing to do any extra work on your behalf. This uses Bresenham's line algorithm to calculate the individual steps. I know this one isn't related to GUI, but its what I used for my second 'GUI fun' example below. Pacman Line-Traversing GUI (>static or >animated). That's right, I managed to animate a GUI! Check it! (now included in the ZIP) Examples that follow will be bundled with the ZIP. Have fun! Updates: GUIShapesExample - whacky shapes flying all over the screen!!! #include "_GUIShapes.au3" ;~ #include <WinAPI.au3> ; already included in <_GUIShapes.au3> ; ======================================================================================================== ; <GUIShapesExample.au3> ; ; Example use of <_GUIShapes.au3> UDF ; ; This example creates a bunch of random GUI shapes with random attributes, and moves ; everything around - randomly. ; ; Author: Ascend4nt ; ======================================================================================================== ; ---------------------- MAIN CODE ------------------------------- Local $iShapeGUIs = 20, $aShapeGUIs[$iShapeGUIs], $iTimer, $iRand, $aRet Local $iRandX, $iRandY, $iRandColor, $iRandLength Local $iTriangles = 0, $iCircles = 0, $iStars = 0, $iDiamonds = 0, $iBoxes = 0 For $i = 0 To $iShapeGUIs - 1 ; Everything random! $iRandX = Random(0, @DesktopWidth - 20, 1) $iRandY = Random(0, @DesktopHeight - 20, 1) $iRandLength = Random(12, 300, 1) $iRandColor = Random(0x111111, 0xFFFFFF, 1) ; Choose a GUI shape at random, with semi-random attributes Switch Random(0, 5, 1) Case 0 $aShapeGUIs[$i] = _TriangleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iTriangles, 1) * Random(1, 10, 1), Default, Mod($i, 4), $iRandColor) $iTriangles += 1 Case 1 $aShapeGUIs[$i] = _CircleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iCircles, 1) * Random(1, 10, 1), Default, $iRandColor) $iCircles += 1 Case 2 $aShapeGUIs[$i] = _StarGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iStars, 1) * Random(1, 10, 1), $iRandColor) $iStars += 1 Case 3 $aShapeGUIs[$i] = _DiamondGUICreate($iRandX, $iRandY, $iRandLength, Default, BitAND($iDiamonds, 1) * Random(1, 10, 1), $iRandColor) $iDiamonds += 1 Case Else ; 4 $aShapeGUIs[$i] = _BoxGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iBoxes, 1) * Random(1, 10, 1), Default, $iRandColor) $iBoxes += 1 EndSwitch ; Show the randomly created GUI GUISetState(@SW_SHOWNOACTIVATE, $aShapeGUIs[$i]) ; And set a random transparency too WinSetTrans($aShapeGUIs[$i], '', Random(50, 255, 1)) Next ConsoleWrite("GUI Totals: Triangles:" & $iTriangles & ", Circles:" & $iCircles & ", Stars:" & $iStars & ", Diamonds:" & $iDiamonds & ", Boxes:" & $iBoxes & @CRLF) ; Timer for moving shapes $iTimer = TimerInit() While 1 ; Exit on 'ESC' keypress (BitAND() test for down-state) If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop Sleep(10) ; Move a random GUI every 30+ms If TimerDiff($iTimer) >= 30 Then $iRand = Random(0, $iShapeGUIs - 1, 1) ; Set GUI above other windows WinSetOnTop($aShapeGUIs[$iRand], "", 1) ; Move to a random position WinMove($aShapeGUIs[$iRand], "", Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), Default, Default, 2) ; Reset timer $iTimer = TimerInit() EndIf WEnd _ LineTraverserExample - Where's the ball? Huh, where is it, Fido?! Ooh, there it is! Fetch the ball! Gooood circle.. #include "_GUIShapes.au3" #include "_LineTraverser.au3" ;~ #include <WinAPI.au3> ; ======================================================================================================== ; <LineTraverserExample.au3> ; ; Simple Example of using the <_LineTraverser.au3> and <_GuiShapes.au3> UDF's ; ; A little red-ball will display, and a hollow ball will move towards it. ; A line will be drawn to show how the path from the hollow ball to the red-ball target should work, ; and then the hollow ball moves to it in $iStep increments. ; ; ; Author: Ascend4nt ; ======================================================================================================== Global Const $iStep = 2 Local $hHollowCircle, $hDestCircle, $iExt Local $iXTarget, $iYTarget, $aLineTraverser ; Create the 2 circle GUIs $hHollowCircle = _CircleGUICreate(Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), 81, 10, Default, Random(0x111111, 0xFFFFFF, 1)) $hDestCircle = _CircleGUICreate(1, 1, 17, 0, 17, 0xFF0000) ; Set initial target point $iXTarget = Random(0, @DesktopWidth - 20, 1) $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Source/Target are same to start off with $aLineTraverser = _LineTraverserCreate($iXTarget, $iYTarget, $iXTarget, $iYTarget) ; Move windows to start positions WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1]) ; + Center of hollow circle, - half of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ; Transparency on 'seeker' circle WinSetTrans($hHollowCircle, '', 150) ; Show both GUIs, and put on top of all windows WinSetState($hDestCircle, '', @SW_SHOWNOACTIVATE) WinSetState($hHollowCircle, '', @SW_SHOWNOACTIVATE) WinSetOnTop($hHollowCircle, '', 1) WinSetOnTop($hDestCircle, '', 1) While 1 ; Exit on 'ESC' keypress (in down state) If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop ; < 10 ms sleep with an API call DllCall("kernel32.dll",'none','Sleep','dword',3) If Not _LineTraverserStep($aLineTraverser, $iStep) Then $iExt = @extended ; Was there movement? Then moooove If $iExt Then WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1]) EndIf $aPos = WinGetPos($hHollowCircle) ; Debug check. Should never be hit, so long as Window is moved to each step (including any last steps - see @extended) If $iXTarget <> $aPos[0] Or $iYTarget <> $aPos[1] Then ConsoleWrite("Mismatch: TargetX:" & $iXTarget & ", TraverserX:" & $aLineTraverser[0] & ", Current X:" & $aPos[0] & _ ", TargetY:" & $iYTarget & ", TraverserY:" & $aLineTraverser[1] & ", Current Y:" & $aPos[1] & ", @extended:" & $iExt & @CRLF) EndIf ; A little extra sleep to make it clear we've reached our destination. DllCall("kernel32.dll",'none','Sleep','dword',6) ; Now we'll set a new destination (with a visible line) Dim $iXTarget = Random(0, @DesktopWidth - 20, 1), $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Create a new Line-Traverser (no need to explicitly destroy the last one, it was just an array of numbers) $aLineTraverser = _LineTraverserCreate($aLineTraverser[0], $aLineTraverser[1], $iXTarget, $iYTarget) ; + Center of hollow circle, - center of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ;~ Draw the line on-screen to give a visual indicator of the path that the hollow circle should take ;~ (note that the line will be overwritten by ANY screen activity, but that's fine for the example) ; Get DC to screen $hDC = _WinAPI_GetDC(0) ; Create pen and select it into DC $hPen = _WinAPI_CreatePen(0, 3, 0xFFFFFF) $hPenOld = _WinAPI_SelectObject($hDC, $hPen) ; Note we add 40 (for the center of the hollow circle GUI) _WinAPI_DrawLine($hDC, $aPos[0] + 40 - 1, $aPos[1] + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1) ; Select the old pen back _WinAPI_SelectObject($hDC, $hPenOld) ; Clean up pen and then release DC _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) ; What fun drawing with GDI is =| Else WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1]) EndIf WEnd GUIShapesFun.zip ~prev downloads: 60
    1 point
  5. Arclite86, Look at Switch or Select - these conditional structures can do what you want. M23
    1 point
  6. altex, Actually you can do this by using a little trick: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $mFilemenu = GUICtrlCreateMenu("File") $mExititem = GUICtrlCreateMenuItem("Exit", $mFilemenu) $mSpecialitem = GUICtrlCreateMenuItem("?", -1) ; I belong to the main menu GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $mExititem Exit Case $mSpecialitem MsgBox($MB_SYSTEMMODAL, "Hi", "I can be actioned!") EndSwitch WEnd M23
    1 point
  7. Take a look at _IsPressed in the help file
    1 point
  8. Jos

    how to read that number ?

    Mutual when that's the shown attitude here.You will have 1 week without posting ability to think about your future here. Jos
    1 point
  9. I will never understand why everyone thinks THEY are somehow the exception...
    1 point
  10. Mat

    GetLocaleInfoEx ?

    It's normally the case that UDFs created a few years ago aren't maintained 100%, so you'll find that more recent functionality is missing. I find this happening quite often with additional constants to controls etc. Implementing GetLocaleInfoEx isn't easy though, it gets a little tricky when the return value isn't actually a string. If you want something to work off then this is my very quickly typed out basic implementation based on the MSDN signature. As normal absolutely no guarantee this code will even run. Func _WinAPI_GetLocaleInfoEx($sLocaleName, $LCType) Local $aResult = DllCall("kernel32.dll", "int", "GetLocaleInfoEx", "wstr", $sLocaleName, "DWORD", $LCType, "wstr", "", "int", 32768) If @error Then Return SetError(@error, @extended, 0) Return $aResult[3] EndFunc ;==>_WinAPI_GetLocaleInfoEx If you do get it working then make sure to submit a trac request so it gets tested and included in the next round of betas.
    1 point
  11. junkew Log Viewer - it is a different type of program. You load is not the whole file, but only part of which can be viewed. When turn the scrollbar, then tip the line number. When released the scrollbar, then loads the specified portion of the file. Either you have to create an item such as GUICtrlCreateEdit, but with better properties, designed for large files. For example Scintilla.
    1 point
  12. iCode

    Spell Checker UDF - Hunspell

    This UDF was originally written by ProgAndy, who gave up Windows, and thus AutoIt, in favor of Linux. Apparently he was well liked and respected for his capabilities, and will be missed. I have been playing with this UDF and modifying it a bit for my own use and i wanted to post the code (permission was granted from ProgAndy after i finally managed to reach him). The original code is still available at progandy.de and is also added here as an attachment. My modified version is attached. You will need the ProgAndy version for the dll code and examples. I think this is a really cool project that could be useful to many, so it would be nice if we could work on it and improve it. I'm not very knowledgeable regarding the depths of AutoIt capabilities, and am especially weak in anything having to do with DLL's. I will post a complete example with a GUI in the near future, but for now, here is my modified UDF... #include-once ; #INDEX# ======================================================================================================================= ; Title .........: Hunspell Hypenate MyThes ; Description ...: This module contains various functions to call Hunspell, Hyphenate and MyThes ; Author ........: Prog@ndy http://progandy.co.cc/downloads/view.download/12 ; Licence .......: The DLLs are open source, taken from the NHunspell project (http://nhunspell.sf.net) ; NHunspell is licenced under: GPL/LGPL/MPL. ; Free use in commercial applications is permittet according to the LGPL and MPL licenses. ; Your commercial application can link against the NHunspell DLLs. ; =============================================================================================================================== OnAutoItExitRegister("__Spell_Shutdown") ; =============================================================================================================================== ; GLOBAL VARIABLES ; =============================================================================================================================== Global $hHunspellDll = -1, $hHunspell = -1 ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_Spell_HunspellAdd ;_Spell_HunspellAddWithAffix ;_Spell_HunspellAnalyze ;_Spell_HunspellFree ;_Spell_HunspellGenerate ;_Spell_HunspellInit ;_Spell_HunspellSpell ;_Spell_HunspellStem ;_Spell_HunspellSuggest ;_Spell_HyphenFree ;_Spell_HyphenHyphenate ;_Spell_HyphenInit ;_Spell_MyThesFree ;_Spell_MyThesInit ;_Spell_MyThesLookup ;_Spell_Startup ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ;__Spell_PtrStringReadW ;__Spell_HunspellReadStringArray ;__Spell_MyThesReadMarshalBuffer ;__Spell_MyThesReadMeaningBuffer ;__Spell_Shutdown ; =============================================================================================================================== ; #ORIGINAL_CALLCONV#============================================================================================================ ; definitions taken from sourcefile: /trunk/Hunspell/HunspellExportFunctions.cpp ; Link: http://nhunspell.svn.sourceforge.net/viewvc/nhunspell/trunk/Hunspell/ ; ; #define DLLEXPORT extern "C" _declspec( dllexport ) ==> CDECL ! ; ; DLLEXPORT NHunspell * HunspellInit(wchar_t * aff_file, wchar_t *dict_file, wchar_t * key) ; DLLEXPORT void HunspellFree(NHunspell * handle ) ; DLLEXPORT bool HunspellAdd(NHunspell * handle, wchar_t * word ) ; DLLEXPORT bool HunspellAddWithAffix(NHunspell * handle, wchar_t * word, wchar_t * affix ) ; DLLEXPORT bool HunspellSpell(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellSuggest(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellAnalyze(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellStem(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellGenerate(NHunspell * handle, wchar_t * word, wchar_t * word2 ) ; ; DLLEXPORT void * HyphenInit(wchar_t * dict_file) ; DLLEXPORT void HyphenFree(NHyphen * handle ) ; DLLEXPORT void * HyphenHyphenate(NHyphen * handle, wchar_t * word ) ; ; DLLEXPORT void * MyThesInit(wchar_t * idx_file, wchar_t * dat_file) ; DLLEXPORT void MyThesFree(NMyThes * handle ) ; DLLEXPORT void * MyThesLookup(NMyThes * handle, wchar_t * word ) ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellAdd ; Description ...: add word to the run-time dictionary ; Syntax.........: _Spell_HunspellAdd($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to add ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellAddWithAffix ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellAdd($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "int:cdecl", "HunspellAdd", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellAddWithAffix ; Description ...: add word to the run-time dictionary with affix flags of the example (a dictionary word) ; Syntax.........: _Spell_HunspellAddWithAffix($hHunspell, $sWord, $sAffix) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to add ; $sAffix - Affix ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: Hunspell will recognize affixed forms of the new word, too. ; Related .......: _Spell_HunspellAdd ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellAddWithAffix($hHunspell, $sWord, $sAffix) Local $aResult = DllCall($hHunspellDll, "int:cdecl", "HunspellAddWithAffix", "ptr", $hHunspell, "wstr", $sWord, "wstr", $sAffix) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellAnalyze ; Description ...: morphological analysis of the word ; Syntax.........: _Spell_HunspellAnalyze($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to analyze ; Return values .: Success - array with analyzation result ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellGenerate ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellAnalyze($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellAnalyze", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellFree ; Description ...: Frees memory associated with a Hunspell handle ; Syntax.........: _Spell_HunspellFree($hHunspell) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; Return values .: Failure - Sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellFree($hHunspell) DllCall($hHunspellDll, "none:cdecl", "HunspellFree", "ptr", $hHunspell) If @error Then Return SetError(1) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellGenerate ; Description ...: morphological generation by example(s) ; Syntax.........: _Spell_HunspellGenerate($hHunspell, $sWord, $sWord2) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - first word ; $sWord2 - second word ; Return values .: Success - array with result ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellAnalyze ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellGenerate($hHunspell, $sWord, $sWord2) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellGenerate", "ptr", $hHunspell, "wstr", $sWord, "wstr", $sWord2) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2,0,0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellInit ; Description ...: Initializes Hunspell ; Syntax.........: _Spell_HunspellInit($sAff_file, $sDict_file, $sKey=0) ; Parameters ....: $sAff_file - Hunspell .aff-file ; $sDict_file - Hunspell .dict-file ; $sKey - [optional] a Key String ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellInit($sAff_file, $sDict_file, $sKey=0) Local $tpKey='ptr' If IsString($sKey) Then $tpKey='wstr' Local $aResult = DllCall($hHunspellDll, 'ptr:cdecl', 'HunspellInit', 'wstr', $sAff_file, 'wstr', $sDict_file, $tpKey, $sKey) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellSpell ; Description ...: Checks the spelling of the given word ; Syntax.........: _Spell_HunspellSpell($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the Word to check ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellSuggest ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellSpell($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "int:cdecl", "HunspellSpell", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellStem ; Description ...: stemmer function ; Syntax.........: _Spell_HunspellStem($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to stem ; Return values .: Success - array with result ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellStem($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellStem", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellSuggest ; Description ...: Suggests alternatives for a misspelled word ; Syntax.........: _Spell_HunspellSuggest($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - The word you want alternatives for ; Return values .: Success - Array with suggestions (0 based) ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellSpell ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellSuggest($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellSuggest", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HyphenFree ; Description ...: Frees memory associated with a Hyphen-handle ; Syntax.........: _Spell_HyphenFree($hHyphen) ; Parameters ....: $hHyphen - Hyphen-handle returned from _Spell_HyphenInit ; Return values .: Failure - Sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HyphenFree($hHyphen) DllCall($hHunspellDll, "none:cdecl", "HyphenFree", "ptr", $hHyphen) If @error Then Return SetError(1) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HyphenHyphenate ; Description ...: Analyze a word for possible hyphenation ; Syntax.........: _Spell_HyphenHyphenate($hHyphen, $sWord) ; Parameters ....: $hHyphen - Hyphen-handle returned from _Spell_HyphenInit ; $sWord - Word to be analyzed ; Return values .: Success - Array with hyphenation result ; |$array[0] contains the siblings separated with = ; |$array[$i] is 0 if you can"t split the word after letter $i ; |$array[$i] is 1 if it is possible to split the word after letter $i ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HyphenHyphenate($hHyphen, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HyphenHyphenate", "ptr", $hHyphen, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $stHyphen = DllStructCreate("ptr;ptr;",$aResult[0]) Local $sTemp = __Spell_PtrStringReadW(DllStructGetData($stHyphen,1)) Local $iMax = StringLen($sWord), $iIndex Local $aTemp[$iMax+1] = [$sTemp] $stHyphen = DllStructCreate("byte[" & $iMax & "]",DllStructGetData($stHyphen,2)) If @error Then Return SetError(3, 0, 0) For $iIndex = 1 To $iMax $aTemp[$iIndex] = Mod(DllStructGetData($stHyphen,1,$iIndex),2) Next Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HyphenInit ; Description ...: Initializes a Hyphen-handle ; Syntax.........: _Spell_HyphenInit($sDict_file) ; Parameters ....: $sDict_file - Dictionary for hyphenation ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HyphenInit($sDict_file) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HyphenInit", "wstr", $sDict_file) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_MyThesFree ; Description ...: Frees memory associated with a MyThes handle ; Syntax.........: _Spell_MyThesFree($hMyThes) ; Parameters ....: $hMyThes - MyThes-handle returned from _Spell_MyThesInit ; Return values .: Failure - Sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_MyThesFree($hMyThes) DllCall($hHunspellDll, "none:cdecl", "MyThesFree", "ptr", $hMyThes) If @error Then Return SetError(1) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_MyThesInit ; Description ...: Initializes a Thesaurus ; Syntax.........: _Spell_MyThesInit($sIdx_file, $sDat_file) ; Parameters ....: $sIdx_file - MyThes .idx-file ; $sDat_file - MyThes .dat-file ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_MyThesInit($sIdx_file, $sDat_file) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "MyThesInit", "wstr", $sIdx_file, "wstr", $sDat_file) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_MyThesLookup ; Description ...: Looks up the meanings and synonyms of a word ; Syntax.........: _Spell_MyThesLookup($hMyThes, $sWord) ; Parameters ....: $hMyThes - MyThes-handle returned from _Spell_MyThesInit ; $sWord - The word o analyze ; Return values .: Success - Array of Arrays: ; |$array[$i] - the entries for one meaning of the word ; |--> $subarray[0] - the description of the meaning ; |--> $subarray[$j] - synonyms for this meaning ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_MyThesLookup($hMyThes, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "MyThesLookup", "ptr", $hMyThes, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) $aResult = __Spell_MyThesReadMarshalBuffer($aResult[0]) If @error Then Return SetError(2, 0, 0) Return $aResult EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_Startup ; Description ...: Loads the DLL containing Hunspell, Hyphen and Thesaurus (selects 32 or 64 bit automatically) ; Syntax.........: _Spell_Startup(directory path where dll can be found) ; Parameters ....: $sDLL - Hunspell.dll for 32 bit ; $sDLLx64 - Hunspell.dll for 64 bit ; Return values .: Success - 1 ; Failure - 0 and sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: No Unload function included, AutoIt does it automatically on termination ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_Startup($sDir) If $hHunspellDll <> -1 Then Return 1 Local $sDLL = $sDir & "\Hunspell_x86.dll" If @AutoItX64 Then $sDLL = $sDir & "\Hunspell_x64.dll" $hHunspellDll = DllOpen($sDLL) If $hHunspellDll = -1 Then Return SetError(1, 0, 0) Return 1 EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_HunspellReadStringArray ; Description ...: Reads a zero-terminated array of pointers to wstrings (zero-terminated) ; Syntax.........: __Spell_HunspellReadStringArray($ptr) ; Parameters ....: $ptr - Pointer to array ; Return values .: Success - Array with read strings ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: This function is used internally by _Spell_HunspellSuggest, _Spell_HunspellAnalyze, _Spell_HunspellStem, and _Spell_HunspellGenerate ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_HunspellReadStringArray($ptr) If $ptr = 0 Then Return SetError(1, 0, 0) Local $stPtr = DllStructCreate("ptr", $ptr) Local $asStrings[50], $iIndex = 0, $iMax = 49 While 1 $asStrings[$iIndex] = __Spell_PtrStringReadW(DllStructGetData($stPtr,1)) If @error = 1 Then ExitLoop $iIndex += 1 If $iIndex > $iMax Then $iMax += 50 ReDim $asStrings[$iMax+1] EndIf $stPtr = DllStructCreate("ptr", $ptr + DllStructGetSize($stPtr)*$iIndex) WEnd If $iIndex = 0 Then Return SetError(2, 0, 0) ReDim $asStrings[$iIndex] Return $asStrings EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_PtrStringReadW ; Description ...: Reads a zero-terminated wstrings from a pointer ; Syntax.........: __Spell_HunspellReadStringArray($ptr) ; Parameters ....: $ptr - Pointer to wstring ; Return values .: Success - read string ; Failure - empty string ("") ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: This function is used internally by __Spell_HunspellReadStringArray, and __Spell_MyThesReadMeaningBuffer ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_PtrStringReadW($ptr) If $ptr = 0 Then Return SetError(1, 0 ,"") Local $aLen = DllCall("kernel32.dll", "int", "lstrlenW", "ptr", $ptr) If @error Or $aLen[0]=0 Then Return SetError(2, 0, "") Local $struct = DllStructCreate("wchar[" & ($aLen[0] + 1) & "]", $ptr) Return DllStructGetData($struct, 1) EndFunc ;==>__Spell_PtrStringReadW ; #INTERNAL_USE_ONLY# ==================================================================================================================== ; Name ..........: __Spell_Shutdown ; Description ...: close hunspell DLL ; Syntax ........: __Spell_Shutdown() ; Parameters ....: ; Return values .: None ; Author ........: iCode ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __Spell_Shutdown() If $hHunspellDll <> -1 Then DllClose($hHunspellDll) EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_MyThesReadMarshalBuffer ; Description ...: Reads the Marhal-Buffer for _Spell_MyThesLookup ; Syntax.........: __Spell_MyThesReadMarshalBuffer($pBuffer) ; Parameters ....: $pBuffer - Pointer to Marshal buffer ; Return values .: Success - Array of Arrays ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: This function is used internally by _Spell_MyThesLookup ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_MyThesReadMarshalBuffer($pBuffer) Local $stPtr = DllStructCreate("int_ptr", $pBuffer) If @error Then Return SetError(1, 0, 0) Local $iCount = DllStructGetData($stPtr, 1) $stPtr = DllStructCreate("int_ptr;ptr[" & $iCount & "]", $pBuffer) Local $aMeanings[$iCount], $i For $i = 1 To $iCount $aMeanings[$i-1] = __Spell_MyThesReadMeaningBuffer(DllStructGetData($stPtr, 2, $i)) Next Return $aMeanings EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_MyThesReadMeaningBuffer ; Description ...: Helper to read the Marhal-Buffer for _Spell_MyThesLookup ; Syntax.........: __Spell_MyThesReadMeaningBuffer($pBuffer) ; Parameters ....: $pBuffer - Pointer to meaning-section in Marshal buffer ; Return values .: Success - Array of Strings ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: This function is used internally by __Spell_MyThesReadMarshalBuffer ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_MyThesReadMeaningBuffer($pBuffer) Local $stPtr = DllStructCreate("int_ptr", $pBuffer) Local $iCount = DllStructGetData($stPtr,1) $stPtr = DllStructCreate("int_ptr;ptr;ptr[" & $iCount & "]", $pBuffer) Local $aSynonyms[$iCount+1], $i $aSynonyms[0] = __Spell_PtrStringReadW(DllStructGetData($stPtr, 2)) For $i = 1 To $iCount $aSynonyms[$i] = __Spell_PtrStringReadW(DllStructGetData($stPtr, 3, $i)) Next Return $aSynonyms EndFunc hunspell-0.9.2-ProgAndy.zip Hunspell_iCode_13_JUN_2014.zip
    1 point
  13. Ascend4nt

    GUI Fun!

    Well, Lakes.. I hope you're happy! After hours of wading through mathematics crap I finally figured out that up was down and vice versa. And well.. Pacman has cometh forth to do its evil bidding upon your computer screen! This was actually pretty fun to figure out the maths with, although I totally forgot that the cartesian coordinate system does not match the Windows coordinate system. And I didn't want to tweak around with Mapping modes or whatnot.. so I just flipped things around and hacked out a coordinate system that works (a counterclockwise upside-down one, but hey.. thats pretty much how I see the world) Here it is (you'll need the ZIP from the first post): *Edit: Fixed borked ATan() related maths Pacman Line-Traversing GUI Goodness #include "_LineTraverser.au3" #include "_GUIShapes.au3" #include <WinAPI.au3> ; ======================================================================================================== ; <LineTraverserPacmanExample.au3> ; ; Simple Example of using the <_LineTraverser.au3> and <_GuiShapes.au3> UDF's ; ; A little red-ball displays, while a 'Pacman' GUI moves towards it along a line ; An actual line is drawn onscreen to show the path from 'Pacman' to the red-ball target GUI, ; and then the PacGUI moves to it in $iStep increments. ; ; Additional Functions: ; _GUIApplyPacman() ; Converts a square GUI into a Pacman-shaped GUI. Regions are recreated ; ; each time, based on the input ; Atan2_Radians() ; An 'atan2()' function ; ; Author: Ascend4nt ; ======================================================================================================== Global Const $iStep = 2 Local $hPacMan, $hDestCircle, $iExt Local $iXTarget, $iYTarget, $aLineTraverser ; Create the Pacman GUI and apply shape to it $hPacMan = GUICreate("", 81, 81,Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), 0x80000000, 0x08000080 + 0x20) GUISetBkColor(Random(0x111111, 0xFFFFFF, 1), $hPacMan) _GUIApplyPacman($hPacMan, 0) ; Red-dot GUI $hDestCircle = _CircleGUICreate(1, 1, 17, 0, 17, 0xFF0000) ; Set initial target point $iXTarget = Random(0, @DesktopWidth - 20, 1) $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Source/Target are same to start off with $aLineTraverser = _LineTraverserCreate($iXTarget, $iYTarget, $iXTarget, $iYTarget) ; Move windows to start positions WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1]) ; + Center of hollow circle, - half of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ; Transparency on 'seeker' circle WinSetTrans($hPacMan, '', 150) ; Show both GUIs, and put on top of all windows WinSetState($hDestCircle, '', @SW_SHOWNOACTIVATE) WinSetState($hPacMan, '', @SW_SHOWNOACTIVATE) WinSetOnTop($hPacMan, '', 1) WinSetOnTop($hDestCircle, '', 1) While 1 ; Exit on 'ESC' keypress (in down state) If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop ; < 10 ms sleep with an API call DllCall("kernel32.dll",'none','Sleep','dword',3) If Not _LineTraverserStep($aLineTraverser, $iStep) Then $iExt = @extended ; Was there movement? Then moooove If $iExt Then WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1]) EndIf $aPos = WinGetPos($hPacMan) ; Debug check. Should never be hit, so long as Window is moved to each step (including any last steps - see @extended) If $iXTarget <> $aPos[0] Or $iYTarget <> $aPos[1] Then ConsoleWrite("Mismatch: TargetX:" & $iXTarget & ", TraverserX:" & $aLineTraverser[0] & ", Current X:" & $aPos[0] & _ ", TargetY:" & $iYTarget & ", TraverserY:" & $aLineTraverser[1] & ", Current Y:" & $aPos[1] & ", @extended:" & $iExt & @CRLF) EndIf ; A little extra sleep to make it clear we've reached our destination. DllCall("kernel32.dll",'none','Sleep','dword',6) ; Now we'll set a new destination (with a visible line) Dim $iXTarget = Random(0, @DesktopWidth - 20, 1), $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Create a new Line-Traverser (no need to explicitly destroy the last one, it was just an array of numbers) $aLineTraverser = _LineTraverserCreate($aLineTraverser[0], $aLineTraverser[1], $iXTarget, $iYTarget) ; + Center of hollow circle, - center of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ; Apply Pacman GUI with calculated angle of line it should point towards _GUIApplyPacman($hPacMan, Atan2_Radians($iYTarget - $aLineTraverser[1], $iXTarget - $aLineTraverser[0])) ; Draw the line on-screen to give a visual indicator of the path that the hollow circle should take ; (note that the line will be overwritten by ANY screen activity, but that's fine for the example) ; Get DC to screen $hDC = _WinAPI_GetDC(0) ; Create pen and select it into DC $hPen = _WinAPI_CreatePen(0, 3, 0xFFFFFF) $hPenOld = _WinAPI_SelectObject($hDC, $hPen) ; Note we add 40 (for the center of the hollow circle GUI) _WinAPI_DrawLine($hDC, $aPos[0] + 40 - 1, $aPos[1] + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1) ; Select the old pen back _WinAPI_SelectObject($hDC, $hPenOld) ; Clean up pen and then release DC _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) ; What fun drawing with GDI is =| ;Sleep(4000) Else WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1]) EndIf WEnd Exit ; ================================================================================================================= ; Func _GUIApplyPacman($hGUI, $fAngleInRads) ; ; Takes a GUI and applies a 'Pacman' shape to it. The angle of Pacman's mouth is based upon the $fAngleinRads ; variable (the mouth is a 90 degree angle rotated towards the angle given) ; ; Returns: ; Success: 1, @error = 0 ; Failure: 0, @error set ; ; Author: Ascend4nt ; ================================================================================================================= Func _GUIApplyPacman($hGUI, $fAngleInRads) Local $aPos, $aVertices, $hEllipseRgn = 0, $hPieRegion = 0 Local $iCenterXY $aPos = WinGetPos($hGUI) If @error Then Return SetError(1, 0, 0) $iCenterXY = $aPos[2] / 2 #cs ;; -------------- ; Vertices array: ; --------------- ; These vertices make up the mouth. 0.78539816 is a 45 degree difference (in Radians) ; Note that the multipler should typically be Radius, not $aPos[2] as here, if we were creating a line ; to the circumference of the circle. However, that would cause a weird triangle-inside-a-circle effect ; when combining Regions. So we overextend it and let Windows clip the line at the GUI borders, ; which does its job of covering up the outer parts of the circle ; ---------------------------------------------------------------- #ce Dim $aVertices[3][2] = [ _ [ $iCenterXY, $iCenterXY ], _ ; We over-extend the lines here ($aPos[2] is way longer than the radius) [ $iCenterXY + $aPos[2] * Cos($fAngleInRads - 0.78539816), $iCenterXY + $aPos[2] * Sin($fAngleInRads - 0.78539816) ], _ [ $iCenterXY + $aPos[2] * Cos($fAngleInRads + 0.78539816), $iCenterXY + $aPos[2] * Sin($fAngleInRads + 0.78539816) ] _ ] Do ; Create a Basic Elliptical region $hEllipseRgn = _WinAPI_CreateEllipticRgn(_WinAPI_CreateRect(0, 0, $aPos[2], $aPos[3])) If $hEllipseRgn = 0 Then SetError(10) ExitLoop EndIf ; Create the Pacman Pie area $hPieRegion = _WinAPI_CreatePolygonRgn($aVertices, 0, -1, 1) If $hPieRegion = 0 Then SetError(12) ExitLoop EndIf ; Combine, put resulting region in $hEllipseRgn. RGN_AND = 1, RGN_OR = 2, RGN_XOR = 3, RGN_DIFF = 4 If Not _WinAPI_CombineRgn($hEllipseRgn, $hEllipseRgn, $hPieRegion, 4) Then SetError(14) ExitLoop EndIf ; Don't need this anymore (already combined with the Region injected into the GUI) _WinAPI_DeleteObject($hPieRegion) ; Set the region into the GUI. (GUI will then own it so there's no need to delete it) If Not _WinAPI_SetWindowRgn($hGUI, $hEllipseRgn, True) Then SetError(16) ExitLoop EndIf Return 1 Until 1 Local $iErr = @error, $iExt = @extended ; Cleanup _WinAPI_DeleteObject($hEllipseRgn) _WinAPI_DeleteObject($hPieRegion) Return SetError($iErr, $iExt, 0) EndFunc ;==>_GUIApplyPacman ; ================================================================================================================= ; Func Atan2_Radians($fY, $fX) ; ; Atan2() implementation, based on Wikipedia description. See notes ; ; atan2() differs from atan() in that it maps atan(Y/X) to correct Quadrants ; ; References: ; https://en.wikipedia.org/wiki/Atan2 ; https://en.wikipedia.org/wiki/Radian ; https://en.wikipedia.org/wiki/Cosine#Unit-circle_definitions ; ; Returns: Atan2() result in radians (for the flipped counterclockwise system) ; ; Author: Ascend4nt ; ================================================================================================================= Func Atan2_Radians($fY, $fX) Local Const $f_PI = 3.14159265 Local Const $f_PIHalf = $f_PI / 2 ;~ ConsoleWrite("Atan2 entry, $fY = " & $fY & ", $fX = " & $fX & @CRLF) If $fX = 0 Then ; Technically 'undefined' If $fY = 0 Then Return 0.0 If $fY < 0 Then Return -$f_PIHalf Else ; $fY >= 0 Return $f_PIHalf EndIf EndIf Local $fTmp = ATan($fY / $fX) If $fX < 0 Then If $fY < 0 Then Return $fTmp - $f_PI Else Return $fTmp + $f_PI EndIf Else ; $fX > 0 ; already checked == 0 at start Return $fTmp EndIf EndFunc ;==>Atan2_Radians
    1 point
  14. jkotecki, Glad I could help. M23
    1 point
  15. Skitty

    Re-sizable gui

    AW STUPID ME!!! What I meant was a gui input control box, not that input box lol. thanks for the effort though.
    1 point
×
×
  • Create New...