Jump to content
Viperking123

Changing value by using GUI

Recommended Posts

Viperking123

Hello

I want to learn how to edit the code, by using GUI. I write this code(i use autoit for a week, don't blame me) for example.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("Coords", 32, 16, 81, 21)
$Input2 = GUICtrlCreateInput("Color", 128, 16, 81, 21)
$Radio1 = GUICtrlCreateRadio("PGUP", 40, 200, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("", 40, 232, 97, 17)
$Button1 = GUICtrlCreateButton("Change", 32, 40, 57, 17)
$Button2 = GUICtrlCreateButton("Change", 128, 40, 49, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

WEnd

MouseMove ( 1010, 361, [10] )
sleep(500)
$test = (PixelSearch(754, 326, 1454, 743, 0x3396D8))
MouseClick("left", $test[0], $test[1], 1, 1)
sleep(600)
MouseMove ( x, y [, speed = 10] )
sleep(500)
Send ( "{PGUP}" ,0 )

I want to learn how change MouseMove ( 1010, 361, [10] ) coordinates, by using Input1 + button1.

$test = (PixelSearch(754, 326, 1454, 743, 0x3396D8)) i want to change for different color by using input2+ button2

and the last thing, how to change Send ( "{PGUP}" ,0 ) to PGDOWN by clicking on radiobox or checkbox.

Can someone tell me how to begin work with it? 

 

Sorry for my bad english.

Share this post


Link to post
Share on other sites
careca

You'll want to create a structure with functions that act on the press of those buttons to read the input and translate that to a variable, to be then used in the mouseclick and whatnot. Same for the color, the issue will be you separating the coordinates, i would create another input, one for X other for Y.

As for the pgup pgdn, that's easy enough too. We'll get to that later.

here's a sample, so you can try to figure it out.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=By:
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Res_Icon_Add=.ico
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;=============================================================================
#Region ;Include + Opt
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>
Opt("TrayMenuMode", 3)
Opt("TrayIconHide", 0)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 0)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
#EndRegion ;Include + Opt
;=============================================================================
#Region ;GuiVars
Local $GUI, $Frm_main, $Button1, $Button2, $Input1, $Input2, $Radio1, $Checkbox1, $ReadIP1
;TrayVars
Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem
;MiscVars
Local $Au3filesArray, $Msg, $txt, $Reg, $RegTrim
#EndRegion ;GuiVars
;=============================================================================
#Region ;GUI
TraySetIcon("ico.ico")
$GUI = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("Coords", 32, 16, 81, 21)
$Input2 = GUICtrlCreateInput("Color", 128, 16, 81, 21)
$Radio1 = GUICtrlCreateRadio("PGUP", 40, 200, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("", 40, 232, 97, 17)
$Button1 = GUICtrlCreateButton("Change", 32, 40, 57, 17)
GUICtrlSetOnEvent($Button1, "ChangeCoords") ;Jump to function at press
$Button2 = GUICtrlCreateButton("Change", 128, 40, 49, 17)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")
$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")
GUISetState()
TraySetState(1)
TraySetClick(8)
#EndRegion ;GUI
;=============================================================================
Do ;Main
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;=============================================================================
Func ChangeCoords()
    $ReadIP1 = GUICtrlRead($Input1) ;Get the text on the input
    MsgBox(64, 'Result', $ReadIP1)
EndFunc   ;==>ChangeCoords
;=============================================================================
#Region ;Window
Func Minimize()
    WinSetState('', '', @SW_MINIMIZE)
EndFunc   ;==>Minimize
Func Restore()
    WinSetState('', '', @SW_RESTORE)
EndFunc   ;==>Restore
Func Quit()
    Exit
EndFunc   ;==>Quit
#EndRegion ;Window
;=============================================================================

 

  • Like 1

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
Jos

@Viperking123,

How is this one different from this closed thread?

You did read and understand the Forum rules you were pointed to?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Viperking123
9 hours ago, careca said:

You'll want to create a structure with functions that act on the press of those buttons to read the input and translate that to a variable, to be then used in the mouseclick and whatnot. Same for the color, the issue will be you separating the coordinates, i would create another input, one for X other for Y.

As for the pgup pgdn, that's easy enough too. We'll get to that later.

here's a sample, so you can try to figure it out.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=By:
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Res_Icon_Add=.ico
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;=============================================================================
#Region ;Include + Opt
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>
Opt("TrayMenuMode", 3)
Opt("TrayIconHide", 0)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 0)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
#EndRegion ;Include + Opt
;=============================================================================
#Region ;GuiVars
Local $GUI, $Frm_main, $Button1, $Button2, $Input1, $Input2, $Radio1, $Checkbox1, $ReadIP1
;TrayVars
Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem
;MiscVars
Local $Au3filesArray, $Msg, $txt, $Reg, $RegTrim
#EndRegion ;GuiVars
;=============================================================================
#Region ;GUI
TraySetIcon("ico.ico")
$GUI = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("Coords", 32, 16, 81, 21)
$Input2 = GUICtrlCreateInput("Color", 128, 16, 81, 21)
$Radio1 = GUICtrlCreateRadio("PGUP", 40, 200, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("", 40, 232, 97, 17)
$Button1 = GUICtrlCreateButton("Change", 32, 40, 57, 17)
GUICtrlSetOnEvent($Button1, "ChangeCoords") ;Jump to function at press
$Button2 = GUICtrlCreateButton("Change", 128, 40, 49, 17)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")
$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")
GUISetState()
TraySetState(1)
TraySetClick(8)
#EndRegion ;GUI
;=============================================================================
Do ;Main
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;=============================================================================
Func ChangeCoords()
    $ReadIP1 = GUICtrlRead($Input1) ;Get the text on the input
    MsgBox(64, 'Result', $ReadIP1)
EndFunc   ;==>ChangeCoords
;=============================================================================
#Region ;Window
Func Minimize()
    WinSetState('', '', @SW_MINIMIZE)
EndFunc   ;==>Minimize
Func Restore()
    WinSetState('', '', @SW_RESTORE)
EndFunc   ;==>Restore
Func Quit()
    Exit
EndFunc   ;==>Quit
#EndRegion ;Window
;=============================================================================

 

 

2 hours ago, Jos said:

@Viperking123,

How is this one different from this closed thread?

You did read and understand the Forum rules you were pointed to?

Jos

I was writing with moderator on pw, he told me my mistakes :) I just want to learn that thing.

Share this post


Link to post
Share on other sites
Viperking123
9 hours ago, careca said:

You'll want to create a structure with functions that act on the press of those buttons to read the input and translate that to a variable, to be then used in the mouseclick and whatnot. Same for the color, the issue will be you separating the coordinates, i would create another input, one for X other for Y.

As for the pgup pgdn, that's easy enough too. We'll get to that later.

here's a sample, so you can try to figure it out.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=By:
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Res_Icon_Add=.ico
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;=============================================================================
#Region ;Include + Opt
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>
Opt("TrayMenuMode", 3)
Opt("TrayIconHide", 0)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 0)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
#EndRegion ;Include + Opt
;=============================================================================
#Region ;GuiVars
Local $GUI, $Frm_main, $Button1, $Button2, $Input1, $Input2, $Radio1, $Checkbox1, $ReadIP1
;TrayVars
Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem
;MiscVars
Local $Au3filesArray, $Msg, $txt, $Reg, $RegTrim
#EndRegion ;GuiVars
;=============================================================================
#Region ;GUI
TraySetIcon("ico.ico")
$GUI = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("Coords", 32, 16, 81, 21)
$Input2 = GUICtrlCreateInput("Color", 128, 16, 81, 21)
$Radio1 = GUICtrlCreateRadio("PGUP", 40, 200, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("", 40, 232, 97, 17)
$Button1 = GUICtrlCreateButton("Change", 32, 40, 57, 17)
GUICtrlSetOnEvent($Button1, "ChangeCoords") ;Jump to function at press
$Button2 = GUICtrlCreateButton("Change", 128, 40, 49, 17)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")
$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")
GUISetState()
TraySetState(1)
TraySetClick(8)
#EndRegion ;GUI
;=============================================================================
Do ;Main
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;=============================================================================
Func ChangeCoords()
    $ReadIP1 = GUICtrlRead($Input1) ;Get the text on the input
    MsgBox(64, 'Result', $ReadIP1)
EndFunc   ;==>ChangeCoords
;=============================================================================
#Region ;Window
Func Minimize()
    WinSetState('', '', @SW_MINIMIZE)
EndFunc   ;==>Minimize
Func Restore()
    WinSetState('', '', @SW_RESTORE)
EndFunc   ;==>Restore
Func Quit()
    Exit
EndFunc   ;==>Quit
#EndRegion ;Window
;=============================================================================

 

Thank u, i don't understand it right now, but i will try :)

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.