I'm trying to use Blink with Julia (1.02) to create a simple login page.
I have a working login_button and a handler function (I think) for button presses, but I cannot get the functions inside the "handle(w, "press") do args..." to do anything useful.
I'd like the handler function to run "body!(w, new_page)" after checking the username & password, but it just hangs after printing out "login_button pressed!" after which the button stops responding.
I've been struggling with this for some time now, any help is appreciated.
Old Julia Code:
using WebIO, Blink
page =
node(:div,
node(:p, "please login below.", attributes=Dict("class"=>"lead")),
node(:input, attributes=Dict("id"=>"username", "type"=>"text", "placeholder"=>"username")),
node(:input, attributes=Dict("id"=>"password", "type"=>"password", "placeholder"=>"password")),
node(:button, "LOGIN", attributes=Dict("id"=>"login_button")));
new_page = node(:div, "New page!");
w = Window()
body!(w, page)
#js_ w document.getElementById("login_button").onclick = () -> Blink.msg("press", "login")
handle(w, "press") do args...
println("login_button pressed!")
username = #js w document.querySelector("""input[id="username"]""").value
password = #js w document.querySelector("""input[id="password"]""").value
println("$username, $password")
if username == "user" && password == "pass"
body!(w, new_page)
else
#js alert("Incorrect username or password. Try again.")
end
end
New Code:
using WebIO, Blink, Interact
using ..User
function page_inputs()
username = textbox("enter username", attributes=Dict("size"=>50))
password = textbox("enter password", typ="password")
login_button = button("LOGIN")
Widget(["username"=>username,"password"=>password,"login_button"=>login_button])
end
inputs = page_inputs();
page =
node(:div,
node(:br),
node(:img, attributes=Dict("src"=>"https://elmordyn.files.wordpress.com/2012/07/20110223084209-beholder.gif")),
node(:h2, "beholder", attributes=Dict("class"=>"display-3")),
node(:p, "VERSION 0.2"),
node(:hr, attributes=Dict("class"=>"my-3")),
node(:p, "No unauthorized access. Please login below.", attributes=Dict("class"=>"lead")),
node(:div, inputs),
attributes=Dict(:align=>"middle"));
title = "LOGIN ~ beholdia"
size = (500, 600)
function validate_user(w, inputs)
if inputs["login_button"][] > 0
inputs["login_button"][] = 0
if inputs["username"][] in keys(User.users) && inputs["password"][] == User.users[inputs["username"][]]
println("""Logging $(inputs["username"][]) in...""")
return true
else
#js w alert("Incorrect username or password. Try again.")
return false
end
end
end
function events(w, inputs)
#async while true
validate_user(w, inputs) == true ? break : sleep(0.1)
end
end
Related
#bot.tree.command(name="user", description="Shows some informations about the mentioned user.")
async def user(interaction: discord.Interaction, member:discord.Member=None):
if member == None:
member = interaction.user
roles = [role for role in member.roles if role.name != "#everyone"]
embed = discord.Embed(title=f"Details about the user, {member.name}",color=0xdaddd8, timestamp = datetime.datetime.utcnow())
embed.set_thumbnail(url=member.avatar) # Avatar Thumbnail
embed.add_field(name="👤 Name", value = f"{member.name}#{member.discriminator}") # Embeds
embed.add_field(name="🏷️ Nickname", value = member.display_name)
embed.add_field(name="🆔 User ID", value = member.id)
embed.add_field(name="📆 Created at", value = member.created_at.strftime("%D \n%I:%M %p"))
embed.add_field(name="👋🏻 Joined at", value = member.joined_at.strftime("%D \n%I:%M %p"))
embed.add_field(name="🟢 Status", value = member.status) #this line is'nt working as it should
embed.add_field(name="❤️🔥 Top role", value = member.top_role.mention)
bot_status = "Yes, it is" if member.bot else "No, They'snt"
embed.add_field(name="🤖 Bot?", value = bot_status)
embed.set_footer(text = interaction.user.name,icon_url = interaction.user.avatar)
await interaction.response.send_message(embed=embed)
I made a User information command and this command shows every person offline even itself how can i fix it?
This is likely due to lack of intents.
Add in your code, under the intents you define:
intents.members = True
intents.presences = True
Use member.raw_status instead of member.status. It will return a string value such as 'online', 'offline' or 'idle'.
So, I've been working on this for the past week. I have tried everything (based on the knowledge I know) and yet nothing... my code didn't work the first time, the second time, the third time... the forth... etc... at the end, I let frustration take control of me and I ended up deleting the whole script. Luckily not the parts and models, otherwise I'm really screwed...
I need to create a game in which I have to create a keypad of sorts, at first I thought GUI would work... no, it needs to be SurfaceGUI, which I don't know how to handle well... Anyway, I needed to create a keypad using SurfaceGUI, and display it on a separate screen, as a typical keypad would...
The Player would first have to enter an "initial" number, meaning in order to enter the randomly generated number he first needed to input the static pin in order to "log in," after that, then he would try to guess the number...
I've literally tried everything I could but nothing... It's mainly because of my lack of experience in LUA, I'm more advanced in Python and barely know a thing in Java... If someone could assist me on how to do this, I would appreciate it greatly
First, download this and put it in a ScreenGui in StarterGui. Then, use the following LocalScript placed inside the PIN frame:
-- Script settings
local len = 4 -- replace this as needed...
local regen = false -- determines whether PIN will regenerate after a failed attempt
local regmes = "Enter PIN..." -- start message of PIN pad
local badmes = "Wrong PIN!" -- message displayed when PIN is wrong
local success = "Correct PIN!" -- message displayed when PIN is right
-- Script workings
local pin = script.Parent
local top = pin.Top
local txt = top.Numbers
local nums = top.NumKeys
local pin
local stpin
local nms
txt.Text = regmes
local see = game:GetStorage("ReplicatedStorage").PINActivate
local function activate()
if pin.Visible then
pin.Visible = false
for _, btn in pairs(nums:GetChildren()) do
btn.Active = false
end
return
else
pin.Visible = true
for _, btn in pairs(nums:GetChildren()) do
btn.Active = true
end
return
end
end
local function rand()
math.randomseed(os.time) -- better random numbers this way
return tostring(math.floor(math.random(0,9.9)))
end
local function gen()
nms = {rand()}
for i=2, len, 1 do
nms[#nms+1]=rand()
end
stpin = nms[1]
for i=2, #nms, 1 do
stpin = stpin..nms[i]
end
pin = tonumber(stpin) -- converts the number string into an actual number
end
gen()
local function activate(str)
if tonumber(str) ~= pin then
txt.Text = badmes
wait(2)
txt.Text = regmes
if regen then
gen()
wait(0.1)
end
return
else
txt.Text = success
wait(2)
activate()
-- insert code here...
end
end
for _, btn in pairs(nums:GetChildren()) do
btn.Activated:Connect(function()
if txt.Text == "Wrong PIN!" then return end
txt.Text = txt.Text..btn.Text
if string.len(txt.Text) >= len then
activate(txt.Text)
end
wait(0.1)
end)
end
see.OnClientEvent:Connect(activate)
And in a Script put this:
local Players = game:GetService("Players")
local see = game:GetService("ReplicatedStorage").PINActivate
local plr
-- replace Event with something like Part.Touched
Event:Connect(function(part)
if part.Parent.Head then
plr = Players:GetPlayerFromCharacter(part.Parent)
see:FireClient(plr)
end
end)
What this will do is bring up a ScreenGui for only that player so they can enter the PIN, and they can close it as well. You can modify as needed; have a great day! :D
There is an easier way, try this
First, Create a GUI in StarterGui, then, Create a textbox and postion it, after that, create a local script inside and type this.
local Password = math.random(1000, 9999)
print(Password)
game.ReplicatedStorage.Password.Value = Password
script.Parent.FocusLost:Connect(function(enter)
if enter then
if script.Parent.Text == tostring(Password) then
print("Correct!")
script.Parent.BorderColor3 = Color3.new(0, 255, 0)
Password = math.random(1000, 9999)
game.ReplicatedStorage.Correct1:FireServer()
print(Password)
game.ReplicatedStorage.Password.Value = Password
else
print("wrong!")
print(script.Parent.Text)
script.Parent.BorderColor3 = Color3.new(255, 0, 0)
end
end
end)
That's all in the textbox.
Or if you want a random username script, create a textlabel, then, create a local script in the textlabel and type in this.
local UserText = script.Parent
local Username = math.random(1,10)
while true do
if Username == 1 then
UserText.Text = "John"
elseif Username == 2 then
UserText.Text = "Thomas"
elseif Username == 3 then
UserText.Text = "Raymond"
elseif Username == 4 then
UserText.Text = "Ray"
elseif Username == 5 then
UserText.Text = "Tom"
elseif Username == 6 then
UserText.Text = "Kai"
elseif Username == 7 then
UserText.Text = "Lloyd"
elseif Username == 8 then
UserText.Text = "Jay"
elseif Username == 9 then
UserText.Text = "User"
else
UserText.Text = "Guest"
end
wait()
end
All of those if statments are checking what username has been chosen. I have made a roblox game like this recently, so I just took all the script from the game.
If you want to check out my game, Click Here
I have carefully reviewed answers to Interactively validating Entry widget content in tkinter, but my script fails to restore previous value if the validate command returns False. I captured %P and %s and print them out...They both show the same value.
import tkinter as tk
class Controller :
def __init__(self) :
i=10
j=20
# list comprehension
self.entry_widgets = [[None for col in range(j)] for row in range(i)]
#print(self.entry_widgets)
self.values = [["string"+str(row) + str(col) for col in range(10)] for row in range(20)]
#print(self.values)
class EnterBox(tk.Entry):
def __init__(self,*args,**kwargs):
#print (args)
self._modified = False
self._save = 0
self._raise = 1
self._lower = 2
frame, i,j, *newargs = args
self._content = tk.StringVar()
# tk.Entry.__init__(self,frame,*newargs,
# validate = 'focusout',
# validatecommand = vcmd,
# **kwargs)
tk.Entry.__init__(self,frame,*newargs,**kwargs)
vcmd = (self.register(self._revert), '%P', '%s')
ct.entry_widgets[i][j] = self
self.config(textvariable=self._content)
self.config(validate = "focusout")
self.config(validatecommand = vcmd )
x=(ct.values[i][j])
self.insert(0,x)
#self._content.set(x)
self.bind("<Return>",lambda event, x=self._save : self._action(event,x) )
self.bind("<Button-2>",lambda event, x=self._save : self._action(event,x) )
self.bind("<FocusIn>", lambda event, x=self._raise : self._action(event,x))
self.bind("<FocusOut>", lambda event, x=self._lower : self._action(event,x))
self.bind('<Button-3>', lambda event, x=self._lower : self._action(event,x))
self.grid(column=i+1,row=j+2)
def _revert(self,P,s):
print ("Hi There")
print(P)
print(s)
return False
def _action(self,event,action):
print(str(action)+' ' + str(event))
if action == self._save :
ct.values[i][j] = self._content.get()
self.config(bg='lightskyblue2')
self._modified = True
elif action == self._raise :
self.config(bg = 'light pink')
elif action == self._lower :
self.config(bg = 'gray80')
self._modified = False
else :
print('action value is bad action =>' + str(action))
if "__main__" == __name__ :
root = tk.Tk()
frame = tk.Frame()
i=j=0
ct = Controller()
root.grid()
frame.grid()
check = EnterBox(frame,i,j,width = 24)
check2 = EnterBox(frame,i+1,j,width = 24)
root.mainloop()
I have tried removing all other bindings, to no avail.
Interestingly, but a separate issue, If I use StringVar. set instead of self.insert, (see commented out line) the validate command runs once, and never again despite several focus changes. Using Python 3.8
The validation isn't designed to restore anything if the validation happens on focusout. The validation can only prevent characters from being added at the time they are added. You will have to add code to restore the previous value.
Hello I am using the following code and trying to write the results in the excel sheet column name result, but it's not writing the results in it, however, it will export the sheet but wouldn't write the result. Can you please help me with what I am missing here? All the help is much appreciated. Thanks.
DataTable.AddSheet "TestCases"
DataTable.AddSheet "TestSteps"
DataTable.ImportSheet "this is the excel sheet", "Tcases", "TestCases"
DataTable.ImportSheet "this is the excel sheet", "Tsteps", "TestSteps"
testcasecount = DataTable.GetSheet("TestCases").GetRowCount
For i = 1 To testcasecount
DataTable.GetSheet("TestCases").SetCurrentRow (i)
If DataTable.Value("Execution", "TestCases") = "Yes" Then
stestcaseid = DataTable.GetSheet("TestCases").GetParameter("TestCaseID")
teststepcount = DataTable.GetSheet("TestSteps").GetRowCount
For j = 1 To teststepcount
DataTable.GetSheet("TestSteps").SetCurrentRow (j)
sid = DataTable.GetSheet("TestSteps").GetParameter("TestCaseID")
If DataTable.GetSheet("TestSteps").GetParameter("TestCaseID") = stestcaseid Then
Select Case DataTable.Value("Keyword", "TestSteps")
Case Browser()
sresult = Browser()
End Select
DataTable.Value("Result", "TestSteps") = sresult
End If
If sresult = "Pass" Then
DataTable.Value("Result", "TestCases") = "Pass"
End If
Next
End If
Next
DataTable.ExportSheet "this is the excel sheet", "TestCases"
DataTable.ExportSheet "this is the excel sheet", "TestSteps"
Function Browser()
systemutil.Run "chrome.exe", "www.google.com"
Browser = "Pass"
End Function
Scenario:
I'm logged in on a website, and want to make AutoIt write in an input field.
How can I achieve this?
Try something like this
#include<IE.au3>
$sUsername = "Username"
$sPassword = "Password"
$sUrl = "https://yoururl.com"
$oIE = _IECreate($sUrl, 0, 1, 0, 1)
Sleep(2000)
$oHWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($oHWND, "", #SW_MAXIMIZE)
$oForm = _IEFormGetCollection($oIE, 0)
$oUsername = _IEFormElementGetObjByName($oForm, 'login') ; change name !
$oPassword = _IEFormElementGetObjByName($oForm, "password") ; change name !
_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)
_IEFormSubmit($oForm)
There is also an UDF FF.au3 for firefox, but I would use greasemonkey instead if you need the script only on your PC.