Goto block that doesn't enclose it

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jaccotjuhhh
Posts: 27
Joined: 16 Mar 2018, 08:45

Goto block that doesn't enclose it

08 Jun 2018, 05:18

Hi all,

I have the following code:

Code: Select all

{ ;QNEXTCOHD
            
            { ;KEYTRIGGER
                #if winexist("WO")
                lctrl & numpad8::
                `::
                guiWOQNCOHD:
                coordmode, mouse, screen
                sendinput, {lalt down}
                sendinput, {F4} 
                send {lalt up}
                sleep 1000
                click, 240, 90
                sleep 100
                click, 240, 90
                Goto, guiWOCOHD
                return
                #if
            }
        }
        { ; WOCOHD - CONTROLE HARDWARE SOFTWARE DOORSTROOM

            { ;KEYTRIGGER
            #if winexist("WO")
            
            lctrl & numpad7::
            guiWOCOHD:
            coordmode, mouse, screen
            sleep 500
            click, 200, 120
            sleep 100
            click, 200, 120
            sleep 50
            ALTCB2:=GETALTCB2(ALTCB2) ; GET WONUMMER
            sleep 100
            click, 505, 120 ;OPEN CHANGE
            sleep 3000
            click, 520, 330 ;OPEN AANVRAGER
            sleep 2000
            click, 110, 735 ;SHOW RECORD DETAILS
            sleep 1000
            click, 230, 490 ;SHOW CI
            GUIWOCOHD()
            return
            
            #if
            }
If i don't include the "Goto, guiWOCOHD". The code works perfectly. I can use lctrl&numpad8 to execute the first bit. And use lctrl&numpad7 to execute the second bit.
But what i want to achieve, is that if i press lctrl&numpad8, that it will automatically execute the tasks of lctrl&numpad7 as well.

The only way to make that happen as far as my knowledge goes, is to add a "Goto, guiWOCOHD". But that doesn't seem to work as it gives me an error "A goto/gosub must not jump into a block that doesn't enclose it".

Could anyone please bring me in the right direction of what to do?
(sorry if some of the comments are not understandable, they are in my own language)
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Goto block that doesn't enclose it

08 Jun 2018, 20:19

Maybe this:

Code: Select all


{ ;QNEXTCOHD
	
	{ ;KEYTRIGGER
		#if winexist("WO")
		lctrl & numpad8::
		`::
		Gosub, guiWOQNCOHD
		Return 
		#if
	}
}
{ ; WOCOHD - CONTROLE HARDWARE SOFTWARE DOORSTROOM
	
	{ ;KEYTRIGGER
		#if winexist("WO")
		
		lctrl & numpad7::
		Gosub, guiWOCOHD
		Return 
		#if
	}
}


guiWOQNCOHD:
coordmode, mouse, screen
sendinput, {lalt down}
sendinput, {F4}
send {lalt up}
sleep 1000
click, 240, 90
sleep 100
click, 240, 90
Goto, guiWOCOHD
return

guiWOCOHD:
coordmode, mouse, screen
sleep 500
click, 200, 120
sleep 100
click, 200, 120
sleep 50
ALTCB2:=GETALTCB2(ALTCB2) ; GET WONUMMER
sleep 100
click, 505, 120 ;OPEN CHANGE
sleep 3000
click, 520, 330 ;OPEN AANVRAGER
sleep 2000
click, 110, 735 ;SHOW RECORD DETAILS
sleep 1000
click, 230, 490 ;SHOW CI
GUIWOCOHD()
return
Outsourcing Clicks & Presses Since 2004.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder, sofista and 189 guests