I am trying to learn a bit more about the libraries before purchasing this great software! I understand most of them in theory (without programming because I dont actually have them) except for the reflection library. I was trying to figure out how I would use the clipboard library (http://developer.android.com/reference/android/text/ClipboardManager.html) to put some text in the clipboard as an example for practice but everything I write does not seem correct.
This is what I have written so far (but have not tested):
Dim r As Reflector
r.target=r.RunMethod("java.text.clipboardmanager")
r.RunMethod2("settext","hello","java.lang.object")
ith hello being the text added to the clipboard but it seems incorrect with the java.text.clipboardmanager compared to the other examples of the reflection library I have seen where there is no dots in there. Could somebody please point me in the right direction or give me the code for the clipboard as a reference.
Help would be appreciated to help me understand more about this library!
It is very easy, I put an example (that here does not seem that they want):
Code:
Sub Copia_Click
Dim r As Reflector
r.Target = r.GetContext
Log(r.Target)
r.Target = r.RunMethod2("getSystemService", "clipboard", "java.lang.String") 'CipboardManager
Log(r.Target)
Log(r.RunMethod2("setText",EditText1.Text,"java.lang.CharSequence"))
End Sub
Sub Pega_Click
Dim r As Reflector
r.Target = r.GetContext
Log(r.Target)
r.Target = r.RunMethod2("getSystemService", "clipboard", "java.lang.String") 'CipboardManager
Log(r.Target)
If r.RunMethod("hasText") Then
EditText2.Text=r.RunMethod("getText")
Log(r.RunMethod("getText"))
Else
ToastMessageShow("Error : No texto",True)
End If
End Sub
I him hope to have helped. Luck.
Manel : www.sintecsl.es
Related
I think the question speaks for itself. I have trouble getting some values out of the registry, and I was hoping someone around here might help me.
I'm stuck at IE9, as it is the only one which has some reasonable CSS capabilities, and does support GetObject().
So right now, lets say I'm trying to retrieve the memory size of a GPU at "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000\HardwareInformation.qwMemorySize" (as far as I know, this should be a universal path & key).
This is where the problem begins. Either I get no output, or some error saying something is different, or what (my system is running in a different language so I cant offer the right translation).
After some research, I seem to have found the issue - the value I'm trying to read is REG_QWORD, and unfortunately I was only able to find very little covering this topic, and most of the solutions did not work for me.
So right now, I am with this code, which, unsurprisingly, also does not work (the code I had since like the beginning):
for Each oItem in colGPUs
memory = oItem.AdapterRAM / 1048576
If memory < 0 Then
If InStr(oItem.Name, "NVIDIA") Then
Set wssx = CreateObject("WScript.Shell")
msgbox CStr(wssx.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\000" + GPUID + "\HardwareInformation.qwMemorySize"))
End If
End If
Unfortunatelly it seems like there is no direct way of retrieving the value - within HTA itself.
I was able to get the value, however I did it using Powershell, executed the command, set its output to a specific file and read it.
Anyways, here is the actual solution I came up with specifically for this issue
wshell.Run "powershell (Get-ItemPropertyValue 'HKLM:\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000' 'HardwareInformation.qwMemorySize') | Out-File -FilePath C:\temp\gpu_mem.txt", 0, true
Set f = fso.OpenTextFile("C:\temp\gpu_mem.txt", 1, False, -1)
gpu_mem = CStr(f.ReadAll)
With this method Im directly obtaining the integer and passing it to the VBS
I'm working with a very weird version of VB...it doesn't want me telling it what is what, it wants to figure that out on its own.
In C# I can easily hard code an array...not so much in this VB.
I would like to create a hard coded array while calling the function...but I'm not sure about the syntax. Can't find much on this specific VB version. It doesn't let you declare types. Anyone here know how to do this? If so, thanks!
FUNCTION HasInput(filters())
HasInput = False
FOR EACH table IN filters
FOR EACH key IN Request.Form
IF LEFT(key, LEN(table)) = table AND Request.Form(key) <> "" THEN
HasInput = TRUE
END IF
NEXT
NEXT
END FUNCTION
IF HasInput({"ih", "hdms"}) THEN
Use the Array() function:
If HasInput(Array("ih", "hdms")) Then
And to recieve the array:
Function HasInput(filters)
(though you can still use filters() if it makes it clearer that you're passing an array)
My code is as follows:
a=msgbox("Do you like waffles",4+16,"Waffles")
Do While a=vbno
a
Loop
if a=vbyes then
b=msgbox("Do you like pancakes",4+16,"Pancakes")
Do While b=vbno
b
loop
if b=vbye then
c=msgbox("Do you like French toast",4+16,"French toast")
Do While c=vbno
c
Loop
else
d-msgbox("good",0+16,"YAY!")
end if
I know it is basic, but it comes up with the error message: "Error: Expected 'End'"
But as you can see 'end' is at the start of line 17, if it is something I haven't seen some where else in the code that might be causing this. I'm kind of new to this language and was putting things I knew how to do into a semi-useful paten.
I saved it as a .bat file and ran it using cmd.
Here is the original code posted in the question (as I'm writing this):
a=msgbox("Do you like waffles",4+16,"Waffles")
Do While a=vbno
a
Loop
if a=vbyes then
b=msgbox("Do you like pancakes",4+16,"Pancakes")
Do While b=vbno
b
loop
if b=vbye then
c=msgbox("Do you like French toast",4+16,"French toast")
Do While c=vbno
c
Loop
else
d-msgbox("good",0+16,"YAY!")
end if
A main error cause seems to be a notion that one can assign a definition to a variable. Well one can, but not in that way. Here is corrected code:
option explicit
dim answer
do
answer = msgbox("Do you like waffles",4+16,"Waffles")
if answer = vbYes then exit do
answer = msgbox("Do you like pancakes",4+16,"Pancakes")
if answer = vbYes then exit do
answer = msgbox("Do you like French toast",4+16,"French toast")
if answer = vbYes then exit do
loop
call msgbox( "good",0+16,"YAY!" )
There are however umpteen zillion ways to prepare food, and so also with code, plus, it's not clear if the above is the intention, but I guess it's pretty close.
At any rate, it's code that works and that you can build further on
Note that VBScript documentation is now only available as a CHM compiled help file, called "script56.chm".
The VBScript documentation is both available as a handy CHM compiled help file, called "script56.chm", as well as online in the MSDN library.
Note: you need to save the source code as a .vbs file.
I'm not a programmer, even amateur, I just wanted a program that would change PSP screen (whole) color as fast as possible infinitely. I made something:
rdupa = Image.load("red.png")
gdupa = Image.load("green.png")
bdupa = Image.load("blue.png")
screen:clear()
while true do
screen:blit(0, 0, rdupa, false)
screen:clear()
screen:blit(0, 0, gdupa, false)
screen:clear()
screen:blit(0, 0, bdupa, false)
screen:clear()
end
Using Google, but that doesn't work. What did I do wrong (I have *.png images in the same folder as script)? Ready script would be seen veeeeeeery nicely.
I'm not sure about your environment but I'd guess it's most likely unable to update its main window or whatever as it's essentially stuck executing the Lua code snipped (unless that's executed in a separate thread).
Lua is a small and concise programming language and provides only few core functions (see this list).
Lua does not provide any functions to work with screen and images by default, so without knowing what library/framework are you using, there is little we can do to help.
For this answer, I'm operating under the assumption that you're using Lua Player (consider adding a luaplayer tag?). From what I can see in the documentation, you should be using
screen.flip()
instead of
screen:clear()
whenever you want to update the screen. Unfortunately, I do not have CFW on my PSP, so I cannot test this myself.
To be honest, I wouldn't even consider using images.
something like this would do :)
(This is using PGELua but can easily be adapted for LuaPlayer)
while pge.running() do
color = pge.gfx.createcolor(pge.math.rand(255),pge.math.rand(255),pge.math.rand(255))
pge.gfx.startdrawing()
pge.gfx.drawrect(0,0,480,272,color)
pge.gfx.enddrawing()
pge.gfx.swapbuffers()
end
if you want defined colours, maybe something like.
red = pge.gfx.createcolor(255,0,0)
gre = pge.gfx.createcolor(0,255,0)
blu = pge.gfx.createcolor(0,0,255)
loop = 1
while pge.running() do
pge.gfx.startdrawing()
if loop==1 then
pge.gfx.drawrect(0,0,480,272,red)
elseif loop==2 then
pge.gfx.drawrect(0,0,480,272,gre)
elseif loop==3 then
pge.gfx.drawrect(0,0,480,272,blu)
end
loop=loop+1
if loop>4 then
loop=1
end
pge.gfx.enddrawing()
pge.gfx.swapbuffers()
end
I think this problem is best described in code. I'm sure the solution is close, I just haven't been able to find it. I've been looking over the Qt4 api as well as doing tutorials. Here is my code so far:
require 'Qt4'
class PictureCommentForm < Qt::Widget
def initialize(parent = nil)
super()
#setFixedSize(300, 100)
#comment_text = nil
picture = Qt::Label.new()
image = Qt::Image.new('image.jpeg')
picture.pixmap = image
comment = Qt::LineEdit.new()
layout = Qt::VBoxLayout.new()
layout.addWidget(picture)
layout.addWidget(comment)
setLayout(layout)
connect(comment, SIGNAL('returnPressed()'), self, setCommentText(comment.text) )
end
def setCommentText(text)
#comment_text = text
$qApp.quit()
end
end
app = Qt::Application.new(ARGV)
comment_form = PictureCommentForm.new()
comment_form.show()
app.exec
comment_text = comment_form.comment_text
puts "Comment was:\n #{comment_text}"
EDIT: Thanks for that answer integer. All I want done is a dialog box showing a picture and comment so I can get that data. I do plan on making a full GUI version with qt4, but that's for later.
I don't know Ruby, so bear with me, but I use Qt extensively in Python.
First point is that Qt really, really doesn't want to be used the way you're trying to use it. If you're making some sort of script, then Qt wants you to give it to Qt so it can run your code when it feels like:
We recommend that you connect clean-up
code to the aboutToQuit() signal,
instead of putting it in your
application's main() function because
on some platforms the
QCoreApplication::exec() call may not
return.
Working with Qt you pretty much have to do event-driven programming and give it control of your program flow / main loop.
If you really just want some "utility" that shows some GUI input box and prints whatever the user inputs to console, consider putting the puts directly in whatever function you connected to the text box. Then you can use that program's output in other console scripts.