Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send changed variables to already running function without pausing macro? Solved
#6
Here is what I've tested with your code and it seems working fine. The hotkeys did call the function and pass the variable with correct value to the function.

Macro PlayerHelper
Code:
Copy      Help
__RegisterHotKey hk1.Register(0 1 MOD_CONTROL|MOD_SHIFT 'X')
__RegisterHotKey hk2.Register(0 2 MOD_CONTROL|MOD_SHIFT 'Y')
__RegisterHotKey hk3.Register(0 3 MOD_CONTROL|MOD_SHIFT 'C')
__RegisterHotKey hk4.Register(0 4 MOD_CONTROL|MOD_SHIFT VK_F10)

;Kampfsperre
int x=0

;Zuschauverbot
int y=0

;Taktikmodus
int c=0

MSG z

rep
,if(GetMessage(&z 0 0 0)<1) break
,sel z.message
,,case WM_HOTKEY
,,sel z.wParam
,,,case 1
,,,,x += 1
,,,,out F"x={x}, y={y}, c={c}"
,,,,if (x=1)
,,,,,OnScreenDisplay "Kampfsperre" -1 20 100 "Arial" 20 0x00FFFF 8 "1"
,,,,,CombatSettings x y c
,,,,else
,,,,,x=0
,,,,,OsdHide "1"
,,,,,;;;end function
,,,,
,,,case 2
,,,,y +=1
,,,,out F"x={x}, y={y}, c={c}"
,,,,if (y=1)
,,,,,OnScreenDisplay "Zuschauverbot" -1 20 140 "Arial" 20 0x00FFFF 8 "2"
,,,,,CombatSettings x y c
,,,,else
,,,,,y = 0
,,,,,OsdHide "2"
,,,,,;;;end function
,,,,
,,,case 3
,,,,c += 1
,,,,out F"x={x}, y={y}, c={c}"
,,,,if (c=1)
,,,,,OnScreenDisplay "Taktikmodus" -1 20 180 "Arial" 20 0x00FFFF 8 "3"
,,,,,CombatSettings x y c
,,,,else
,,,,,c = 0
,,,,,OsdHide "3"
,,,,,;;;end function
,,,,
,,,case 4
,,,,OnScreenDisplay "END" 3 50 400 "Arial" 20 0x00FFFF

,,,ret
,DispatchMessage &z

In "CombatSettings" function I limit the "rep" to "rep 3" so you could easily see the changes. Later on you could remove the number 3 to let it run continuously. I've changed the logic to just output something to easy to see what's going on...

Function CombatSettings
Code:
Copy      Help
;/exe
function x1 y1 c1

rep 3
,if (x1=1)
,,out "x1 = 1 Do something here..."
,
,if (y1=1)
,,out "y1 = 1 Do something here..."
,
,if (c1=1)
,,,out "c1 = 1 Do something here..."


Messages In This Thread
RE: How to send changed variables to already running function without pausing macro? - by TeddyBear - 08-06-2020, 02:42 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)