ajuda com a GUI

Tire suas dúvidas sobre programação em AutoHotkey

Moderator: Gio

theon
Posts: 124
Joined: 23 Jun 2019, 15:39

ajuda com a GUI

10 Feb 2022, 20:40

boa noite, o drop list nao pega nao sei porque alguém pode me explica como fazer funcionar pf...

Code: Select all

#SingleInstance, Force
#Persistent
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1

Gui Font, s9, Segoe UI
Gui Add, CheckBox, x91 y92 w120 h23 , Ativar 
Gui Add, DropDownList, x90 y54 w120 vname ggot, char1||char2||char3||char4||char5||
Gui Add, Text, x16 y7 w120 h23 +0x2000, Lider

Gui Show, w299 h173, Window

SetTimer, ParseChatLog, 1 ;// 3 seconds
return
got:




MyChatID = GetChatID("name") ;// The name assigned to the channel

return

GetChatID(Channel) { ;// Get the unique chat_id value using the channel name
	HttpRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	HttpRequest.Open("GET", "https://tlk.io/" Channel, true)
	HttpRequest.Send()
	HttpRequest.WaitForResponse()
	RegExMatch(HttpRequest.ResponseText, "chat_id\s=\s'(\d+)';", ChatID)
	return ChatID1
}

GetChatLog(ChatID) { ;// Get the JSON data returned from the API URL
	HttpRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	HttpRequest.Open("GET", "https://tlk.io/api/chats/" ChatID "/messages", true)
	HttpRequest.Send()
	HttpRequest.WaitForResponse()
	return HttpRequest.ResponseText
}

ParseChatLog() { ;// Parse the JSON data
	Global MyChatID
	Static LastID
	
	MyChatLog := GetChatLog(MyChatID) ;// Get the JSON data
	
	ChatLog := [{}] ;// Create an array containing an object

	Pos := 1, Match := ""
	While (Pos := RegExMatch(MyChatLog, "({.*?})", Match, Pos + StrLen(Match))) {
		RegExMatch(Match1, """id"":(\d+),", id)
		RegExMatch(Match1, """user_token"":""(.*?)"",", user_token)
		RegExMatch(Match1, """nickname"":""(.*?)"",", nickname)
		RegExMatch(Match1, """body"":""(.*?)"",", body)
		RegExMatch(Match1, """user"":{(.*?)},", user)
		RegExMatch(user1, """token"":""(.*?)"",", u_token)
		RegExMatch(user1, """nickname"":""(.*?)"",", u_nickname)
		RegExMatch(user1, """provider"":""(.*?)"",", u_provider)
		RegExMatch(user1, """avatar"":""(.*?)"",", u_avatar)
		RegExMatch(user1, """profile_url"":""(.*?)""}", u_profile_url)
		RegExMatch(Match1, """timestamp"":(\d+),", timestamp)
		RegExMatch(Match1, """closest_milestone"":(\d+),", closest_milestone)
		RegExMatch(Match1, """deleted"":(.*?)}", deleted)
		
		;// Assign parsed items to the array
		ChatLog[A_Index] := {"id": id1
		,"user_token": user_token1
		,"nickname": nickname1
		,"body": body1
		,"u_token": u_token1
		,"u_nickname": u_nickname1
		,"u_provider": u_provider1
		,"u_avatar": u_avatar1
		,"u_profile_url": u_profile_url1
		,"timestamp": timestamp1
		,"closest_milestone": closest_milestone1
		,"deleted": deleted1}
	}
	
	;// Do nothing if no new messages
	If (LastID = ChatLog[ChatLog.MaxIndex()].id) {
		return
	}
	
	;// Store ID of last message to variable
	LastID := ChatLog[ChatLog.MaxIndex()].id
	
	;// Execute command based on the message text
	ExecuteCommand(ChatLog[ChatLog.MaxIndex()].body)
}

ExecuteCommand(Text) {
	If (Text = "MsgBox") { ;// Keyword 1
		MsgBox, % Hello World! ;// Display message box
	} Else If (Text = "start") { ;// Keyword 2
		Send, {f10} ;// Open start menu
	} Else If (Text = "Notepad") { ;// Keyword 3
		Run, notepad.exe ;// Run notepad
	} Else { ;// Other
		If (Text = "") {
			return ;// Do nothing if no text (messages deleted, etc...)
		}
		
		MsgBox, % Text ;// Show text if not matching defined keywords
	}
}
User avatar
Gio
Posts: 1248
Joined: 30 Sep 2013, 10:54
Location: Brazil

Re: ajuda com a GUI

11 Feb 2022, 12:01

Bom dia theon.

O que exatamente não está funcionando no dropdownlist?

Vejo que você não colocou nenhum comando Gui, submit, nohide no seu script. Não se esqueça que este comando é necessário para que os controles da GUI populem as variáveis com os seus valores (ele existe para que você controlar o momento exato disso). Portanto, se você deseja selecionar a opção "char3" e quer que essa opção seja armazenada na variável "name", você precisa chamar o comando Gui, submit, nohide APÓS a seleção da opção no controle DropDownList (normalmente isso é feito com uma glabel ou com um botão que "ativa" a função da janela).

Return to “Ajuda e Suporte Geral”

Who is online

Users browsing this forum: No registered users and 9 guests