GuiControl and ahkgetvar with AutoHotkey.dll

Get help with using AutoHotkey and its commands and hotkeys
manehscripts
Posts: 82
Joined: 03 May 2019, 16:10

GuiControl and ahkgetvar with AutoHotkey.dll

23 May 2019, 04:55

Hi guys!

The script below runs a loop using Autohotkey.dll, my question is about the GuiControl system that changes the Gui information. It is not working inside ahktextdll ("(LTrim ...)")

Note that just above I made a resemblance out of this condition and it works. Can someone help me? I started messing with Autohotkey.dll today, and I'm still learning.

Code: Select all

AhkThread := AhkDllThread("AutoHotkey.dll")

Gui, Add, Edit, r4 ReadOnly w200 vChangeInfo, STOPPED!
Gui, Add, Button, vStart gStart, START!
Gui, Show
return

toggle := 0
Start:
    toggle := !toggle
    if (toggle) {
		GuiControl,, Start, STOP!		
		; HERE WORK
		; ==================
		;~ AhkThread.ahktextdll() 
		;~ AhkThread.ahkassign.a := "Starting..."
		;~ MsgBox % AhkThread.ahkgetvar.a
		;~ Loop {
			;~ GuiControl,, ChangeInfo, %A_Index% !
		;~ }
		; ==================

		; HERE DON'T WORK
		; ==================
		AhkThread.ahkassign.a := "Starting..."
		AhkThread.ahktextdll("
		(LTrim
			MsgBox % AhkThread.ahkgetvar.a
			Loop {
				GuiControl,, ChangeInfo, %A_Index%!
			}
		)")
		; ==================
		AhkThread.ahkPause("Off")
    } else {
        AhkThread.ahkTerminate.1
        GuiControl,, ChangeInfo, STOPPED!
        GuiControl,, Start, START!
    }
return

ESC::ExitApp
GuiClose:
ExitApp
manehscripts
Posts: 82
Joined: 03 May 2019, 16:10

Re: GuiControl and ahkgetvar with AutoHotkey.dll

23 May 2019, 15:08

Hi,

I able to do change the GuiControl using ahkReady() But would there be another way I can add this change inside the Loop?

Code: Select all

AhkThread := AhkDllThread("AutoHotkey.dll")

Gui, Add, Edit, r4 ReadOnly w200 vChangeInfo, STOPPED!
Gui, Add, Button, vStart gStart, START!
Gui, Show
return

toggle := 0
Start:
    toggle := !toggle
    if (toggle) {
		GuiControl,, Start, STOP!		
		AhkThread.ahktextdll("
		(LTrim
			Loop {
				var1++
				Tooltip, Script 1 | Contagem: %var1%, 14, -100
			}
		)")
		if AhkThread.ahkReady() {
			GuiControl,, ChangeInfo,  RUNNING!
		}
		AhkThread.ahkPause("Off")
    } else {
        AhkThread.ahkTerminate.1
        GuiControl,, ChangeInfo, STOPPED!
        GuiControl,, Start, START!
    }
return

ESC::ExitApp
GuiClose:
ExitApp
HotKeyIt
Posts: 1850
Joined: 29 Sep 2013, 18:35
Contact:

Re: GuiControl and ahkgetvar with AutoHotkey.dll

07 Jun 2019, 17:20

Like this:

Code: Select all

AhkThread := AhkDllThread("AutoHotkey.dll")

Gui, Add, Edit, r4 ReadOnly w200 vChangeInfo hwndhControl, STOPPED!
Gui, Add, Button, vStart gStart, START!
Gui, Show
return

toggle := 0
Start:
    toggle := !toggle
    if (toggle) {
		GuiControl,, Start, STOP!		
		AhkThread.ahktextdll("
		(LTrim
			Pause
			Loop {
				var1++
				ControlSetText, , Script 1 | Contagem: %var1%, ahk_id %hControl%
			}
		)")
		ahkThread.ahkassign("hControl",hControl)
		AhkThread.ahkPause("Off")
    } else {
        AhkThread.ahkTerminate.1
        GuiControl,, ChangeInfo, STOPPED!
        GuiControl,, Start, START!
    }
return

ESC::ExitApp
GuiClose:
ExitApp

Return to “Ask For Help”

Who is online

Users browsing this forum: JoeWinograd, phamduc0110, teadrinker, WilburBr and 133 guests