Jump to content
UBot Underground

Tutorial : How to CLOSE UI Html Window using a CLOSE BUTTON


Recommended Posts

Hi,

 

I have seen several post in ubot forum about how to close UI html window using a button.

 

I think it would be added in a future update of Ubot, but for the moment you can't do it in Ubot.

 

I will show you how I got it working and you won't need to click the x button anymore (like in the video below)

 

http://www.youtube.com/watch?v=QavtV8griHM

 

I won't show you how to add a push button because I think you already know it.

 

STEP 1 - Add a javascript function to the button you have created. I will call my button "Close".

 

onclick="ubot.runScript('close()')

 

STEP 2 - Download and install Autohotkey. It's free and you can download it here : http://www.autohotkey.com/download/

 

STEP 3 - Once installed create a new Autohotkey script (you just need to right click on your desktop, select new then Autohotkey script.

Edit the script, remove everything, and add the code below :

 

IfWinExist, The exact name of your ui html window
WinClose

 

Save it and compile it as close button.exe (or anything else you want). I have placed it in a script folder, directly in my application folder.

 

STEP 4 - We will now create a define command. We will call it "close" and we will add a shell command in order to launch our autohotkey script.

 

define close {
shell("{$special folder("Application")}\\script\\close button.exe")
}

 

STEP 5 - THAT'S ALL !!

 

Open your ui html window, click the Close button ... and the magic happen !

 

The ui html window has been closed without clicking the x button ...

 

I hope this will help you and sorry for my english (I'm french).

 

ENJOY and feel free to press the like button :D

  • Like 8
Link to post
Share on other sites

Wow thanks I was just looking for this

 

I know ! I have read your post about the stop button in ui html window then I have decided to share how I do it ...

 

I hope it will solve your issue.

Link to post
Share on other sites

Cool.

 

It is possible to using the same auto hot key make it open a window?

 

For example:

 

Place a button on the UI html panel and onclick open a UI html Window

 

I am looking on it but it seems that all I can do is activate a window but not open it if closed.

 

P0s3id0n

Link to post
Share on other sites

Yes, it is possible. With AutoHotKey you can write a simple script to open any window. Here is the script

 

Send {Alt}t

Click 101,52 // These are the cordinates of your UI HTML Menu or HTML Menu

return

Save this file as .ahk and compile the script, call it in ur UBOT Script. Hope it helps :)

 

Here is the Video

http://www.screencast.com/t/2bXs9ZHHpeJ

  • Like 1
Link to post
Share on other sites

But this wouldn't work if we sold a bots to someone correct? Unless they did these same steps with the autohotkey. I'm a little confused on that front.

 

Right... they would need autohotkey installed and configured for this to work...

Link to post
Share on other sites

But this wouldn't work if we sold a bots to someone correct? Unless they did these same steps with the autohotkey. I'm a little confused on that front.

 

No, it works because your autohotkey script is compiled in an .exe file.

 

Let's make a test : I have created a test ubot exe file. http://www.mediafire.com/?cgts405wz78tf14

 

Once download, open it and go to the tools section, then User license tabs.

 

Click the close button.

 

Let us know what happen ... (of course you don't have autohotkey on your computer).

 

Thanks.

 

:)

  • Like 1
Link to post
Share on other sites

Worked on a better version, Here are the Code and instructions

1) Open AutoHotKey and write down this code

IfWinExist, Automation
WinClose

2) Save Flie as CloseUIHTMLwindow.ahk
3) Complie it and make an exe file
4) Open AutoHotKey and write down this code

IfWinExist, ui_html_window_automation ;// name of ur UI HTML Window
{
WinActivate ; use the window found above
SetControlDelay -1
Send {Alt}t
sleep, 50
ControlClick, x101 y52,,,,, Pos  ;// x and y are the cordinates of ur menu u need to call
return
}

5) Save it as OpenUIHTMLwindow.ahk
6) Compile it as an exe
7) Here is the ubot code

ui html panel("<html>
<body bgcolor=\"purple\">
<title>Automation of Ui HTML Window</title>
<input type=\"button\" name=\"automationwindow\" value=\"Click to Open UI HTML Window\" onclick=ubot.runScript(\'OpenAutomationWindow()\')>
</body>
</html>", 300)
ui html window("Automation", "<html>
<body bgcolor=\"CCCCCC\">
<title>Automation of Ui HTML Window</title>
<p>
<font face=\"verdana\" size=\"4\" color=\"purple\">
Wow! Its all about automation!!!
</font>
</p>
<input type=\"button\" name=\"Closeme\" value=\"Close Me\" onclick=ubot.runScript(\'CloseAutomationWindow()\')>
</body>
</html>", 250, 250)
define OpenAutomationWindow {
   shell("{$special folder("Application")}\\OpenUIHTMLwindow.exe")
}
define CloseAutomationWindow {
   shell("{$special folder("Application")}\\CloseUIHTMLwindow.exe")
}

  • Like 3
Link to post
Share on other sites

Hi,

 

Another way to close ui html window. Using VBScript code.

 

Code:

ui stat monitor("<script type=\"text/javascript\">
window.onload = ubot.runScript(\'defaultvalues()\')
</script> Running loop:", #loopcnt)
ui stat monitor("Status:", #loopstat)
ui button("Run") {
runall()
}
ui button("Stop") {
stopthis()
}
comment("set uihtmlwindowtitle to the same value as your ui html window->Label field")
set(#uihtmlwindowtitle, "Status ui html window", "Global")
ui html window("Status ui html window", "<htnl>
<head>
</head>
<body onclick=\"window.opener=self; window.close();\">
ui html window
<br><button id=\"closewin2\" onclick=\"ubot.runScript(\'closeuiwindow()\')\">Close window</button>
</body>
</html>", 200, 200)
runall()
define defaultvalues {
set(#loopcnt, 0, "Global")
set(#loopstat, "Not Running", "Global")
set(#uihtmlwindowtitle, "Status ui html window", "Global")
}
define runall {
set(#loopcnt, 0, "Global")
set(#loopstop, "false", "Global")
set(#loopstat, "Running", "Global")
Surf()
}
define Surf {
loop(10) {
 if($comparison(#loopstop, "=", "false")) {
	 then {
		 increment(#loopcnt)
		 mouse over(<innertext="FEATURES">, "No")
		 wait($rand(7, 10))
	 }
	 else {
	 }
 }
}
set(#loopstat, "Stopped", "Global")
}
define stopthis {
set(#loopstop, "true", "Global")
}
define closeuiwindow {
clear list(%vbspgm)
set(#vbscode, "Option Explicit
Dim objWshShell

Set objWshShell = Wscript.CreateObject(\"Wscript.Shell\")", "Global")
add list to list(%vbspgm, $list from text(#vbscode, $new line), "Delete", "Global")
add item to list(%vbspgm, "If objWshShell.AppActivate(\"{#uihtmlwindowtitle}\") Then", "Delete", "Global")
set(#vbscode, " WScript.Sleep 500
objWshShell.SendKeys \"%\{F4\}\"
End If", "Global")
add list to list(%vbspgm, $list from text(#vbscode, $new line), "Delete", "Global")
save to file("{$special folder("Application Data")}\\closeuiwindow.vbs", %vbspgm)
shell("wscript.exe /Nologo \"{$special folder("Application Data")}\\closeuiwindow.vbs\"")
loop(1) {
 delete file("{$special folder("Application Data")}\\closeuiwindow.vbs")
}
}

 

sample-ui-html-button-002.ubot

 

Kevin

  • Like 3
Link to post
Share on other sites

Hi,

 

Another way to close ui html window. Using VBScript code.

 

Code:

ui stat monitor("<script type=\"text/javascript\">
window.onload = ubot.runScript(\'defaultvalues()\')
</script> Running loop:", #loopcnt)
ui stat monitor("Status:", #loopstat)
ui button("Run") {
runall()
}
ui button("Stop") {
stopthis()
}
comment("set uihtmlwindowtitle to the same value as your ui html window->Label field")
set(#uihtmlwindowtitle, "Status ui html window", "Global")
ui html window("Status ui html window", "<htnl>
<head>
</head>
<body onclick=\"window.opener=self; window.close();\">
ui html window
<br><button id=\"closewin2\" onclick=\"ubot.runScript(\'closeuiwindow()\')\">Close window</button>
</body>
</html>", 200, 200)
runall()
define defaultvalues {
set(#loopcnt, 0, "Global")
set(#loopstat, "Not Running", "Global")
set(#uihtmlwindowtitle, "Status ui html window", "Global")
}
define runall {
set(#loopcnt, 0, "Global")
set(#loopstop, "false", "Global")
set(#loopstat, "Running", "Global")
Surf()
}
define Surf {
loop(10) {
 if($comparison(#loopstop, "=", "false")) {
	 then {
		 increment(#loopcnt)
		 mouse over(<innertext="FEATURES">, "No")
		 wait($rand(7, 10))
	 }
	 else {
	 }
 }
}
set(#loopstat, "Stopped", "Global")
}
define stopthis {
set(#loopstop, "true", "Global")
}
define closeuiwindow {
clear list(%vbspgm)
set(#vbscode, "Option Explicit
Dim objWshShell

Set objWshShell = Wscript.CreateObject(\"Wscript.Shell\")", "Global")
add list to list(%vbspgm, $list from text(#vbscode, $new line), "Delete", "Global")
add item to list(%vbspgm, "If objWshShell.AppActivate(\"{#uihtmlwindowtitle}\") Then", "Delete", "Global")
set(#vbscode, " WScript.Sleep 500
objWshShell.SendKeys \"%\{F4\}\"
End If", "Global")
add list to list(%vbspgm, $list from text(#vbscode, $new line), "Delete", "Global")
save to file("{$special folder("Application Data")}\\closeuiwindow.vbs", %vbspgm)
shell("wscript.exe /Nologo \"{$special folder("Application Data")}\\closeuiwindow.vbs\"")
loop(1) {
 delete file("{$special folder("Application Data")}\\closeuiwindow.vbs")
}
}

 

sample-ui-html-button-002.ubot

 

Kevin

 

Thanks ! Great share ... This thread is very useful thanks to share like this and other :)

Link to post
Share on other sites
  • 2 weeks later...

Well. Better late than never I say.

 

I have a way to accomplish this closure using UBot only.

 

"WHAT?"

 

Yes, I can close that UI HTML Window with the click of the button and NOT the "X". How?

 

After I add my Close button to the HTML code for the window. I point that button to execute a "CloseWindow" Define node. In that Define I execute a single Shell command where I run a Closewindow.exe file.

 

Now for the secret...LOL.

 

That "Closewindow.exe" file was created using UBot Studio version 3.5. It really does work!

 

The only gotcha is that when the "Closewindow.exe" runs it opens up in a Full Window and then it ends and closes. Yes, it is not entirely pretty BUT for UBot zealots like myself it keeps my hands clean of AutoIt stink. LOL

 

Buddy

Link to post
Share on other sites

Well. Better late than never I say.

 

I have a way to accomplish this closure using UBot only.

 

"WHAT?"

 

Yes, I can close that UI HTML Window with the click of the button and NOT the "X". How?

 

After I add my Close button to the HTML code for the window. I point that button to execute a "CloseWindow" Define node. In that Define I execute a single Shell command where I run a Closewindow.exe file.

 

Now for the secret...LOL.

 

That "Closewindow.exe" file was created using UBot Studio version 3.5. It really does work!

 

The only gotcha is that when the "Closewindow.exe" runs it opens up in a Full Window and then it ends and closes. Yes, it is not entirely pretty BUT for UBot zealots like myself it keeps my hands clean of AutoIt stink. LOL

 

Buddy

 

Nice one Buddy,

 

Any chance there is a way to shell out flash upload pop-ups as well?

 

Similar to the fix offered here:

http://www.ubotstudio.com/forum/index.php?/topic/11007-picture-file-upload-with-pop-up-window/

 

Sorry to take the thread off topic, but these damn flash uploads are killing me...

 

Would like to know if this is possible by shelling out to 3.5?

 

To impatient to wait for future updates...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...