Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

IF/ELSE



  • Please log in to reply
2 replies to this topic
Strahinja
  • Members
  • 21 posts
  • Last active: Jul 02 2013 10:14 AM
  • Joined: 28 Sep 2012

Hello!
How could I incorporate SHIFT in this script, so that I could use both CTRL and SHIFT keys? 

PressButton()
{
If (SubStr(A_ThisHotkey,1,1) = "^")
   {
   StringReplace, key, A_ThisHotkey, ^, ctrl_, all
   newX := X_%key% * A_ScreenWidth   
   newY := Y_%key% * A_ScreenHeight
   }
else  
   {
   newX := X_%A_ThisHotkey% * A_ScreenWidth   
   newY := Y_%A_ThisHotkey% * A_ScreenHeight
   }
 
   MouseGetPos, oldX, oldY
   MouseMove, newX, newY, 0
   Send {Lbutton}
   MouseMove, oldX, oldY, 0
   return
}

Thank you!



A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013
✓  Best Answer

Sorry if I my understood you but this should allow usage of Shift in your function.

PressButton()
{
If (SubStr(A_ThisHotkey,1,1) = "^") or (Substr(A_thishotkey, 1, 1) = "+")
   {
	tofind := Substr(A_thishotkey, 1, 1)
	replacetext := ( tofind == "^" ) ? "ctrl_" : "shift_"
	StringReplace, key, A_ThisHotkey, %tofind%, %replacetext%, all
	newX := X_%key% * A_ScreenWidth   
	newY := Y_%key% * A_ScreenHeight
   }
else  
   {
   newX := X_%A_ThisHotkey% * A_ScreenWidth   
   newY := Y_%A_ThisHotkey% * A_ScreenHeight
   }
 
   MouseGetPos, oldX, oldY
   MouseMove, newX, newY, 0
   Send {Lbutton}
   MouseMove, oldX, oldY, 0
   return
}

Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


Strahinja
  • Members
  • 21 posts
  • Last active: Jul 02 2013 10:14 AM
  • Joined: 28 Sep 2012

It worked! Thank you!