Jump to content

PixelSearch - Edited [RESOLVED]


Alias
 Share

Recommended Posts

Is there a better way to find a shortcut/icon on the screen?? I can't find the item I am looking for. I have used AIT Window Viewer to get the correct color.

I am trying to find certain icons/shortcuts on the desktop so I can click and drag them to specific areas on the desktop......but PixelSearch only finds certain items and is unreliable.

There must be a better way.

Thanks.

******************************** UPDATE ************************************

I managed to get it to work very reliably (as long as another icon has the exact same color DOESN'T end up on the screen) It turns out it is very difficult at times to find the proper color code, even when using AIT Window Viewer, for some reason many colors of an icon will not be found during the search. The reliable way to find an actual color of an icon was to use PixelGetColor() shown below, put in the coordinates of the icon area you deem to be unique. Using the number it finds worked everytime for me I put my script in below, if anyone would like to make any suggestions that would be cool, I am always open to learning better ways to do stuff.

;find HEX#
$var = PixelGetColor( 1226 , 923 )
MsgBox(0,"The hex color is", Hex($var, 6))

;Arranges specific icons on the desktop.

; *************************************************** Declarations ******************************************

Local $Dragon[4]
$Dragon[0] = "CallArgArray"     
$Dragon[1] = 0xF0B1A2           ; This color seems unique to Dragon
$Dragon[2] = @DesktopWidth - 55 ; icon position X
$Dragon[3] = 25                 ; icon position Y (from top of the screen)

Local $Kurzweil[4]
$Kurzweil[0] = "CallArgArray"   
$Kurzweil[1] = 0x26789E         ; This color seems unique to Kurzweil.
$Kurzweil[2] = @DesktopWidth - 55; icon position X
$Kurzweil[3] = 100              ; icon position Y (from top of the screen)

Local $Books[4]
$Books[0] = "CallArgArray"  
$Books[1] = 0x93F85E            ; This color seems unique to Kurzweil.
$Books[2] = @DesktopWidth - 55  ; icon position X
$Books[3] = 150                 ; icon position Y (from top of the screen)

Local $ReadWrite[4]
$ReadWrite[0] = "CallArgArray"  
$ReadWrite[1] = 0x6B9D2B        ; This color seems unique to SOLO
$ReadWrite[2] = @DesktopWidth - 55; icon position X
$ReadWrite[3] = 250         ; icon position Y (from top of the screen)

Local $SOLO[4]
$SOLO[0] = "CallArgArray"   
$SOLO[1] = 0xBD920D             ; This color seems unique to SOLO
$SOLO[2] = @DesktopWidth - 55   ; icon position X
$SOLO[3] = 300              ; icon position Y (from top of the screen)

Local $WordQ[4]
$WordQ[0] = "CallArgArray"  
$WordQ[1] = 0xFA6801            ; This color seems unique to Dragon
$WordQ[2] = @DesktopWidth - 55  ; icon position X
$WordQ[3] = 380                 ; icon position Y (from top of the screen)

Local $TrashCan[4]
$TrashCan[0] = "CallArgArray"   
$TrashCan[1] = 0xDEFFFF         ; This color seems unique to Dragon
$TrashCan[2] = @DesktopWidth - 55   ; icon position X
$TrashCan[3] = 930              ; icon position Y (from top of the screen)

Local $array[7]=[0,0,0,0,0,0,0] ; clear array of any contents
Local $array[7]=[$Dragon, $Kurzweil, $Books, $ReadWrite, $SOLO, $WordQ, $TrashCan]


; ********************************************************* Main ************************************************

For $i=0 To UBound($array)-1
    Call("FindIcons", $array[$i])
Next
    
        
Func FindIcons($sColor, $sXPos, $sYPos)
    Local $x=0                  ;set flag to zero 
    Dim $coord[2]
    
    While $x <> -1
        $coord = PixelSearch( 0, 0, @DesktopWidth, @DesktopHeight, $sColor, 0, 0 )  

        If Not @error Then
            $var1=$coord[0]
            $var2=$coord[1]
            MouseClickDrag("left", $coord[0], $coord[1], $sXPos, $sYPos, 1);click & drag an icon
            $x=-1               ; Sets flag to exit loop
        Else
            MsgBox(1,"Info","No icon found", 1)
            $x=-1
        EndIf
        
    WEnd
    
EndFunc
Edited by Alias
Link to comment
Share on other sites

All the shortcuts on your desktop are located in either or both: (if using XP)

@DesktopDir - This is the macro for path to current user's Desktop

@DesktopCommonDir - Common directory for desktop

Look in the help file under Macro Reference > Directory Macros

Simply get a list of files using this example as your guide.

; Shows the filenames of all files in the current directory
$search = FileFindFirstFile("*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)
Edited by Volly
Link to comment
Share on other sites

All the shortcuts on your desktop are located in either or both: (if using XP)

@DesktopDir - This is the macro for path to current user's Desktop

@DesktopCommonDir - Common directory for desktop

Look in the help file under Macro Reference > Directory Macros

no no.. he's trying to actually *MOVE* the icon locations on his desktop, not move the shortcuts themselves. Like find them and drag them to where he wants them.

Link to comment
Share on other sites

Found this.

http://www.msfn.org/board/lofiversion/index.php/t22555.html

It talks about registry keys. You may be able to get the keys you need, then simply update the registry after sysprep.

Thanks Volly but I don't think this will work with what I am trying to do. I will have unknown applications installed during sysprep (guirunone), the programs will be some what unknown, so each sysprep could be different...... That is why I have to search for the name and then place where I want on the desktop based on which program it is.

I am suprised you can simply find icons/shortcuts as easily as a window.......but I am a noob so, I am sure there is a reason.

Edited by Alias
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...