How to Use GuiDropFiles with GUI controls? - scripting

How can I use GuiDropFiles with GUI controls?
I have several edit fields in my form, and I want to be able to drop files onto them separately and work with them.
This is what I came up with:
First, my controls are set up like this:
WS_EX_ACCEPTFILES=0x10
Gui, add, edit, vedit1, %file_1%
WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1
And my drag-drop routine is as such:
GuiDropFiles: ; Support drag & drop.
Loop, parse, A_GuiControlEvent, `n
{
thisfile := a_loopfield ; Get the first file only (in case there's more than one).
thiscontrol := a_guicontrol
break
}
alert(thisfile . "`r" . thiscontrol)
if(thiscontrol = edit1)
guicontrol,,%edit1%, %thisfile%
if(thiscontrol = edit2)
guicontrol,,%edit2%, %thisfile%
if(thiscontrol = edit3)
guicontrol,,%edit3%, %thisfile%
return
I am using the basic example from the autohotkey documentation. I also tried the example from here, but it keep saying, "not dropped on an edit box".
Any clue would be great.

Figured it out (after a few lost hours).
First, I didn't need this: WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1
and I didn't need to set any styles on the edit controls.
All I needed was this, which works since my edit controls have the variable-name starting with "UI_file":
GuiDropFiles: ; Support drag & drop.
Loop, parse, A_GuiEvent, `n
{
thisfile := A_LoopField ; Get the first file only (in case there's more than one).
thiscontrol := a_guicontrol
break
}
;alert(thisfile . "`r" . thiscontrol)
If InStr(A_GuiControl, "UI_file")
guicontrol,,%A_GuiControl%, %thisfile%
return

Related

Birt export in pdf does not wordwrap long lines

My reports preview is ok.
But now, I need to export to pdf...and I've got an issue : the content of some cells are truncated to the witdh of the column.
For instance, 1 cell should display "BASELINE"...in the preview it's ok...but in pdf, it displays "BASEL".
I've been looking for a solution the whole day and did not find anything...
Of course : I don't want to fit the width of the column on the length of this word "BASELINE" because the content is dynamic...
Instead, I want to fix the column width and then, the cell should display something like that :
BASEL
INE
Any idea ?
Thanks in advance (am a little bit desperated...)
The solution is trivial in BIRT v4.9 if you've integrated the engine into your java code. Just set the PDF rendering options.
RenderOption options = new PDFRenderOption();
options.setOutputStream(out);
options.setOutputFormat("pdf");
options.setOption(PDFRenderOption.PDF_WORDBREAK, true);
options.setOption(PDFRenderOption.PDF_TEXT_WRAPPING, true);
task.setRenderOption(options);
You have to set a special PDF emitter option:
PDFRenderOption options = new PDFRenderOption();
options.setOption(PDFRenderOption.PDF_HYPHENATION, true);
This is if you integrated BIRT into your Java program.
For the viewer servlet, it is possible to set such options, too, AFAIK, but I don't know how; maybe on the URL or using environment variables.
I had the same issue. I found a very good topic about that : http://developer.actuate.com/community/forum/index.php?/topic/19827-how-do-i-use-word-wrap-in-report-design/?s=173b4ad992e47395e2c8b9070c2d3cce
This will split the string in the given number of character you want :
The function to add in a functions.js (for example). To let you know, I create some folder in my report project : one for the reports, one for the template, one for the libraries, another for the resources, I added this js file in the resources folder.
/**
* Format a long String to be smaller and be entirely showed
*
*#param longStr
* the String to split
*#param width
* the character number that the string should be
*
*#returns the string splited
*/
function wrap(longStr,width){
length = longStr.length;
if(length <= width)
return longStr;
return (longStr.substring(0, width) + "\n" + wrap(longStr.substring(width, length), width));
}
You will have to add this js file in the reports : in the properties -> Resources -> Javascript files
This is working for me.
Note: you can add this function in your data directly if you need only once...
The disadvantage of this : you will have to specify a max length for your character, you can have blank spaces in the column if you specify a number to small to fill the column.
But, this is the best way I found. Let me know if you find something else and if it's working.

Octave printf does not output when followed by ginput

I am trying to make a prompt for the user to select from the figure (plot).
When I run it with the code below, the prompt doesnt display until i click on the figure, after which the prompt displays and the code continues. In fact, no call to printf (or disp) that is called before the ginput call displays until i select the figure.
printf("Select part\n"); % (disp also doesnt work properly)
[xinput,yinput] = ginput(1);
The purpose of the prompt is to alert the user to move to the figure, so naturally it needs to display before selecting the figure.
I can add an extra redundant input call between the two which forces the printf to display in the console. eg input("Press Enter"). but this is an inconvenient solution.
Strangely, if you run just the code above it does work normally. But when running in the remainder of the program it displays the issue. So it may be a difficult one to debug. Also, running it one line at a time in the full code using the debugger works properly, displaying the prompt before selecting the figure.
Just to add to the confusion. When running this part of the program in a loop, the first instance doesnt display the prompt correctly, but every other instance it works.
Thanks
EDIT:
The following code reliably fails (for me) in the same way my full program fails; (edited again to simplify)
figure(1);
input_test = input("press 1: ");
switch input_test
case 1
while true
clc;
printf("Left click to get coords or right click to finish\n");
[xinput,yinput,mouse_button] = ginput(1)
if mouse_button == 3
break
endif
endwhile
endswitch
It appears it has something to do with the line;
input_test = input("press 1: ");
If I replace this with
input_test = 1;
it works properly.
I dont know what is the reason for this, and I cannot remove the input request from this location.
Thanks Roger, you were correct, I did find a solution.
Using
fflush(stdout)
before the 'ginput' call solves the problem.
Found this in the 'input' help;
"Because there may be output waiting to be displayed by the pager,
it is a good idea to always call 'fflush (stdout)' before calling
'input'. This will ensure that all pending output is written to
the screen before your prompt."

Autohotkey: Save variable into forum field

I am trying to write an autohotkey script to fill an online forum using COM. My problem is that the username is incremented by numbers, so ideally I want to loop the script to fill the form 5 or 6 times.
Here is the autohotkey part I am struggling with:
number := 28
username = user%number%
wb.document.all.getElementById(username).value := "username" ;HERE IS THE PROBLEM
number++
I have tried %username%, username without quotes, and with single quotes, and nothing seem to be working.
any ideas?
Thanks for your help.
First thing that popped out to me was all in you, I see Joe DF asked if you had tried without?
Second thing is you shouldn't have ""'s around your Variable.
If you are doing multiple assignments you can enclose them in ()'s like so:
:= (UserName "`n" Address "`n" PhoneNumber "`n" SocialSecurity)
If you are having problem's with a document not fully being loaded you can implement a custom loading routine like so:
wb.Navigate("Yourwebsite")
GoSub loading
.
.
.
loading:
ComObjError(false) ;turn off com errors
While value = "" {
value := wb.document.getElementsByClassname("somethingHere") [0].innerText
Continue
}
ComObjError(true)
Return
Without seeing more of your code and the website you are trying to work with, it will be difficult to help you further.
It worked... turns out it was the sleep time for the form to load. form was slower than Sleep 100 for some reason. Now, the form loads, but it is only taking 1 field. so password and email are not being filled.

Fixed text when scrolling

My program displays an ABAP list, I'm trying to show a header (some lines of text, nothing fancy) fixed when scrolling down in a report.
Is there some kind of tag or declaration that I have to use?
In SE38 you can define list heading with 'GOTO -> Text Elements -> List Headings`.
You can define a list header, and titles for your list (Columns heading).
One advantage: With GOTO -> Translations you can define different texts in different languages.
Another way to get this maintenance screen:
From your list, you can choose: System -> List -> List Header.
Another way:
You can use top-of-page to define your header text inside your report code.
top-of-page.
write 'My header'.
You can use the TOP OF PAGE event to write something that will stick at the top of the page while scrolling. You can find more info here.
You can also use the list headers from Text Elements menu. More info here.
Best regards,
Sergiu
One way is directly using top-of-page in your code.
Other way is calling reuse_alv_grid_display or reuse_alv_list_display (depending on your output type) and declaring "top-of-page" in the I_CALLBACK_TOP_OF_PAGE line. Then create a sub-routine with the same name as your "top-of-page". In that you can write
wa_list-typ = 'H'.
wa_list-info = ''.
APPEND wa_list to it_list.
clear wa_list.
OR
wa_list-typ = 'A'.
wa_list-info = 'Report Header'.
APPEND wa_list to it_list.
clear wa_list.
OR
wa_list-typ = 'S'.
wa_list-info = 'Report Header'.
APPEND wa_list to it_list.
clear wa_list.
depending on what you want (header, action or selection).
Finally you can use REUSE_ALV_COMMENTARY_WRITE function and call the table(in this example it_list).
Hope it helped.

Rebol/View: How to assign images to layout already created?

Using Rebol/View 2.7.7, I'm trying to create a card game based on Nick's Rebol tutorial at: http://re-bol.com/rebol.html#section-10.18. What I want to do though is read the cards from the binary file Nick created, discard some of the data, and use it to layout a tableau of cards, 4 rows of 3 columns, with the 2 center card locations not used.
Here's my code:
protect-system
random/seed now
do %cards.r ;--include the binary card data
the-tableau: [
size 320x480 backdrop 0.170.0
style tabstyle image 80x100 teal
style holdplace box 80x100 coal
across
at 30x20 tc1: tabstyle
tc2: tabstyle
tc3: tabstyle return
at 30x130 tc4: tabstyle
tc100: holdplace
tc5: tabstyle return
at 30x240 tc6: tabstyle
tc200: holdplace
tc7: tabstyle return
at 30x350 tc8: tabstyle
tc9: tabstyle
tc10: tabstyle
]
lc: copy []
lc: [tc1 tc2 tc3 tc4 tc5 tc6 tc7 tc8 tc9 tc10]
deck-cards: copy [] ; The deck holds all of the cards from the binary file
deck-cards-num: copy []
deck-cards-color: copy []
lay: layout the-tableau
foreach [card label num color pos] cards [
dimg: load to-binary decompress (card)
append deck-cards dimg ;feel movestyle
throw-away-label: label
append deck-cards-num num
append deck-cards-color color
throw-away-pos: pos
]
random-card: does [pick deck-cards random length? deck-cards]
foreach c lc [set-face get c deck-cards]
view lay
do-events
But this doesn't show the cards at all. I'm not even sure it's reading the correctly? Where is the problem?
Actually you didn't use the random-card function in your for loop at the end... :-)
foreach c lc [get c set-face get c random-card ]
You note that you are not sure if data was loaded correctly...
here is a simple way to find out... just print/probe the TYPE? of that data
dimg: load to-binary decompress (card)
probe type? dimg
In this case it will print out image! in the console... so yep... that's working. :-)
As an added little detail, I noticed you didn't compensate your random for the "back face" image in the card data (which is at its end), so the random-card function should be fixed like so:
random-card: does [pick deck-cards random (length? deck-cards) - 1] ; - 1 since we don't want the back face to be picked.
You only need 'do-events if the event loop is not started.
View/new does not start the event loop .. but View does
I'm not addressing your actual problem though :(
to make the do-events note clear, I added a little answer here so I can add some inline code....
here is an example where you'd want your do-events to be used.
view/new lay ; display the interface right now. (with no cards)
random-card: does [pick deck-cards random (length? deck-cards) - 1] ; - 1 since we don't want the back face to be picked.
; deal cards with a half second delay.
foreach c lc [f: get c set-face get c random-card wait 0.5]
do-events
here, any code you put after 'DO-EVENTS will be executed once all view windows have closed.
which can be things like tmp file cleanup, save on exit, "save changes" dialogs, etc.
additional note:
While building graphics code, its a good habit to place this at the very start of you application:
print " "
It will open up the console, and then any view windows will show up in front of it.
When ready to share, just comment the line and remove any print statements in your code.
this is useful for 3 things:
1) Its usually highly annoying when the console always pops-up over your application while its tracing (print/probe/etc) some stuff after your window opens.
2) This also has the more useful side-effect of showing you if your application quit correctly since the console will ALSO quit when all waits have terminated correctly.
In your original example, if you add the above print, then you'll see that the console never closes, so this means the application is still running with no more application windows listening to events.
3) It also has the advantage that you can terminate the graphic app directly by closing the console window. This effectively closes all windows and waits immediately and shortcuts any "on application quit" code you might have (code after do-events).