Jump to content

Recommended Posts

Posted (edited)
#AutoIt3Wrapper_UseX64=y
#include <GuiListView.au3>

Func _SetShortcutPos($Name = "", $X = 0, $Y = 0)
    Local $Desktop = ControlGetHandle("[CLASS:Progman]", "", "[CLASS:SysListView32;INSTANCE:1]")
    Local $Pos = _GUICtrlListView_FindInText($Desktop, $Name)

    If $Pos == -1 Then
        ConsoleWrite("Could not find icon: " & $Name & @CRLF)
        Return
    EndIf

    _GUICtrlListView_SetItemPosition($Desktop, $Pos, $X, $Y)
    ConsoleWrite("Set position of " & $Name & " to (" & $X & ", " & $Y & ")" & @CRLF)
EndFunc   ;==>_SetShortcutPos

This code works beautifully on W11 does not work at all on W10

Any guesses as to why? Both systems are X64, and the API would be more likely to lose something than gain it in that regard...

Edited by Jos
tidied the code
Posted

It does, I just did not call the function because it seemed implied....

 

_SetShortcutPos("test",100,150)

Where there is an icon on the desktop named "test.lnk"

Reports icon not found because 

_GUICtrlListView_FindInText

Returns -1 in w10 system, returns correctly on w11 allowing the subsequent move to specified x-y cords.

Posted (edited)

 

; https://www.autoitscript.com/forum/topic/210280-_guictrllistview_findintext-and-windows-10/#comment-1518544

#AutoIt3Wrapper_UseX64=y
#include <GuiListView.au3>

_SetShortcutPos("Recycle Bin", 0, 0)

Func _SetShortcutPos($Name = "", $X = 0, $Y = 0)

    ConsoleWrite("[CLASS:Progman]=" & WinGetHandle("[CLASS:Progman]") & @CRLF)

    Local $hDesktop = _WinGetDesktopHandle()
    ConsoleWrite("$hDesktop=" & $hDesktop & @CRLF)

    Local $hDesktopCtrl = ControlGetHandle($hDesktop, "", "[CLASS:SysListView32;INSTANCE:1]")
    ConsoleWrite("$hDesktopCtrl=" & $hDesktopCtrl & @CRLF)

    Local $Pos = _GUICtrlListView_FindInText($hDesktopCtrl, $Name)
    ConsoleWrite("$Pos=" & $Pos & @CRLF)

    If $Pos == -1 Then
        ConsoleWrite("Could not find icon: " & $Name & @CRLF)
        Return
    EndIf

    _GUICtrlListView_SetItemPosition($hDesktopCtrl, $Pos, $X, $Y)
    ConsoleWrite("Set position of " & $Name & " to (" & $X & ", " & $Y & ")" & @CRLF)

EndFunc   ;==>_SetShortcutPos
;----------------------------------------------------------------------------------------
; http://www.autoitscript.com/forum/topic/119783-desktop-class-workerw/page__view__findpost__p__903081
; ===============================================================================================================================
; <_WinGetDesktopHandle.au3>
;
; Function to get the Windows' Desktop Handle.
;   Since this is no longer a simple '[CLASS:Progman]' on Aero-enabled desktops, this method uses a slightly
;   more involved method to find the correct Desktop Handle.
;
; Author: Ascend4nt, credits to Valik for pointing out the Parent->Child relationship: Desktop->'SHELLDLL_DefView'
; ===============================================================================================================================
; Example use:
#cs
    #include <GuiListView.au3>
    $iTimer = TimerInit()
    $hDeskWin = _WinGetDesktopHandle()
    $h_Listview_Configs = HWnd(@extended)
    ConsoleWrite("Time elapsed:" & TimerDiff($iTimer) & " ms" & @CRLF)
    $iDeskItems = _GUICtrlListView_GetItemCount($h_Listview_Configs)
    ConsoleWrite("Handle to desktop: " & $hDeskWin & ", Title: '" & WinGetTitle($hDeskWin) & "', Handle to Listview: " & $h_Listview_Configs & ", # Items:" & $iDeskItems & ", Title: " & WinGetTitle($h_Listview_Configs) & @CRLF)
    MsgBox(0, "Desktop handle (with ListView) found", "Handle to desktop: " & $hDeskWin & ", Title: '" & WinGetTitle($hDeskWin) & "'," & @CRLF & "Handle to Listview: " & $h_Listview_Configs & @CRLF & "# Desktop Items:" & $iDeskItems)
#ce

Func _WinGetDesktopHandle()
    Local $i, $hDeskWin, $hSHELLDLL_DefView, $h_Listview_Configs
    ; The traditional Windows Classname for the Desktop, not always so on newer O/S's
    $hDeskWin = WinGetHandle("[CLASS:Progman]")
    ; Parent->Child relationship: Desktop->SHELLDLL_DefView
    $hSHELLDLL_DefView = ControlGetHandle($hDeskWin, '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]')
    ; No luck with finding the Desktop and/or child?
    If $hDeskWin = '' Or $hSHELLDLL_DefView = '' Then
        ; Look through a list of WorkerW windows - one will be the Desktop on Windows 7+ O/S's
        $aWinList = WinList("[CLASS:WorkerW]")
        For $i = 1 To $aWinList[0][0]
            $hSHELLDLL_DefView = ControlGetHandle($aWinList[$i][1], '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]')
            If $hSHELLDLL_DefView <> '' Then
                $hDeskWin = $aWinList[$i][1]
                ExitLoop
            EndIf
        Next
    EndIf
    ; Parent->Child relationship: Desktop->SHELDLL_DefView->SysListView32
    $h_Listview_Configs = ControlGetHandle($hSHELLDLL_DefView, '', '[CLASS:SysListView32; INSTANCE:1]')
    If $h_Listview_Configs = '' Then Return SetError(-1, 0, '')
    Return SetExtended($h_Listview_Configs, $hDeskWin)
EndFunc   ;==>_WinGetDesktopHandle

out:

[CLASS:Progman]=0x0000000000010154
$hDesktop=0x00000000000B0294
$hDesktopCtrl=0x000000000001015A
$Pos=10
Set position of Recycle Bin to (0, 0)

 

Edited by ioa747
UpDate

I know that I know nothing

Posted
2 hours ago, Andreik said:

What about this line?

Local $Desktop = ControlGetHandle("[CLASS:Progman]", "", "[CLASS:SysListView32;INSTANCE:1]")

What it returns on win 10?

The same handle for the SysListView32 control that autoit_info does.

Posted

Tested on an installed one, no joy, installed a new clean one to be sure, still no joy... Version information attached.

2023-05-24_17-10.png

Posted
1 hour ago, ioa747 said:

 

"ioa747"

...._WinGetDesktopHandle....
Truncated for brevity :-)

 

CLASS:Progman]=0x00010114
$hDesktop=0x00010114
$hDesktopCtrl=0x00010118
2525$Pos=-1

2023-05-24_17-18.png

Posted

The function you are trying to use is based on another simpler function.  Could you run this and report console :

#AutoIt3Wrapper_UseX64=y
#include <GuiListView.au3>

Local $Desktop = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
ConsoleWrite($Desktop & @CRLF)
Local $iCount = _GUICtrlListView_GetItemCount($Desktop)
ConsoleWrite($iCount & @CRLF)
For $i = 0 to $iCount - 1
  ConsoleWrite(_GUICtrlListView_GetItemText($Desktop, $i) & @CRLF)
Next

 

Posted (edited)

What you showed me in the console report is a 32 bits handle, not a 64 bits.  There is something wrong in there...

Are you really -- really sure you are running it x64 ?

Edited by Nine
Posted

So I can confirm the Windows 11 system does return the x64 handles, they are running as VMs on the same hypervsisor, and used same auto it installer...

 

0x0000000000160844
28

2023-05-24_19-47.png

Posted

I can also confirm after installing on a fresh windows 10 system using the "Use native x64 tools by default" handles are still x86.

I had assumed the usex64 directive was doing a translation here.

Direct running the script with the x64 version of autoit executable from the commandline does not work, and I cannot find a way to edit the scite install to use it by default.

Posted (edited)

Maybe @Jos can confirm, but you may need to have full version of Scite to enable x64 wrapper to work.  Anyway, your script will never work until you find a way to run it x64.

ps.  maybe it is your VM soft that is causing all your problems

Edited by Nine
  • Developers
Posted (edited)
6 hours ago, Nine said:

you may need to have full version of Scite to enable x64 wrapper to work. 

The full version is required or else the x86 version is ran by SciTE!
The easiest way to get confirmation is to show the SciTE Ouput pane information generated when the script is ran.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Au contraire...

I renamed the AutoIt.exe to AutoIt3_x86 and make a hard symlink to it by the original name.

Worked fine, so removed the hardlink, and recreated to the _x64, worked fine too. As well solved the original issue.

mklink /h "C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe"

Created a new shell handler for "Debug x86" and one for "Debug x64"

So now can selectively swap back and forth to the x86/x64 version at will in scite.

Presumably a script to do renaming would work as well, and not require admin elevation, but you would have to change security on its program file directory so 6 of one 1/2 dozen of the other. The elevation is cleaner from a security stand.

and... Robert's your mother's brother!

I figured I would contribute that back for the assistance received.

Thank you to all that helped.

  • Developers
Posted (edited)

Using the full SciTE installer and using the directives is way more simple and keeps things flexible, but whatever makes you tick! ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

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