Sign in to follow this  
Followers 0
Mag91

Checkbox Beginner

3 posts in this topic

#1 ·  Posted

Hey guys,

im not very good in AutoIT.

I only made Little scripts like MouseClick, MouseMove(...).

Now i have a little Question. I Build a GUI with 3 Checkboxes.
When i check the Box 1 and hit the Start-button it shoud open the Noepad and write the letter A

When i check the Box 1 & 2 and hit the Start-button it shoud open the Noepad and write the letters AB

When i check the Box 1 - 3 and hit the Start-button it shoud open the Noepad and write the letters ABC

How can i do that?

THANKS!

 

 

Quote

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 237, 142, 230, 134)
$Button1 = GUICtrlCreateButton("Start", 16, 96, 201, 33)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 16, 193, 25)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 40, 193, 25)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 64, 177, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
case $Button1
Run("notepad.exe")
  Local $hWnd = WinWait("Untitled - Notepad", "", 2)
  WinMove($hWnd, "", 1177, 0, 743, 1040)

;===IF CHECKBOX1 IS CHECKED THEN SEND ("A")
;===IF CHECKBOX1 AND CHECKBOX2 ARE CHECKED THEN ("AB")
;===IF CHECKBOX1 - CHECKBOX3 ARE CHECKED THEN SEND ("ABC")
;===IF CHECKBOX2 IS CHECKED THEN SEND ("B")
;===IF CHECKBOX2 AND CHECKBOX3 ARE CHECKED THEN ("BC")
;===IF CHECKBOX3 IS CHECKED THEN SEND ("C")
;===IF CHECKBOX1 AND CHECKBOX3 ARE CHECKED THEN ("AC")

 EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello Mag91 and welcome to the AutoIT forums :)

You can use GUICtrlRead to check if a checkbox is checked or not.

Here is the related code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 237, 142, 230, 134)
$Button1 = GUICtrlCreateButton("Start", 16, 96, 201, 33)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 16, 193, 25)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 40, 193, 25)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 64, 177, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
    Run("notepad.exe")
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 2)
    WinMove($hWnd, "", 1177, 0, 743, 1040)
    if GUICtrlRead($Checkbox1) = $GUI_CHECKED then send("A")
    if GUICtrlRead($Checkbox2) = $GUI_CHECKED then send("B")
    if GUICtrlRead($Checkbox3) = $GUI_CHECKED then send("C")
 EndSwitch
WEnd

Enjoy :)

Edited by Neutro
1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thank you very much!

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
Sign in to follow this  
Followers 0