Jump to content

XabiK

Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Location
    UK

Recent Profile Visitors

94 profile views

XabiK's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Probably it's slow... but it works quite well, but I found a strange behavior: when I look for an image (actually, an icon) at the desktop, using '_ImageSearch_Desktop' function, it doesn't find it, but when I look for the same icon in a specific area of the desktop, using following code (yeah, it's derived from yours!): ; #FUNCTION# ==================================================================================================================== ; Name...........: _ImageSearch_Position ; Description ...: Image search in a position of the desktop, according to provided width and height ; Syntax.........: _ImageSearch_Position($Image, $Position, $Width, $Height, $TransColorRGB = '') ; Parameters ....: $Image - search image: string address for file, or bitmap (format .bmp 24-bit) ; $Position - topleft, topcenter, topright, middleleft, center (default), middleright, bottomleft, bottomcenter, bottomright ; $Width - width of searching area [Default is @DesktopWidth.] ; $Height - height of searching area [Default is @DesktopHeight.] ; $TransColorRGB - Color transparency / Ignore color. Must be string and format RGB. a.g: "0xFFFFFF".[Default is "".] ; ; Return values . : On Success - Returns two-element array coordinates, or 2D array coordinates. CENTER of search image. ; On Failure - @Error = 1 - Path not found or invalid image/bitmap. ; @Error = 2 - Image not exist (in searching area). ; =============================================================================================================================== Func _ImageSearch_Position($Image, $Position = "center", $width = @DesktopWidth, $height = @DesktopHeight, $TransColorRGB = '') Local $aCoords[4], $aReturn, $error ;Some initial checks $width = Int($width) $height = Int($height) If $width = 0 Or $width > @DesktopWidth Then $width = @DesktopWidth EndIf If $height = 0 Or $height > @DesktopHeight Then $height = @DesktopHeight EndIf ;Coordinates calculation Switch $Position Case "topleft" $aCoords[0] = 0 $aCoords[1] = 0 Case "topcenter" $aCoords[0] = Int((@DesktopWidth - $width) / 2) $aCoords[1] = 0 Case "topright" $aCoords[0] = @DesktopWidth - $width $aCoords[1] = 0 Case "middleleft" $aCoords[0] = 0 $aCoords[1] = Int((@DesktopHeight - $height) / 2) Case "middleright" $aCoords[0] = @DesktopWidth - $width $aCoords[1] = Int((@DesktopHeight - $height) / 2) Case "bottomleft" $aCoords[0] = 0 $aCoords[1] = @DesktopHeight - $height Case "bottomcenter" $aCoords[0] = Int((@DesktopWidth - $width) / 2) $aCoords[1] = @DesktopHeight - $height Case "bottomright" $aCoords[0] = @DesktopWidth - $width $aCoords[1] = @DesktopHeight - $height Case Else ;"center" $aCoords[0] = Int((@DesktopWidth - $width) / 2) $aCoords[1] = Int((@DesktopHeight - $height) / 2) EndSwitch $aCoords[2] = $aCoords[0] + $width $aCoords[3] = $aCoords[1] + $height $aReturn = _ImageSearch_Desktop($Image, $aCoords[0], $aCoords[1], $aCoords[2], $aCoords[3], $TransColorRGB) $error = @error Switch $error Case 0 Return $aReturn Case 1 Return SetError(1, 1, '') Case 2 Return SetError(2, 2, '') EndSwitch EndFunc ;==>_ImageSearch_Position It finds it! I think the reason is that my desktop is quite big (1920x1200), and the original code 'get lost'. As I know that the icon is located in a specific area of the desktop, I can search in a smaller area. Anyway, thanks a lot for your code!
  2. Hi! Thanks for your interest... but the '$GUI_DISABLE' thing it's a feature, not a bug Actually, I enable the button a bit later, when the user selects an actual option from the combo box: ... If GUICtrlRead($cmbMode) = $acmbMode[$i] Then $strMode = $astrMode[$i] GUICtrlSetData($lblExplanation, $alblExplanation[$i]) GUICtrlSetState($btnOK, $GUI_ENABLE) <------------- ExitLoop ... EndIf
  3. Thanks a lot!!! I didn't notice the size of the label control because I didn't use Koda (BTW, it's a wonderful tool) Yeah: I did modify the label size and button position... it works!!! BR
  4. Hi all, This is my first post in the AutoIt forum... I'm a newbie, but I used AutoIt to develop an internal tool in my company; long to explain, but we need to convert some CAD files (3D models and drawings) into a new format, and instead of click, click, select, etc. thousands of times, I tried to use AutoIt. I managed to do all the conversion, but I wanted to put some 'icing on the cake', creating a form to let the user select what type of conversion he/she wants to do. Actually, it's my first form, and it's driving me nuts! It's very easy: one combo box with 3 different options. When the user selects one option from the combo box, an explanation appears, and he/she can click 'OK'. The thing is... I can't click on the button (it's not working) I suppose it's just a silly mistake of mine, but I can't find it, and I've read a lot of tutorials, forum posts, etc... Can someone help me? Code follows: #region Include #include-once #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #endregion Include #region AutoItSetOption Opt("GUIOnEventMode", 1) #endregion AutoItSetOption #region Input Form definition Local $frmInput = GUICreate("Conversion tool", 300, 200, -1, -1) Local $lblTitle = GUICtrlCreateLabel("Please, select elements to convert:", 65, 15, 170, 17, $SS_CENTER) Local $acmbMode[3] $acmbMode[0] = "Convert drawings and parts" $acmbMode[1] = "Only convert parts" $acmbMode[2] = "Convert drawings and assemblies" Local $cmbMode = GUICtrlCreateCombo("", 45, 45, 210, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetOnEvent(-1, "_cmbModeFunction") ;Set the combo box's function GUICtrlSetData(-1, $acmbMode[0] & "|" & $acmbMode[1] & "|" & $acmbMode[2]) Local $alblExplanation[3] $alblExplanation[0] = "Parts and drawings" & @LF & "will be converted and linked" $alblExplanation[1] = "Only parts will be converted" $alblExplanation[2] = "Assemblies and drawings" & @LF & "will be converted and linked" & @LF & @LF & "Assemblies must exist on input folder!" Local $lblExplanation = GUICtrlCreateLabel("", 45, 90, 210, 100, $SS_CENTER) Local $btnOK = GUICtrlCreateButton("&OK", 125, 160, 50, 25) GUICtrlSetOnEvent(-1, "_btnOKFunction") ;Set the button's function GUICtrlSetState(-1, $GUI_DISABLE) GUISetOnEvent($GUI_EVENT_CLOSE, "_frmExitGUIFunction") ;What function to call when we try close the GUI #endregion Input Form definition GUISetState(@SW_SHOW) Local $astrMode[3] $astrMode[0] = "3D+2D" $astrMode[1] = "3D" $astrMode[2] = "ASSY+2D" Global $strMode = $astrMode[0] ;Endless While loop to keep the GUI Open While 1 Sleep(10); So we don't use heaps of CPU WEnd #region Event functions Func _cmbModeFunction() For $i = 0 To 2 If GUICtrlRead($cmbMode) = $acmbMode[$i] Then $strMode = $astrMode[$i] GUICtrlSetData($lblExplanation, $alblExplanation[$i]) GUICtrlSetState($btnOK, $GUI_ENABLE) ExitLoop EndIf Next EndFunc ;==>_cmbModeFunction Func _btnOKFunction() MsgBox(64, "Mode...", $strMode) ;Check! GUIDelete() ;It closes the window EndFunc ;==>_btnOKFunction Func _frmExitGUIFunction() Exit ;Exit the program EndFunc ;==>_frmExitGUIFunction #endregion Event functions MsgBox(65, "Return value...", $strMode) ;Final check ($strMode is used after) Thanks in advance!
×
×
  • Create New...