Jump to content

Auto3Lib


PaulIA
 Share

Recommended Posts

This release contains the first version of the Auto3Lib help file. All of the functions are documented, but I am still working on the examples. The examples will be added and included with the next several releases. For those of you with time to kill, you could contribute to the project by proofing the help file and reporting any errors you find. Since I'm sure there will be a large quantity of typos, please PM/email me the ones you find rather than posting them here. It will make the whole process saner. :whistle:

While working on the help file, I discovered that some of the modules had "get" functions without "set" functions or vice versa. There was also some discrepency between function names, so I took the time to clean this all up.

I added code to the Toolbar demo to show how to add a drop down button with a popup menu. The ImageList module has a few new features that were requested as well.

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Hi Paul,

Thank you very much. As a newbie the included examples are a huge help in the study process. So far just about everything I've set out to learn I've checked for reference in your library first and had luck.

I think I've been through all 20-odd pages of this thread but I didn't come across an issue I'm having with the Win Explorer references while running Vista. The minor difference is that Vista now refers to My Computer as simply "Computer", so waiting for "My Computer" fails. Also, unless I'm doing something wrong; I can't seem to get explorer to launch using the "root" switch like your examples show. It gives me some sort of error about that file not having the correct association or something along those lines. I tried it from the run-line and got the same error so it's probably just part of Vista's new "Don't you dare try anything tech-savvy on my watch!" -policy. Either that or it might require one of the gazillion services which I've disabled. Do you happen to know if the root switch requires that "Plug And Play Korean Toaster Lan Sync" is running? :whistle:

Like I said, just minor but thought you might want to hear about it. I've been getting by just fine with dropping the "My" and switching "/root" to "/e" (or my fave: "/n"), I even have a snippet on standby. :)

Thanks again, mighty kind of you sir.

Link to comment
Share on other sites

pffouuuu

as usual with your release : just awesome !

the help file if clear and simple

now the funny part : how implementing some NTFS and SHARE permissions functions ? I don't know if you have started something like that so i ask ^^

and i've started to study OpenSSL source code and documentation, but i don't really what functions to call (names, parameters) in the dlls

SSL is the major security issue in the TCP functions of autoit, so maybe Autoit3Lib can bring the solution

it's some ideas ... not a request

btw, really good job, i really often use your functions, and more like that, i really like your structure, and the "naming" of the functions, just clear ^^

keep up the good job ! and thx for the community

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

Hi Paul,

Your Help file is very useful...

I want to manage a contextual menu issued from a Listview (SysListView321) item. i obtain this contextual menu with right mouse click.

What's the mean to avoid a handle for this contextual menu to manage it.

Can i use the AL3Menu library ?

Thank you for your reply

Alex

Link to comment
Share on other sites

Hi Paul,

Thank you very much. As a newbie the included examples are a huge help in the study process. So far just about everything I've set out to learn I've checked for reference in your library first and had luck.

I think I've been through all 20-odd pages of this thread but I didn't come across an issue I'm having with the Win Explorer references while running Vista. The minor difference is that Vista now refers to My Computer as simply "Computer", so waiting for "My Computer" fails. Also, unless I'm doing something wrong; I can't seem to get explorer to launch using the "root" switch like your examples show. It gives me some sort of error about that file not having the correct association or something along those lines. I tried it from the run-line and got the same error so it's probably just part of Vista's new "Don't you dare try anything tech-savvy on my watch!" -policy. Either that or it might require one of the gazillion services which I've disabled. Do you happen to know if the root switch requires that "Plug And Play Korean Toaster Lan Sync" is running? :whistle:

Like I said, just minor but thought you might want to hear about it. I've been getting by just fine with dropping the "My" and switching "/root" to "/e" (or my fave: "/n"), I even have a snippet on standby. :)

Thanks again, mighty kind of you sir.

I haven't tested any of Auto3Lib with Vista yet. Hopefully, the functions will work and it will just be a matter of tweaking the demos. Thanks for the feedback though and let me know if you run onto anythng major with Vista and Auto3Lib.
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

pffouuuu

as usual with your release : just awesome !

the help file if clear and simple

now the funny part : how implementing some NTFS and SHARE permissions functions ? I don't know if you have started something like that so i ask ^^

and i've started to study OpenSSL source code and documentation, but i don't really what functions to call (names, parameters) in the dlls

SSL is the major security issue in the TCP functions of autoit, so maybe Autoit3Lib can bring the solution

it's some ideas ... not a request

btw, really good job, i really often use your functions, and more like that, i really like your structure, and the "naming" of the functions, just clear ^^

keep up the good job ! and thx for the community

The only work that I have done with shares is in the A3LNetShare module. That is more related to managing the share itself, not to permissions. I haven't looked into SSL either and it's not on the "to do" list.
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Hi Paul,

Your Help file is very useful...

I want to manage a contextual menu issued from a Listview (SysListView321) item. i obtain this contextual menu with right mouse click.

What's the mean to avoid a handle for this contextual menu to manage it.

Can i use the AL3Menu library ?

Thank you for your reply

Alex

Yes, you can manage a context menu with Auto3Lib. There are several ways to do this, depending on if you are managing an AutoIt ListView or a ListView in another application. If the ListView was created in AutoIt, it's fairly straight forward. You might want to look at the Context.au3 file in the Auto3Lib Misc folder. It shows how to trap the WM_CONTEXTMENU message and display a context menu.

If you want to manage a context menu in an external application, it is still fairly easy to do. The following snippet shows how to manipulate a context menu in Explorer:

#include <A3LMenu.au3>
#include <A3LListView.au3>

Global $hList, $hMenu, $iI

; Open Explorer
Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
_Lib_WinWaitActive("My Computer")

; Get a handle to the ListView
$hList = ControlGetHandle("My Computer", "", "SysListView321")
if $hList = 0 then _Lib_ShowError("Unable to obtain ListView handle")

; Right click on the second item (usually the C: drive)
_ListView_ClickItem($hList, 1, "right", False, 1, 1, True)

; Get the handle to the popup menu
$hMenu = _Lib_PopupGetHwnd()

; From here, you can use $hMenu in all the A3LMenu functions
for $iI = 0 to _Menu_GetItemCount($hMenu) - 1
  _Lib_ConsoleWrite(_Menu_GetItemText($hMenu, $iI))
next
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Paul,

My 'My Computer' folder had the toolbar 'FlashGet Bar' activated.

Folders demo, for some reason activates the 'FlashGet' icon, and stops - I assume - it's when _Lib_PopupClose() times out.

Even a newbie like me worked out to deactivate the toolbar and run the demo again.

Just thought you'd like to know.

Just as an aside, perhaps you could include a small warning, or bailout option, on what's about to happen to your [newbie] settings :P when running the Folders and PerfOpts demos. Not complaining mind, just a suggestion to help people like me who probably had no business playing with fire :whistle:

-Greg

Link to comment
Share on other sites

Yes, you can manage a context menu with Auto3Lib. There are several ways to do this, depending on if you are managing an AutoIt ListView or a ListView in another application. If the ListView was created in AutoIt, it's fairly straight forward. You might want to look at the Context.au3 file in the Auto3Lib Misc folder. It shows how to trap the WM_CONTEXTMENU message and display a context menu.

If you want to manage a context menu in an external application, it is still fairly easy to do. The following snippet shows how to manipulate a context menu in Explorer:

#include <A3LMenu.au3>
#include <A3LListView.au3>

Global $hList, $hMenu, $iI

; Open Explorer
Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
_Lib_WinWaitActive("My Computer")

; Get a handle to the ListView
$hList = ControlGetHandle("My Computer", "", "SysListView321")
if $hList = 0 then _Lib_ShowError("Unable to obtain ListView handle")

; Right click on the second item (usually the C: drive)
_ListView_ClickItem($hList, 1, "right", False, 1, 1, True)

; Get the handle to the popup menu
$hMenu = _Lib_PopupGetHwnd()

; From here, you can use $hMenu in all the A3LMenu functions
for $iI = 0 to _Menu_GetItemCount($hMenu) - 1
  _Lib_ConsoleWrite(_Menu_GetItemText($hMenu, $iI))
next
Thank you for your reply.

Your example works fine.

I use AutoIt with your library to install automaticaly the differents applications from a Genesys Solutions (Siebel CTI applications).

I win many hours with this solution compared to a manualy installation. Your library helps me largely

Sorry for my language, i'm French (nobody is perfect ;-))

Alex

Edited by Alexandre34
Link to comment
Share on other sites

Paul,

My 'My Computer' folder had the toolbar 'FlashGet Bar' activated.

Folders demo, for some reason activates the 'FlashGet' icon, and stops - I assume - it's when _Lib_PopupClose() times out.

Even a newbie like me worked out to deactivate the toolbar and run the demo again.

Just thought you'd like to know.

Just as an aside, perhaps you could include a small warning, or bailout option, on what's about to happen to your [newbie] settings :P when running the Folders and PerfOpts demos. Not complaining mind, just a suggestion to help people like me who probably had no business playing with fire :whistle:

-Greg

Haven't heard about the FlashGet icon problem before. It would be interesting to see what is causing the problem. If you find out how to code around the problem, please let me know.

Good idea about the Folder and PerfOpts demos. I'll put a message at the start that tells people that the scripts will modify their system.

Thanks for the feedback.

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Thank you for your reply.

Your example works fine.

I use AutoIt with your library to install automaticaly the differents applications from a Genesys Solutions (Siebel CTI applications).

I win many hours with this solution compared to a manualy installation. Your library helps me largely

Sorry for my language, i'm French (nobody is perfect ;-))

Alex

Merci de la rétroaction :whistle:
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Hi PaulIA et al,

Has just taken a look through the new helpfile - brilliant work, amazed at the consistency of the library as a whole!

While looking I stumbled across "_Menu_SetItemBmp", tried demoing it in the "Menus 1.au3" example by adding the following code snippets:

Global $h_Icon = @ScriptDir & "\Images\icon.ico" ; a 16x16 xp icon
(...)
 ; Create Edit menu
  $hEdit = _Menu_CreateMenu()
  _Menu_AddMenuItem($hEdit, 0, "&Cut"  , $idCut  )
  _Menu_AddMenuItem($hEdit, 1, "C&opy" , $idCopy )
  _Menu_AddMenuItem($hEdit, 2, "&Paste", $idPaste)
  _Menu_SetItemBmp($hEdit, 1, $h_Icon) ; <-- added that one too

Cannot seem to get it working (item simply disappears when bitmap is set), also tried with various bmps and so forth.. probably some trivial error on my part - haven't gotten completely used to the syntax of Auto3Lib! If you could show me a working syntax example it would be great! :whistle:

Link to comment
Share on other sites

Hi PaulIA et al,

Has just taken a look through the new helpfile - brilliant work, amazed at the consistency of the library as a whole!

While looking I stumbled across "_Menu_SetItemBmp", tried demoing it in the "Menus 1.au3" example by adding the following code snippets:

Global $h_Icon = @ScriptDir & "\Images\icon.ico" ; a 16x16 xp icon
(...)
 ; Create Edit menu
  $hEdit = _Menu_CreateMenu()
  _Menu_AddMenuItem($hEdit, 0, "&Cut"  , $idCut  )
  _Menu_AddMenuItem($hEdit, 1, "C&opy" , $idCopy )
  _Menu_AddMenuItem($hEdit, 2, "&Paste", $idPaste)
  _Menu_SetItemBmp($hEdit, 1, $h_Icon) ; <-- added that one too

Thanks for the feedback!

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

The _Menu_SetItemBmp function requires a handle to a bitmap instead of a path to a bitmap. The above should look something like this:

(...)

Hi again PaulIA, thanks for the quick feedback - can see I did wrong thing with the path vs handle thing; still fails the same way though? :whistle:

I have included the bmp I'm trying to load just to make sure that that's not the source of the error.. here's full code! (sidenote: how to get a 'scrollable code' windows embedded in the post?)

#include <A3LMenu.au3>


; =================================================================================================
; Description ...: Menu test script
; Author ........: Paul Campbell (PaulIA)
; Notes .........:
; =================================================================================================

; =================================================================================================
; Global variables
; =================================================================================================

Global $hGUI , $hFile  , $hEdit  , $hHelp , $hMain
Global Enum $idNew=1000, $idOpen , $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout
Global $hBmp

; =================================================================================================
; Main
; =================================================================================================

CreateGUI()
Test()
ShowMenu()
ShowItems()
MsgLoop()

; =================================================================================================
; Create the GUI
; =================================================================================================
Func CreateGUI()
  $hGUI = GUICreate("Menu Test", 400, 300)

  ; Create File menu
  $hFile = _Menu_CreateMenu()
  _Menu_AddMenuItem($hFile, 0, "&New"  , $idNew  )
  _Menu_AddMenuItem($hFile, 1, "&Open" , $idOpen )
  _Menu_AddMenuItem($hFile, 2, "&Save" , $idSave )
  _Menu_AddMenuItem($hFile, 3, ""      , 0       )
  _Menu_AddMenuItem($hFile, 4, "E&xit" , $idExit )

  ; Create Edit menu
  $hEdit = _Menu_CreateMenu()
  _Menu_AddMenuItem($hEdit, 0, "&Cut"  , $idCut  )
  _Menu_AddMenuItem($hEdit, 1, "C&opy" , $idCopy )
  _Menu_AddMenuItem($hEdit, 2, "&Paste", $idPaste)

  $hBMP = _Lib_LoadBitmap(@ScriptDir & "\test.bmp") ; <-- added bmp loader code
  _Menu_SetItemBmp($hEdit, 1, $hBmp) ; <-- added bmp loader code
  

  ; Create Help menu
  $hHelp = _Menu_CreateMenu()
  _Menu_AddMenuItem($hHelp, 0, "&About", $idAbout)

  ; Create Main menu
  $hMain = _Menu_CreateMenu()
  _Menu_AddMenuItem($hMain, 0, "&File", 0, $hFile)
  _Menu_AddMenuItem($hMain, 1, "&Edit", 0, $hEdit)
  _Menu_AddMenuItem($hMain, 2, "&Help", 0, $hHelp)

  ; Set the window menu
  _Menu_SetMenu($hGUI, $hMain)

  GUISetState()
EndFunc

; =================================================================================================
; MsgLoop
; =================================================================================================
Func MsgLoop()
  GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
  do
  until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc

; =================================================================================================
; ShowItems
; =================================================================================================
Func ShowItems()
  Local $iI, $iCount, $sItem, $aRect

  $iCount = _Menu_GetItemCount($hFile)
  for $iI = 0 to $iCount - 1
    $sItem = "Item " & $iI & " "
    $aRect = _Menu_GetItemRect($hGUI, $hFile, $iI)
    _Lib_ConsoleWrite($sItem & "checked bitmap ......: " & _Menu_GetItemBmpChecked  ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "data ................: " & _Menu_GetItemData        ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "ID ..................: " & _Menu_GetItemID          ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is checked ..........: " & _Menu_GetItemChecked     ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is disabled .........: " & _Menu_GetItemDisabled    ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is grayed ...........: " & _Menu_GetItemGrayed      ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is highlighted ......: " & _Menu_GetItemHighlighted ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is menu .............: " & _Menu_IsMenu             ($hFile     ))
    _Lib_ConsoleWrite($sItem & "is bitmap ...........: " & _Menu_GetTypeBitmap      ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is menu bar break ...: " & _Menu_GetTypeMenuBarBreak($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is menu break .......: " & _Menu_GetTypeMenuBreak   ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is owner draw .......: " & _Menu_GetTypeOwnerDraw   ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is radio checks .....: " & _Menu_GetTypeRadioCheck  ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is right justified ..: " & _Menu_GetTypeRightJustify($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is right ordered ....: " & _Menu_GetTypeRightOrder  ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is separator ........: " & _Menu_GetTypeSeparator   ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "is string ...........: " & _Menu_GetTypeString      ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "rectangle ...........: [" & $aRect[1] & ", " & $aRect[2] & ", " & $aRect[3] & ", " & $aRect[4] & "]"  )
    _Lib_ConsoleWrite($sItem & "state ...............: " & _Menu_GetItemStateEx     ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "submenu .............: " & _Menu_GetItemSubMenu     ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "text ................: " & _Menu_GetItemText        ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "type ................: " & _Menu_GetItemTypeEx      ($hFile, $iI))
    _Lib_ConsoleWrite($sItem & "unchecked bitmap ....: " & _Menu_GetItemBmpUnchecked($hFile, $iI))
    _Lib_ConsoleWrite()
  next
EndFunc

; =================================================================================================
; ShowMenu
; =================================================================================================
Func ShowMenu()
  Local $aInfo

  $aInfo = _Menu_GetMenuBarInfo($hGUI, 0, 1)
  _Lib_ConsoleWrite("Menu .......................: " & _Menu_GetMenu             ($hGUI ))
  _Lib_ConsoleWrite("Menu background ............: " & _Menu_GetMenuBackground   ($hMain))
  _Lib_ConsoleWrite("Menu bar info: Result ......: " & $aInfo[0]                         )
  _Lib_ConsoleWrite("Menu bar info: Left ........: " & $aInfo[1]                         )
  _Lib_ConsoleWrite("Menu bar info: Top .........: " & $aInfo[2]                         )
  _Lib_ConsoleWrite("Menu bar info: Right .......: " & $aInfo[3]                         )
  _Lib_ConsoleWrite("Menu bar info: Bottom ......: " & $aInfo[4]                         )
  _Lib_ConsoleWrite("Menu bar info: Menu bar ....: " & $aInfo[5]                         )
  _Lib_ConsoleWrite("Menu bar info: Submenu .....: " & $aInfo[6]                         )
  _Lib_ConsoleWrite("Menu bar info: Menu focused : " & $aInfo[7]                         )
  _Lib_ConsoleWrite("Menu bar info: Item focused : " & $aInfo[8]                         )
  _Lib_ConsoleWrite("Menu context help ID .......: " & _Menu_GetMenuContextHelpID($hMain))
  _Lib_ConsoleWrite("Menu data ..................: " & _Menu_GetMenuData         ($hMain))
  _Lib_ConsoleWrite("Menu default item ..........: " & _Menu_GetMenuDefaultItem  ($hMain))
  _Lib_ConsoleWrite("Menu height ................: " & _Menu_GetMenuHeight       ($hMain))
  _Lib_ConsoleWrite("Menu style .................: " & _Menu_GetMenuStyle        ($hMain))
  _Lib_ConsoleWrite("Menu system menu ...........: " & _Menu_GetSystemMenu       ($hMain))
  _Lib_ConsoleWrite()
EndFunc

; =================================================================================================
; Test
; =================================================================================================
Func Test()
  _Lib_ConsoleWrite("Check radio item ...........: " & _Menu_CheckRadioItem      (       $hFile, 0, 4, 2))
  _Lib_ConsoleWrite("Click accelerator (F) ......: " & _Menu_ClickAccel          ($hGUI, $hMain, "F"    ))
  _Lib_ConsoleWrite("Click popup (1) ............: " & _Menu_ClickPopup          (1                     ))
;  _Lib_ConsoleWrite("Click popup accel (O).......: " & _Menu_ClickPopupAccel     ("O"                   ))
;  _Lib_ConsoleWrite("Delete menu item ...........: " & _Menu_DeleteMenu          (       $hMain, 2      ))
;  _Lib_ConsoleWrite("Destroy menu ...............: " & _Menu_DestroyMenu         (       $hHelp         ))
  _Lib_ConsoleWrite("Set context id .............: " & _Menu_SetMenuContextHelpID(       $hMain, 123    ))
  _Lib_ConsoleWrite("Set menu data ..............: " & _Menu_SetMenuData         (       $hMain, 456    ))
  _Lib_ConsoleWrite("Set menu height ............: " & _Menu_SetMenuHeight       (       $hFile, 20     ))
  _Lib_ConsoleWrite("Set menu item checked ......: " & _Menu_SetItemChecked      (       $hFile, 0      ))
  _Lib_ConsoleWrite("Set menu item default ......: " & _Menu_SetItemDefault      (       $hFile, 0      ))
  _Lib_ConsoleWrite("Set menu item disabled .....: " & _Menu_SetItemDisabled     (       $hFile, 1      ))
  _Lib_ConsoleWrite("Set menu item grayed .......: " & _Menu_SetItemGrayed       (       $hMain, 2      ))
  _Lib_ConsoleWrite("Set menu item highlight ....: " & _Menu_SetItemHighlighted  (       $hMain, 1      ))

  _Lib_ConsoleWrite("Draw menu bar...............: " & _Menu_DrawMenuBar         ($hGUI                 ))
  _Lib_ConsoleWrite()
EndFunc

; =================================================================================================
; This code shows how to capture WM_COMMAND messages
; =================================================================================================
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
  Switch _Lib_LoWord($iwParam)
    case $idNew
      _Lib_ConsoleWrite("New"  )
    case $idOpen
      _Lib_ConsoleWrite("Open" )
    case $idSave
      _Lib_ConsoleWrite("Save" )
    case $idExit
      Exit
    case $idCut
      _Lib_ConsoleWrite("Cut"  )
    case $idCopy
      _Lib_ConsoleWrite("Copy" )
    case $idPaste
      _Lib_ConsoleWrite("Paste")
    case $idAbout
      _Lib_ConsoleWrite("About")
  EndSwitch
  Return $GUI_RUNDEFMSG
EndFunc

test.bmp

Link to comment
Share on other sites

Hi again PaulIA, thanks for the quick feedback - can see I did wrong thing with the path vs handle thing; still fails the same way though? :whistle:

I have included the bmp I'm trying to load just to make sure that that's not the source of the error.. here's full code! (sidenote: how to get a 'scrollable code' windows embedded in the post?)

Hmm... Well that's just odd. The Menu module on my machine is different from the one that I released. I remember making this change while working on the help file, but it didn't get pulled into the release. I'll definitely have to check that out. In the mean time, replace _Menu_SetItemBmp with this:

Func _Menu_SetItemBmp($hMenu, $iItem, $hBmp, $fByPos=True)
  Local $tInfo

  $tInfo = _Menu_GetItemInfo($hMenu, $iItem, $fByPos)
  _tagSetData($tInfo, "Mask"   , $MIIM_BITMAP)
  _tagSetData($tInfo, "BmpItem", $hBmp)
  Return _Menu_SetItemInfo($hMenu, $iItem, $tInfo, $fByPos)
EndFunc

Oh, the 'scrollable code' window use the "codebox" tag (with and without the slash, just like the quote tag)

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

When running the Folders demo - My 'My Computer' folder had the toolbar 'FlashGet Bar' activated

Paul, I investigated the problem a bit further.

Seems that in Func _Toolbar_FindToolbar($hWnd, $sText)

_Toolbar_GetButtonText($hToolbar, $iCommandID)
can return a 0(zero) and = True when tested against "&File", returning the first matching Toolbar.

Fix 1.

overrode the mixed case test and changed

if _Toolbar_GetButtonText($hToolbar, $iCommandID) = $sText Then Return $hToolbar

to

If _Toolbar_GetButtonText($hToolbar, $iCommandID) == $sText Then Return $hToolbar

OR Fix2.

Local $bText
...
$bText = _Toolbar_GetButtonText($hToolbar, $iCommandID)
If $bText <> 0 Or $bText <> "" Then
  if $bText = $sText then Return $hToolbar
EndIf
...

Both solutions worked for me.

Link to comment
Share on other sites

Great, with this tweak everything flows as it should :whistle: - I hope that the error which caused the inconsistency is benign to fix!

One last question on this subject - is there any way to make the background of a bmp file transparent in a menu? (or, alternatively: is there any way to make the function load a *.ico file?). Edit: Ok, I actually one more question.. is there any way to keep the menu -slim- when adding bitmaps to it? Right now it add's a large margin on the left when a bitmap is loaded.. (see the attached picture for explanation).

Thanks again for your help with this one - it is really invaluable to me :P Hope that you can make use of something I contribute to the forum at some point!

Edit: added image and one more (very) last question

Hmm... Well that's just odd. The Menu module on my machine is different from the one that I released. I remember making this change while working on the help file, but it didn't get pulled into the release. I'll definitely have to check that out. In the mean time, replace _Menu_SetItemBmp with this:

Func _Menu_SetItemBmp($hMenu, $iItem, $hBmp, $fByPos=True)
  Local $tInfo

  $tInfo = _Menu_GetItemInfo($hMenu, $iItem, $fByPos)
  _tagSetData($tInfo, "Mask"   , $MIIM_BITMAP)
  _tagSetData($tInfo, "BmpItem", $hBmp)
  Return _Menu_SetItemInfo($hMenu, $iItem, $tInfo, $fByPos)
EndFunc

Oh, the 'scrollable code' window use the "codebox" tag (with and without the slash, just like the quote tag)

post-15602-1173190853_thumb.png

Edited by Sunaj
Link to comment
Share on other sites

Paul, I investigated the problem a bit further.

Seems that in Func _Toolbar_FindToolbar($hWnd, $sText)

_Toolbar_GetButtonText($hToolbar, $iCommandID)
can return a 0(zero) and = True when tested against "&File", returning the first matching Toolbar.

Fix 1.

overrode the mixed case test and changed

if _Toolbar_GetButtonText($hToolbar, $iCommandID) = $sText Then Return $hToolbar

to

If _Toolbar_GetButtonText($hToolbar, $iCommandID) == $sText Then Return $hToolbar

OR Fix2.

Local $bText
...
$bText = _Toolbar_GetButtonText($hToolbar, $iCommandID)
If $bText <> 0 Or $bText <> "" Then
  if $bText = $sText then Return $hToolbar
EndIf
...

Both solutions worked for me.

I'm having trouble seeing the problem on this one. If _Toolbar_FindToolbar fails, it should set @Error to a negative value and return 0 for the Toolbar handle. Are you saying that this isn't the case in your situation? It may be finding the "&File" string in another Toolbar, which is a possiblity. Also, I believe that you might be tripped up by the way that AutoIt compares strings and numbers. If you run this code:

$sText = ""
if $sText = "" then ConsoleWrite('Text is blank' & @CR)
if $sText = 0  then ConsoleWrite('Text is zero'  & @CR)

You'll see that it prints both blank and zero. So it must be something else that we're not seeing. Can you revert back to the orginal code and see what value _Toolbar_FindToolbar returns? Is it 0 and @Error is negative or is it the handle to your Flash toolbar and @Error is 0?

Thanks for working with me on this.

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Great, with this tweak everything flows as it should :whistle: - I hope that the error which caused the inconsistency is benign to fix!

One last question on this subject - is there any way to make the background of a bmp file transparent in a menu? (or, alternatively: is there any way to make the function load a *.ico file?). Edit: Ok, I actually one more question.. is there any way to keep the menu -slim- when adding bitmaps to it? Right now it add's a large margin on the left when a bitmap is loaded.. (see the attached picture for explanation).

Thanks again for your help with this one - it is really invaluable to me :P Hope that you can make use of something I contribute to the forum at some point!

Edit: added image and one more (very) last question

I found the problem with the menu code. I have a script that compiles the Auto3Lib releases and I had a typo for the menu file name. That's what I get for changing things. :D

IFAIK, the menu image commands only work on bitmaps. You can make a bitmap with a transparent background though. Do a Google and you'll find a ton of hits on how to do this with your favorite image editor.

The default menu is created with space for a checkbox. If you want a slim menu, just change the value that you pass to _Menu_CreateMenu like this:

#include <A3LMenu.au3>

Opt("MustDeclareVars", 1)

Global $hGUI, $hFile, $hMain

$hGUI  = GUICreate("Menu Test", 400, 300)
$hFile = _Menu_CreateMenu(24)
_Menu_AddMenuItem($hFile, 0, "&New"  , 1000)
_Menu_AddMenuItem($hFile, 1, "&Open" , 1001)
_Menu_AddMenuItem($hFile, 2, "&Save" , 1002)
_Menu_AddMenuItem($hFile, 3, ""      , 0   )
_Menu_AddMenuItem($hFile, 4, "E&xit" , 1003)

_Menu_SetItemBmp($hFile, 2, _Lib_LoadBitmap(@ScriptDir & "\Blue.bmp"))

$hMain = _Menu_CreateMenu(24)
_Menu_AddMenuItem($hMain, 0, "&File", 0, $hFile)

_Menu_SetMenu($hGUI, $hMain)

GUISetState()

do
until GUIGetMsg() = $GUI_EVENT_CLOSE

If you want it really slim, remove the _Menu_SetItemBmp line.

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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