Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/25/2015 in all areas

  1. Melba23

    A New Moderator

    Hi, For those of you still using monochrome monitors, or who have some degree of colour-blindness, I would like to announce that we have a new forum Moderator - JLogan3o13. He has kindly agreed to join the Mod team and I would like to take this opportunity to welcome him - I am sure you will all join with me in wishing him well , because he will certainly need it! M23
    3 points
  2. Jewtus, Here you go: #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiComboBox.au3> $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($cCombo, "!23|456|789") GUISetState() Local $tInfo _GUICtrlComboBox_GetComboBoxInfo($cCombo, $tInfo) $hEdit = DllStructGetData($tInfo, "hEdit") ; Handle to the Edit Box $iStyle = _WinAPI_GetWindowLong($hEdit, $GWL_STYLE) ; Get current style _WinAPI_SetWindowLong($hEdit, $GWL_STYLE, BitOr($iStyle, $ES_NUMBER)) ; Add number only style While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndM23
    3 points
  3. We see a lot of examples submitted by users but rarely do we see threads about good coding practice. Post below if you have an example which exhibits the "dos and don'ts" of coding in AutoIt. Why using Dim over Local/Global is not always a good option: #include <MsgBoxConstants.au3> Dim $vVariableThatIsGlobal = "This is a variable that has ""Program Scope"" aka Global." MsgBox($MB_SYSTEMMODAL, "", "An example of why Dim can cause more problems than solve them.") Example() Func Example() MsgBox($MB_SYSTEMMODAL, "", $vVariableThatIsGlobal) ; That looks alright to me as it displays the following text: This is a variable that has "Program Scope" aka Global. Local $vReturn = SomeFunc() ; Call some random function. MsgBox($MB_SYSTEMMODAL, $vReturn, $vVariableThatIsGlobal) ; The Global variable ($vVariableThatIsGlobal) changed because I totally forgot I had a duplicate variable name in "SomeFunc". EndFunc ;==>Example Func SomeFunc() ; This should create a variable in Local scope if the variable name doesn"t already exist. ; For argument sake I totally forgot that I declared a variable already with the same name. ; Well I only want this to be changed in the function and not the variable at the top of the script. ; Should be OK right? Think again. Dim $vVariableThatIsGlobal = "" For $i = 1 To 10 $vVariableThatIsGlobal &= $i ; This will return 12345678910 totally wiping the previous contents of $vVariableThatIsGlobal. Next Return $vVariableThatIsGlobal EndFunc ;==>SomeFunc
    1 point
  4. Hi, rietproductions, welcome to the forum. Look at ControlClick in the Help File. Take a look at the example; should provide you with what you're after.
    1 point
  5. cant tell if this is the same way you are doing it, but heres how i would add the array as additional columns to the base #include <Array.au3> Global $aBase[3][3] = [["0-0", "0-1", "0-2"], _ ["1-0", "1-1", "1-2"], _ ["2-0", "2-1", "2-2"]] Global $aAdd[3][3] = [["A", "B", "C"] , _ ["D", "E", "F"] , _ ["G", "H", "I"]] redim $aBase[ubound($aBase)][ubound($aBase , 2) + ubound($aAdd , 2)] For $k = 0 to ubound($aAdd) - 1 For $i = 0 to ubound($aBase) - 1 $aBase[$i][ubound($aBase , 2) - ubound($aAdd , 2) + $k] = $aAdd[$k][$i] Next Next _ArrayDisplay($aBase)
    1 point
  6. kcvinu, But so can I: #include <Array.au3> Global Enum $eAddRow, $eAddCol Global $aBase[3][3] = [["0-0", "0-1", "0-2"], _ ["1-0", "1-1", "1-2"], _ ["2-0", "2-1", "2-2"]] Global $aAdd[1][3] = [["A", "B", "C"]] _ArrayDisplay($aBase, "", Default, 8) $aBaseArray = $aBase _ArrayAdd_Ex($aBaseArray, $aAdd) _ArrayDisplay($aBaseArray, "", Default, 8) $aBaseArray = $aBase _ArrayAdd_Ex($aBaseArray, $aAdd, $eAddCol) _ArrayDisplay($aBaseArray, "", Default, 8) Func _ArrayAdd_Ex(ByRef $aBaseArray, $aAdd, $iLocation = $eAddRow) If $iLocation = $eAddCol Then _ArrayTranspose($aBaseArray) _ArrayAdd($aBaseArray, $aAdd) If $iLocation = $eAddCol Then _ArrayTranspose($aBaseArray) EndFuncM23
    1 point
  7. ^^You should be able to call it like this too (.item is default prop/method): Msgbox(0, '' , $mDictMaster("German")("Chicken"))...Tho Au3Check isn't maintained properly and doesn't follow AutoIt correctly which is why you should disable it before running such code.
    1 point
  8. Oups, sorry, Eval was not needed : $newstring = Execute('"' & StringRegExpReplace(StringReplace($string, '"', '""'), "%([^%]+)%", '" & $$1 & "' ) & '"')For '^%', do you refer to the ^ anchor or is it used as escape character ? ; This ? $newstring = Execute('"' & StringRegExpReplace(StringReplace($string, '"', '""'), "(?<!\^)%(\w+)%", '" & $$1 & "' ) & '"') ; Or This ? $newstring = Execute('"' & StringRegExpReplace(StringReplace($string, '"', '""'), "(?<!^)%(\w+)%", '" & $$1 & "' ) & '"')
    1 point
  9. ? #Include <Array.au3> $s = 'Hello World "Helloo Woorld" This Is "an example" ok? ' $res = StringRegExp($s, '^|"([^"]*)"|\S+', 3) $res[0] = UBound($res)-1 _ArrayDisplay($res)
    1 point
  10. Hi all, I know this is a crazy idea. But i think it might be a help for somebody. The name of this program is GRM Helper. i.e. GUIRegisterMsg Helper. This program helps you to write the guiregistermsg function code automatically. You can choose a control from the combo box. Then all events of that control will be displayed in a list view. You can click on an event for it;s details. Then you can check the events which you want to include in your code. Then type some details like; 1) Your control's handle. 2) Line number for inserting GUIRegisterMsg code. 3) Line number for inserting main function. And press the "Isert To SciTE" button. Your code is ready in scite. Here is the program. Updated Version 1.1 GRM Helper V1.1.zip The code written by this program. GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox If Not IsHWnd($Sample) Then $hWndListBox = GUICtrlGetHandle($Sample) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $Sample, $hWndListBox Switch $iCode Case $LBN_ERRSPACE ; Insert your code here Case $LBN_SELCHANGE ; Insert your code here Case $LBN_DBLCLK ; Insert your code here Case $LBN_SELCANCEL ; Insert your code here EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND
    1 point
  11. Over the past year of use, I've made a few mods (but not much), and core code is unchanged. I discovered that the function got slower over time, and was cursing windows until I realised my font data file had been bloated horrifically with logging of unrecognised characters. I thus added a cleaner function to remove them. I've also slightly altered the default options, with defaults for initial training (when logging is useful) and another set once usage is stable (when it probably isn't) which also stops asking for user input. I thus thought an update was in order. I'll claim much of the kudos offerred by dmob, as civilcalc's code and subsequent discussion was only a stub, but did give me an idea of how to start with screen OCR (which is why my post appeared under hers in the first place - I was hoping for a bit of constructive input, but it never eventuated). Hopefully the 700 downloads so far of my code mean at least someone other than me is using it. Cheers David OCR.au3_PixelGetColor.au3
    1 point
  12. Func _GUICtrlRichEdit_AppendTextColor($hWnd, $sText, $iColor) Local $iLength = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) ; RichEdit stores text as 2 Byte Unicode chars Local $iCp = _GUICtrlRichEdit_GetCharPosOfNextWord($hWnd, $iLength) _GUICtrlRichEdit_AppendText($hWnd, $sText) _GUICtrlRichEdit_SetSel($hWnd, $iCp-1, $iLength + StringLen($sText)) ; position in 2 Byte "Unicode" _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) _GuiCtrlRichEdit_Deselect($hWnd) EndFunc
    1 point
×
×
  • Create New...