Jump to content
Sign in to follow this  
CloudD901

no ListView with Win7 (32 or 64)

Recommended Posts

CloudD901

Hello, I hope someone would be able to assist with my problem.

I've been using a program for a while on Windows XP.

Now, we are switching to Windows 7 (32) and part of my scripts stopped working.

I found that anything related to _GUICtrlListView_ is giving me trouble.

The code to get the handle of the main window and the handle of the SysListView32 works.

The following examples are trying to find an "Issue Number" of a multicolumn ListView.

This example returns 0 (even when entering the handle manually and "Issue Number" exists).

$Line = _GUICtrlListView_FindText($list, "Issue Number")

This example returns blank (even when entering the handle and line manually).

$IssueNumber = _GUICtrlListView_GetItemText($list, $Line, 1)

Please let me know if any further information is needed.

I've tested this on x64 and 32 bit Win7.

Thanks!

Edited by cloudd901

Share this post


Link to post
Share on other sites
BrewManNH

Is the text "Issue Number" in the first column of the ListView? What version of AutoIt are you using? Can you post a short reproducer script that shows the problem? As it is now, it's hard to reproduce it without reinventing your code with no idea how you wrote it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
CloudD901

Sorry about that.

Autoit v3.3.8.0 (Win7) v3.3.6.0 (WinXP)

SciTE v2.28

Cisco Agent v8.0.2.200 (Program with ListView)

My scripts is actually about 2600 lines.

This is the trimmed version of the part of my script giving the issue.

This same script works fine in Windows XP (both 32bit).

Tested script compiled under both XP and 7 using 3.3.6.0 and 3.3.8.0.

-Verified that $Agent is correct. Verified $list is correct. $Line returns 0. $Queue returns blank.

#include <Array.au3>
#include <Constants.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>

$Agent = GetAgentHandle()
If Not @error Then
  ConsoleWrite(@CRLF & $Agent)
  $list = ControlGetHandle($Agent, "", "[CLASS:SysListView32; INSTANCE:2]")
  If Not @error Then
   ConsoleWrite(@CRLF & $list)
   $Line = _GUICtrlListView_FindText($list, "CSQName")
   $Queue = _GUICtrlListView_GetItemText($list, $Line, 1)
  Else
   TrayTip("Cisco Assistant", "Failed to Find ListView Handle.", 7, 17)
  EndIf
Else
  TrayTip("Cisco Assistant", "Failed to Find the Cisco Agent.", 7, 17)
EndIf
MsgBox(0,"",$Queue)

Func GetAgentHandle()
Local $Agent
$Agent = WinGetHandle("Reserved - Cisco Agent Desktop")
If @error Then
  $Agent = WinGetHandle("Talking - Cisco Agent Desktop")
  If @error Then
   $Agent = WinGetHandle("Work - Cisco Agent Desktop")
   If @error Then
    $Agent = WinGetHandle("Ready - Cisco Agent Desktop")
    If @error Then
     $Agent = WinGetHandle("Not Ready - Cisco Agent Desktop")
     If @error Then
      $Agent = WinGetHandle("Cisco Agent Desktop")
     EndIf
    EndIf
   EndIf
  EndIf
EndIf
If $Agent = "" Then SetError(1)
Return $Agent
EndFunc   ;==>GetAgentHandle

Posted Image

By cloudd901 at 2012-01-11

Please let me know if you have any thoughts or ideas. There has to be some difference between XP and Win7 when reading this ListView.

Edit:

I've had time to test some more tonight and still no luck.

I've tried changing "_GUICtrlListView_GetItemText" and "_GUICtrlListView_FindText" with "ControlListView".

Still the same results. Works on XP but not Win7.

Tried combinations of "Name or Handle" for the Window with "ClassnameNN or Handle or Advanced Info" for the Control.

Any other way of getting information from a ListView control?

Edit 2:

... I'm speachless ...

The ammount I worked on this just to find the simplest solution is crazy.

I went through every step of the _ListView_FindText() function and found the fault.

I found that I was getting an access error in the internal memory function __Mem_OpenProcess().

This could only mean one thing.......... UAC.

#RequireAdmin seems to be the best rout to ensure a working script. :)

Edited by cloudd901

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • ammaul
      By ammaul
      Hi folks, I'm having problems with a screenshot capture script.
      Let me explain.
      Everyday I (and my colleagues at work) need to take some screenshots from a web-page. These screenshots are used to compile a report. Normally, I (and others) used to log in into the website and took screenshots of desired graphics and tables. This is tediuos and time consuming. To easy this task I made a script using autoit that basically logs into the website (user and password) and using some clicks, stroke send, coordinates, it is able to generate the graphics and save them to some folders into our network (this script saves arouund 50 pics. It works like a sharm.
      In order to make things easier, I tried to schedule this script (compiled to a Screnpics.exe file) using task scheduler from windows. We already use this (task scheduler) to run some vbs scripts, some vba excel scripts and so on. The computer used for this tasks is a windows 7 desktop computer. Due to security policies, the computer locks after some time. All this tasks run in the locked computer.
      My script screenpics.exe runs also from this locked computer. When the computer is unlocked, it does everything as expected. But, when it is locked, all the "pics" are BLACK. As I understand, it runs ok, but, as the "windows" are innactive, it prints what it "sees": a black rectangular.
      Some details: The web-page with hold the information I need, it only works in Firefox and, because of this it couldn`t be managed by vba or some "getobject" like commands. In fact, it has some flash things that make it impossible to control programatically. So my script is based on mouse move to coordinates, mouse click, screen capture and so one.
       
      So, I read many posts trying to figure out a way to overcome this, but... nothing came to mind. My first idea was try to unlock windows. Theses lead me to some posts with no solution. This is worse because I'm not a computer admin, so procedures that need to replace/change the register are not an option.
       
      If someone has any idea, I'll be gratefull.
    • therks
      By therks
      Has anybody else noticed that Windows 7 reacts ignorantly when you use the Windows key + arrow key shortcuts on a GUI with GUIEventMode set to 1? I discovered this recently when I was working on an app where I wanted complete control over the maximize/minimize buttons.
      Just give it a spin:
      #include <GUIConstants.au3> Opt('GUIEventOptions', 1) $hGUI = GUICreate('', 300, 200, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE ToolTip('Maximized') Case $GUI_EVENT_MINIMIZE ToolTip('Minimized') Case $GUI_EVENT_RESTORE ToolTip('Restored') Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Run that, then hit Win+Up or Win+Down. None of those events get triggered, and it still maximizes/minimizes. Although I can't get it to restore down from a maximize unless the window is also resizable ($WS_THICKFRAME in the style).
      Is there a way to stop Windows from doing what it wants or is the only option to check with WinGetState() and then change it back?
       
      Windows 10 seems to respect my settings, and I don't have any other versions to test on.
    • Skysnake
      By Skysnake
      I am tracking this topic by @LarsJ.  It is very advanced and overkill for what I am currently trying to do.
       
      Problem is this.
      Listview contains columns, one of which is right aligned and gets populated by float values, such as 123.99.  Some do not have decimals ie 124.00 and on sort gets truncated to 124.  Its obviously still the same value, but the display has reset.
      ; line below is for list VIEW ;..................................0.........1......2............ $cListView = GUICtrlCreateListView("CUSTOMER|AMOUNT|DESCRIPTION", 8, 152, 764, 279) GUICtrlSetBkColor($cListView, $GUI_BKCOLOR_LV_ALTERNATE) ; alternate between the listview background color and the listview item background color GUICtrlSetBkColor($cListView, $LVStdClr) ; Set the background color for the listview _GUICtrlListView_SetColumnWidth($cListView, 0, 120) ; -- the client name _GUICtrlListView_SetColumnWidth($cListView, 1, 90) ;-- the amount _GUICtrlListView_JustifyColumn($cListView, 1, 1) ; 1 - Text is right aligned _GUICtrlListView_SetColumnWidth($cListView, 2, 200) ; the description What I am looking for is something native and simple like a 
          _GUICtrlListView_SetColumnFormat($cListView, 1, "%.2f") ;  1 - column is stringformatted to "%.2f"
      So that after each sort it will appear as it was in the original rendering.
      Is there something like this? I have not been able to find a simple solution.

      Thanks.
      Skysnake
    • msd1994
      By msd1994
      I have a script that just adds some keyboard shortcuts for things like displaying the current song and artist, moving the window to the side so it won't pop up in my way, and play/pause, next song, previous song (these are the only 3 to still work since they don't need the window handle.)
      In some update recently, Spotify's window class swapped from "[CLASS:SpotifyMainWindow]" to "[CLASS:Chrome_WidgetWin_0]". Using the new class in my controls doesn't seem to work, I've tried getting the window handle from the process handle (_GetHwndFromPID($PID)) but that seems to fail as well.
      Does anybody have some idea of a way I could get this script working again?
       
      edit: seems like discord has the same window class name, so could be some issue with this? Still not sure of a way to solve the issue though, I added a function to get the handle of the active window and can just use that now, but it was able to find it on its own before on spotify startup or script startup which would be preferred.
       
      Thanks!
    • Ambient
      By Ambient
      I have tried several way sto get this to work to no avail. Any help would be appreciated. #include <ListViewConstants.au3> #include <GuiListView.au3> #include "GuiListViewEx.au3" $idItem = GUICtrlCreateListViewItem($r & " | " & $c & $adoRs.Fields("TransactionAmount").value & " | " & $Timestamp & " | " & _StringProper($adoRs.Fields("Tillid").value) & @CRLF & @CRLF & "Card Number : " & $cardnum & " " , $idListView) ConsoleWrite( "IDITEM" & $idItem) If STRINGLEFT($adoRs.Fields("TransactionAmount").value,1)= "-" Then Consolewrite(" String is Negative" & @CRLF) ;Drops in Here as expected ;GUICtrlSetColor(-1, $COLOR_RED) ; Colour line if item is negative this didn' work $TxC= _GUICtrlListView_SetTextColor($hListView, $CLR_RED) ; I also tried $TxC= _GUICtrlListView_SetTextColor(-1, 0xFF0000) CONSOLEWRITE("TEXTCOLOUR RETURNED " & $TxC & @crlf) ; This is returning True ELSE Consolewrite(" String is NOT Negative" & @CRLF) EndIf  
×