Sign in to follow this  
Followers 0
narayanjr

ComboBox Help

18 posts in this topic

Is there a way to limit the height of the box when the pull down menu is clicked? Right now the list is so long that it covers the Buttons on the Gui Its not really a big deal since once an item is clicked the list disappears and you can see the buttons again but it would look nicer.

Maybe around 150pixels.

I'm using this code to take all the files on my desktop and put them into a ComboBox but it adds the total number of files found as one of the values in the array so it puts that into the Combobox. How do I stop it from adding that number to the Combo Box? Thanks.

$FileList = _FileListToArray(@DesktopDir)
GUICtrlDelete($CBox)
$CBox = GUICtrlCreateCombo("Choose...", 8, 16, 169, 25)

For $i = 0 To UBound($FileList) - 1
    GUICtrlSetData($CBox,$FileList[$i],"") 
Next

Share this post


Link to post
Share on other sites



Default list height is 30 items.

To change it, include the GuiCombo.au3 and use the _GUICtrlComboSetMinVisible() function:

#include <GuiCombo.au3>
#include <file.au3>
#include <GuiConstants.au3>

GUICreate("myGui")
$FileList = _FileListToArray(@DesktopDir)
;GUICtrlDelete($CBox)
$CBox = GUICtrlCreateCombo("Choose...", 8, 16, 169, 5)
_GUICtrlComboSetMinVisible($CBox,10);  limits dropdown to 10 items, scroll for rest


For $i = 0 To UBound($FileList) - 1
    GUICtrlSetData($CBox,$FileList[$i],"")
Next

GUISetState()

While 1
    $msg = GUIGetMsg()
   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend

Share this post


Link to post
Share on other sites

Thank you ResNullius.

Does anyone know how to get rid of the number?

Share this post


Link to post
Share on other sites

I got rid of the number by change the for loop to start at 1 not 0.

Is there an easy way to Hide desktop icons? i know i could do it with mouseclick but is there a way to change a registry or some thing i can type into cmd.exe that will hide them and show them? Thanks

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you ResNullius.

Does anyone know how to get rid of the number?

What number?

Also, I just noticed that on Windows 2000, the number of selections shown is not affected by the _GUICtrlComboSetMinVisible() function, it's affected by the height attribute of the combobox so if you're code is going to run in a multi OS environment, you might want to set the height attribute to the "default keyword". On Win 2000 with my current config, that makes the dropdown show about 9 entries. BTW, the _GUICtrlComboSetMinVisible() doesn't do anything in Win 2000 so it doesn't hurt to leave it in and just set it for those using XP.

Edited by ResNullius

Share this post


Link to post
Share on other sites

The _FileToArray() function makes the First value in the array the number of files it found. So on my desktop i have 44 icons so when you clicked the pull down menu it said 44, then the rest of the icons but i got rid of that. Its only meant for my computer and if anyone else wants it but its not really meant to be used by a lot of people its just for me since i have so many icons on my screen sometimes i just get tired of looking and i want to see them on in the gui not on the desktop i know i could just use the Desktop folder but thats not fun and i wanted to work with more things in autoit. Now I need to know if there are registry keys that I can change so that I can hide and show the icons on my desktop. or I could move all the icons to a folder somewhere else on my computer but i want to be able to put them all back onto the desktop just like they were and I have no idea where to start with trying to put them all back, so I figure that if there are registry keys i could just hide and show them when needed.

Share this post


Link to post
Share on other sites

Is there an easy way to Hide desktop icons?

This will toggle the icons on/off, but beware that you can't interact with the desktop in the normal way with them hidden,ie: can't right-click to bring up display properties, etc.

If BitAnd(WinGetState("Program Manager"),2) then ;checks to see if visible
    WinSetState("Program Manager","",@SW_HIDE)
else
    WinSetState("Program Manager","",@SW_SHOW)
EndIf

Share this post


Link to post
Share on other sites

Ok i got the registry keys to hide the icons and show them again and right now I'm using _Refresh() to refresh it but every time i run it it makes the menu bar(or what ever its called the thing with the start button) disappear and reappear and it reloads all the icons that were there then it opens My Documents. Making the menu bar disappear isn't a big deal but i don't want it to open my documents. I don't really want it to reload the menu bar either. Is there another way i can refresh it so that it hides/shows the icons without closing and then opening explorer.exe?

Func _Refresh()
    Local $process = "explorer.exe"
    Do
        ProcessClose($process)
    Until Not ProcessExists($process)
    Run($process)
EndFunc

Share this post


Link to post
Share on other sites

Ok i got the registry keys to hide the icons and show them again ...

Is there another way i can refresh it so that it hides/shows the icons without closing and then opening explorer.exe?

What Reg keys are you using? There may be another way to refresh depending on the keys. Can you post that portion of your script?

Share this post


Link to post
Share on other sites

$Visible = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideIcons")
If $Visible = 1 Then
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideIcons", "REG_DWORD", 0)
    _Refresh()
EndIf

thats to hide them and to show them i just change the 2 numbers around

Share this post


Link to post
Share on other sites
$Visible = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideIcons")
If $Visible = 1 Then
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideIcons", "REG_DWORD", 0)
    _Refresh()
EndIfoÝ÷ ÚØZ¶Ëh'^¶¦jwm¢ÈhÂØ^(î²×!jx¶¶éz»®§wú®¢×¯+aÇè®ÈhÂ)àþxzÉ-¢¢{0)^²Ø¥W¾)ණzËh~Ø^uë$¶ZrدxÚ'_¢ºÞ+-¯)ÊÊ+­ë-j»b±¦Z+z´zk-è¢{­ê'juéÜ)]Â)Ý£
¶zÉ-¢®¶­sbb33c´6öäÆW#Ò6öçG&öÄvWDæFÆRgV÷Cµ&öw&ÒÖævW"gV÷C²ÂgV÷C²gV÷C²ÂgV÷Cµ4TÄÄDÄÅôFVefWsgV÷C²¤6öçG&öÄFRb33c´6öäÆW"ÂgV÷C²gV÷C²ÂgV÷Cµ74Æ7EfWs3#gV÷C²¤×6t&÷ÂgV÷C²gV÷C²ÂgV÷C´FFVââgV÷C²fײ5$ÄbfײgV÷C·&W72ô²Fò6÷rgV÷C²¤6öçG&öÅ6÷rb33c´6öäÆW"ÂgV÷C²gV÷C²ÂgV÷Cµ74Æ7EfWs3#gV÷C²

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

That works perfect Thanks again. Sadly I found one more thing wrong. When _FileListToArray() runs for some reason it doesnt get all of the icons. It doesn't get FireFox, Norton, Intel Desktop Monitor, Logitech Mouse and Keyboard Settings, Netgear Wireless Adapter or the Recycle Bin.

Edited by narayanjr

Share this post


Link to post
Share on other sites

That works perfect Thanks again. Sadly I found one more thing wrong. When _FileListToArray() runs for some reason it doesnt get all of the icons. It doesn't get FireFox, Norton, Intel Desktop Monitor, Logitech Mouse and Keyboard Settings, Netgear Wireless Adapter or the Recycle Bin.

Could they be on the "All Users" desktop (@DesktopCommonDir) ?

Share this post


Link to post
Share on other sites

Yup that was it made it a little bit more complicated since i wanted to keep them all in order but i got it to work Thank you very much ResNullius for all your help I couldn't have done it without you. If you want the full code with all the fixes I will send it to you if want just send me a PM.

Share this post


Link to post
Share on other sites

Try this for showing/hiding desktop icons, while still leaving the rest of the desktop active. No need for registry keys or restarting explorer.

Seems the icons are on a hidden child window of the desktop:

$IconLayer= ControlGetHandle("Program Manager","","SHELLDLL_DefView1")
ControlHide($IconLayer,"","SysListView321")
MsgBox(0,"","Hidden." & @CRLF & "press OK to show")
ControlShow($IconLayer,"","SysListView321")oÝ÷ Ûú®¢×áå¢,)¶«{ljÉZk¡¹^ë"aɶ!ü¨¹ÉbrKaz«¨µ(hÀ7¬Ú)ªê-Ê'¢{az«¢rIZºw!mªÛyú+{*.{º×­+¡×°éò¢è(¶buëaz'(ËazÖ¬¶«Â)ev+¦­·¢
Þ׫yا¾+"nWÛaz'(Ë-Yl(Ø^uë$¶h!ü¨º»§jÈh®×.µúèØ^uë$¶mè¢{0YméÝÆ©¥æ«jwmëZ²FÚ®ËZÊÈbuקFéíç(uëh²0¶¢rìjwg¢ØbZ¦§±.~*춯zÚ+º{(ç(uëh²0¶­jÉj¶®¶­sd÷Bb33µtåDDÄTÔD4ÔôDRb33²ÂB¤6öçG&öÅ6÷rb33¶6Æ76æÖSÕ6VÆÅõG&væBb33²Âb33²b33²Âb33²b33²

and then you have to use the "Show Desktop" icon again to actually restore your icons!

I've tried combining the show taskbar code into the hide/show icon code, but not really working as planned. I think we might have to implement a toggle desktop line into the code too. Especially for the "failsafe" restore. I have only tested on Windows 2000 so far, but I imagine it's the same on XP and probably also with the right click on taskbar and "show desktop" option...

Share this post


Link to post
Share on other sites

I cant get it to make the task bar disappear after hitting the show desktop button then running the code. and I tested Right Click Show Desktop Icons when they are hidden like that and the code is run to show the icons instead of having a transparent background around the text of the icons its black with the text in white. I could put the registry key back into the fail safe just to be sure i guess. Since Right Click Show Desktop Icons does change the registry. But I have not been able to replicate the problem with the disappearing task bar. But I found one more problem and not sure why it does it. If i run the program and hit clear the first time it sets the combo box text to Choose... but after the first hit every time I hit it, it changes the text to Norton Systemworks.lnk I have no idea why it wouldn't go back to Choose... like it is suppose to.

Share this post


Link to post
Share on other sites

OH-OH... looks like there's a small problem using this method. If you click the "Show Desktop" icon on the quick launch bar before you execute this code, when you go to hide the icons the taskbar will disappear, being rendered invisible, and the icons still show on the desktop.

OK, the problem with the disappearing task bar was my fault because I was fiddling with the original code and tried some WinSetState() commands instead of the ControlHide()/ControlShow().

But, it's still possible to have a problem where the toggling of desktop icons won't work properly. It shouldn't/won't affect your application because you'll always have a window (your GUI) display when the toggling happens. Still, here's what I found:

  • Compile the following code leaving the first line commented out and put the exe or a link to it on your desktop, or your Quick Launch bar.
  • Click the "Show Desktop" icon on the quick launch, or right-click the task bar and choose "Show Desktop".
  • Now, without opening any other apps, run the exe from the desktop shortcut or the quick launch. You should see that the icons remain.
Next, uncomment the first line, recompile and repeat the above steps (show desktop, run exe) and it works as intended. It appears to be something with the taskbar being updated somehow. In the first scenario, if you open any app, or restore any window, or even put a message box into the script at the start, it will work as intended. It has to do with the taskbar, because in the second scenario, if you apply the WS_EX_TOOLWINDOW to the $DeskTopReset Gui, then it won't work; it behaves exactly as in the first scenario. I've fiddled a little with sending messages to the task bar but can't seem to find the right combination.

;_DeskTopReset() ;uncomment to make it work as intended

If ControlCommand("Program Manager","","SysListView321", "IsVisible") then
    ControlHide("Program Manager","","SysListView321")
else
  ControlShow("Program Manager","","SysListView321")
EndIf

Func _DeskTopReset()
    $DeskTopReset = GuiCreate("MY GUI",1,1,-50,-50)
    GuiSetState(@SW_SHOW,$deskTopReset)
    GuiDelete($deskTopReset)
EndFuncoÝ÷ Ù³hµæ¥²Ûb¢}ý¶wvØ^jëh×6$IconLayer= ControlGetHandle("Program Manager","","SHELLDLL_DefView1")
line I originally suggested as the SysListView can be deteced directly through the "Program Manager" window.

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  
Followers 0