Recently Browsing 0 members
No registered users viewing this page.
Recently I was working on a script with icons using GuiCtrkCreatIcon.
I decided to change the sub folder name of the icons to a more meaning name, however made a typo.
I tested the .exe on my test computer and it worked flawlessly (because both icon folder where on my test computer) 😁
But after I installed the script on the intended computers , I got chaos!😵
Zooming into the problem, I discovered, that because the icons could not be found, the ControlID were returned with a value of 0
and thus played havoc within the GuiGetMsg() switch/case statement.
I have been able to reproduce this (see example)
#include <GUIConstantsEx.au3> ;============================================================================================================ ; PLEASE, do not save this example in the example folder: C:\Program Files (x86)\AutoIt3\Examples\Helpfile ;============================================================================================================ Example() Func Example() GUICreate(" My GUI Icons", 250, 250) $Icon1 = GUICtrlCreateIcon("shell32.dll", 10, 20, 20) $Icon2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 20, 40, 32, 32) $Icon3 = GUICtrlCreateIcon("shell32.dll", 7, 20, 75, 32, 32) GUISetState(@SW_SHOW) ;$Icon2 = -1 ; ==> When this line is uncommented the script "works", so -1 could be a potential fix. ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Icon2 Beep (500,500) EndSwitch WEnd GUIDelete() EndFunc ;==>Example If you save the above script outside the Autoit example folder and run it, it will keep beeping because GuiCtrlCreatIcon did not find horse.ani and return $Icon2=0.
At the moment GUICtrlCreateIcon () only returns the conntrolID on success and 0 on failure.
I would like to propose a return of -1 on failure, so a existing and working script won't go awry when the icon can not be found.
it has been a long time since i have been here and a long time since i last used autoit. ever so often when the time allows me to, then i follow up on an idea that i had a long time ago. i have done all the work on paper but now it is up to writing it in autoit and i keep stumbling over many little issues here and there. sometimes after a few days i will try again and get a step further but sometimes it just will not help no matter how long i try and think about a solution. for most of you it will be the basics but for me it is not all that easy, but at least i give it a try.
right, down to business:
here is my code:
#include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <String.au3> ; ; PART 1: define replacements and check with msgbox ; Global $y, $z $y = "Yes" $z = "No" MsgBox(0,"replacements", $y & @CRLF & $z) ;the replacements in a message box ; ; PART 2: set the texts and check via console and msgbox ; Global $my1string = "abab" ;the first specified text MsgBox(0,"my1string", $my1string) ;the message box to output the first specified text Global $my2string = "icic" ;the second specified text MsgBox(0,"my2string", $my2string) ;the message box to output the second specified text ; ; PART 3: transform the strings to individual arrays ; $my1array = StringSplit($my1string, "") $my1array = "" _ArrayDelete($my1array, 0) _ArrayDisplay($my1array, "my1array") ;the display of the first specified array $my2array = StringSplit($my2string, "") $my2array = "" _ArrayDelete($my2array, 0) _ArrayDisplay($my2array, "my2array") ;the display of the first specified array ; ; PART 4: create an empty array for filling ; Global $OutputArray $OutputArray = "" _ArrayDisplay($OutputArray, "OutputArray") ;the display of the first specified array ; ; PART 5: compare & fill empty OutputArray with data after evaluation ; Global $i, $j, $k For $i = 0 to UBound($my1array) -1 For $j = 0 to UBound($my2array) -1 For $k = 0 to UBound($OutputArray) -1 If $my1array[$i] = "a" And $my2array[$j] = "i" Then $OutputArray[$k] = $y Else $OutputArray[$k] = $z EndIf Next Next Next _ArrayDisplay($OutputArray, "OutputArray") ;the display of the Newly filled Array In "Part 2" i make a string that is converted to an array in "Part 3" ... Now, I know that "a" and "i" are always in the exact same spot in both arrays and so i wanted to compare this and make a further array to document my findings by saying "yes" or "no" ... however my new array keeps saying just "no" allthough i can clearly see and know that it should say:
yes no yes no my guess is that there is something wrong within my for-loops and that the counting is somehow "off" i guess that when the first for-loop is finished it reaches the second whilst the second for-loop is checking the first which would explain why it always says "no" instead of seeing the obvious.
so my question would be: what is wrong with my for-loop? or where am i making an error that ultimately gives me the wrong results?
help is much appreciated.
PS: sorry for my not so great english spelling ... stupid german sitting here trying out intermediate english skills.
I want to add a new checkbox with its own variable every time the add button is clicked.
The added checkboxes should remain when I close the window or exit the script and when I reopen I should be able to add new checkboxes aswell.
here is what I have so far..
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> $test = GUICreate("adding test", 475, 345, 500, 175) $Check1 = GUICtrlCreateCheckbox("Checkbox 1", 15, 25, 300, 25) $Button = GUICtrlCreateButton("Add", 365, 25, 90, 20) $Check2 = GUICtrlCreateCheckbox("Checkbox 2", 15, 50, 300, 25) $Check3 = GUICtrlCreateCheckbox("Checkbox 3", 15, 75, 300, 25) GUICtrlSetState($Check2, $GUI_HIDE) GUICtrlSetState($Check3, $GUI_HIDE) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Exit Case $Button GUICtrlSetPos($Check2, 15, 50, 300, 25) GUICtrlSetState($Check2, $GUI_SHOW) Case $Button GUICtrlSetPos($Check3, 15, 75, 300, 25) GUICtrlSetState($Check3, $GUI_SHOW) EndSwitch WEnd
I have a string like this :
Global $Msga = "urrent directory is /send. (Submission of file with log number 29381077284 is confirmed)";
I want to extract the number 29381077284 from the string. I did StringSplit to split based on "(" and then use space to reach there, But it's not a good choice.
Can anyone help me with regular expression to find the number from String using AutoIT. TIA
I have this example string:
2020-06-08 09:23:33 : abcdefghifjklm How to trim just the right part? Or how to trim this text right to left?
I want to trim this string right to left until ' : '.
In ohter words: I need the 'abcdefghifklm' text.
I have tried StringTrimRight, but that requires
The number of characters to trim. Unfortunately StringSplit trims the left part of the strings.