crysis weapon wheel styled gui Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
yawikflame
Posts: 21
Joined: 02 Jan 2017, 06:19
Contact:

crysis weapon wheel styled gui

15 Apr 2017, 08:51

A little intro:
i'm currently working on enhancing my code which lets me open favorite folders/websites/programs/etc..
i took rajat's ToolTip Mouse Menu and changed it a little bit to my liking.
as i study further into the language of AHK, i could really use some professional guidance on how to approach the next "update" to this code.

Code: Select all

#SingleInstance, force

;    Protection
;------------------------
;-----------------------------
/*
password = **********(password)
InputBox, pass, Please Enter Password
If ( pass <> password )
{
	Run, folder dir
	ExitApp
}
MsgBox You reached here - correct!
*/

;    Globals
;------------------------
;-----------------------------

UMDelay = 20


;    Initiate Interface
;------------------------
;-----------------------------


;opens the gui where the last position of the mouse was
/*
~MButton::
HowLong = 0
Loop
{
    HowLong ++
    Sleep, 10
    GetKeyState, MButton, MButton, P
    IfEqual, MButton, U, Break
}
IfLess, HowLong, %UMDelay%, Return
CoordMode, Mouse, Screen
MouseGetPos, mX, mY
Gui, Show, x%mX% y%mY% w300 h180, `t
*/

;opens the gui on the right side of the screen as a horizontal taskbar
~MButton::
HowLong = 0
Loop
{
    HowLong ++
    Sleep, 10
    GetKeyState, MButton, MButton, P
    IfEqual, MButton, U, Break
}
IfLess, HowLong, %UMDelay%, Return
CoordMode, Mouse, Screen


;   Gui Layout
;----------------
;---------------------------

MyPics:
	Mx = 0
	My = 0
	num = 1
	Loop, 14
	{
		Gui, Add, Picture, x%Mx% y%My% w60 h60 g%num%, folder dir\%num%.png
		num++
		Mx += 60
		IfGreater, Mx, 0
		{
			My += 60
			Mx = 0
		}
		IfGreater, num, 14
			break
	}
	Gui, +AlwaysOnTop
	;Gui, -caption        //removes the gui's menu bar
	Gui, Color, 000111
	Gui, Show, x1840 y0 w60 h900, `t
	WinSet, Transcolor, 000111, `t
	return




;   Lables
;----------------
;---------------------------

GuiClose:
	Gui, Hide
	return


1:	;
	Gui, Hide
	Run, "weblink"
	return

2:	;WhatsApp
	Gui, Hide
	Run, "weblink"
	return

3:	;Google Photos
	Gui, Hide
	Run, "weblink"
	return
	
	return

4:	;Starcraft 2
	Gui, Hide
	Run, "folder dir"
	return
	
5:	;YouTube
	Gui, Hide
	Run, "weblink"
	return

6:	;Facebook
	Gui, Hide
	Run, "weblink"
	return

7:	;Mobizen
	Gui, Hide
	Run, "weblink"
	return
	
8:	;Kodi
	Gui, Hide
	Run, "folder dir"
	return

9:	;Twitch
	Gui, Hide
	Run, "weblink"
	return

10:
	;JavaFolder
	Gui, Hide
	Run, "folder dir"
	return

11:	;Edit My Code
	Gui, Hide
	Edit
	return

12:	;Inbox By Gmail
	Gui, Hide
	Run, "weblink"
	return

13:	;Memory
	Gui, Hide
	Run, "script"
	return

14:	;My Site
	Gui, Hide
	Run, "weblink"
	return





;   Functions
;----------------
;---------------------------




;   Hotkeys
;----------------
;---------------------------

~^Numpad5::
	send, ***********(password)
	send, {enter}
	return

~^Numpad4::
	send, ************(username)
	send, {Tab}
	send, *********(password)
	send, {Enter}
	return



Esc::ExitApp
The question:
I am now trying to apply features inspired by a game i played called crysis(by EA).
in this first person shooter you have an option to hold down the middle mouse button in order to show(gui, show) a menu of which you can(firstly) highlight a "power"(in the game you have a suite that enhances your powers) and then simply by releasing the middle mouse button(over the desired power, or program in my case) it is "clicked"(or selected) and in that case it would run a certain function for example.
an image to illustrate:
https://www.epicgames.com/unrealtournam ... ?id=353730


any ideas/improvements/notes/remarks are always welcome!
i'd greatly appreciate any help!
thanks for reading!
cheers,
yawik ;)
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: crysis weapon wheel styled gui

15 Apr 2017, 09:21

This mechanic is mouse gestures I belive. It could indeed be realy cool and I wonder how it's done in AHK.

This is what I found googling this therm: https://autohotkey.com/docs/scripts/MouseGestures.htm, an fully scripted example.

Is this what you searched for?
User avatar
yawikflame
Posts: 21
Joined: 02 Jan 2017, 06:19
Contact:

Re: crysis weapon wheel styled gui

15 Apr 2017, 10:19

DyaTactic wrote:This mechanic is mouse gestures I belive. It could indeed be realy cool and I wonder how it's done in AHK.

This is what I found googling this therm: https://autohotkey.com/docs/scripts/MouseGestures.htm, an fully scripted example.

Is this what you searched for?
Thank you for replying to my question!

unfortunately it is not what i am looking for.

i believe(and hope) the answer is more "mechanical" than gestures(tried using the code from the link you provided).

while gesture capture is very cool on its own, what i'm attempting to apply probably has to do with the key state of the middle mouse button and perhaps something that highlights and selects a part of the dynamic gui which will appear after holding it(MM Button) simply by hovering over it with the mouse and releasing it there.

Thanks again!
cheers,
yawik ;)
User avatar
Spawnova
Posts: 557
Joined: 08 Jul 2015, 00:12
Contact:

Re: crysis weapon wheel styled gui  Topic is solved

15 Apr 2017, 10:24

I've written a quick example that you may find useful.

It checks the distance and angle from the first mouse position on mbutton and the current mouse position during the loop
then checks to see which item is selected based off the current angle

Code: Select all

menuItems := ["item1","item2","item3","item4"]
angleIncrease := 360 / menuItems.MaxIndex() ;sets the angle increase based off how many items so 4 items = (360/4 = 90)  0-90 = item1, 91-180 = item2 etc
gui,font,cred s14
Gui, Add, Text, 0x200 center x2 y0 w80 h70 vi1
Gui, Add, Text, 0x200 center x2 y70 w80 h70 vi2
Gui, Add, Text, 0x200 center x82 y70 w80 h70 vi3
Gui, Add, Text, 0x200 center x82 y0 w80 h70 vi4
Gui, Show, x293 y315 h143 w164, test
Return

GuiClose:
ExitApp

mbutton::
mousegetpos,ox,oy
lastSelected := -1
while(getkeystate("mbutton","P")) {
	mousegetpos,nx,ny
	x := nx-ox
	y := ny-oy
	dist:= sqrt((x*x) + (y*y))
	angle:= abs(180 + Atan2(X,Y) * (180 / 3.14))
	if (dist > 70) { ;if mouse has moved outwards
		ang_current := angleIncrease ;loop from min angle to max angle checking to see which item should be selected
		loop % menuItems.MaxIndex() {
			if (angle < ang_current) { ;if current checked angle is smaller than an item angle then this must be selected
				if (lastSelected != a_index) {
					guicontrol,,i%a_index%, % menuItems[a_index]
					guicontrol,,i%lastSelected%,
					lastSelected := a_index
				}
				break
			}
			ang_current += angleIncrease
		}
	}
}
msgbox % "You've chosen " (lastSelected > 0 ? menuItems[lastSelected] : "nothing")
return

f9::reload


Atan2(y,x)
{
	return (x > 0 ? Atan(y/x)
	: ((y >= 0 AND x < 0) ? Atan(y/x) + 3.14159265359
	: ((y < 0 AND x < 0) ? Atan(y/x) - 3.14159265359
	: ((y > 0 AND x = 0) ? 3.14159265359/2
	: ((y < 0 AND x = 0) ? -3.14159265359/2 : "")))))
}
User avatar
yawikflame
Posts: 21
Joined: 02 Jan 2017, 06:19
Contact:

Re: crysis weapon wheel styled gui

15 Apr 2017, 11:11

@Spawnova
thank you for the reply!

the code you sent seems very relevant!

i'll send a finished code for my gui hopefully in the next few days.


thanks again!
cheers,
yawik ;)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mstrauss2021, Spawnova, william_ahk and 363 guests