Jump to content

Moving slider "behind the scenes"


anger
 Share

Recommended Posts

Hello,

I'm trying to make a program where I can make a toggle button ( which i can do).

But the toggle button needs to:

  • Move a slider to a specified location
  • Push an apply button

But i need this to be done "behind the scenes" so that I can have 1 full screen application running, and then i can push this hotkey to move a slider to a certain point and then push an apply button. And then push the button again to move the slider to its original position and push the apply button.

Psuedo code:

dim toggle as boolean = false

if <button name> is down and toggle = false then

toggle = true

moveSlider(15)

clickApplyButton()

else if <button name> is down and toggle = true then

toggle = false

moveSlider(0)

clickApplyButton()

end if

I would like to find out how to click the button and move the slider when it is not the maximised window. I found ControlClick and ControlSend but i found that it didnt actually work ;(

Any help?

Link to comment
Share on other sites

Hello,

I'm trying to make a program where I can make a toggle button ( which i can do).

But the toggle button needs to:

  • Move a slider to a specified location
  • Push an apply button

But i need this to be done "behind the scenes" so that I can have 1 full screen application running, and then i can push this hotkey to move a slider to a certain point and then push an apply button. And then push the button again to move the slider to its original position and push the apply button.

Psuedo code:

dim toggle as boolean = false

if <button name> is down and toggle = false then

toggle = true

moveSlider(15)

clickApplyButton()

else if <button name> is down and toggle = true then

toggle = false

moveSlider(0)

clickApplyButton()

end if

I would like to find out how to click the button and move the slider when it is not the maximised window. I found ControlClick and ControlSend but i found that it didnt actually work ;(

Any help?

Slider uses values.

GUICtrlSetData () sends values to controls.

GUICtrlSetData ($slider, 40) will send the value "40" to control $slider.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

Enter is the default key for the hidden button. Just run this and push enter and you will see what it does. Push apply and you see what that does. After clicking through the message boxes, push Enter key again and see how it works together. This should help you get started.

#include <GUIConstants.au3>

Global $isset = 0
$GUI = GUICreate("My GUI", 300, 200,-1,-1,-1,$WS_EX_ACCEPTFILES)
$toggle = GUICtrlCreateSlider(10,10,100,20)
$applybtn = GUICtrlCreateButton("Apply",10,40,100,20)
GUICtrlSetState($applybtn,$GUI_DISABLE)
Global $hiddenBTN = GUICtrlCreateButton("",150,10,100,10,$BS_DEFPUSHBUTTON) ; hidden button that accepts ENTER Key
GUICtrlSetState($hiddenBTN, $GUI_HIDE)
GUISetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $hiddenBTN
        MsgBox(0,"Hidden Button","We hit our hidden button which is set to ENTER key.")
       if $isset = 0 Then
            GUICtrlSetState($applybtn, $GUI_ENABLE)
            GUICtrlSetData($toggle,50)
            $isset = 1
        Else
            GUICtrlSetState($applybtn, $GUI_ENABLE)
            GUICtrlSetData($toggle,0)
            $isset = 0
        EndIf
    Case $msg = $applybtn
        $var = GUICtrlRead($toggle)
        MsgBox(0,"My Slider = ",$var)
        GUICtrlSetState($applybtn, $GUI_DISABLE)
        _focus()
    EndSelect
WEnd

Func _focus()
    GUICtrlSetState($hiddenBTN,$GUI_FOCUS)
    GUICtrlSetState($hiddenBTN,$GUI_DEFBUTTON)
EndFunc
Edited by Ealric

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Link to comment
Share on other sites

I'm not sure if those commands posted are for an autoit GUI or for an external program. Sorry if I wasn't clear enough, but I need to move this slider on another external program which is not coded in autoit and is in the background (ie maximised but I have a fullscreen application in front).

I was looking at this sort of thing:

ControlClick("DirectX Settings", "Slider1", 1028, "left", 20, 770, 433)

But it doesn't work :)

This is what I have so far:

#include <Misc.au3>

$dll = DllOpen("user32.dll")
$Toggle = False

While True
    If _IsPressed("11", $dll) And $Toggle = False Then
;move slider
;click apply
        $Toggle = True
    ElseIf _IsPressed("11", $dll) And $Toggle = True Then
;move slider back
;click apply
        $Toggle = False
    EndIf
WEnd

DllClose($dll)
Edited by anger
Link to comment
Share on other sites

I'm not sure if those commands posted are for an autoit GUI or for an external program. Sorry if I wasn't clear enough, but I need to move this slider on another external program which is not coded in autoit and is in the background (ie maximised but I have a fullscreen application in front).

I was looking at this sort of thing:

ControlClick("DirectX Settings", "Slider1", 1028, "left", 20, 770, 433)

But it doesn't work :)

This is what I have so far:

#include <Misc.au3>

$dll = DllOpen("user32.dll")
$Toggle = False

While True
    If _IsPressed("11", $dll) And $Toggle = False Then
;move slider
;click apply
        $Toggle = True
    ElseIf _IsPressed("11", $dll) And $Toggle = True Then
;move slider back
;click apply
        $Toggle = False
    EndIf
WEnd

DllClose($dll)

Look at GuiSlider Management in the help under UDFs that may help.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Look at GuiSlider Management in the help under UDFs that may help.

Is there any sort of tutorial I can follow to understand the basics of this.

If i look it up i find this:

_GUICtrlSlider_SetPos($hWnd, $iPosition)

Which seems useful, but I don't understand this:

$hWnd Handle to the control

I tried the "AutoIt v3 Window Info" and found its handle and tried this:

_GUICtrlSlider_SetPos(0x00020650, 15.0)

But it didn't seem to work.

Is there any basic tutorial I can follow that goes through what I need to do to even use this function or get the $hWnd of a slider on an external program?

Thanks

Link to comment
Share on other sites

YES!

I found it :)

Heres my code (works exactly how I wanted :)):

#include <Misc.au3>
#Include <GuiSlider.au3>

$dll = DllOpen("user32.dll")
$Toggle = False
$applyHandle = ControlGetHandle("Settings", "Slider1",1028)

While True
    If _IsPressed("11", $dll) And $Toggle = False Then
        _GUICtrlSlider_SetPos($applyHandle, 125)
        $Toggle = True
        sleep(500)
    ElseIf _IsPressed("11", $dll) And $Toggle = True Then
        _GUICtrlSlider_SetPos($applyHandle, 0)
        $Toggle = False
        sleep(500)
    EndIf
WEnd

DllClose($dll)
WinClose($handle)
Edited by anger
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...