Jump to content

Lupo73

Active Members
  • Posts

    159
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Lupo73's Achievements

Prodigy

Prodigy (4/7)

13

Reputation

  1. An user reported me the same problem in my program. Tested with beta 3.3.11.4 and the issue is still there.
  2. I updated the code in the second post... after several tests and improvements: - it correctly manages taskbar on any side - it works with both window on top or not - it may works much better also with multiple monitors
  3. Don't worry.. but obviously feel free to propose (or directly do) other improvements and fixes to the code.
  4. I wrote an improved version of the code, that now correctly works on all screen sides (auto-detecting the nearest side and the taskbar position): #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGUI = GUICreate("Example", 300, 300) Local $hButtonIn = GUICtrlCreateButton("IN BOUNDS", 50, 60, 200, 26) Local $hButtonTop = GUICtrlCreateButton("TOP (ON/OFF)", 50, 160, 200, 26) Local $hButtonMove = GUICtrlCreateButton("HIDE (ON/OFF)", 50, 260, 200, 26) Local $iOnTop, $iToMove GUISetState(@SW_SHOW, $hGUI) While 1 If $iToMove = 1 Then __GUIGraduallyHide($hGUI, $iOnTop) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButtonMove If $iToMove = 1 Then $iToMove = 0 __GUIInBounds($hGUI) Else $iToMove = 1 EndIf Case $hButtonIn __GUIInBounds($hGUI) Case $hButtonTop If $iOnTop = 1 Then $iOnTop = 0 Else $iOnTop = 1 EndIf WinSetOnTop($hGUI, "", $iOnTop) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func __GUIGraduallyHide($hHandle, $iOnTop = 0, $iSpeed = 5, $iVisiblePixels = 50, $iMarginFromSide = 10, $iRevealOnly = 0, $iSide = -1) #cs Description: Gradually Hide GUI On The Nearest Side Of The Screen. Returns: 1 #ce Local $aDesktopArea, $hMonitor, $aMousePos, $aWinPos, $iLength, $iMouseHover, $iInternalDist $aMousePos = MouseGetPos() $aWinPos = __WinGetPosEx($hHandle) If @error Then Return SetError(2, 0, 0) $hMonitor = __MonitorFromWindow($hHandle) If @error Then Return SetError(3, 0, 0) $aDesktopArea = __MonitorGetInfo($hMonitor) If @error Then Return SetError(4, 0, 0) If $iOnTop Then ; To Ignore Taskbar If Win On Top. $aDesktopArea[4] = $aDesktopArea[0] $aDesktopArea[5] = $aDesktopArea[1] $aDesktopArea[6] = $aDesktopArea[2] $aDesktopArea[7] = $aDesktopArea[3] EndIf If $iSide = -1 Then $iSide = __GetNearSide($aDesktopArea[2] - $aDesktopArea[0], $aDesktopArea[3] - $aDesktopArea[1], $aWinPos[4] - $aDesktopArea[0], $aWinPos[5] - $aDesktopArea[1]) Switch $iSide Case 1 ; Hide On Top Side. If $hMonitor <> __MonitorFromPoint($aWinPos[4], $aDesktopArea[1] - 10) Then Return SetError(5, 0, 0) ; Do Not Hide On Sides Between Two Monitors. Local $aRefPos[4] = [$aWinPos[0] - 5, $aWinPos[6] + 5, $aDesktopArea[5], $aWinPos[7] + 10] $iInternalDist = $aWinPos[1] - $aDesktopArea[5] $iLength = $aWinPos[3] Case 2 ; Hide On Right Side. If $hMonitor <> __MonitorFromPoint($aDesktopArea[2] + 10, $aWinPos[5]) Then Return SetError(5, 0, 0) ; Do Not Hide On Sides Between Two Monitors. Local $aRefPos[4] = [$aWinPos[0] - 10, $aDesktopArea[6], $aWinPos[1] - 5, $aWinPos[7] + 5] $iInternalDist = $aDesktopArea[6] - $aWinPos[6] $iLength = $aWinPos[2] Case 3 ; Hide On Bottom Side. If $hMonitor <> __MonitorFromPoint($aWinPos[4], $aDesktopArea[3] + 10) Then Return SetError(5, 0, 0) ; Do Not Hide On Sides Between Two Monitors. Local $aRefPos[4] = [$aWinPos[0] - 5, $aWinPos[6] + 5, $aWinPos[1] - 10, $aDesktopArea[7]] $iInternalDist = $aDesktopArea[7] - $aWinPos[7] $iLength = $aWinPos[3] Case Else ; Hide On Left Side. If $hMonitor <> __MonitorFromPoint($aDesktopArea[0] - 10, $aWinPos[5]) Then Return SetError(5, 0, 0) ; Do Not Hide On Sides Between Two Monitors. Local $aRefPos[4] = [$aDesktopArea[4], $aWinPos[6] + 10, $aWinPos[1] - 5, $aWinPos[7] + 5] $iInternalDist = $aWinPos[0] - $aDesktopArea[4] $iLength = $aWinPos[2] EndSwitch If $aMousePos[0] >= $aRefPos[0] And $aMousePos[0] <= $aRefPos[1] And $aMousePos[1] >= $aRefPos[2] And $aMousePos[1] <= $aRefPos[3] Then $iMouseHover = 1 ; Show. If $iInternalDist < $iMarginFromSide And $iMouseHover = 1 Then ; Gradually Show Window. If WinActive($hHandle) = 0 Then WinActivate($hHandle) $iInternalDist += $iSpeed If $iInternalDist > $iMarginFromSide Then $iInternalDist = $iMarginFromSide ElseIf $iInternalDist > ($iVisiblePixels - $iLength) And $iMouseHover = 0 And $iRevealOnly = 0 Then ; Gradually Hide Window. If $iInternalDist > 0 Then $iInternalDist = 0 $iInternalDist -= $iSpeed If $iInternalDist < ($iVisiblePixels - $iLength) Then $iInternalDist = $iVisiblePixels - $iLength Else Return SetError(1, 0, 0) ; Completely Hidden/Revealed. EndIf Switch $iSide Case 1 ; Hide On Top Side. $aWinPos[1] = $aDesktopArea[5] + $iInternalDist Case 2 ; Hide On Right Side. $aWinPos[0] = $aDesktopArea[6] - $iLength - $iInternalDist Case 3 ; Hide On Bottom Side. $aWinPos[1] = $aDesktopArea[7] - $iLength - $iInternalDist Case Else ; Hide On Left Side. $aWinPos[0] = $aDesktopArea[4] + $iInternalDist EndSwitch WinMove($hHandle, "", $aWinPos[0], $aWinPos[1]) Sleep(20) Return 1 EndFunc ;==>__GUIGraduallyHide Func __WinGetPosEx($hHandle) #cs Description: Get Position And Size Of A Window. Returns: Array[8] [0] - Left-Side Position From Left [1] - Top-Side Position From Top [2] - Width [3] - Height [4] - Center Position From Left [5] - Center Position From Top [6] - Right-Side Position From Left [7] - Bottom-Side Position From Top #ce Local $aWinPos = WinGetPos($hHandle) If @error Then Return SetError(@error, 0, 0) Local $aReturn[8] = [$aWinPos[0], $aWinPos[1], $aWinPos[2], $aWinPos[3], $aWinPos[0] + Ceiling($aWinPos[2] / 2), $aWinPos[1] + Ceiling($aWinPos[3] / 2), $aWinPos[0] + $aWinPos[2], $aWinPos[1] + $aWinPos[3]] Return $aReturn EndFunc ;==>__WinGetPosEx Func __GetNearSide($iScreenW, $iScreenH, $iWinCX, $iWinCY) #cs Description: Get The Nearest Side Of Current Monitor To The Window Center. Returns: 0 = Left, 1 = Top, 2 = Right, 3 = Bottom. #ce Local $iReturn Local $aRatio[3] = [$iScreenW / $iScreenH, $iWinCX / $iWinCY, ($iScreenW - $iWinCX) / $iWinCY] Select Case $iWinCX <= 0 Or ($aRatio[1] < $aRatio[0] And $aRatio[2] >= $aRatio[0]) ; Near Left. $iReturn = 0 Case $iWinCY <= 0 Or ($aRatio[1] >= $aRatio[0] And $aRatio[2] >= $aRatio[0]) ; Near Top. $iReturn = 1 Case $iWinCX >= $iScreenW Or ($aRatio[1] >= $aRatio[0] And $aRatio[2] < $aRatio[0]) ; Near Right. $iReturn = 2 Case Else ; Near Bottom. $iReturn = 3 EndSelect Return $iReturn EndFunc ;==>__GetNearSide Func __GUIInBounds($hHandle) ; Original Idea By wraithdu, Modified By guinness And Lupo73. #cs Description: Check If The GUI Is Within View Of The Users Screen. Returns: Move GUI If Out Of Bounds #ce Local $iXPos = 5, $iYPos = 5, $aWinPos = __WinGetPosEx($hHandle) If @error Then Return SetError(1, 0, WinMove($hHandle, "", $iXPos, $iYPos)) Local $aDesktopArea = __MonitorGetInfo(__MonitorFromWindow($hHandle)) If @error Then Return SetError(2, 0, WinMove($hHandle, "", $iXPos, $iYPos)) $iXPos = $aWinPos[0] $iYPos = $aWinPos[1] If $aWinPos[0] < $aDesktopArea[4] Then $iXPos = $aDesktopArea[4] ElseIf $aWinPos[6] > $aDesktopArea[6] Then $iXPos = $aDesktopArea[6] - $aWinPos[2] EndIf If $aWinPos[1] < $aDesktopArea[5] Then $iYPos = $aDesktopArea[5] ElseIf $aWinPos[7] > $aDesktopArea[7] Then $iYPos = $aDesktopArea[7] - $aWinPos[3] EndIf WinMove($hHandle, "", $iXPos, $iYPos) Return 1 EndFunc ;==>__GUIInBounds Func __MonitorGetInfo($hMonitor) ; Modified From: http://www.autoitscript.com/forum/topic/134534-desktopdimensions-details-about-the-primary-and-secondary-monitors/ #cs Description: Get Info About A Monitor (Given A Monitor Handle). ; Returns: $Array[10] [0] = Monitor upper-left corner X coordinate (this rect is same as full-screen size) [1] = Monitor upper-left corner Y coordinate [2] = Monitor lower-right corner X coordinate [3] = Monitor lower-right corner Y coordinate [4] = Monitor Work Area upper-left corner X coordinate (this rect is same as maximized size) [5] = Monitor Work Area upper-left corner Y coordinate [6] = Monitor Work Area lower-right corner X coordinate [7] = Monitor Work Area lower-right corner Y coordinate [8] = Primary monitor boolean (0 = not, 1 = is) [9] = Monitor Or Display Device Name (usually '.DISPLAY#' where # starts at 1) #ce If IsPtr($hMonitor) = 0 Or $hMonitor = 0 Then Return SetError(1,0,'') Local $aRet, $stMonInfoEx = DllStructCreate('dword;long[8];dword;wchar[32]') DllStructSetData($stMonInfoEx, 1, DllStructGetSize($stMonInfoEx)) $aRet = DllCall('user32.dll', 'bool', 'GetMonitorInfoW', 'handle', $hMonitor, 'ptr', DllStructGetPtr($stMonInfoEx)) If @error Then Return SetError(2, 0, '') If $aRet[0] = 0 Then Return SetError(3, 0, '') Dim $aRet[10] For $A = 0 To 7 ; Both RECT's $aRet[$A] = DllStructGetData($stMonInfoEx, 2, $A + 1) Next $aRet[8] = DllStructGetData($stMonInfoEx, 3) ; 0 or 1 for Primary Monitor [MONITORINFOF_PRIMARY = 1] $aRet[9] = DllStructGetData($stMonInfoEx, 4) ; Device String of type '.DISPLAY1' etc Return $aRet EndFunc ;==>__MonitorGetInfo Func __MonitorFromPoint($iX, $iY) Local $aRet, $stPoint = DllStructCreate($tagPOINT) DllStructSetData($stPoint, "x", $iX) DllStructSetData($stPoint, "y", $iY) $aRet = DllCall("user32.dll", "handle", "MonitorFromPoint", "struct", $stPoint, 'dword', 2) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>__MonitorFromPoint Func __MonitorFromWindow($hWin) Local $aRet = DllCall("user32.dll", "hwnd", "MonitorFromWindow", "hwnd", $hWin, "int", 2) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>__MonitorFromWindow Func __WindowFromPoint($iX, $iY) Local $stInt64, $aRet, $stPoint = DllStructCreate("long;long") DllStructSetData($stPoint, 1, $iX) DllStructSetData($stPoint, 2, $iY) $stInt64 = DllStructCreate("int64", DllStructGetPtr($stPoint)) $aRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", "int64", DllStructGetData($stInt64, 1)) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>__WindowFromPoint
  5. Sorry, I misunderstood, I read "the last version of AutoIt" instead of "the last version for AutoIt" It perfectly works now, thanks!
  6. I'm not sure to understand, probably I'm too sleepy ..why the double enumeration? Anyway, for the record, I tested StringRegExp solution with "corncob_lowercase.txt" (58000 lines) and it extracts all words that start with "na" in 6/18 ms.. so it could be used to dynamically take matching words without store them in array.. but maybe I have misunderstood what the problem is (in this case, sorry)
  7. I already use it I'm doing some tests.. the problem seems in these lines: Local $Header = DllStructCreate($tagBITMAPINFO) ConsoleWrite('1 ' & @Error & @CRLF) ; <<<<<<<<<<<<<<<<< @Error = 0 ConsoleWrite('2 ' & $Header & @CRLF) ; <<<<<<<<<<<<<<<<< $Header = '' ConsoleWrite('3 ' & $tagBITMAPINFO & @CRLF) ; <<<<<<<<<<<<<<<<< $tagBITMAPINFO = struct;dword biSize;long biWidth;long biHeight;word biPlanes;word biBitCount;dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;endstruct;dword biRGBQuad[1] DllStructSetData($Header, "Size", 40) DllStructSetData($Header, "Width", $Width) DllStructSetData($Header, "Height", $Height) DllStructSetData($Header, "Planes", 1) DllStructSetData($Header, "BitCount", 1) DllStructSetData($Header, "SizeImage", $Stride * $Height) ConsoleWrite('4 ' & @Error & @CRLF) ; <<<<<<<<<<<<<<<<< @Error = 2 All the DllStructSetData return 2 as error and after the second Do-Until loop the script crashes.
  8. Perfect! What about load the list as multi-line string and use something like this to extract matching values? #include <Array.au3> Local $iTime_Now, $aList Local $sLangText = FileRead('english.txt') Local $sTypedString = 'na' ; example of typed text $iTime_Now = TimerInit() $aList = StringRegExp($sLangText, '(?i)' & @LF & $sTypedString & '(.*?)' & @CR, 3) If IsArray($aList) = 0 Then Exit EndIf MsgBox(0, 'Time', TimerDiff($iTime_Now)) _ArrayDisplay($aList)
  9. For example typing "n " (n+whitespace) in "Example6_PredictText(AutoSuggest).au3" second field.
  10. I'm trying to use this UDF, but it crashes with a strange error: !>13:11:31 AutoIt3.exe ended.rc:-1073741819 I'd like to save a .ICO file starting from a .PNG image, is this code the solution? thanks!
  11. I'm doing some tests to use your code in a program.. I think there is a minor issue: if I type the first character of a predictable string and then type a whitespace, the suggestion list is still visible (I think it may disappears); in addition, if I select the first suggestion, (in case there are more than one edit fields) it adds the first suggestion of the other edit field.
  12. I'm trying to extend this function to work also with other meta data, using these parameters: http://msdn.microsoft.com/en-us/library/ms534416(v=vs.85).aspx#_gdiplus_constant_propertytagexifdtorig But some Exif are not modified. Do you know if there are some limits following this way? This is the updated code I'm using: Func _GDIPlus_SetMetaData($hHandle, $sTagName, $vStr) Local $tagPropertyItem = "ulong id; ulong length; ushort Type; ptr value" Local $Struct_String, $Struct_Meta, $aResult, $PropertyTagType Local Const $PropertyTagTypeByte = 1 Local Const $PropertyTagTypeASCII = 2 Local Const $PropertyTagTypeShort = 3 Local Const $PropertyTagTypeLong = 4 Local Const $PropertyTagTypeRational = 5 Local Const $PropertyTagTypeUndefined = 7 Local Const $PropertyTagTypeSLong = 9 Local Const $PropertyTagTypeSRational = 10 Switch $sTagName Case "ImageWidth" $ID = 0x100 $PropertyTagType = $PropertyTagTypeShort Case "ImageLength" $ID = 0x101 $PropertyTagType = $PropertyTagTypeShort Case "BitsPerSample" $ID = 0x102 $PropertyTagType = $PropertyTagTypeShort Case "Compression" $ID = 0x103 $PropertyTagType = $PropertyTagTypeShort Case "PhotometricInterpretation" $ID = 0x106 $PropertyTagType = $PropertyTagTypeShort Case "Orientation" $ID = 0x112 $PropertyTagType = $PropertyTagTypeShort Case "SamplesPerPixel" $ID = 0x115 $PropertyTagType = $PropertyTagTypeShort Case "PlanarConfiguration" $ID = 0x11C $PropertyTagType = $PropertyTagTypeShort Case "YCbCrSubSampling" $ID = 0x212 $PropertyTagType = $PropertyTagTypeShort Case "YCbCrPositioning" $ID = 0x213 $PropertyTagType = $PropertyTagTypeShort Case "XResolution" $ID = 0x11A $PropertyTagType = $PropertyTagTypeRational Case "YResolution" $ID = 0x11B $PropertyTagType = $PropertyTagTypeRational Case "ResolutionUnit" $ID = 0x296 $PropertyTagType = $PropertyTagTypeShort Case "StripOffsets" $ID = 0x111 $PropertyTagType = $PropertyTagTypeShort Case "RowsPerStrip" $ID = 0x116 $PropertyTagType = $PropertyTagTypeShort Case "StripByteCounts" $ID = 0x117 $PropertyTagType = $PropertyTagTypeShort Case "JPEGInterchangeFormat" $ID = 0x201 $PropertyTagType = $PropertyTagTypeLong Case "JPEGInterchangeFormatLength" $ID = 0x202 $PropertyTagType = $PropertyTagTypeLong Case "TransferFunction" $ID = 0x12D $PropertyTagType = $PropertyTagTypeShort Case "WhitePoint" $ID = 0x13E $PropertyTagType = $PropertyTagTypeRational Case "PrimaryChromaticities" $ID = 0x13F $PropertyTagType = $PropertyTagTypeRational Case "YCbCrCoefficients" $ID = 0x211 $PropertyTagType = $PropertyTagTypeRational Case "ReferenceBlackWhite" $ID = 0x214 $PropertyTagType = $PropertyTagTypeRational Case "DateTime" $ID = 0x132 $PropertyTagType = $PropertyTagTypeASCII Case "ImageDescription" $ID = 0x10E $PropertyTagType = $PropertyTagTypeASCII Case "Make" $ID = 0x10F $PropertyTagType = $PropertyTagTypeASCII Case "Model" $ID = 0x110 $PropertyTagType = $PropertyTagTypeASCII Case "Software" $ID = 0x131 $PropertyTagType = $PropertyTagTypeASCII Case "Artist", "Author" $ID = 0x13B $PropertyTagType = $PropertyTagTypeASCII Case "ImageTitle" $ID = 0x320 $PropertyTagType = $PropertyTagTypeASCII Case "Copyright" $ID = 0x8298 $PropertyTagType = $PropertyTagTypeASCII Case "ExposureTime" $ID = 0x829A $PropertyTagType = $PropertyTagTypeRational Case "FNumber" $ID = 0x829D $PropertyTagType = $PropertyTagTypeRational Case "ISO" $ID = 0x8827 $PropertyTagType = $PropertyTagTypeShort Case "ExifVersion" $ID = 0x9000 $PropertyTagType = $PropertyTagTypeUndefined Case "DateTimeOriginal" $ID = 0x9003 $PropertyTagType = $PropertyTagTypeASCII Case "DateTimeDigitized" $ID = 0x9004 $PropertyTagType = $PropertyTagTypeASCII Case "ExposureBiasValue" $ID = 0x9204 $PropertyTagType = $PropertyTagTypeSRational Case "FocalLength" $ID = 0x920A $PropertyTagType = $PropertyTagTypeRational Case "ShutterSpeedValue" $ID = 0x9201 $PropertyTagType = $PropertyTagTypeSRational Case "ApertureValue" $ID = 0x9202 $PropertyTagType = $PropertyTagTypeRational Case "BrightnessValue" $ID = 0x9203 $PropertyTagType = $PropertyTagTypeSRational Case "MaxApertureValue" $ID = 0x9205 $PropertyTagType = $PropertyTagTypeRational Case "SubjectDistance" $ID = 0x9206 $PropertyTagType = $PropertyTagTypeRational Case "UserComments" $ID = 0x9286 $PropertyTagType = $PropertyTagTypeUndefined Case Else Return SetError(1, -1, False) EndSwitch ConsoleWrite("$sTagName = " & $sTagName & " | $vStr = " & $vStr & @LF) ; Store String In Array: $Struct_String = DllStructCreate("char[" & StringLen($vStr) +1 & "];") DllStructSetData($Struct_String, 1, $vStr) $Struct_Meta = DllstructCreate($tagPropertyItem) DllStructSetData($Struct_Meta, "ID", $ID) DllStructSetData($Struct_Meta, "Length", StringLen($vStr) +1) DllStructSetData($Struct_Meta, "Type", $PropertyTagType) DllStructSetData($Struct_Meta, "Value", DllStructGetPtr($Struct_String)) $aResult = DllCall($ghGDIPDll, "int", "GdipSetPropertyItem", "hwnd", $hHandle, "ptr", DllStructGetPtr($Struct_Meta)) If @error Then Return SetError(@error, @extended, False) EndIf Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetMetaData
  13. In the meanwhile I wrote this code that maybe could be used for it: '?do=embed' frameborder='0' data-embedContent>>
  14. I found different solutions to do it and I finally decided to merge them in a single "optimal" code. During the typing it checks each new word (from the previous whitespace to the current pointer) and proposes to complete it with words included in a array. Predicted words are shown in a list under the input field and can be selected with mouse or with up/down/enter keys. These are the sources considered to create this code: '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> And this is the code: #include <GUIConstantsEx.au3> #include <WinAPI.au3> #Include <GuiListBox.au3> #include <WindowsConstants.au3> Global $asKeyWords[21] = [20, "fight", "first", "fly", "third", "fire", "wall", "hi", "hello", "world", "window", _ "window 1", "window 2", "window 3", "window 4", "window 5", "window 6", "window 7", "window 8", "window 9", "window 10"] _Main() Func _Main() Local $hGUI, $hList, $hInput, $aSelected, $sChosen, $hUP, $hDOWN, $hENTER, $hESC Local $sCurrInput = "", $aCurrSelected[2] = [-1, -1], $iCurrIndex = -1, $hListGUI = -1 $hGUI = GUICreate("AutoComplete Input Text", 300, 100) GUICtrlCreateLabel('Start to type words like "window" or "fire" to test it:', 10, 10, 280, 20) $hInput = GUICtrlCreateInput("", 10, 40, 280, 20) GUISetState(@SW_SHOW, $hGUI) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() $hESC = GUICtrlCreateDummy() Dim $AccelKeys[4][2] = [["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER], ["{ESC}", $hESC]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hESC If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 Else ExitLoop EndIf Case $hUP If $hListGUI <> -1 Then ; List is visible. $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $hListGUI <> -1 Then ; List is visible. $iCurrIndex += 1 If $iCurrIndex > _GUICtrlListBox_GetCount($hList) - 1 Then $iCurrIndex = _GUICtrlListBox_GetCount($hList) - 1 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $hListGUI <> -1 And $iCurrIndex <> -1 Then ; List is visible and a item is selected. $sChosen = _GUICtrlListBox_GetText($hList, $iCurrIndex) EndIf Case $hList $sChosen = GUICtrlRead($hList) EndSwitch Sleep(10) $aSelected = _GetSelectionPointers($hInput) If GUICtrlRead($hInput) <> $sCurrInput Or $aSelected[1] <> $aCurrSelected[1] Then ; Input content or pointer are changed. $sCurrInput = GUICtrlRead($hInput) $aCurrSelected = $aSelected ; Get pointers of the string to replace. $iCurrIndex = -1 If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 EndIf $hList = _PopupSelector($hGUI, $hListGUI, _CheckInputText($sCurrInput, $aCurrSelected)) ; ByRef $hListGUI, $aCurrSelected. EndIf If $sChosen <> "" Then GUICtrlSendMsg($hInput, 0x00B1, $aCurrSelected[0], $aCurrSelected[1]) ; $EM_SETSEL. _InsertText($hInput, $sChosen) $sCurrInput = GUICtrlRead($hInput) GUIDelete($hListGUI) $hListGUI = -1 $sChosen = "" EndIf WEnd GUIDelete($hGUI) EndFunc ;==>_Main Func _CheckInputText($sCurrInput, ByRef $aSelected) Local $sPartialData = "" If (IsArray($aSelected)) And ($aSelected[0] <= $aSelected[1]) Then Local $aSplit = StringSplit(StringLeft($sCurrInput, $aSelected[0]), " ") $aSelected[0] -= StringLen($aSplit[$aSplit[0]]) If $aSplit[$aSplit[0]] <> "" Then For $A = 1 To $asKeyWords[0] If StringLeft($asKeyWords[$A], StringLen($aSplit[$aSplit[0]])) = $aSplit[$aSplit[0]] And $asKeyWords[$A] <> $aSplit[$aSplit[0]] Then $sPartialData &= $asKeyWords[$A] & "|" EndIf Next EndIf EndIf Return $sPartialData EndFunc ;==>_CheckInputText Func _PopupSelector($hMainGUI, ByRef $hListGUI, $sCurr_List) Local $hList = -1 If $sCurr_List = "" Then Return $hList EndIf $hListGUI = GUICreate("", 280, 160, 10, 62, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hMainGUI) $hList = GUICtrlCreateList("", 0, 0, 280, 150, BitOR(0x00100000, 0x00200000)) GUICtrlSetData($hList, $sCurr_List) GUISetControlsVisible($hListGUI) ; To Make Control Visible And Window Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hListGUI) Return $hList EndFunc ;==>_PopupSelector Func _InsertText(ByRef $hEdit, $sString) #cs Description: Insert A Text In A Control. Returns: Nothing #ce Local $aSelected = _GetSelectionPointers($hEdit) GUICtrlSetData($hEdit, StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString & StringTrimLeft(GUICtrlRead($hEdit), $aSelected[1])) Local $iCursorPlace = StringLen(StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString) GUICtrlSendMsg($hEdit, 0x00B1, $iCursorPlace, $iCursorPlace) ; $EM_SETSEL. EndFunc ;==>_InsertText Func _GetSelectionPointers($hEdit) Local $aReturn[2] = [0, 0] Local $aSelected = GUICtrlRecvMsg($hEdit, 0x00B0) ; $EM_GETSEL. If IsArray($aSelected) Then $aReturn[0] = $aSelected[0] $aReturn[1] = $aSelected[1] EndIf Return $aReturn EndFunc ;==>_GetSelectionPointers Func GUISetControlsVisible($hWnd) ; By Melba23. Local $aControlGetPos = 0, $hCreateRect = 0, $hRectRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) Local $iLastControlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle(-1)) For $i = 3 To $iLastControlID $aControlGetPos = ControlGetPos($hWnd, '', $i) If IsArray($aControlGetPos) = 0 Then ContinueLoop $hCreateRect = _WinAPI_CreateRectRgn($aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[0] + $aControlGetPos[2], $aControlGetPos[1] + $aControlGetPos[3]) _WinAPI_CombineRgn($hRectRgn, $hCreateRect, $hRectRgn, 2) _WinAPI_DeleteObject($hCreateRect) Next _WinAPI_SetWindowRgn($hWnd, $hRectRgn, True) _WinAPI_DeleteObject($hRectRgn) EndFunc ;==>GUISetControlsVisible Any advice to improve the code is welcome.
  15. Very good UDF, I like it! It could be interesting to add support to select between more predictions with a popup list, maybe using codes like these: '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>>
×
×
  • Create New...