Universal Control Remapper (UCR) - v0.1.22 28th Oct 2018

Post gaming related scripts
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

12 May 2016, 06:30

Are you talking about a custom plugin? I can't think of anything in UCR at the moment that sends a sequence.

With a custom plugin, you could add an InputButton for "Stop Sequence", then have the down event for the Stop Sequence hotkey set a class property that the code going through the sequence checks for.

Feel free to post code and I will see if I can help.
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

13 May 2016, 05:25

tnx for answer, u are right i am talking about custom plugin, here is my plugin for example, how can i add "Stop Sequence" button ?

Code: Select all

class string4 extends _Plugin {
        Type := "string4"
        Description := "Your description here"
        ; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
        Init(){ 
                ; Create the GUI
                ; Add a hotkey, and give it the name "MyHk1". All hotkey objects can be accessed via this.InputButtons[name]
                ; Have it call MyHkChangedState when it changes state.
                this.AddInputButton("IB1", 0, this.MyHkChangedState.Bind(this), "xm ym w200")
                ; Add an Output, and give it the name "MyOp1". All output objects can be accessed via this.OutputButtons[name]
                this.AddOutputButton("OB1", 0, "xm yp+25 w200")
                this.AddOutputButton("OB2", 0, "xm yp+25 w200")
                this.AddOutputButton("OB3", 0, "xm yp+25 w200")
                this.AddOutputButton("OB4", 0, "xm yp+25 w200")
                this.AddOutputButton("OB5", 0, "xm yp+25 w200")
                this.AddOutputAxis("OutputAxis1", 0, "xm yp+25 w125")
                this.AddOutputAxis("OutputAxis2", 0, "xm yp+25 w125")
        }

        ; Called when the hotkey changes state (key is pressed or released)
        MyHkChangedState(e){
                if (e){ ; Only do this on press of the Input Button (e=1), do nothing on release (e=0)
                        static StickOps := UCR.Libraries.StickOps
                        ; The input button was pressed, send the sequence of actions
                        Sleep 100
                        ; X Axis Forward
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
                        Sleep 25
                        ; X Axis Centre
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
                        Sleep 75
                        ; X Axis Forward
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
                        Sleep 50
                        ; Hold Button 5
                        this.OutputButtons.OB5.SetState(1)
                        Sleep 25
                        ; Release Button 5
                        this.OutputButtons.OB5.SetState(0)
                        Sleep 100
                        ; Hold Button 2
                        this.OutputButtons.OB2.SetState(1)
                        Sleep 25
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
                        ; X Axis centre
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
                        Sleep 75
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
                        Sleep 800
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
                        Sleep 150
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
                        Sleep 382
                        ; X Axis Forward
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
                        Sleep 25
                        ; Hold Button 2
                        this.OutputButtons.OB2.SetState(1)
                        Sleep 25
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
                        ; X Axis centre
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
                        Sleep 75
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
                        Sleep 75
                        ; Hold Button 2
                        this.OutputButtons.OB2.SetState(1)
                        Sleep 25
                } else {
                        ; Input Button was released
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
                }
        }
}
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

13 May 2016, 06:17

Something like this (untested)

Code: Select all

class string4 extends _Plugin {
        Type := "string4"
        Description := "Your description here"
        ; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
        Init(){ 
                ; Create the GUI
                ; Add a hotkey, and give it the name "MyHk1". All hotkey objects can be accessed via this.InputButtons[name]
                ; Have it call MyHkChangedState when it changes state.
                this.AddInputButton("IB1", 0, this.MyHkChangedState.Bind(this), "xm ym w200")
                ; Add an Output, and give it the name "MyOp1". All output objects can be accessed via this.OutputButtons[name]
                this.AddOutputButton("OB1", 0, "xm yp+25 w200")
                this.AddOutputButton("OB2", 0, "xm yp+25 w200")
                this.AddOutputButton("OB3", 0, "xm yp+25 w200")
                this.AddOutputButton("OB4", 0, "xm yp+25 w200")
                this.AddOutputButton("OB5", 0, "xm yp+25 w200")
                this.AddOutputAxis("OutputAxis1", 0, "xm yp+25 w125")
                this.AddOutputAxis("OutputAxis2", 0, "xm yp+25 w125")
                this.AddInputButton("Stop", 0, this.StopPressed.Bind(this), "xm w200")
        }
 
        ; Called when the hotkey changes state (key is pressed or released)
        MyHkChangedState(e){
                static StickOps := UCR.Libraries.StickOps
                if (e){ ; Only do this on press of the Input Button (e=1), do nothing on release (e=0)
						this.Stop := 0
                        ; The input button was pressed, send the sequence of actions
                        Sleep 100
                        ; X Axis Forward
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
						if (this.Stop)
							return
                        Sleep 25
                        ; X Axis Centre
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
						if (this.Stop)
							return
                        Sleep 75
                        ; X Axis Forward
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
						if (this.Stop)
							return
                        Sleep 50
                        ; Hold Button 5
                        this.OutputButtons.OB5.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                        ; Release Button 5
                        this.OutputButtons.OB5.SetState(0)
						if (this.Stop)
							return
                        Sleep 100
                        ; Hold Button 2
                        this.OutputButtons.OB2.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
						if (this.Stop)
							return
                        ; X Axis centre
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
						if (this.Stop)
							return
                        Sleep 75
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
						if (this.Stop)
							return
                        Sleep 800
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
						if (this.Stop)
							return
                        Sleep 150
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
						if (this.Stop)
							return
                        Sleep 382
                        ; X Axis Forward
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
						if (this.Stop)
							return
                        Sleep 25
                        ; Hold Button 2
                        this.OutputButtons.OB2.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
						if (this.Stop)
							return
                        ; X Axis centre
                        this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
						if (this.Stop)
							return
                        Sleep 75
                        ; Hold Button 1
                        this.OutputButtons.OB1.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                        ; Release Button 1
                        this.OutputButtons.OB1.SetState(0)
						if (this.Stop)
							return
                        Sleep 75
                        ; Hold Button 2
                        this.OutputButtons.OB2.SetState(1)
						if (this.Stop)
							return
                        Sleep 25
                } else {
                        ; Input Button was released
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
                }
        }
		
		StopPressed(e){
			if (e){
				this.Stop := 1
			}
		}
}
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

13 May 2016, 07:03

Of course, you could also have the sequence stop when you release the button:

Code: Select all

                } else {
                        ; Input Button was released
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
                        this.Stop := 1
                }
[Edit] Hmm, this may not work. Not sure if another thread will launch on release. If not, try putting #MaxThreadsPerHotkey 2 at the start of the script.
If this is needed, let me know, and I will add it to the UCR source, because this setting can only be made once for all plugins, so it should default to something other than 1
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

14 May 2016, 05:12

i tried

Code: Select all

StopPressed(e){
			if (e){
				this.Stop := 1
			}
		}
with adding #MaxThreadsPerHotkey 2 at the start of the script and it does not work :(
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

14 May 2016, 10:57

You are right TheFatal, I was hoping that it could be done simpler, but it appears that it cannot.
The problem is that due to the way UCR works, one hotkey cannot interrupt another hottkey's processing - regardless of the state of SetBatchLines, #MaxThreadsPerHotkey etc.

However, there is a solution. What we need to do is to allow the hotkey function (in your case MyHkChangedState) to return, but still start sending the sequence of keys.
We do this with SetTimer. SetTimer allows you to call functions at a given point in time, and can be used to say "run this function when this function ends".

We also need to be careful - if the input button is set to a key, and "Suppress Repeats" is not on, then the Send Sequence will be triggered over and over. To prevent this, on the down event for the input button, i check if the sequence is already active, and if so just return.

Code: Select all

class string4 extends _Plugin {
        Type := "string4"
        Description := "Your description here"
        ; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
        Init(){ 
                ; Create the GUI
                ; Add a hotkey, and give it the name "MyHk1". All hotkey objects can be accessed via this.InputButtons[name]
                ; Have it call MyHkChangedState when it changes state.
                this.AddInputButton("IB1", 0, this.MyHkChangedState.Bind(this), "xm ym w200")
                ; Add an Output, and give it the name "MyOp1". All output objects can be accessed via this.OutputButtons[name]
                this.AddOutputButton("OB1", 0, "xm yp+25 w200")
                this.AddOutputButton("OB2", 0, "xm yp+25 w200")
                this.AddOutputButton("OB3", 0, "xm yp+25 w200")
                this.AddOutputButton("OB4", 0, "xm yp+25 w200")
                this.AddOutputButton("OB5", 0, "xm yp+25 w200")
                this.AddOutputAxis("OutputAxis1", 0, "xm yp+25 w125")
                this.AddOutputAxis("OutputAxis2", 0, "xm yp+25 w125")
                this.AddInputButton("Stop", 0, this.StopPressed.Bind(this), "xm w200")
                this.SequenceOn := 0
                this.SendSequenceFn := this.SendSequence.Bind(this)
        }
 
        ; Called when the hotkey changes state (key is pressed or released)
        MyHkChangedState(e){
                static StickOps := UCR.Libraries.StickOps
                if (e){ ; Only do this on press of the Input Button (e=1), do nothing on release (e=0)
                        ; Manually enforce "No repeats" (keyboard keys may repeat "down" events)
                        if (this.SequenceOn)
                                return
                        ; Get the BoundFunc object for the Send Seqence function
                        fn := this.SendSequenceFn
                        ; Pass the boundfunc object to SetTimer and ask it to execute it once this function exits...
                        ; ... so that other hotkey functions can be called while SendSequence runs
                        SetTimer, % fn, -0
                } else {
                        ; Input Button was released
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
                        this.SequenceOn := 0
                }
        }
        
        SendSequence(){
                static StickOps := UCR.Libraries.StickOps
                this.SequenceOn := 1
                ; The input button was pressed, send the sequence of actions
                Sleep 100
                ; X Axis Forward
                this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; X Axis Centre
                this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
                Sleep 75
                if (!this.SequenceOn)
                    return
                ; X Axis Forward
                this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
                Sleep 50
                if (!this.SequenceOn)
                    return
                ; Hold Button 5
                this.OutputButtons.OB5.SetState(1)
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Release Button 5
                this.OutputButtons.OB5.SetState(0)
                Sleep 100
                if (!this.SequenceOn)
                    return
                ; Hold Button 2
                this.OutputButtons.OB2.SetState(1)
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Release Button 2
                this.OutputButtons.OB2.SetState(0)
                if (!this.SequenceOn)
                    return
                ; X Axis centre
                this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
                Sleep 75
                if (!this.SequenceOn)
                    return
                ; Hold Button 1
                this.OutputButtons.OB1.SetState(1)
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Release Button 1
                this.OutputButtons.OB1.SetState(0)
                Sleep 800
                if (!this.SequenceOn)
                    return
                ; Hold Button 1
                this.OutputButtons.OB1.SetState(1)
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Release Button 1
                this.OutputButtons.OB1.SetState(0)
                Sleep 150
                if (!this.SequenceOn)
                    return
                ; Hold Button 1
                this.OutputButtons.OB1.SetState(1)
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Release Button 1
                this.OutputButtons.OB1.SetState(0)
                Sleep 382
                if (!this.SequenceOn)
                    return
                ; X Axis Forward
                this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Hold Button 2
                this.OutputButtons.OB2.SetState(1)
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Release Button 2
                this.OutputButtons.OB2.SetState(0)
                if (!this.SequenceOn)
                    return
                ; X Axis centre
                this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
                Sleep 75
                if (!this.SequenceOn)
                    return
                ; Hold Button 1
                this.OutputButtons.OB1.SetState(1)
                Sleep 25
                if (!this.SequenceOn)
                    return
                ; Release Button 1
                this.OutputButtons.OB1.SetState(0)
                Sleep 75
                if (!this.SequenceOn)
                    return
                ; Hold Button 2
                this.OutputButtons.OB2.SetState(1)
                Sleep 25
                this.SequenceOn := 0
        }
 
		StopPressed(e){
			if (e){
				this.SequenceOn := 0
			}
		}
}

TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

15 May 2016, 03:01

changed pluggin but still no effect :(

Code: Select all

class string4 extends _Plugin {
	Type := "string4"
	Description := "Your description here"
	; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
	Init(){
		; Create the GUI
		; Add a hotkey, and give it the name "MyHk1". All hotkey objects can be accessed via this.InputButtons[name]
		; Have it call MyHkChangedState when it changes state.
		this.AddInputButton("IB1", 0, this.MyHkChangedState.Bind(this), "xm ym w200")
		; Add an Output, and give it the name "MyOp1". All output objects can be accessed via this.OutputButtons[name]
		this.AddOutputButton("OB1", 0, "xm yp+25 w200")
		this.AddOutputButton("OB2", 0, "xm yp+25 w200")
		this.AddOutputButton("OB3", 0, "xm yp+25 w200")
		this.AddOutputButton("OB4", 0, "xm yp+25 w200")
		this.AddOutputButton("OB5", 0, "xm yp+25 w200")
		this.AddOutputAxis("OutputAxis1", 0, "xm yp+25 w125")
		this.AddOutputAxis("OutputAxis2", 0, "xm yp+25 w125")
		this.AddInputButton("Stop", 0, this.StopPressed.Bind(this), "xm w200")
     		this.SequenceOn := 0
           this.SendSequenceFn := this.SendSequence.Bind(this)
	}
 
	; Called when the hotkey changes state (key is pressed or released)
	MyHkChangedState(e){
		static StickOps := UCR.Libraries.StickOps
		if (e){	; Only do this on press of the Input Button (e=1), do nothing on release (e=0)
			if (this.SequenceOn)
                                return
                        ; Get the BoundFunc object for the Send Seqence function
                        fn := this.SendSequenceFn
                        ; Pass the boundfunc object to SetTimer and ask it to execute it once this function exits...
                        ; ... so that other hotkey functions can be called while SendSequence runs
                        SetTimer, % fn, -0
                } else {
                        ; Input Button was released
                        ; Release Button 2
                        this.OutputButtons.OB2.SetState(0)
                        this.SequenceOn := 0
                }
		}

	SendSequence(){
                static StickOps := UCR.Libraries.StickOps
                this.SequenceOn := 1
			; The input button was pressed, send the sequence of actions
			Sleep 100
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 25
			; X Axis Centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 75
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 50
			; Hold Button 5
			this.OutputButtons.OB5.SetState(1)
			Sleep 25
			; Release Button 5
			this.OutputButtons.OB5.SetState(0)
			Sleep 100
			; Hold Button 2
			this.OutputButtons.OB2.SetState(1)
			Sleep 25
			; Release Button 2
			this.OutputButtons.OB2.SetState(0)
			; X Axis centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 75
			; Hold Button 1
			this.OutputButtons.OB1.SetState(1)
			Sleep 25
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			Sleep 800
			; Hold Button 1
			this.OutputButtons.OB1.SetState(1)
			Sleep 25
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			Sleep 150
			; Hold Button 1
			this.OutputButtons.OB1.SetState(1)
			Sleep 25
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			Sleep 382
			; X Axis Forward
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(100))	
			Sleep 25
			; Hold Button 2
			this.OutputButtons.OB2.SetState(1)
			Sleep 25
			; Release Button 2
			this.OutputButtons.OB2.SetState(0)
			; X Axis centre
			this.OutputAxes.OutputAxis1.SetState(StickOps.AHKToVjoy(50))
			Sleep 75
			; Hold Button 1
			this.OutputButtons.OB1.SetState(1)
			Sleep 25
			; Release Button 1
			this.OutputButtons.OB1.SetState(0)
			Sleep 75
			; Hold Button 2
			this.OutputButtons.OB2.SetState(1)
			Sleep 25
			this.SequenceOn := 0
		}
		StopPressed(e){
			if (e){
				this.SequenceOn := 0
			}
		}
}
 
 
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

16 May 2016, 12:09

evilC wrote:Did you change my code at all? did my code work?
if i use your script i need to hold input button to sequence work, but i want to press 1 button to start sequence and 1 another button to cancel it, is it possible ?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

16 May 2016, 12:26

My script has both methods.

If you do not want it to stop on release of button, comment out the line this.SequenceOn := 0 from StopPressed()
replace

Code: Select all

                        this.OutputButtons.OB2.SetState(0)
                        this.SequenceOn := 0
with

Code: Select all

                        this.OutputButtons.OB2.SetState(0)
                        ;this.SequenceOn := 0
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

16 May 2016, 13:02

i have one more question: can i use 1 button (space for example) to cancel sequences from 4 plugins ?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

16 May 2016, 13:42

I had intended on supporting inter-plugin communication, which would allow that, but for the moment, as far as I am aware there is nothing stopping you from binding the same key as an input for multiple plugins.
So simply bind Space to the stop button for all the plugins.

I had originally intended to not allow you to bind the same key in multiple places, but I am now coming to the conclusion that would be a bad idea. Maybe warn the user, but it should be allowed as it clearly has it's uses.
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

16 May 2016, 16:08

evilC wrote:I had intended on supporting inter-plugin communication, which would allow that, but for the moment, as far as I am aware there is nothing stopping you from binding the same key as an input for multiple plugins.
So simply bind Space to the stop button for all the plugins.

I had originally intended to not allow you to bind the same key in multiple places, but I am now coming to the conclusion that would be a bad idea. Maybe warn the user, but it should be allowed as it clearly has it's uses.
well i bind space in 2 plugins, in 1 it works correctly, in 2 it does not work

https://i.gyazo.com/215ba38e4ef82b90bd4 ... 07dc6e.png
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

16 May 2016, 16:12

I have been toying around with ideas for incorporating the Profile Toolbox into the main UI.

I have come up with this (AHK_H required)
Note that the Toolbox (Red) pane can be resized using it's left edge.

This version uses the actual border of the toolbox window to do the resize, but I may end up doing my own version as it is not easy to see the border.
This technique also requires specific layering and sizing to that only the left border of the toolbox window is visible.

Code: Select all

#SingleInstance force
OutputDebug DBGVIEWCLEAR

MAIN_WIDTH := 100

Gui +HwndhMainGui
Gui, % hMainGui ":Margin", 0, 0
Gui, % hMainGui ":+Resize"

Gui, New, HwndhSidePanel
Gui, % hSidePanel ":+Resize"
Gui, % hSidePanel ":-Caption"
Gui, % hSidePanel ":Add", Edit, w100 aw ah , Profile Toolbox
Gui, % hSidePanel ":Show", Hide
Gui, % hSidePanel ":Color", Red
Gui, % hMainGui ":Add", Gui, % "x" MAIN_WIDTH " ", % hSidePanel

Gui, New, HwndhTopPanel
Gui, % hTopPanel ":Add", Edit, aw ah, Top Panel
Gui, % hTopPanel ":-Caption"
Gui, % hTopPanel ":Show", Hide
Gui, % hTopPanel ":Color", Blue
Gui, % hMainGui ":Add", Gui, % "x0 w" MAIN_WIDTH " h50", % hTopPanel

Gui, New, HwndhPluginArea
Gui, % hPluginArea ":-Caption"
Gui, % hPluginArea ":+Scroll"
;Gui, % hPluginArea ":+MaxSize500"	; Doesn't work :(
Gui, % hPluginArea ":Show", Hide
Gui, % hPluginArea ":Color", Green
Gui, % hMainGui ":Add", Gui, % "w" MAIN_WIDTH " h50 x0", % hPluginArea

Gui, % hMainGui ":Show", x0 y0 Hide, UCR Layout POC
Gui, % hMainGui ":Show", x0 y0 w400 h300

Loop 10 {
	Gui, % hPluginArea ":Add", Edit, w400 h50, % "Plugin " A_Index
}
return

GuiSize(hwnd, EventInfo, Width, Height){
	static tw := 100
	global hMainGui, hSidePanel, hTopPanel, hPluginArea
	if (hwnd == hSidePanel && tw != rect.Width){
		; Side panel dragged
		rect := WindowGetRect(hwnd)
		OutputDebug % "UCR| Toolbar - Width: " rect.Width " tw: " tw
		tw := rect.Width
		; Set variables for MainGui, allow to drop through and re-draw main window
		hwnd := hMainGui
		rect := WindowGetRect(hwnd)
		Width := rect.Width, Height := rect.Height
	}
	if (hwnd == hMainGui){
		OutputDebug % "UCR| Main Width: " Width
		Gui % hTopPanel ":Show", % "x0 y0 w" Width " h40"
		;Gui % hPluginArea ":Show", % "x0 y40 w" Width - tw - 20 " h" Height - 40
		GuiControl, % hMainGui ":Move", % hPluginArea, % "x0 y40 w" Width - tw " y40 h" Height - 40
		Gui % hSidePanel ":Show", % "x" Width - tw " y30 w" tw " h" Height - 35
		;GuiControl, % hMainGui ":Move", % hSidePanel, % "x" Width - tw " y40 w" tw " h" Height - 40
		
	}
}

WindowGetRect(hwnd) {
	VarSetCapacity(rect, 16, 0)
	DllCall("GetClientRect", "Ptr", hwnd, "Ptr", &rect)
	return {width: NumGet(rect, 8, "Int"), height: NumGet(rect, 12, "Int")}
}

GuiClose:
	ExitApp

User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

16 May 2016, 16:18

Yeah, of course, thinking about it, I was thinking per profile, not per plugin.
Being able to talk to other plugins will not happen until I give each plugin a unique ID.
When I do that, then I could make a plugin selector like the profile selector, and you could configure one plugin to be able to point to another.

So usage would be something like:
PluginSelects.MyPluginSelect.PleaseStop() to call the "PleaseStop()" function in the plugin that the user selected.
TheFatal
Posts: 34
Joined: 30 Jan 2016, 06:58

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

17 May 2016, 03:49

so is there any way to bind global stop button for all plugins in profile ?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.7 13th Mar 2016

17 May 2016, 06:40

I have not provided a mechanism to do it, but it could be done.

For example, if in the Init() function of plugin A, you put:

UCR.PluginA:= this

Then you could call the "StopSequence()" function of PluginA from PluginB by using this code in PluginB:

UCR.PluginA.StopSequence()

Or you could store the variable on the parent profile:

Put in PluginA's Init():
this.ParentProfile.PluginA:= this

In Plugin B:
this.ParentProfile.PluginA.StopSequence()
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.0.12 17th May 2016

21 May 2016, 15:08

New release - quite a lot in here.

PLEASE READ THE RELEASE NOTES AT THE BOTTOM OF THE POST. TLDR: BACK UP YOUR INI FILE BEFORE RUNNING

First up, plugins now all have a unique ID, in fact profiles also moved to a new "GUID" system.
This does not really change anything now, but it opens the door to many possibilities in the future.

Secondly, and more noticeably, the state of the hotkeys for each profile is shown in the profile toolbox.

Blue = Current profile, so is obviously active/
Green = profile running, hotkeys active (will just be global profile for now, but could optionally be parent profile too soon)
Amber = hotkey thread loaded but inactive, profile inactive. (ie ready to be turned on very quickly).

If you point a profile switcher plugin to another profile, that profile will turn amber to tell you that it is "linked" and ready to rock at a moment's notice.

Image

The plan is to allow you to set a profile to inherit the hotkeys of it's parent (ie when that profile is active, also keep the parent active).

In this way, you can do "shift states" without having to reproduce all the controls on each shifted profile, and all the needed profiles stay running and ready to shift to, but all your other profiles stay out of memory.

Code: Select all

Key:
! : Warning
* : Comment
= : Change / Fix
+ : Added feature

0.0.13 - 21st May 2016
! INI (Settings) file format changed. UCR will attempt to upgrade for you.
  YOU ARE ADVISED TO BACK UP YOUR UCR.INI BEFORE RUNNING THIS VERSION.
  If you have problems, please post on the forums.
= Plugins are now uniquely identified by IDs.
  This does not affect anything now, but it is an enabler for future features.
  eg: Renaming of plugins, moving plugins between profiles, inter-plugin communication.
= All IDs (Profile and Plugin) are now GUIDs generated via windows APIs
+ Status of Input Threads is now show in the Profile Toolbox.
  Blue = current profile, Green = active (eg global), Amber = Loaded but paused
= Fixes to logic for loading / unloading of Input Threads
= Up event for joystick buttons should now properly trigger...
  ... when entering a profile with the button already held.
+ UCR should now wait until done saving if you close the GUI mid-save.
+ Profile Toolbox now has a title in the GUI

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 41 guests