Jump to content

Recommended Posts

Hi

I am trying to set Accelerator keys from an array.

I select the KEY and CONTROL from a SQLite table, the Array looks like that generated for the Helpfile, but I can't get the CONTROLS to resolve...

I though about Assign & Eval, but not sure if that's a step in the right direction. IsDeclared shows that the $var exists in Local Scope -1.  

 

Local $Main = GUICreate("Custom MsgBox", 225, 80)

    GUICtrlCreateLabel("Please select a button.", 10, 10)
    Local $idButton_Yes = GUICtrlCreateButton("Yes", 10, 50, 65, 25)
    Local $idButton_No = GUICtrlCreateButton("No", 80, 50, 65, 25)
    Local $idButton_Exit = GUICtrlCreateButton("Exit", 150, 50, 65, 25)


    Local $query, $aResult, $iRows, $iColumns
    $query = "" ;reset
    $query = "Select hotkey_key, hotkey_ctrl from mytable where mykeys = 'hotkey' ; " ;
    ; Query
    $iRval = _SQLite_GetTable2d($sqliteDb, $query, $aResult, $iRows, $iColumns)
    If $iRval = $SQLITE_OK Then
        Local $sizeofHotkeys = UBound($aResult) - 1
        ConsoleWrite("$sizeofHotkeys " & $sizeofHotkeys & @CRLF)
        If $sizeofHotkeys > 0 Then
            Local $main__aAccelKeys[$sizeofHotkeys][2]
            For $i = 0 To $sizeofHotkeys - 1
                $j = $i + 1
                ; replace friendly text with code -- ! alt + Shift ^ Ctrl # Windows
                $aResult[$j][0] = StringReplace($aResult[$j][0], "Alt", "!")
                $aResult[$j][0] = StringReplace($aResult[$j][0], "Shift", "+")
                $aResult[$j][0] = StringReplace($aResult[$j][0], "Ctrl", "^")
                $main__aAccelKeys[$i][0] = $aResult[$j][0] ;---
                $main__aAccelKeys[$i][1] = $aResult[$j][1] ;---
            Next
;~ Row|Col 0|Col 1
;~ Row 0|F2|$idButton_Yes
;~ Row 1|F3|$idButton_No

            _DebugArrayDisplay($main__aAccelKeys)
            Local $rv = GUISetAccelerators($main__aAccelKeys, $Main)


    GUISetState(@SW_SHOW) ; Display the GUI.

 

Please note that this is a modified Helpfile example.

The Helpfile specifies (a) WinHandle and (b) last Gui created.

--> the example uses a control not a WinHandle and (b) what happens with ChildGuis? Also, the HelpFile specifies lower case, yet the examples show "{F1}" upper case?

Also, is there a way to check the result of the GuiSetAccelerator function? 

Note, if I add these to lines after the FOR loop, then the F1 works, and the DebugArrayDisplays shows control 4... not it's name... So I am in the right place, but my $vars names do not convert to their control numbers in the GUI

Next
            $main__aAccelKeys[$sizeofHotkeys - 1][0] = "{F1}" ; -- -- use the extra row for the F1
            $main__aAccelKeys[$sizeofHotkeys - 1][1] = $ChmHLP   ;---

Skysnake

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

Hi @Skysnake How do you match the SQLite column hotkey_ctrl with the actual control id in the GUI.  That seems to me the major problem of your approach.  The moment you change your GUI by adding, for example, a label or a button or a dummy, you will need to change your database accordingly.

Share this post


Link to post
Share on other sites
1 hour ago, Nine said:

you will need to change your database accordingly.

@Nine Thanks for the reply.

This is true, but a different question.  The issue you refer to here occurs when new functions / controls are created and that needs to be taken care of separately. I am thinking of putting that into an array.

However, right now, I need to get the value out of the SQLite array into the Accelerator array. 

Any ideas?


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites
1 hour ago, Skysnake said:

Any ideas?

oh, I just noticed your commented lines after the loop.  So if I understand correctly.  It is the name of the control that you have inside the database, Not the control id, right ?  If it is the case, you could use eval () ? 

Edited by Nine

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

  • Similar Content

    • By VinMe
      HELLO All,
      is there any function in Auto it to Remove the repeating  strings separated by ","  which is present in the array.
      ex.
      Available state
      a[0]= D97,D96,,D85,D86,D85,D86,D85,D86,D85,,D86,D85,D86,D85,D86
      a[1]=D85,D24,,,,,D85
      Required state
      a[0]= D97,D96,D85,D86,
      a[1]=D85,D24
      thank  you in advance!
      vin!
    • By D2thunder
      Hi all, I wasnt active in this Forum forum for Years. 😅
      Since I need something with Json in AutoIt i write a little UDF to save a variable to file to read it with another language - and back. After a while until my other script grows i thought - lets integrate all variables wich is possible, because i want have arrays to.
      This is my first public UDF in Autoit - normaly my AutoIt scripts are quick an dirty.... - like the examples for this udf. - someone want to write nice examples?
      I tried to write this UDF properly, cared for processing speed, low mem consumption as possible, a short code, and a high usability without beeing very familiar with arrays.
      What is it for? - convert nearly all types of variables to a json string for saving it in a file or to an ini. Read it back in to a same formated variable and preserv variable types. All array types are supported with nested arrays, the only restriction is ram and array/stringsize - and time if the array is very big. You can use Filters for variable types and some other options.
      If anyone found a bug or any suggestions, please post it.
       
      get Json.au3 from here Json.au3
       
       
      JsonVar 2019.01.25.1.zip
    • By Ho3ein
      Hi, i have a source code of "Danny35d" and i have 2 main question that are:
       How to extract this function's results (Datas are as Array) to combo-box without set number of datas?  When i type 1, 2 in _SystemUsers($AccountType = 0) to get only Local or Domain users, it just give me both of them, it's old problem of this function, please share us debugged code :)❤ #include <Array.au3> $Users = _ArrayToString(_SystemUsers(), "|", 1) ConsoleWrite($Users & @CRLF) #cs =============================================================================== Function: _SystemUsers($AccountType = 0) Description: Return an array with the local or domain username Parameter(s): $AccountType: Local, domain or both username 0 = Local and Domain usernames 1 = Local usernames only 2 = Domain usernames only Returns: An array with the list of usernames - Succeeded @error 1 - Didn't query any username @error 2 - Failed to create Win32_SystemUsers object @error 3 - Invalid $AccountType Author(s): Danny35d #ce =============================================================================== Func _SystemUsers($AccountType = 0) Local $aSystemUsers Local $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $colItems = "", $strComputer = "localhost" If Not StringRegExp($AccountType, '[012]') Then Return SetError(3, 3, '') $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SystemUsers", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = StringSplit($objItem.PartComponent, ',') If IsArray($Output) Then $Temp = StringReplace(StringTrimLeft($Output[2], StringInStr($Output[2], '=', 0, -1)), '"', '') If $AccountType = 0 Or ($AccountType = 1 And @ComputerName = $Temp) Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' ElseIf $AccountType = 2 And @ComputerName <> $Temp Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' EndIf EndIf Next $aSystemUsers = StringTrimRight($aSystemUsers, 1) If $aSystemUsers = '' Then Return(SetError(1, 1, $aSystemUsers)) Return(SetError(0, 0, StringSplit($aSystemUsers, '|'))) Else $aSystemUsers = '' Return(SetError(2, 2, $aSystemUsers)) EndIf EndFunc ;==>_SystemUsers Thanks to your best Team.
    • By sksbir
      Hi
      Trying this from autoit v3.3.14.5 and SCITE 3.19.102.1901.0 :
      help file , page "Language Reference - Variables" , sample autoit script about maps:

      Maps must be declared before use by defining their scope using the 'Global/Local/Static' keywords. Local $mControls[]
      So is my test script : only with this local declation.
      -check syntax is OK
      - running script : 

      test.au3" (13) : ==> Variable subscript badly formatted.: Local $mControls[] Local $mControls[^ ERROR ->14:51:49 AutoIt3.exe ended.rc:1
      any clue ?
    • By Blitzkid
      Hello, i want to search several directories for files with the largest numbers behind them (Like "video123") . They dont have a datatype. But there are also files with longer names and datatypes in these folders (Like "video778.mp4"). Is it possible to filter the _FileListToArray Syntax from
      to smth. like
       
      Here is my Code
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> #include <File.au3> $filedir = @ScriptDir & "\" _checkfile() Func _checkfile() ConsoleWrite("______________________" & @CRLF) Local $arr[3] = ["music", "picture", "video"] For $i = 0 To UBound($arr) - 1 Local $arrayfiles = _FileListToArray($filedir & $arr[$i], $arr[$i] & "*", 1) If @error = 1 Then ConsoleWrite($arr[$i] & "Error 1") EndIf If @error = 4 Then ConsoleWrite($arr[$i] & "Error 2") ;Exit EndIf $arrayfilter = _ArrayMax($arrayfiles, 0, 1) Global $stringfiles = StringReplace($arrayfilter, $arr[$i], "") ConsoleWrite($arrayfilter & @CRLF) Next EndFunc ;==>_checkfile  
×
×
  • Create New...