Autoit make combo show when another combo has a certain value - autoit

In my script: http://pastebin.com/Az6vabnK I am trying to make a combo show up when another combo has a certain value as seen here:
Case $Combo2
If Read() = "Vanilla" Then
GUISwitch($GUI, $TabSheet2)
$Combo3 = GUICtrlCreateCombo("Choose Version", 10, 85, 161, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo3, "Latest|1.6.4|1.6.2|1.5.2|1.4.7|1.4.5")
Else
GUISwitch($GUI, $TabSheet2)
GUICtrlDelete($Combo3)
EndIf
Func Read();The function for reading the state of the server type combo.
Return GUICtrlRead($Combo2)
EndFunc ;==>Read
In the while it's a:
AdlibRegister("Read")
To read the value. For some reason, nothing happens when the combo changes value. Any ideas?

Delete that AdlibRegister("Read") because it does nothing.
You are already getting value of $combo2 here
If Read() = "Vanilla" Then
$Combo2 should be a global variable or you can remove that Read() function and use GuiCtrlRead directly
If GUICtrlRead($Combo2) = "Vanilla" Then
Try this
If GUICtrlRead($Combo2) = "Vanilla" Then
GUISwitch($GUI, $TabSheet2)
$Combo3 = GUICtrlCreateCombo("Choose Version", 10, 85, 161, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo3, "Latest|1.6.4|1.6.2|1.5.2|1.4.7|1.4.5")
GUICtrlCreateTabItem("")
Else
GUISwitch($GUI, $TabSheet2)
GUICtrlDelete($Combo3)
EndIf

Related

How in GUI to show the text from the file which changes?

In the file 1.txt in the first line there is an inscription, and it changes over time. In the GUI, it should also be changed. How to make it not flicker?
Local $Form1 = GUICreate('Form1', 261, 200, 192, 124)
$10 = FileReadLine ( "1.txt", 1);
GUISetState()
Local $spic = $10, $Pic1
While 1
$Pic1 = GUICtrlCreateLabel($10, 10, 70, 235, 50)
Switch FileExists($spic)
Case 0
If $Pic1 Then
GUICtrlDelete($Pic1)
$Pic1 = 0
EndIf
Case 1
If Not $Pic1 Then $Pic1 = GUICtrlCreatePic($spic, 16, 24, 212, 124)
EndSwitch
Sleep(1)
WEnd
#include <GUIConstantsEx.au3>
; Create the Gui.
$Form1 = GUICreate('Form1', 261, 200, 192, 124)
$iLabel = GUICtrlCreateLabel('', 10, 10, 235, 50)
$iPic = GUICtrlCreatePic('', 16, 34, 212, 124)
GUISetState()
; Hide picture control if no file [True|False].
$bHideImage = FileExists('default.jpg') ? False : True
; Updates in the loop to recognize change.
$sSavedFilename = ''
; Set time to reset image etc.
$iTimeReset = 1000
$hTimeStamp = TimerInit()
While 1
; Get Gui messages.
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete()
Exit
EndSwitch
; Check if time needs reset.
If TimerDiff($hTimeStamp) > $iTimeReset Then
$hTimeStamp = TimerInit()
Else
ContinueLoop
EndIf
; Read 1st line of a file.
$sReadFilename = FileReadLine ('1.txt', 1)
; If the saved line is different to read line.
If $sSavedFilename <> $sReadFilename Then
GUICtrlSetData($iLabel, $sReadFilename)
Switch FileExists($sReadFilename)
Case 0
If $bHideImage Then
GUICtrlSetState($iPic, $GUI_HIDE)
Else
; Display a default (blank?) image.
GUICtrlSetImage($iPic, 'default.jpg')
EndIf
Case 1
If $bHideImage Then
GUICtrlSetState($iPic, $GUI_SHOW)
EndIf
; Display the new image.
GUICtrlSetImage($iPic, $sReadFilename)
EndSwitch
; Save the current filename.
$sSavedFilename = $sReadFilename
EndIf
WEnd
Sleep is accurate to approximately
10 milliseconds, which is of so little time to update a control, thus
you get the flicker.
Update of labels which do not occur on an event like a button click,
can be handled using a timer.
If you use a message loop Gui, then you get the Gui messages with using
GuiGetMsg. After the messages, you can check a time stamp to know if
the time difference is larger than the time reset value which is currently
set as 1000 milliseconds. If larger, timer is reset and the code below
is executed, else will continue the loop from the top.
The filename read from the text file is saved to $sSavedFilename.
Updating of controls is only done when the read filename is different. If
the filename read does not exist, then display a default (blank?) image.
I sometimes choose a default image else an empty filename instead can
cause control sizing issues with the next image change. The control could
be instead be hidden, if no image to show. $bHideImage current decides
to use the file default.jpg if exist, else to hides the control.
This code updates the created controls instead of deleting and recreating them.
Update GUICtrlCreateLabel text with GUICtrlSetData.
Update GUICtrlCreatePic image with GUICtrlSetImage.

autoit and koda: how does gui create knows which koda form to use?

I'm new to autoit, I wanted to create 2 forms and open the second one by clicking on a button of the first one.
Here are my forms in koda:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Act = GUICreate("Activités et Compétences", 615, 441, 196, 125)
$RetourAccueil=1
$ETAPE = 1
$Label1 = GUICtrlCreateLabel(" Activités && Compétences", 41, 12, 558, 85)
GUICtrlSetFont(-1, 36, 800, 0, "My Lucky Penny")
$PPE = GUICtrlCreateButton("PPE", 48, 168, 75, 25)
$TP = GUICtrlCreateButton("TP", 152, 168, 75, 25)
$TD = GUICtrlCreateButton("TD", 256, 168, 75, 25)
$STAGE1 = GUICtrlCreateButton("STAGE 1", 368, 168, 75, 25)
$STAGE2 = GUICtrlCreateButton("STAGE 2", 480, 168, 75, 25)
$Group1 = GUICtrlCreateGroup("Activités", 24, 136, 561, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(#SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func RetourAccueil()
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $PPE
if $ETAPE=1 THEN
GUICtrlSetData(-1, "|PPE2.1-Mission ADISPO|PPE -Installation PFSENSE|PPE-Cas Kaspersky|Autres")
EndIf
Case $TP
$TP = GUICtrlCreateButton("NewName", 480, 168, 75, 25)
Case $TD
$TD = GUICreate("Activités et Compétences", 615, 441, 196, 125)
WinActivate($TDPAGE)
Case $STAGE1
MsgBox(64,'information','ok')
Case $STAGE2
EndSwitch
WEnd
And here is the result whn I run it:
By clicking on the button TD, I want to open the second form and close the first one but I have o idea how I tried with:
Case $TD
$TD = GUICreate("Activités et Compétences", 615, 441, 196, 125)
WinActivate($TDPAGE)
But it didn't work...
When you generate form code in KODA, it only generates code for the form you have currently selected, so you need to generate the code for the second form separately.
The reason your current code does not work is that new GUI's are invisible by default, and you need to make them visible by executing GUISetState(#SW_SHOW) after creating them (just like the code generated by KODA does for the first form).
If you want to close the first form, use GUIDelete(). If you look at AutoIt's documentation, you'll find that all GUI functions accept an optional parameter to specify which GUI you want to operate on, and if you don't specify it, it will use the last window you created (or operated on). As you want to specifically delete the first GUI, you either have to make sure you delete it before creating the second GUI, or explicitly specify the GUI you want to delete, i.e. GUIDelete($Act).
Finally, you seem to have made a typo in writing WinActivate($TDFORM). Did you mean to write WinActivate($TD)? Regardless, it should not be necessary to activate the form, as a newly created GUI will be activated automatically.

Adobe LiveCycle Designer Numeric Field set value

To Whom it may concern:
In a Adobe Form there is a Exchange Rate field, the rawValue is based on numeric field that has to be completed by the user.
The following code is what is used to do this under (formCalc, Client):
if (Paid2.selectedIndex == "Cash")then
Exch2.rawValue = AdvCash.rawValue
elseif (Exch2.selectedIndex == "Card") then
Exch2.rawValue = ""
endif
The problem with above code is that once the user type in there own value for Card Exchange rate Exch2.rawValue and made a mistake and reselect "Cash" it does not run the first line of the If statement.
the last part of the question is how to add the following code into the above if then statement
Exch2.rawValue.ui.oneOfChild.border.fill.color.value = " *, *, * "
if (Paid2.selectedIndex == "Cash")then
Exch2.rawValue = AdvCash.rawValue
Exch2.rawValue.ui.oneOfChild.border.fill.color.value = "229, 229, 229"
elseif (Exch2.selectedIndex == "Card") then
Exch2.rawValue = ""
Exch2.rawValue.ui.oneOfChild.border.fill.color.value = "255, 255, 153"
endif
The above fill.color does not provide the desired results.
Hope anybody can assist in this regard
To your first issue:
You are probably running the script in "wrong"(change?) event. Try to run in on exit event of the drop-down list.
To your second issue:
Remove rawValue in the Exch2.rawValue.ui.oneOfChild.border.fill.color.value = "255, 255, 153" and it should be good.

Checking for an area of the screen to change then sending a message to a skype group conversation

I'm looking for some help creating a bit of code that will look at an area of my screen and then after 60 seconds for it to check if it has changed.
After it has changed I am then trying to send a message over skype to a group of people with a message however the problem i'm having is that I can't change chat easily using ControlCommand, MouseMove, MouseClick, ControlSend...etc
I even tried MouseClickPlus to click when minimised but that didn't work at all.
The coordinates in question for the box that I'm trying to look at are: 86, 109, 280, 109
If anyone knows ways to do this I would greatly appreciate the help.
Looks like you need to use the Skype UDF and PixelChecksum or maybe even ImageSearch with ImageCapture
I would say the best way to check if the said area changes is using PixelChecksum which can be used like below.
PixelChecksum Code Example 1
Local $GetAreaChecksumOne = PixelChecksum(86, 109, 280, 109)
Sleep(60000)
Local $GetAreaChecksumTwo = PixelChecksum(86, 109, 280, 109)
While $GetAreaChecksumOne <> $GetAreaChecksumTwo
$GetAreaChecksumTwo = PixelChecksum(86, 109, 280, 109)
Sleep(1000)
ConsoleWrite("Match not found")
WEnd
Or a more normal way of doing it would be:
PixelChecksum Code Example 2
Local $GetAreaChecksumOne = PixelChecksum(86, 109, 280, 109)
While $GetAreaChecksumOne = PixelChecksum(86, 109, 280, 109)
Sleep(100)
WEnd
Refrence Link: PixelChecksum
To send a skype message you'll need the Skype UDF if you want to send messages to a favourite chat in Skype.
Skype Code Example
#include <Skype.au3>
Local $sTopic = "Bookmarked (favourited) chat name here"
Local $aBookMarkedChat = _Skype_ChatGetBookmarked(), $oChattmp = 0
For $i = 0 To UBound($aBookMarkedChat) -1
$oChattmp = $aBookMarkedChat[$i]
If _Skype_ChatGetTopic($oChattmp) = $sTopic Then
_Skype_ChatSendMessage($oChattmp, "Message here")
EndIf
Next
If you want to go down an imagecapture and imagesearch route then use something similar to below, however again you'll need the ImageSearch UDF
ScreenCapture and ImageSearch Code Example
#include <ImageSearch.au3>
#include <ScreenCapture.au3>
Local $XCoords = 0
Local $YCoords = 0
_ScreenCapture_Capture(#DesktopDir & "Compare.png", 86, 109, 280, 109)
Sleep(60000)
$Compare = _ImageSearch(#DesktopDir & "Compare.png", 1, $XCoords, $YCoords, 5)
While $Compare = 0
$Compare = _ImageSearch(#DesktopDir & "Compare.png", 1, $XCoords, $YCoords, 5)
Sleep(1000)
WEnd
FileDelete(#DesktopDir & "Compare.png")
If you want to make a more througah ImageSearch then use ImageSearchArea (faster and for what you need it's better)

Can't figure out why this AutoIt code isn't working

the problem is that after you hit ok on this GUI, it doesn't start the function I have.
Func BeginningGUI()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Stronghold Kingdoms", 248, 95, -1, -1)
$Password = GUICtrlCreateInput("Password", 8, 32, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$ButtonOk = GUICtrlCreateButton("OK", 86, 64, 75, 25, $BS_NOTIFY)
$ButtonCancel = GUICtrlCreateButton("Cancel", 167, 64, 75, 25, $BS_NOTIFY)
$EnterPassLabel = GUICtrlCreateLabel("Please Enter Your Stronghold Kingdoms Password", 0, 12, 241, 17, 0)
GUISetState(#SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonCancel
Exit
Case $ButtonOk
Exit
OpenSHK()
EndSwitch
WEnd
EndFunc
I want it to obtain the input word, then save that as a variable and enter it into the later function OpenSHK()
Also when I run OpenSHK() Alone it works fine so it's not that.
You're exiting before the call to OpenSHK() is made, causing it to never be called.
Case $ButtonOk
Exit
OpenSHK()
EndSwitch
Exit after that call is made instead:
Case $ButtonOk
OpenSHK()
Exit
EndSwitch
The second problem is that $Password is not the password the user entered; it's a control ID. You need to use GuiCtrlRead to retrieve the value the user entered after the Ok button has been clicked.

Resources